Display SRB2's mapthing slopes in Visual Mode

This commit is contained in:
MascaraSnake 2022-01-29 09:13:01 +01:00
parent 5fd7fdb65b
commit a604d5b382
6 changed files with 102 additions and 0 deletions

View file

@ -5581,6 +5581,7 @@ udmf
{
title = "Create Vertex-Based Slope";
prefix = "(704)";
id = "srb2_vertexslope";
arg0
{
title = "Plane";

View file

@ -505,6 +505,7 @@
<Compile Include="VisualModes\EffectPlaneCopySlope.cs" />
<Compile Include="VisualModes\EffectThingLineSlope.cs" />
<Compile Include="VisualModes\EffectThingSlope.cs" />
<Compile Include="VisualModes\EffectSRB2ThingVertexSlope.cs" />
<Compile Include="VisualModes\EffectThingVertexSlope.cs" />
<Compile Include="VisualModes\EffectTransferCeilingBrightness.cs" />
<Compile Include="VisualModes\EffectTransferFloorBrightness.cs" />

View file

@ -970,6 +970,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
Dictionary<int, List<Sector>> sectortags = new Dictionary<int, List<Sector>>();
Dictionary<int, List<Thing>> thingtags = new Dictionary<int, List<Thing>>();
Dictionary<int, List<Linedef>> linetags = new Dictionary<int, List<Linedef>>();
sectordata = new Dictionary<Sector, SectorData>(General.Map.Map.Sectors.Count);
thingdata = new Dictionary<Thing, ThingData>(General.Map.Map.Things.Count);
@ -1006,6 +1007,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
}
foreach (Thing t in General.Map.Map.Things)
{
if (t.Type != 750) continue;
if (!thingtags.ContainsKey(t.Tag)) thingtags[t.Tag] = new List<Thing>();
thingtags[t.Tag].Add(t);
}
// Find interesting linedefs (such as line slopes)
// This also determines which slope lines belong to pass one and pass two. See https://zdoom.org/wiki/Slope
foreach (Linedef l in General.Map.Map.Linedefs)
@ -1043,6 +1051,23 @@ namespace CodeImp.DoomBuilder.BuilderModes
slopelinedefpass[1].Add(l);
break;
case "srb2_vertexslope":
{
List<Thing> sourcethings = new List<Thing>();
if (!thingtags.ContainsKey(l.Args[1]) || thingtags[l.Args[1]].Count == 0)
break;
if (!thingtags.ContainsKey(l.Args[2]) || thingtags[l.Args[2]].Count == 0)
break;
if (!thingtags.ContainsKey(l.Args[3]) || thingtags[l.Args[3]].Count == 0)
break;
sourcethings.Add(thingtags[l.Args[1]][0]);
sourcethings.Add(thingtags[l.Args[2]][0]);
sourcethings.Add(thingtags[l.Args[3]][0]);
SectorData sd = GetSectorData((l.Args[0] < 2) ? l.Front.Sector : l.Back.Sector);
sd.AddEffectSRB2ThingVertexSlope(sourcethings, (l.Args[0] & 1) != 1);
break;
}
// ========== Sector 3D floor (160) (see http://zdoom.org/wiki/Sector_Set3dFloor) ==========
case "sector_set3dfloor":
if(l.Front != null)

View file

@ -415,6 +415,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
pos.z = sd.Floor.sector.FloorHeight + Thing.Position.z;
}
}
else if (Thing.Type == 750)
{
if (Thing.Sector != null) //mxd
{
// This is a special thing that needs special positioning
SectorData sd = mode.GetSectorData(Thing.Sector);
pos.z = (Thing.Args[0] == 0) ? sd.Floor.sector.FloorHeight + Thing.Position.z : Thing.Position.z;
}
}
else if(info.AbsoluteZ)
{
// Absolute Z position

View file

@ -0,0 +1,59 @@
#region === Copyright (c) 2010 Pascal van der Heiden ===
using System.Collections.Generic;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class EffectSRB2ThingVertexSlope : SectorEffect
{
// Thing used to create this effect
private List<Thing> things;
// Floor or ceiling?
private bool slopefloor;
// Constructor
public EffectSRB2ThingVertexSlope(SectorData data, List<Thing> sourcethings, bool floor) : base(data)
{
things = sourcethings;
slopefloor = floor;
// New effect added: This sector needs an update!
if(data.Mode.VisualSectorExists(data.Sector))
{
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
vs.UpdateSectorGeometry(true);
}
}
// This makes sure we are updated with the source linedef information
public override void Update()
{
Vector3D[] verts = new Vector3D[3];
int index = 0;
foreach (Thing t in things)
{
ThingData td = data.Mode.GetThingData(t);
td.AddUpdateSector(data.Sector, true);
verts[index] = t.Position;
if (t.Args[0] == 0)
{
t.DetermineSector(data.Mode.BlockMap);
if (t.Sector != null) verts[index].z += t.Sector.FloorHeight;
}
index++;
if (index > 2) break; //Only the first three vertices are used
}
// Make new plane
if (slopefloor)
data.Floor.plane = new Plane(verts[0], verts[1], verts[2], true);
else
data.Ceiling.plane = new Plane(verts[0], verts[2], verts[1], false);
}
}
}

View file

@ -197,6 +197,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
alleffects.Add(e);
}
// SRB2 thing vertex slope effect
public void AddEffectSRB2ThingVertexSlope(List<Thing> sourcethings, bool slopefloor)
{
EffectSRB2ThingVertexSlope e = new EffectSRB2ThingVertexSlope(this, sourcethings, slopefloor);
alleffects.Add(e);
}
//mxd. Add UDMF vertex offset effect
public void AddEffectVertexOffset()
{