mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Some refactoring to remove convoluted code
This commit is contained in:
parent
caf7477d75
commit
bccb1ace56
1 changed files with 21 additions and 29 deletions
|
@ -170,7 +170,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private ICollection<Vertex> unselectedvertices;
|
||||
private ICollection<Linedef> unselectedlines;
|
||||
private ICollection<Linedef> unstablelines; //mxd
|
||||
private Dictionary<Sector, float[]> slopeheights;
|
||||
private Dictionary<Sector, Vector2D> oldsectorcenters;
|
||||
|
||||
// Modification
|
||||
|
@ -1329,34 +1328,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
thingangle.Add(t.Angle);
|
||||
}
|
||||
|
||||
// Get z heights of floor and ceiling slopes (from the center of the sector). This is used
|
||||
// to easily compute the new slope after moving and rotating. We can't simply use the sector
|
||||
// heights, since they might be wrong (as sector heights are technically irrelevant for slopes)
|
||||
// Floor/ceiling heights are stored if there is no slope, but they won't get used anyway
|
||||
// Important: this has to be done before the first call to UpdateGeometry, since that will change
|
||||
// the sector and subsequently the bounding box, but not the slope
|
||||
slopeheights = new Dictionary<Sector, float[]>();
|
||||
|
||||
oldsectorcenters = new Dictionary<Sector, Vector2D>();
|
||||
|
||||
foreach(Sector s in sectors)
|
||||
// Get the centers of all selected sectors. This will later be used to update slopes more easily
|
||||
if (General.Map.UDMF)
|
||||
{
|
||||
// Make sure the sector has a valid bounding box
|
||||
s.UpdateBBox();
|
||||
oldsectorcenters = new Dictionary<Sector, Vector2D>();
|
||||
|
||||
oldsectorcenters[s] = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2);
|
||||
|
||||
Vector2D center = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2);
|
||||
float floorz = s.FloorHeight;
|
||||
float ceilingz = s.CeilHeight;
|
||||
|
||||
if (!float.IsNaN(s.FloorSlopeOffset) && s.FloorSlope.IsNormalized())
|
||||
floorz = new Plane(s.FloorSlope, s.FloorSlopeOffset).GetZ(center);
|
||||
|
||||
if (!float.IsNaN(s.CeilSlopeOffset) && s.CeilSlope.IsNormalized())
|
||||
ceilingz = new Plane(s.CeilSlope, s.CeilSlopeOffset).GetZ(center);
|
||||
|
||||
slopeheights.Add(s, new float[] { floorz, ceilingz });
|
||||
foreach (Sector s in sectors)
|
||||
{
|
||||
// Make sure the sector has a valid bounding box
|
||||
s.UpdateBBox();
|
||||
oldsectorcenters[s] = new Vector2D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2);
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate size
|
||||
|
@ -1629,7 +1611,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//if (size.x < 0.0f) angle += Angle2D.PI;
|
||||
//if (size.y < 0.0f) angle += Angle2D.PI;
|
||||
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, slopeheights[s][0]);
|
||||
// Get the center of the *new* sector position. Use the z value of the center *old* sector position
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, 0.0f);
|
||||
center.z = new Plane(s.FloorSlope, s.FloorSlopeOffset).GetZ(oldsectorcenters[s]);
|
||||
|
||||
Plane p = new Plane(center, angle, -s.FloorSlope.GetAngleZ(), true);
|
||||
s.FloorSlope = p.Normal;
|
||||
s.FloorSlopeOffset = p.Offset;
|
||||
|
@ -1644,6 +1629,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
continue;
|
||||
|
||||
float angle = cs.FloorSlope.GetAngleXY() + rotation + Angle2D.PIHALF;
|
||||
|
||||
// Get the center of the *new* tagged sector position. Use the z value of the center *old* tagged sector position
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, 0.0f);
|
||||
center.z = new Plane(cs.FloorSlope, cs.FloorSlopeOffset).GetZ(oldsectorcenters[s]);
|
||||
|
||||
|
@ -1661,7 +1648,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
//if (size.x < 0.0f) angle += Angle2D.PI;
|
||||
//if (size.y < 0.0f) angle += Angle2D.PI;
|
||||
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, slopeheights[s][1]);
|
||||
// Get the center of the *new* sector position. Use the z value of the center *old* sector position
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, 0.0f);
|
||||
center.z = new Plane(s.CeilSlope, s.CeilSlopeOffset).GetZ(oldsectorcenters[s]);
|
||||
|
||||
Plane p = new Plane(center, angle, -s.CeilSlope.GetAngleZ(), false);
|
||||
s.CeilSlope = p.Normal;
|
||||
s.CeilSlopeOffset = p.Offset;
|
||||
|
@ -1676,6 +1666,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
continue;
|
||||
|
||||
float angle = cs.CeilSlope.GetAngleXY() + rotation + Angle2D.PIHALF;
|
||||
|
||||
// Get the center of the *new* tagged sector position. Use the z value of the center *old* tagged sector position
|
||||
Vector3D center = new Vector3D(s.BBox.X + s.BBox.Width / 2, s.BBox.Y + s.BBox.Height / 2, 0.0f);
|
||||
center.z = new Plane(cs.CeilSlope, cs.CeilSlopeOffset).GetZ(oldsectorcenters[s]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue