Fixed a problem where negative Y scales of sidedefs would result in a wrong offset when auto-aligning

This commit is contained in:
biwa 2020-01-02 01:32:55 +01:00
parent 73364a130e
commit e4e05542ec
2 changed files with 13 additions and 3 deletions

View file

@ -1937,6 +1937,9 @@ namespace CodeImp.DoomBuilder.Geometry
if(side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset;
// Make sure the offset doesn't go in the wrong direction
scaleY = Math.Abs(scaleY);
//if we don't have UpperUnpegged flag, normalize offset
float surfaceHeight = side.GetHighHeight() * scaleY;
return (float)Math.Round((fromNormalized ? offset + surfaceHeight : offset - surfaceHeight), General.Map.FormatInterface.VertexDecimals);
@ -1947,6 +1950,9 @@ namespace CodeImp.DoomBuilder.Geometry
{
if(side.Sector == null) return offset;
// Make sure the offset doesn't go in the wrong direction
scaleY = Math.Abs(scaleY);
// Normalize offset
float surfaceHeight;
if(side.Other != null && side.Other.Sector != null)
@ -1985,7 +1991,11 @@ namespace CodeImp.DoomBuilder.Geometry
public static float GetSidedefBottomOffsetY(Sidedef side, float offset, float scaleY, bool fromNormalized)
{
float surfaceHeight;
if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
// Make sure the offset doesn't go in the wrong direction
scaleY = Math.Abs(scaleY);
if (side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
{
if(side.Other == null || side.Other.Sector == null || side.Sector.CeilTexture != General.Map.Config.SkyFlatName ||
side.Other.Sector.CeilTexture != General.Map.Config.SkyFlatName)

View file

@ -4203,7 +4203,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
float offset;
if (!texture.WorldPanning && !General.Map.Data.MapInfo.ForceWorldPanning)
offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * j.scaleY + ystartalign - j.sidedef.OffsetY; //mxd
offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * Math.Abs(j.scaleY) + ystartalign - j.sidedef.OffsetY; //mxd
else
offset = (start.Sidedef.Sector.CeilHeight - j.ceilingHeight + ystartalign - j.sidedef.OffsetY);
@ -4345,7 +4345,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(aligny)
{
float offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * j.scaleY + ystartalign; //mxd
float offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * Math.Abs(j.scaleY) + ystartalign; //mxd
offset -= j.sidedef.OffsetY; //mxd
if(matchtop)