Merge remote-tracking branch 'udb/master'

This commit is contained in:
spherallic 2023-10-10 14:23:59 +02:00
commit f4506b22dc
23 changed files with 349 additions and 54 deletions

View file

@ -1,10 +1,10 @@
gzdoom_lights
{
staticlights
lightmaplights
{
color = 7;
arrow = 0;
title = "Static Lights";
title = "Lightmap Lights";
sort = 1;
width = 0;
height = 0;
@ -15,8 +15,8 @@ gzdoom_lights
9876
{
title = "Static Point Light";
class = "StaticPointLight"; // Fake class name
title = "Lightmap Point Light";
class = "pointlighttraceattenuated";
arg0
{
title = "Red";
@ -38,11 +38,104 @@ gzdoom_lights
default = 64;
}
}
9877
{
title = "Lightmap Point Light (Pulsing)";
class = "pointlightpulsetraceattenuated";
arg0
{
title = "Red";
default = 255;
}
arg1
{
title = "Green";
default = 255;
}
arg2
{
title = "Blue";
default = 255;
}
arg3
{
title = "Start intensity";
default = 64;
}
arg4
{
title = "End intensity";
default = 32;
}
}
9878
{
title = "Lightmap Point Light (Flickering)";
class = "pointlightflickertraceattenuated";
arg0
{
title = "Red";
default = 255;
}
arg1
{
title = "Green";
default = 255;
}
arg2
{
title = "Blue";
default = 255;
}
arg3
{
title = "Primary intensity";
default = 64;
}
arg4
{
title = "Secondary intensity";
default = 32;
}
}
9879
{
title = "Lightmap Point Light (Random Flickering)";
class = "pointlightflickerrandomtraceattenuated";
arg0
{
title = "Red";
default = 255;
}
arg1
{
title = "Green";
default = 255;
}
arg2
{
title = "Blue";
default = 255;
}
arg3
{
title = "Primary intensity";
default = 64;
}
arg4
{
title = "Secondary intensity";
default = 32;
}
}
9881
{
title = "Static Spotlight";
class = "StaticSpotLight"; // Fake class name
title = "Lightmap Spotlight";
class = "spotlighttraceattenuated";
arg0
{
title = "Color";
@ -65,6 +158,102 @@ gzdoom_lights
default = 64;
}
}
9882
{
title = "Lightmap Spotlight (Pulsing)";
class = "spotlightpulsetraceattenuated";
arg0
{
title = "Color";
default = 16777215;
str = true;
}
arg1
{
title = "Inner angle";
default = 8;
}
arg2
{
title = "Outer angle";
default = 32;
}
arg3
{
title = "Start intensity";
default = 64;
}
arg4
{
title = "End intensity";
default = 32;
}
}
9883
{
title = "Lightmap Spotlight (Flickering)";
class = "spotlightflickertraceattenuated";
arg0
{
title = "Color";
default = 16777215;
str = true;
}
arg1
{
title = "Inner angle";
default = 8;
}
arg2
{
title = "Outer angle";
default = 32;
}
arg3
{
title = "Primary intensity";
default = 64;
}
arg4
{
title = "Secondary intensity";
default = 32;
}
}
9884
{
title = "Lightmap Spotlight (Random Flickering)";
class = "spotlightflickerrandomtraceattenuated";
arg0
{
title = "Color";
default = 16777215;
str = true;
}
arg1
{
title = "Inner angle";
default = 8;
}
arg2
{
title = "Outer angle";
default = 32;
}
arg3
{
title = "Primary intensity";
default = 64;
}
arg4
{
title = "Secondary intensity";
default = 32;
}
}
9890
{
@ -73,7 +262,7 @@ gzdoom_lights
adduniversalfields
{
lm_suncolor;
lm_sampledistance;
lm_sampledist;
}
}
}

View file

@ -377,7 +377,7 @@ universalfields
default = "";
}
lm_sampledist_line
lm_sampledist
{
type = 0;
default = 0;
@ -529,6 +529,30 @@ universalfields
type = 3;
default = false;
}
lm_sampledist
{
type = 0;
default = 0;
}
lm_sampledist_top
{
type = 0;
default = 0;
}
lm_sampledist_mid
{
type = 0;
default = 0;
}
lm_sampledist_bot
{
type = 0;
default = 0;
}
}
thing
@ -744,7 +768,7 @@ universalfields
thingtypespecific = true;
}
lm_sampledistance
lm_sampledist
{
type = 0;
default = 16;

View file

@ -584,7 +584,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
color = new PixelColor((byte)linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
break;
case GZGeneral.LightDef.POINT_STATIC:
case GZGeneral.LightDef.POINT_LIGHTMAP:
// ZDRay static lights have an intensity that's set through the thing's alpha value
double intensity = t.Fields.GetValue("alpha", 1.0);
byte r = (byte)General.Clamp(t.Args[0] * intensity, 0.0, 255.0);
@ -627,7 +627,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
else color = new PixelColor((byte)linealpha, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
// ZDRay static lights have an intensity that's set through the thing's alpha value
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_STATIC)
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_LIGHTMAP)
{
double intensity = t.Fields.GetValue("alpha", 1.0);
if (intensity != 1.0)

View file

@ -120,17 +120,17 @@ namespace CodeImp.DoomBuilder.GZBuilder
[LightDefClass("vavoomlightcolor")]
VAVOOM_COLORED,
[LightDefRenderStyle(LightRenderStyle.STATIC)]
[LightDefNum(9876)]
[LightDefClass("staticpointlight")]
[LightDefModifier(LightModifier.NORMAL)]
POINT_STATIC,
[LightDefRenderStyle(LightRenderStyle.LIGHTMAP)]
[LightDefNum(9876, 9877, 9878, 9879)]
[LightDefClass("pointlighttraceattenuated", "pointlightpulsetraceattenuated", "pointlightflickertraceattenuated", "pointlightflickerrandomtraceattenuated")]
[LightDefModifier(LightModifier.NORMAL, LightModifier.PULSE, LightModifier.FLICKER, LightModifier.FLICKERRANDOM)]
POINT_LIGHTMAP,
[LightDefRenderStyle(LightRenderStyle.STATIC)]
[LightDefNum(9881)]
[LightDefClass("staticspotlight")]
[LightDefModifier(LightModifier.NORMAL)]
SPOT_STATIC,
[LightDefRenderStyle(LightRenderStyle.LIGHTMAP)]
[LightDefNum(9881, 9882, 9883, 9884)]
[LightDefClass("spotlighttraceattenuated", "spotlightpulsetraceattenuated", "spotlightflickertraceattenuated", "spotlightflickerrandomtraceattenuated")]
[LightDefModifier(LightModifier.NORMAL, LightModifier.PULSE, LightModifier.FLICKER, LightModifier.FLICKERRANDOM)]
SPOT_LIGHTMAP,
[LightDefRenderStyle(LightRenderStyle.NONE)]
[LightDefNum(9890)]
@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder.GZBuilder
ATTENUATED = 98,
VAVOOM = 50,
ADDITIVE = 25,
STATIC = 98, // Same as attenuated
LIGHTMAP = 98, // Same as attenuated
NONE = 0,
}
@ -232,14 +232,14 @@ namespace CodeImp.DoomBuilder.GZBuilder
case LightDef.POINT_ADDITIVE:
case LightDef.POINT_SUBTRACTIVE:
case LightDef.POINT_ATTENUATED:
case LightDef.POINT_STATIC:
case LightDef.POINT_LIGHTMAP:
LightType = LightType.POINT;
break;
case LightDef.SPOT_NORMAL:
case LightDef.SPOT_ADDITIVE:
case LightDef.SPOT_SUBTRACTIVE:
case LightDef.SPOT_ATTENUATED:
case LightDef.SPOT_STATIC:
case LightDef.SPOT_LIGHTMAP:
LightType = LightType.SPOT;
break;
case LightDef.VAVOOM_GENERIC:

View file

@ -593,7 +593,7 @@ namespace CodeImp.DoomBuilder.Rendering
color = new PixelColor(255, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
// ZDRay static lights have an intensity that's set through the thing's alpha value
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_STATIC)
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.SPOT_LIGHTMAP)
{
double intensity = t.Fields.GetValue("alpha", 1.0);
if (intensity != 1.0)
@ -609,7 +609,7 @@ namespace CodeImp.DoomBuilder.Rendering
}
// Point light
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.POINT_STATIC)
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.POINT_LIGHTMAP)
{
// ZDRay static lights have an intensity that's set through the thing's alpha value
double intensity = t.Fields.GetValue("alpha", 1.0);

View file

@ -608,7 +608,7 @@ namespace CodeImp.DoomBuilder.Rendering
case GZGeneral.LightRenderStyle.VAVOOM: lightOffsets[0]++; break;
case GZGeneral.LightRenderStyle.ADDITIVE: lightOffsets[2]++; break;
case GZGeneral.LightRenderStyle.SUBTRACTIVE: lightOffsets[3]++; break;
case GZGeneral.LightRenderStyle.STATIC: // Static lights look the same as attenuated lights
case GZGeneral.LightRenderStyle.LIGHTMAP: // Static lights look the same as attenuated lights
default: lightOffsets[1]++; break; // attenuated
}
}

