Apply Justburner's fixes to flat offsets/rotation in Visual Mode, from the Zone Builder Unofficial fork.

This commit is contained in:
sphere 2021-02-18 17:13:07 +01:00
parent 365aff2803
commit 4cbc56318a

View file

@ -966,31 +966,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
if (General.Map.SRB2)
{
//MascaraSnake: Flat alignment
if (l.IsFlatAlignment)
{
int sectortag = l.Tag;
bool alignfloor = !l.IsFlagSet("2048");
bool alignceiling = !l.IsFlagSet("4096");
bool useoffsets = l.IsFlagSet("8192");
float xoffset = useoffsets ? -l.Front.OffsetY : -l.Start.Position.y;
float yoffset = useoffsets ? l.Front.OffsetX : -l.Start.Position.x;
Vector2D offset = new Vector2D(xoffset, yoffset);
float rotation = General.ClampAngle(l.AngleDeg - 90);
offset = offset.GetRotated(Angle2D.DegToRad(-l.AngleDeg));
//MascaraSnake: Flat alignment
//With flat offset/rotation fixes by Justburner
if (l.IsFlatAlignment)
{
int sectortag = l.Tag;
bool alignfloor = !l.IsFlagSet("2048");
bool alignceiling = !l.IsFlagSet("4096");
bool useoffsets = l.IsFlagSet("8192");
float xoffset = useoffsets ? l.Front.OffsetX : -l.Start.Position.x;
float yoffset = useoffsets ? -l.Front.OffsetY : -l.Start.Position.y;
float rotation = General.ClampAngle(90f - l.Angle * Angle2D.PIDEG);
if (sectortag == 0)
ApplyFlatAlignment(l, l.Front.Sector, alignfloor, alignceiling, offset, rotation);
else if (sectortags.ContainsKey(sectortag))
{
List<Sector> sectors = sectortags[sectortag];
foreach (Sector s in sectors)
{
ApplyFlatAlignment(l, s, alignfloor, alignceiling, offset, rotation);
}
}
}
// Affine offset, this got me a few headaches of why both rotation and offset didn't worked at same time
float rotationrad = rotation / Angle2D.PIDEG;
float cos = (float)Math.Cos(rotationrad);
float sin = (float)Math.Sin(rotationrad);
float rx = cos * xoffset - sin * yoffset;
float ry = sin * xoffset + cos * yoffset;
xoffset = rx;
yoffset = -ry;
Vector2D offset = new Vector2D(xoffset, yoffset);
if (sectortag == 0)
ApplyFlatAlignment(l, l.Front.Sector, alignfloor, alignceiling, offset, rotation);
else if (sectortags.ContainsKey(sectortag))
{
List<Sector> sectors = sectortags[sectortag];
foreach (Sector s in sectors)
ApplyFlatAlignment(l, s, alignfloor, alignceiling, offset, rotation);
}
}
//MascaraSnake: Colormap
if (l.IsColormap && l.Front != null && General.Settings.ShowColormaps)
{