Fixed a problem where dragging or drawing geometry sometimes broke sectors. Fixes #556

This commit is contained in:
biwa 2021-04-21 22:24:10 +02:00 committed by spherallic
parent 4b0dce43ed
commit b7d92fb704

View file

@ -302,8 +302,9 @@ namespace CodeImp.DoomBuilder.Geometry
float px = foundv.Position.x; //mxd
float py = foundv.Position.y; //mxd
float scanlinefoundvdistance = float.MaxValue;
foreach(Linedef ld in General.Map.Map.Linedefs)
foreach(Linedef ld in General.Map.Map.Linedefs)
{
// Line to the right of start point?
if((ld.Start.Position.x > px) || (ld.End.Position.x > px))
@ -321,6 +322,7 @@ namespace CodeImp.DoomBuilder.Geometry
{
scanline = ld;
foundu = thisu;
scanlinefoundvdistance = scanline.DistanceTo(foundv.Position, true);
}
//mxd. Special cases: when foundv.y matches ld's start or end y,
// prefer the line, which is clser to being parallel to the x axis
@ -331,7 +333,13 @@ namespace CodeImp.DoomBuilder.Geometry
&& GetRelativeAngle(scanline, foundv.Position, out scanlineanglerel)
&& (ldanglerel < scanlineanglerel))
{
scanline = ld; // foundu already matches
// biwa. This fixes a problem with breaking geometry. It's unknown if this breaks the original fix
// See https://github.com/jewalky/UltimateDoomBuilder/issues/556 for an explanation
if (ld.DistanceTo(foundv.Position, true) < scanlinefoundvdistance)
{
scanline = ld; // foundu already matches
scanlinefoundvdistance = scanline.DistanceTo(foundv.Position, true);
}
}
}
}