View file

@ -62,8 +62,17 @@ namespace CodeImp.DoomBuilder.Types
list = arginfo.Enum;
}
// When set up for an UDMF field
public override void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
{
defaultvalue = (int)fieldinfo.Default;
base.SetupField(attr, fieldinfo);
// Keep enum list reference
list = fieldinfo.Enum;
}
#endregion
#region ================== Methods
public override void Browse(IWin32Window parent)

View file

@ -16,6 +16,7 @@
#region ================== Namespaces
using CodeImp.DoomBuilder.Config;
using System;
using System.Globalization;
@ -33,6 +34,7 @@ namespace CodeImp.DoomBuilder.Types
#region ================== Variables
private double value;
private double defaultvalue;
#endregion
@ -42,6 +44,18 @@ namespace CodeImp.DoomBuilder.Types
#region ================== Methods
public override void SetupArgument(TypeHandlerAttribute attr, ArgumentInfo arginfo)
{
defaultvalue = (double)arginfo.DefaultValue;
base.SetupArgument(attr, arginfo);
}
public override void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
{
defaultvalue = (fieldinfo == null || fieldinfo.Default == null) ? 0.0 : (double)fieldinfo.Default;
base.SetupField(attr, fieldinfo);
}
public override void SetValue(object value)
{
// Null?
@ -87,7 +101,7 @@ namespace CodeImp.DoomBuilder.Types
public override object GetDefaultValue()
{
return 0.0;
return defaultvalue;
}
#endregion

View file

@ -51,6 +51,12 @@ namespace CodeImp.DoomBuilder.Types
base.SetupArgument(attr, arginfo);
}
public override void SetupField(TypeHandlerAttribute attr, UniversalFieldInfo fieldinfo)
{
defaultvalue = (fieldinfo == null || fieldinfo.Default == null) ? 0 : (int)fieldinfo.Default;
base.SetupField(attr, fieldinfo);
}
public override void SetValue(object value)
{
// Null?

View file

@ -681,7 +681,7 @@ namespace CodeImp.DoomBuilder.VisualModes
if (ld.LightDef != GZGeneral.LightDef.POINT_SUBTRACTIVE) // normal, additive, attenuated
{
// ZDRay static lights have an intensity that's set through the thing's alpha value
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.STATIC ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.LIGHTMAP ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
//lightColor.Alpha used in shader to perform some calculations based on light type
lightColor = new Color4(
@ -720,7 +720,7 @@ namespace CodeImp.DoomBuilder.VisualModes
if (ld.LightDef != GZGeneral.LightDef.SPOT_SUBTRACTIVE)
{
// ZDRay static lights have an intensity that's set through the thing's alpha value
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.STATIC ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
float intensity = ld.LightRenderStyle == GZGeneral.LightRenderStyle.LIGHTMAP ? (float)thing.Fields.GetValue("alpha", 1.0) : 1.0f;
lightColor = new Color4(
c1 / DYNLIGHT_INTENSITY_SCALER * intensity,

View file

@ -258,6 +258,11 @@ namespace CodeImp.DoomBuilder.ZDoom
// Skip entire line
char c4 = c3;
while((c4 != '\n') && (datastream.Position < datastream.Length)) { c4 = (char)datareader.ReadByte(); }
// Reached end of file?
if (datastream.Position == datastream.Length)
return true;
c = c4;
}
else

View file

@ -30,6 +30,7 @@ namespace CodeImp.DoomBuilder.ZDoom
LineComment, // // blablabla
BlockComment, // /* blablabla */
Whitespace, // whitespace is a legit token.
Region, // #region, #endregion
// invalid token
Invalid,
@ -199,7 +200,7 @@ namespace CodeImp.DoomBuilder.ZDoom
{
while (true)
{
ZScriptToken tok = ExpectToken(ZScriptTokenType.Newline, ZScriptTokenType.BlockComment, ZScriptTokenType.LineComment, ZScriptTokenType.Whitespace);
ZScriptToken tok = ExpectToken(ZScriptTokenType.Newline, ZScriptTokenType.BlockComment, ZScriptTokenType.LineComment, ZScriptTokenType.Whitespace, ZScriptTokenType.Region);
if (tok == null || !tok.IsValid) break;
}
}
@ -460,7 +461,7 @@ namespace CodeImp.DoomBuilder.ZDoom
return null;
}
private ZScriptToken TryReadStringOrComment(bool allowstring, bool allowname, bool allowblock, bool allowline)
private ZScriptToken TryReadStringOrComment(bool allowstring, bool allowname, bool allowblock, bool allowline, bool allowregion)
{
long cpos = LastPosition = reader.BaseStream.Position;
char c;
@ -552,7 +553,41 @@ namespace CodeImp.DoomBuilder.ZDoom
}
break;
}
case '#': // #region and #endregion
{
if (!allowregion) break;
char cnext;
SB.Length = 0;
// Read until the end of the line
while (true)
{
try
{
cnext = reader.ReadChar();
}
catch(EndOfStreamException)
{
break;
}
if(cnext == '\n')
{
reader.BaseStream.Position--;
break;
}
SB.Append(cnext);
}
string line = SB.ToString();
// GZDoom actually doesn't care what's coming after #region or #endregion, so something like #regionlalala is valid.
// But they have to be in lower case
if (line.StartsWith("region") || line.StartsWith("endregion"))
return new ZScriptToken() { Position = cpos, Type = ZScriptTokenType.Region, Value = "" };
break;
}
case '"':
case '\'':
{
@ -586,7 +621,6 @@ namespace CodeImp.DoomBuilder.ZDoom
}
}
}
}
reader.BaseStream.Position = cpos;
@ -642,11 +676,12 @@ namespace CodeImp.DoomBuilder.ZDoom
bool bblockcomment = oneof.Contains(ZScriptTokenType.BlockComment);
bool bstring = oneof.Contains(ZScriptTokenType.String);
bool bname = oneof.Contains(ZScriptTokenType.Name);
bool bregion = oneof.Contains(ZScriptTokenType.Region);
if (bstring || bname || bblockcomment || blinecomment)
if (bstring || bname || bblockcomment || blinecomment || bregion)
{
// try to expect a string
ZScriptToken tok = TryReadStringOrComment(bstring, bname, bblockcomment, blinecomment);
ZScriptToken tok = TryReadStringOrComment(bstring, bname, bblockcomment, blinecomment, bregion);
if (tok != null) return tok;
}
@ -721,7 +756,7 @@ namespace CodeImp.DoomBuilder.ZDoom
if (tok != null) return tok;
}
tok = TryReadStringOrComment(true, true, true, true);
tok = TryReadStringOrComment(true, true, true, true, true);
if (tok != null) return tok;
if (!short_circuit)

View file

@ -513,11 +513,13 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
foreach(VisualMiddle3D m3d in part.middle3d)
{
if(m3d.Vertices == null) continue;
texture = m3d.GetControlLinedef().Front.MiddleTexture;
texture = m3d.GetTextureName();
if (!skipTextures.Contains(texture))
{
CheckTextureName(ref texturegeo, ref texture);
texturegeo[texture].AddRange(OptimizeGeometry(m3d.Vertices, m3d.GeometryType));
// 3D floor sides are cut so that there are only triangles for the visible parts. Some of those might be
// triangles and not rectangles, so we can't optimize them into rectangles
texturegeo[texture].AddRange(OptimizeGeometry(m3d.Vertices, m3d.GeometryType, true));
}
}
}

View file

@ -848,15 +848,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Texture offset change
public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
public virtual bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
{
if(horizontal == 0 && vertical == 0) return; //mxd
if(horizontal == 0 && vertical == 0) return false; //mxd
//mxd
if(!General.Map.UDMF)
{
General.Interface.DisplayStatus(StatusType.Warning, "Floor/ceiling texture offsets cannot be changed in this map format!");
return;
return false;
}
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
@ -914,6 +914,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
if(vs != null) vs.UpdateSectorGeometry(false);
return true;
}
//mxd

