mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Using visual sloping to create a horizontal slope will now remove the slope and set the appropriate sector height instead
The Edit Sector dialog will not remove horizontal slopes anymore unless necessary
This commit is contained in:
parent
4f5a4eba24
commit
46962aac89
2 changed files with 45 additions and 9 deletions
|
@ -906,15 +906,20 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
|
||||
// Clear horizontal slopes
|
||||
if(Math.Round(Angle2D.RadToDeg(s.FloorSlope.GetAngleZ()), 3) == 90.0)
|
||||
double diff = Math.Abs(Math.Round(s.FloorSlopeOffset) - s.FloorSlopeOffset);
|
||||
if (Math.Abs(s.FloorSlope.z) == 1.0 && diff < 0.000000001)
|
||||
{
|
||||
s.FloorHeight = -Convert.ToInt32(s.FloorSlopeOffset);
|
||||
s.FloorSlope = new Vector3D();
|
||||
s.FloorSlopeOffset = float.NaN;
|
||||
s.FloorSlopeOffset = double.NaN;
|
||||
}
|
||||
if(Math.Round(Angle2D.RadToDeg(s.CeilSlope.GetAngleZ()), 3) == 270.0)
|
||||
|
||||
diff = Math.Abs(Math.Round(s.CeilSlopeOffset) - s.CeilSlopeOffset);
|
||||
if (Math.Abs(s.CeilSlope.z) == 1.0 && diff < 0.000000001)
|
||||
{
|
||||
s.CeilHeight = -Convert.ToInt32(s.CeilSlopeOffset);
|
||||
s.CeilSlope = new Vector3D();
|
||||
s.CeilSlopeOffset = float.NaN;
|
||||
s.CeilSlopeOffset = double.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -222,6 +222,9 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
public static void ApplySlope(SectorLevel level, Plane plane, BaseVisualMode mode)
|
||||
{
|
||||
bool applytoceiling = false;
|
||||
bool reset = false;
|
||||
int height = 0;
|
||||
|
||||
|
||||
Vector2D center = new Vector2D(level.sector.BBox.X + level.sector.BBox.Width / 2,
|
||||
level.sector.BBox.Y + level.sector.BBox.Height / 2);
|
||||
|
@ -239,16 +242,44 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
applytoceiling = true;
|
||||
}
|
||||
|
||||
// If the plane horizontal remove the slope and set the sector height instead
|
||||
// Rounding errors can result in offsets of horizontal planes to be a tiny, tiny bit off a whole number,
|
||||
// assume we want to remove the plane in this case
|
||||
double diff = Math.Abs(Math.Round(plane.d) - plane.d);
|
||||
if (plane.Normal.z == 1.0 && diff < 0.000000001)
|
||||
{
|
||||
reset = true;
|
||||
height = -Convert.ToInt32(plane.d);
|
||||
}
|
||||
|
||||
if (applytoceiling)
|
||||
{
|
||||
Plane downplane = plane.GetInverted();
|
||||
level.sector.CeilSlope = downplane.Normal;
|
||||
level.sector.CeilSlopeOffset = downplane.Offset;
|
||||
if (reset)
|
||||
{
|
||||
level.sector.CeilHeight = height;
|
||||
level.sector.CeilSlope = new Vector3D();
|
||||
level.sector.CeilSlopeOffset = double.NaN;
|
||||
}
|
||||
else
|
||||
{
|
||||
Plane downplane = plane.GetInverted();
|
||||
level.sector.CeilSlope = downplane.Normal;
|
||||
level.sector.CeilSlopeOffset = downplane.Offset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
level.sector.FloorSlope = plane.Normal;
|
||||
level.sector.FloorSlopeOffset = plane.Offset;
|
||||
if (reset)
|
||||
{
|
||||
level.sector.FloorHeight = height;
|
||||
level.sector.FloorSlope = new Vector3D();
|
||||
level.sector.FloorSlopeOffset = double.NaN;
|
||||
}
|
||||
else
|
||||
{
|
||||
level.sector.FloorSlope = plane.Normal;
|
||||
level.sector.FloorSlopeOffset = plane.Offset;
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild sector
|
||||
|
|
Loading…
Reference in a new issue