ZoneBuilder/Source/Plugins/BuilderModes/VisualModes/EffectGlowingFlat.cs
MaxED 0db92cb46c Added, Visual mode: "Increase/Decrease Scale", "Reset Texture Offsets" and "Reset Local Texture Offsets" actions now work when used on 3d floor sides.
Fixed: CVARINFO parser was unable to parse negative int/float values.
Fixed: in some cases TextLabel text size was checked before it was calculated.
Internal, Visual mode: reduced the number of unnecessary geometry updates when changing map geometry.
Updated ZDoom_DECORATE.cfg (atan2 and VectorAngle).
2023-01-04 18:59:10 +01:00

81 lines
2.3 KiB
C#

using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class EffectGlowingFlat
{
private readonly SectorData data;
// Level planes
private SectorLevel ceillevel;
private SectorLevel floorlevel;
// Constructor
public EffectGlowingFlat(SectorData sourcedata)
{
data = sourcedata;
}
public void Update()
{
// Create ceiling glow effect?
if(General.Map.Data.GlowingFlats.ContainsKey(data.Sector.LongCeilTexture))
{
// Create ceiling level?
if(ceillevel == null)
{
ceillevel = new SectorLevel(data.Ceiling) { type = SectorLevelType.Glow, disablelighting = true };
data.AddSectorLevel(ceillevel);
}
// Update ceiling level
data.CeilingGlow = General.Map.Data.GlowingFlats[data.Sector.LongCeilTexture];
ceillevel.brightnessbelow = -1; // We need this plane for clipping only,
ceillevel.color = 0; // so we need to reset all shading and coloring
ceillevel.plane = data.Ceiling.plane;
ceillevel.plane.Offset -= data.CeilingGlow.Height;
data.CeilingGlowPlane = ceillevel.plane;
}
else
{
data.CeilingGlow = null;
}
// Create floor glow effect?
if(General.Map.Data.GlowingFlats.ContainsKey(data.Sector.LongFloorTexture))
{
// Create floor level?
if(floorlevel == null)
{
floorlevel = new SectorLevel(data.Floor) { type = SectorLevelType.Glow, disablelighting = true };
data.AddSectorLevel(floorlevel);
}
// Update floor level
data.FloorGlow = General.Map.Data.GlowingFlats[data.Sector.LongFloorTexture];
floorlevel.plane = data.Floor.plane.GetInverted();
floorlevel.plane.Offset += data.FloorGlow.Height;
if(floorlevel.plane.Offset < data.Ceiling.plane.Offset)
{
floorlevel.brightnessbelow = -1; // We need this plane for clipping only,
floorlevel.color = 0; // so we need to reset all shading and coloring
floorlevel.colorbelow = new PixelColor(0, 0, 0, 0);
}
else
{
// If glow plane is above real ceiling, apply ceiling colouring
floorlevel.brightnessbelow = data.Ceiling.brightnessbelow;
floorlevel.color = data.Ceiling.color;
floorlevel.colorbelow = data.Ceiling.colorbelow;
}
data.FloorGlowPlane = floorlevel.plane;
}
else
{
data.FloorGlow = null;
}
}
}
}