mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
Fixed: Drag Geometry Mode: dragged sectors, linedefs or vertices were snapped to 0, 0 in some cases when trying to snap them to a linedef fully inside of a grid cell.
This commit is contained in:
parent
ee8e31db37
commit
e611c9347e
1 changed files with 23 additions and 18 deletions
|
@ -267,28 +267,33 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Get grid intersection coordinates
|
||||
List<Vector2D> coords = nl.GetGridIntersections(snapgridincrement ? dragstartoffset : new Vector2D());
|
||||
|
||||
// Find nearest grid intersection
|
||||
float found_distance = float.MaxValue;
|
||||
Vector2D found_coord = new Vector2D();
|
||||
foreach(Vector2D v in coords)
|
||||
// mxd. Do the rest only if we actually have some coordinates
|
||||
if (coords.Count > 0)
|
||||
{
|
||||
Vector2D delta = anchorpos - v;
|
||||
if(delta.GetLengthSq() < found_distance)
|
||||
// Find nearest grid intersection
|
||||
float found_distance = float.MaxValue;
|
||||
Vector2D found_coord = new Vector2D();
|
||||
|
||||
foreach (Vector2D v in coords)
|
||||
{
|
||||
found_distance = delta.GetLengthSq();
|
||||
found_coord = v;
|
||||
Vector2D delta = anchorpos - v;
|
||||
if (delta.GetLengthSq() < found_distance)
|
||||
{
|
||||
found_distance = delta.GetLengthSq();
|
||||
found_coord = v;
|
||||
}
|
||||
}
|
||||
|
||||
// Move the dragged item
|
||||
dragitem.Move(found_coord);
|
||||
|
||||
// Align to line here
|
||||
offset = found_coord - dragitemposition;
|
||||
|
||||
// Do not snap to grid anymore
|
||||
snapgrid = false;
|
||||
snapgridincrement = false; //mxd
|
||||
}
|
||||
|
||||
// Move the dragged item
|
||||
dragitem.Move(found_coord);
|
||||
|
||||
// Align to line here
|
||||
offset = found_coord - dragitemposition;
|
||||
|
||||
// Do not snap to grid anymore
|
||||
snapgrid = false;
|
||||
snapgridincrement = false; //mxd
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue