Visual mode: added support for "Transfer Brightness Level" (50) effect type parameter (arg 1).

Visual mode: added support for "Transfer Floor Brightness" (210) effect.
Visual mode: added support for "Transfer Ceiling Brightness" (211) effect.
Visual mode: changed the way thing brightness is calculated. Should be closer to GZDoom now.
Sector Edit Form: you can now enter "++" or "--" into "Height Offset" input to raise or lower sectors by their height.
Cosmetic fix in ZDoom_linedefs.cfg.
This commit is contained in:
MaxED 2015-04-01 12:51:26 +00:00
parent c742684bf8
commit 5fe89efc7c
21 changed files with 465 additions and 196 deletions

View file

@ -1770,7 +1770,7 @@ zdoom
type = 11;
enum
{
0 = "From control sector's ceiling down to top of another type 0 light";
0 = "From control sector's ceiling down to the top of another type 0 light";
1 = "From control sector's ceiling down to control sector's floor";
2 = "From control sector's ceiling down to the top of another extra light";
}

View file

@ -175,6 +175,14 @@ namespace CodeImp.DoomBuilder.Controls
// Validate contents
protected override void OnValidating(CancelEventArgs e)
{
//mxd. We may want "++" and "--" on their own...
if(allowrelative && (this.Text == "++" || this.Text == "--"))
{
// Call base and bail out
base.OnValidating(e);
return;
}
// Strip prefixes
string textpart = this.Text.Replace("+", "").Replace("*", "").Replace("/", ""); //mxd
if(!allownegative) textpart = textpart.Replace("-", "");

View file

@ -44,8 +44,7 @@ namespace CodeImp.DoomBuilder.Rendering
// Rendering methods
int CalculateBrightness(int level);
//mxd
int CalculateBrightness(int level, Sidedef sd);
int CalculateBrightness(int level, Sidedef sd); //mxd
void SetHighlightedObject(IVisualPickable obj);
void AddSectorGeometry(VisualGeometry g);

View file

@ -903,8 +903,8 @@ namespace CodeImp.DoomBuilder.Rendering
{
wantedshaderpass += 4; //render using one of passes, which uses World3D.VertexColor
graphics.Shaders.World3D.VertexColor = t.LightColor;
//mxd. check if Thing is affected by dynamic lights and set color accordingly
}
}
//mxd. check if Thing is affected by dynamic lights and set color accordingly
else if (General.Settings.GZDrawLightsMode != LightRenderMode.NONE && !fullbrightness && thingsWithLight.Count > 0)
{
Color4 litColor = GetLitColorForThing(t);

View file

@ -188,7 +188,8 @@ namespace CodeImp.DoomBuilder.Windows
label7.TabIndex = 25;
label7.Text = "Height offset:";
label7.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.tooltip.SetToolTip(label7, "Changes floor and ceiling\r\nheight by given value.");
this.tooltip.SetToolTip(label7, "Changes floor and ceiling height by given value.\r\nUse \"++\" to raise by sector hei" +
"ght.\r\nUse \"--\" to lower by sector height.");
//
// label5
//
@ -212,7 +213,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.heightoffset.AllowDecimal = false;
this.heightoffset.AllowNegative = true;
this.heightoffset.AllowRelative = false;
this.heightoffset.AllowRelative = true;
this.heightoffset.ButtonStep = 8;
this.heightoffset.ButtonStepBig = 16F;
this.heightoffset.ButtonStepFloat = 1F;

View file

@ -225,19 +225,33 @@ namespace CodeImp.DoomBuilder.Windows
private void UpdateCeilingHeight()
{
int i = 0;
int offset = heightoffset.GetResult(0);
int offset;
//restore values
if(string.IsNullOrEmpty(ceilingheight.Text))
if(heightoffset.Text == "++" || heightoffset.Text == "--") // Raise or lower by sector height
{
foreach(Sector s in sectors)
s.CeilHeight = sectorprops[i++].CeilHeight + offset;
int sign = (heightoffset.Text == "++" ? 1 : -1);
foreach (Sector s in sectors)
{
offset = sectorprops[i].CeilHeight - sectorprops[i].FloorHeight;
s.CeilHeight += offset * sign;
i++;
}
}
else //update values
else
{
foreach(Sector s in sectors)
s.CeilHeight = ceilingheight.GetResult(sectorprops[i++].CeilHeight) + offset;
offset = heightoffset.GetResult(0);
//restore values
if(string.IsNullOrEmpty(ceilingheight.Text))
{
foreach(Sector s in sectors)
s.CeilHeight = sectorprops[i++].CeilHeight + offset;
}
else //update values
{
foreach(Sector s in sectors)
s.CeilHeight = ceilingheight.GetResult(sectorprops[i++].CeilHeight) + offset;
}
}
}
@ -245,19 +259,34 @@ namespace CodeImp.DoomBuilder.Windows
private void UpdateFloorHeight()
{
int i = 0;
int offset = heightoffset.GetResult(0);
int offset;
//restore values
if(string.IsNullOrEmpty(floorheight.Text))
if(heightoffset.Text == "++" || heightoffset.Text == "--")
{
foreach(Sector s in sectors)
s.FloorHeight = sectorprops[i++].FloorHeight + offset;
}
else //update values
// Raise or lower by sector height
int sign = (heightoffset.Text == "++" ? 1 : -1);
foreach (Sector s in sectors)
{
offset = sectorprops[i].CeilHeight - sectorprops[i].FloorHeight;
s.FloorHeight += offset * sign;
i++;
}
}
else
{
foreach(Sector s in sectors)
s.FloorHeight = floorheight.GetResult(sectorprops[i++].FloorHeight) + offset;
offset = heightoffset.GetResult(0);
//restore values
if(string.IsNullOrEmpty(floorheight.Text))
{
foreach (Sector s in sectors)
s.FloorHeight = sectorprops[i++].FloorHeight + offset;
}
else //update values
{
foreach (Sector s in sectors)
s.FloorHeight = floorheight.GetResult(sectorprops[i++].FloorHeight) + offset;
}
}
}

View file

@ -366,7 +366,8 @@
label15.TabIndex = 27;
label15.Text = "Height offset:";
label15.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.tooltip.SetToolTip(label15, "Changes floor and ceiling\r\nheight by given value.");
this.tooltip.SetToolTip(label15, "Changes floor and ceiling height by given value.\r\nUse \"++\" to raise by sector hei" +
"ght.\r\nUse \"--\" to lower by sector height.");
//
// label6
//
@ -390,7 +391,7 @@
//
this.heightoffset.AllowDecimal = false;
this.heightoffset.AllowNegative = true;
this.heightoffset.AllowRelative = false;
this.heightoffset.AllowRelative = true;
this.heightoffset.ButtonStep = 8;
this.heightoffset.ButtonStepBig = 16F;
this.heightoffset.ButtonStepFloat = 1F;
@ -584,7 +585,7 @@
//
// floorAngleControl
//
this.floorAngleControl.Angle = -270;
this.floorAngleControl.Angle = -360;
this.floorAngleControl.AngleOffset = 90;
this.floorAngleControl.Location = new System.Drawing.Point(6, 132);
this.floorAngleControl.Name = "floorAngleControl";
@ -818,7 +819,7 @@
//
// ceilAngleControl
//
this.ceilAngleControl.Angle = -270;
this.ceilAngleControl.Angle = -360;
this.ceilAngleControl.AngleOffset = 90;
this.ceilAngleControl.Location = new System.Drawing.Point(6, 132);
this.ceilAngleControl.Name = "ceilAngleControl";

View file

@ -531,24 +531,38 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void UpdateCeilingHeight()
{
int offset = heightoffset.GetResult(0);
int offset;
//restore values
if(string.IsNullOrEmpty(ceilingheight.Text))
if(heightoffset.Text == "++" || heightoffset.Text == "--") // Raise or lower by sector height
{
int sign = (heightoffset.Text == "++" ? 1 : -1);
foreach (Sector s in sectors)
{
s.CeilHeight = sectorprops[s].CeilHeight + offset;
offset = sectorprops[s].CeilHeight - sectorprops[s].FloorHeight;
s.CeilHeight += offset * sign;
SynchCeilSlopeOffsetToHeight(s);
}
}
else //update values
}
else
{
foreach (Sector s in sectors)
offset = heightoffset.GetResult(0);
//restore values
if(string.IsNullOrEmpty(ceilingheight.Text))
{
s.CeilHeight = ceilingheight.GetResult(sectorprops[s].CeilHeight) + offset;
SynchCeilSlopeOffsetToHeight(s);
foreach (Sector s in sectors)
{
s.CeilHeight = sectorprops[s].CeilHeight + offset;
SynchCeilSlopeOffsetToHeight(s);
}
}
else //update values
{
foreach (Sector s in sectors)
{
s.CeilHeight = ceilingheight.GetResult(sectorprops[s].CeilHeight) + offset;
SynchCeilSlopeOffsetToHeight(s);
}
}
}
}
@ -556,24 +570,38 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private void UpdateFloorHeight()
{
int offset = heightoffset.GetResult(0);
int offset;
//restore values
if(string.IsNullOrEmpty(floorheight.Text))
if(heightoffset.Text == "++" || heightoffset.Text == "--")
{
// Raise or lower by sector height
int sign = (heightoffset.Text == "++" ? 1 : -1);
foreach (Sector s in sectors)
{
s.FloorHeight = sectorprops[s].FloorHeight + offset;
SynchFloorSlopeOffsetToHeight(s);
offset = sectorprops[s].CeilHeight - sectorprops[s].FloorHeight;
s.FloorHeight += offset * sign;
}
}
else //update values
}
else
{
foreach (Sector s in sectors)
offset = heightoffset.GetResult(0);
//restore values
if(string.IsNullOrEmpty(floorheight.Text))
{
s.FloorHeight = floorheight.GetResult(sectorprops[s].FloorHeight) + offset;
SynchFloorSlopeOffsetToHeight(s);
foreach (Sector s in sectors)
{
s.FloorHeight = sectorprops[s].FloorHeight + offset;
SynchFloorSlopeOffsetToHeight(s);
}
}
else //update values
{
foreach (Sector s in sectors)
{
s.FloorHeight = floorheight.GetResult(sectorprops[s].FloorHeight) + offset;
SynchFloorSlopeOffsetToHeight(s);
}
}
}
}

View file

@ -138,36 +138,12 @@
<metadata name="label8.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label14.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label9.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label13.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label8.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="groupfloorceiling.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label15.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label6.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label5.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label15.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@ -186,10 +162,4 @@
<metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="fieldslist.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="tooltip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -39,8 +39,10 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ClassicModes\BaseClassicMode.cs" />
@ -372,6 +374,8 @@
<Compile Include="VisualModes\EffectThingLineSlope.cs" />
<Compile Include="VisualModes\EffectThingSlope.cs" />
<Compile Include="VisualModes\EffectThingVertexSlope.cs" />
<Compile Include="VisualModes\EffectTransferCeilingBrightness.cs" />
<Compile Include="VisualModes\EffectTransferFloorBrightness.cs" />
<Compile Include="VisualModes\EffectUDMFVertexOffset.cs" />
<Compile Include="VisualModes\IVisualEventReceiver.cs" />
<Compile Include="VisualModes\NullVisualEventReceiver.cs" />

View file

@ -168,12 +168,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
List<WallPolygon> polygons = new List<WallPolygon>(poly);
List<WorldVertex> verts = new List<WorldVertex>();
SectorLevel prevlight = null; //mxd
// Go for all levels to build geometry
for(int i = sd.LightLevels.Count - 1; i >= 0; i--)
{
SectorLevel l = sd.LightLevels[i];
//mxd. Skip current light level when it's between TYPE1 and TYPE1_BOTTOM
if(prevlight != null
&& prevlight.type == SectorLevelType.Light && l.type == SectorLevelType.Light
&& (prevlight.lighttype == LightLevelType.TYPE1 && l.lighttype != LightLevelType.TYPE1_BOTTOM))
continue;
if(l.type == SectorLevelType.Light) prevlight = l;
if((l != sd.Floor) && (l != sd.Ceiling) && (l.type != SectorLevelType.Floor || l.alpha < 255))
{
// Go for all polygons

View file

@ -764,7 +764,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (!gzdoomRenderingEffects)
{
//store all sectors with effects
if(sectordata != null && sectordata.Count > 0)
{
@ -824,11 +823,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
// ========== Thing vertex slope, vertices with UDMF vertex offsets ==========
if(s.Sidedefs.Count == 3)
{
if(General.Map.UDMF) //mxd
GetSectorData(s).AddEffectVertexOffset();
if(General.Map.UDMF) GetSectorData(s).AddEffectVertexOffset(); //mxd
List<Thing> slopeceilingthings = new List<Thing>(3);
List<Thing> slopefloorthings = new List<Thing>(3);
foreach(Sidedef sd in s.Sidedefs)
{
Vertex v = sd.IsFront ? sd.Line.End : sd.Line.Start;
@ -866,122 +864,157 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Find interesting linedefs (such as line slopes)
foreach(Linedef l in General.Map.Map.Linedefs)
{
// ========== Plane Align (see http://zdoom.org/wiki/Plane_Align) ==========
if(l.Action == 181)
switch(l.Action)
{
// Slope front
if(((l.Args[0] == 1) || (l.Args[1] == 1)) && (l.Front != null))
{
SectorData sd = GetSectorData(l.Front.Sector);
sd.AddEffectLineSlope(l);
}
// Slope back
if(((l.Args[0] == 2) || (l.Args[1] == 2)) && (l.Back != null))
{
SectorData sd = GetSectorData(l.Back.Sector);
sd.AddEffectLineSlope(l);
}
}
// ========== Plane Copy (mxd) (see http://zdoom.org/wiki/Plane_Copy) ==========
else if(l.Action == 118)
{
//check the flags...
bool floorCopyToBack = false;
bool floorCopyToFront = false;
bool ceilingCopyToBack = false;
bool ceilingCopyToFront = false;
if(l.Args[4] > 0 && l.Args[4] != 3 && l.Args[4] != 12)
{
floorCopyToBack = (l.Args[4] & 1) == 1;
floorCopyToFront = (l.Args[4] & 2) == 2;
ceilingCopyToBack = (l.Args[4] & 4) == 4;
ceilingCopyToFront = (l.Args[4] & 8) == 8;
}
// Copy slope to front sector
if(l.Front != null)
{
if( (l.Args[0] > 0 || l.Args[1] > 0) || (l.Back != null && (floorCopyToFront || ceilingCopyToFront)) )
// ========== Plane Align (see http://zdoom.org/wiki/Plane_Align) ==========
case 181:
if(((l.Args[0] == 1) || (l.Args[1] == 1)) && (l.Front != null))
{
SectorData sd = GetSectorData(l.Front.Sector);
sd.AddEffectPlaneClopySlope(l, true);
sd.AddEffectLineSlope(l);
}
}
// Copy slope to back sector
if(l.Back != null)
{
if( (l.Args[2] > 0 || l.Args[3] > 0) || (l.Front != null && (floorCopyToBack || ceilingCopyToBack)) )
if(((l.Args[0] == 2) || (l.Args[1] == 2)) && (l.Back != null))
{
SectorData sd = GetSectorData(l.Back.Sector);
sd.AddEffectPlaneClopySlope(l, false);
sd.AddEffectLineSlope(l);
}
}
}
// ========== Sector 3D floor (see http://zdoom.org/wiki/Sector_Set3dFloor) ==========
else if((l.Action == 160) && (l.Front != null))
{
//mxd. Added hi-tag/line ID check
int sectortag = (l.Args[1] & (int)Effect3DFloor.FloorTypes.HiTagIsLineID) != 0 ? l.Args[0] : l.Args[0] + (l.Args[4] << 8);
if(sectortags.ContainsKey(sectortag))
break;
// ========== Plane Copy (mxd) (see http://zdoom.org/wiki/Plane_Copy) ==========
case 118:
{
List<Sector> sectors = sectortags[sectortag];
foreach(Sector s in sectors)
//check the flags...
bool floorCopyToBack = false;
bool floorCopyToFront = false;
bool ceilingCopyToBack = false;
bool ceilingCopyToFront = false;
if(l.Args[4] > 0 && l.Args[4] != 3 && l.Args[4] != 12)
{
SectorData sd = GetSectorData(s);
sd.AddEffect3DFloor(l);
floorCopyToBack = (l.Args[4] & 1) == 1;
floorCopyToFront = (l.Args[4] & 2) == 2;
ceilingCopyToBack = (l.Args[4] & 4) == 4;
ceilingCopyToFront = (l.Args[4] & 8) == 8;
}
// Copy slope to front sector
if(l.Front != null)
{
if( (l.Args[0] > 0 || l.Args[1] > 0) || (l.Back != null && (floorCopyToFront || ceilingCopyToFront)) )
{
SectorData sd = GetSectorData(l.Front.Sector);
sd.AddEffectPlaneClopySlope(l, true);
}
}
// Copy slope to back sector
if(l.Back != null)
{
if( (l.Args[2] > 0 || l.Args[3] > 0) || (l.Front != null && (floorCopyToBack || ceilingCopyToBack)) )
{
SectorData sd = GetSectorData(l.Back.Sector);
sd.AddEffectPlaneClopySlope(l, false);
}
}
}
}
// ========== Transfer Brightness (see http://zdoom.org/wiki/ExtraFloor_LightOnly) =========
else if((l.Action == 50) && (l.Front != null))
{
if(sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
break;
// ========== Sector 3D floor (see http://zdoom.org/wiki/Sector_Set3dFloor) ==========
case 160:
if(l.Front != null)
{
SectorData sd = GetSectorData(s);
sd.AddEffectBrightnessLevel(l);
//mxd. Added hi-tag/line ID check
int sectortag = (l.Args[1] & (int)Effect3DFloor.FloorTypes.HiTagIsLineID) != 0 ? l.Args[0] : l.Args[0] + (l.Args[4] << 8);
if(sectortags.ContainsKey(sectortag))
{
List<Sector> sectors = sectortags[sectortag];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffect3DFloor(l);
}
}
}
}
break;
// ========== Transfer Brightness (see http://zdoom.org/wiki/ExtraFloor_LightOnly) =========
case 50:
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectBrightnessLevel(l);
}
}
break;
// ========== mxd. Transfer Floor Brightness (see http://www.zdoom.org/w/index.php?title=Transfer_FloorLight) =========
case 210:
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferFloorBrightness(l);
}
}
break;
// ========== mxd. Transfer Ceiling Brightness (see http://www.zdoom.org/w/index.php?title=Transfer_CeilingLight) =========
case 211:
if(l.Front != null && sectortags.ContainsKey(l.Args[0]))
{
List<Sector> sectors = sectortags[l.Args[0]];
foreach(Sector s in sectors)
{
SectorData sd = GetSectorData(s);
sd.AddEffectTransferCeilingBrightness(l);
}
}
break;
}
}
// Find interesting things (such as sector slopes)
foreach(Thing t in General.Map.Map.Things)
{
// ========== Copy slope ==========
if((t.Type == 9510) || (t.Type == 9511))
switch(t.Type)
{
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectCopySlope(t);
}
}
// ========== Thing line slope ==========
else if((t.Type == 9500) || (t.Type == 9501))
{
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectThingLineSlope(t);
}
}
// ========== Thing slope ==========
else if((t.Type == 9502) || (t.Type == 9503))
{
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectThingSlope(t);
}
// ========== Copy slope ==========
case 9511:
case 9510:
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectCopySlope(t);
}
break;
// ========== Thing line slope ==========
case 9501:
case 9500:
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectThingLineSlope(t);
}
break;
// ========== Thing slope ==========
case 9503:
case 9502:
t.DetermineSector(blockmap);
if(t.Sector != null)
{
SectorData sd = GetSectorData(t.Sector);
sd.AddEffectThingSlope(t);
}
break;
}
}
}

View file

@ -125,7 +125,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(Thing.Sector != null)
{
SectorData sd = mode.GetSectorData(Thing.Sector);
SectorLevel level = sd.GetLevelAbove(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + Thing.Sector.FloorHeight));
SectorLevel level = sd.GetLevelAboveOrAt(new Vector3D(Thing.Position.x, Thing.Position.y, Thing.Position.z + Thing.Sector.FloorHeight));
if(nointeraction && level == null && sd.LightLevels.Count > 0) level = sd.LightLevels[sd.LightLevels.Count - 1]; //mxd. Use the light level of the highest surface when a thing is above highest sector level.
if(level != null)
{

View file

@ -10,10 +10,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
// Linedef that is used to create this effect
// The sector can be found by linedef.Front.Sector
private Linedef linedef;
private readonly Linedef linedef;
// Level plane
private SectorLevel level;
// Level planes
private SectorLevel toplevel;
private SectorLevel bottomlevel; //mxd
// Constructor
public EffectBrightnessLevel(SectorData data, Linedef sourcelinedef) : base(data)
@ -35,15 +36,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!sd.Updated) sd.Update();
sd.AddUpdateSector(data.Sector, false);
if(level == null)
// Create top level?
if(toplevel == null)
{
level = new SectorLevel(sd.Ceiling);
data.AddSectorLevel(level);
toplevel = new SectorLevel(sd.Ceiling);
data.AddSectorLevel(toplevel);
}
// Update top level
sd.Ceiling.CopyProperties(toplevel);
toplevel.lighttype = (LightLevelType)General.Clamp(linedef.Args[1], 0, 2); //mxd
toplevel.type = SectorLevelType.Light;
//mxd. Create bottom level?
if(toplevel.lighttype == LightLevelType.TYPE1)
{
// Create bottom level? Skip this step if there's a different light level between toplevel and bottomlevel
if(bottomlevel == null)
{
bottomlevel = new SectorLevel(data.Ceiling);
data.AddSectorLevel(bottomlevel);
}
// Update bottom level
data.Ceiling.CopyProperties(bottomlevel);
bottomlevel.type = SectorLevelType.Light;
bottomlevel.lighttype = LightLevelType.TYPE1_BOTTOM;
bottomlevel.plane = sd.Floor.plane.GetInverted();
}
// Update level
sd.Ceiling.CopyProperties(level);
level.type = SectorLevelType.Light;
}
}
}

View file

@ -0,0 +1,38 @@
#region === Copyright (c) 2015 MaxED ===
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
class EffectTransferCeilingBrightness : SectorEffect
{
// Linedef that is used to create this effect
private readonly Linedef linedef;
// Constructor
public EffectTransferCeilingBrightness(SectorData data, Linedef sourcelinedef) : base(data)
{
linedef = sourcelinedef;
// New effect added: This sector needs an update!
if(data.Mode.VisualSectorExists(data.Sector))
{
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
vs.UpdateSectorGeometry(false);
}
}
// This makes sure we are updated with the source linedef information
public override void Update()
{
SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);
if(!sd.Updated) sd.Update();
sd.AddUpdateSector(data.Sector, false);
// Transfer ceiling brightness
data.Ceiling.color = General.Map.Renderer3D.CalculateBrightness(sd.Sector.Brightness);
}
}
}

View file

@ -0,0 +1,39 @@
#region === Copyright (c) 2015 MaxED ===
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class EffectTransferFloorBrightness : SectorEffect
{
// Linedef that is used to create this effect
private readonly Linedef linedef;
// Constructor
public EffectTransferFloorBrightness(SectorData data, Linedef sourcelinedef) : base(data)
{
linedef = sourcelinedef;
// New effect added: This sector needs an update!
if(data.Mode.VisualSectorExists(data.Sector))
{
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
vs.UpdateSectorGeometry(false);
}
}
// This makes sure we are updated with the source linedef information
public override void Update()
{
SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);
if(!sd.Updated) sd.Update();
sd.AddUpdateSector(data.Sector, false);
// Transfer floor brightness
data.Floor.color = General.Map.Renderer3D.CalculateBrightness(sd.Sector.Brightness);
data.Floor.brightnessbelow = sd.Floor.brightnessbelow;
}
}
}

View file