View file

@ -1660,7 +1660,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Texture offset change
public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
public virtual bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
{
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture offsets");
@ -1695,6 +1695,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. Update linked effects
SectorData sd = mode.GetSectorDataEx(Sector.Sector);
if(sd != null) sd.Reset(true);
return true;
}
//mxd

View file

@ -111,7 +111,7 @@ namespace CodeImp.DoomBuilder.VisualModes
public void OnSelectBegin() { }
public void OnEditBegin() { }
public void OnChangeTargetBrightness(bool up, bool local) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { return true; }
public void OnSelectTexture() { }
public void OnCopyTexture() { }
public void OnPasteTexture() { }

View file

@ -704,7 +704,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnSelectBegin() { }
public void OnEditBegin() { }
public void OnChangeTargetBrightness(bool up, bool local) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { return true; }
public void OnSelectTexture() { }
public void OnCopyTexture() { }
public void OnPasteTexture() { }

View file

@ -241,7 +241,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnEditBegin() { }
public void OnMouseMove(MouseEventArgs e) { }
public void OnChangeTargetBrightness(bool up, bool local) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { return true; }
public void OnChangeScale(int incrementX, int incrementY) { }
public void OnSelectTexture() { }
public void OnCopyTexture() { }

View file

@ -35,7 +35,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
void OnMouseMove(MouseEventArgs e);
void OnChangeTargetHeight(int amount);
void OnChangeTargetBrightness(bool up, bool local);
void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection);
bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection);
void OnChangeScale(int incrementX, int incrementY); //mxd
void OnResetTextureOffset();
void OnResetLocalTextureOffset(); //mxd. This should reset upper/middle/lower offsets (UDMF only)

View file

@ -34,7 +34,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnMouseMove(MouseEventArgs e) { }
public void OnChangeTargetHeight(int amount) { }
public void OnChangeTargetBrightness(bool up, bool local) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { return true; }
public void OnChangeScale(int incrementX, int incrementY) { } //mxd
public void OnResetTextureOffset() { }
public void OnResetLocalTextureOffset() { } //mxd

View file

@ -279,16 +279,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
public override void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
public override bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
{
bool appliedoffset = false;
// Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors
SectorData sd = mode.GetSectorData(level.sector);
if(!sd.CeilingChanged)
{
sd.CeilingChanged = true;
base.OnChangeTextureOffset(horizontal, vertical, doSurfaceAngleCorrection);
sd.CeilingChanged = appliedoffset = base.OnChangeTextureOffset(horizontal, vertical, doSurfaceAngleCorrection);
}
return appliedoffset;
}
// Move texture coordinates

View file

@ -233,16 +233,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
//mxd
public override void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
public override bool OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
{
bool appliedoffset = false;
// Only do this when not done yet in this call
// Because we may be able to select the same 3D floor multiple times through multiple sectors
SectorData sd = mode.GetSectorData(level.sector);
if(!sd.FloorChanged)
{
sd.FloorChanged = true;
base.OnChangeTextureOffset(horizontal, vertical, doSurfaceAngleCorrection);
sd.FloorChanged = appliedoffset = base.OnChangeTextureOffset(horizontal, vertical, doSurfaceAngleCorrection);
}
return appliedoffset;
}
// Move texture coordinates

View file

@ -1,2 +1,3 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
mono Builder.exe