@ -107,6 +107,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
alleffects.Add(e);
}
//mxd. Transfer Floor Brightness effect
public void AddEffectTransferFloorBrightness(Linedef sourcelinedef)
{
EffectTransferFloorBrightness e = new EffectTransferFloorBrightness(this, sourcelinedef);
alleffects.Add(e);
}
//mxd. Transfer Floor Brightness effect
public void AddEffectTransferCeilingBrightness(Linedef sourcelinedef)
{
EffectTransferCeilingBrightness e = new EffectTransferCeilingBrightness(this, sourcelinedef);
alleffects.Add(e);
}
// Line slope effect
public void AddEffectLineSlope(Linedef sourcelinedef)
{
@ -290,11 +304,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Now that we know the levels in this sector (and in the right order) we
// can determine the lighting in between and on the levels.
// Start from the absolute ceiling and go down to 'cast' the lighting
SectorLevel stored = ceiling; //mxd
for(int i = startindex; i >= 0; i--)
{
SectorLevel l = lightlevels[i];
SectorLevel pl = lightlevels[i + 1];
if(l.lighttype == LightLevelType.TYPE1) stored = pl; //mxd
//mxd. If the real floor has "lightfloor" value and the 3d floor above it doesn't cast down light, use real floor's brightness
if(General.Map.UDMF && l == floor && lightlevels.Count > 2 && (pl.disablelighting || pl.restrictlighting) && l.sector.Fields.ContainsKey("lightfloor"))
{
@ -303,13 +320,34 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
// Set color when no color is specified, or when a 3D floor is placed above the absolute floor
if((l.color == 0) || ((l == floor) && (lightlevels.Count > 2)))
//mxd. Or when lightlevel is above a floor/ceiling level
bool uselightlevellight = ((l.type != SectorLevelType.Light) && pl != null && pl.type == SectorLevelType.Light); //mxd
if((l.color == 0) || ((l == floor) && (lightlevels.Count > 2)) || uselightlevellight)
{
PixelColor floorbrightness = PixelColor.FromInt(mode.CalculateBrightness(pl.brightnessbelow));
PixelColor floorcolor = PixelColor.Modulate(pl.colorbelow, floorbrightness);
l.color = floorcolor.WithAlpha(255).ToInt();
if(uselightlevellight) l.brightnessbelow = pl.brightnessbelow;
}
//mxd. Bottom TYPE1 border requires special handling...
else if(l.lighttype == LightLevelType.TYPE1_BOTTOM)
{
//Use brightness and color from previous light level when it's between TYPE1 and TYPE1_BOTTOM levels
if(pl.type == SectorLevelType.Light && pl.lighttype != LightLevelType.TYPE1)
{
l.brightnessbelow = pl.brightnessbelow;
l.colorbelow = pl.colorbelow;
}
//Use brightness and color from the light level above TYPE1 level
else if(stored.type == SectorLevelType.Light)
{
l.brightnessbelow = stored.brightnessbelow;
l.colorbelow = stored.colorbelow;
}
// Otherwise light values from the real ceiling are used
}
if(l.colorbelow.a == 0) l.colorbelow = pl.colorbelow;
if(l.brightnessbelow == -1) l.brightnessbelow = pl.brightnessbelow;
}
@ -339,6 +377,25 @@ namespace CodeImp.DoomBuilder.BuilderModes
return found;
}
//mxd. This returns the level above the given point or the level given point is located on
public SectorLevel GetLevelAboveOrAt(Vector3D pos)
{
SectorLevel found = null;
float dist = float.MaxValue;
foreach(SectorLevel l in lightlevels)
{
float d = l.plane.GetZ(pos) - pos.z;
if((d >= 0.0f) && (d < dist))
{
dist = d;
found = l;
}
}
return found;
}
// This returns the level above the given point
public SectorLevel GetCeilingAbove(Vector3D pos)
{

View file

@ -6,7 +6,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
internal abstract class SectorEffect
{
protected SectorData data;
protected readonly SectorData data;
// Constructor
protected SectorEffect(SectorData data)

View file

@ -13,6 +13,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Type of level
public SectorLevelType type;
//mxd. Type of extralight
public LightLevelType lighttype = LightLevelType.UNKNOWN;
// Sector where this level originates from
public Sector sector;
@ -52,6 +55,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
target.sector = this.sector;
target.type = this.type;
target.lighttype = this.lighttype; //mxd
target.plane = this.plane;
target.alpha = this.alpha;
target.color = this.color;

View file

@ -23,7 +23,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Comparer
public int Compare(SectorLevel x, SectorLevel y)
{
return (x == y ? 0 : Math.Sign(x.plane.GetZ(center) - y.plane.GetZ(center))); //mxd. Added equality check
if(x == y) return 0; //mxd
float diff = (float)Math.Round(x.plane.GetZ(center) - y.plane.GetZ(center), 3);
if(diff == 0)
{
//mxd. Push light levels above floor and ceiling levels when height is the same
if(x.type != SectorLevelType.Light) return (y.type == SectorLevelType.Light ? -1 : 0);
if(y.type != SectorLevelType.Light) return (x.type == SectorLevelType.Light ? 1 : 0);
//mxd. Push light levels without lighttype (those should be lower levels of type 1 Transfer Brightness effect) above other ones
if(x.type == SectorLevelType.Light && y.type == SectorLevelType.Light)
{
if(x.lighttype == y.lighttype) return 0; //TODO: how this should be handled?
if(x.lighttype == LightLevelType.TYPE1_BOTTOM) return 1;
return -1;
}
return 0;
}
return Math.Sign(diff);
}
}
}

View file

@ -10,4 +10,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
Floor,
Ceiling
}
//mxd
internal enum LightLevelType
{
TYPE1_BOTTOM = -2,
UNKNOWN = -1,
TYPE0 = 0,
TYPE1 = 1,
TYPE2 = 2,
}
}