mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Fixed a problem where linedefs were not split correctly under certain conditions when drawing or moving lines
This commit is contained in:
parent
926fcd486d
commit
0d78a48bd5
1 changed files with 47 additions and 39 deletions
|
@ -2988,22 +2988,31 @@ namespace CodeImp.DoomBuilder.Map
|
|||
lineverts.Add(l.End);
|
||||
}
|
||||
|
||||
for(int w = 0; w < bmWidth; w++)
|
||||
foreach (Vertex v in verts)
|
||||
{
|
||||
for(int h = 0; h < bmHeight; h++)
|
||||
{
|
||||
BlockEntry block = bmap[w, h];
|
||||
if(block.Vertices.Count == 0 || block.Lines.Count == 0) continue;
|
||||
HashSet<BlockEntry> blocks;
|
||||
|
||||
// Go for all the lines
|
||||
for(int i = 0; i < block.Lines.Count; i++)
|
||||
// If a vertex is in the very bottom left of it's block, and a linedef passes through the vertex it can
|
||||
// happen (depending on the linedef's direction) that the vertex and the linedef are not in the same
|
||||
// block. This will cause the linedef to not be split correctly. The prevent this we'll get all blocks
|
||||
// surrounding the vertex, since the linedef will definitely be in at least one of them. Otherwise
|
||||
// just take the block the vertex is in.
|
||||
if ((blockmap.Range.Left - (int)v.Position.x) % blockmap.BlockSize == 0 && (blockmap.Range.Bottom - (int)v.Position.y) % blockmap.BlockSize == 0)
|
||||
{
|
||||
Linedef l = block.Lines[i];
|
||||
blocks = blockmap.GetSquareRange(v.Position.x - 1, v.Position.y - 1, 2, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks = new HashSet<BlockEntry>() { blockmap.GetBlockAt(v.Position) };
|
||||
}
|
||||
|
||||
// Go for all the vertices
|
||||
for(int c = 0; c < block.Vertices.Count; c++)
|
||||
foreach (BlockEntry be in blocks)
|
||||
{
|
||||
Vertex v = block.Vertices[c];
|
||||
if (be == null) continue;
|
||||
|
||||
for (int i = 0; i < be.Lines.Count; i++)
|
||||
{
|
||||
Linedef l = be.Lines[i];
|
||||
|
||||
// Check if v is close enough to l for splitting
|
||||
if (l.DistanceToSq(v.Position, true) <= splitdist2)
|
||||
|
@ -3011,8 +3020,8 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Line is not already referencing v?
|
||||
Vector2D deltastart = l.Start.Position - v.Position;
|
||||
Vector2D deltaend = l.End.Position - v.Position;
|
||||
if(((Math.Abs(deltastart.x) > 0.001f) || (Math.Abs(deltastart.y) > 0.001f)) &&
|
||||
((Math.Abs(deltaend.x) > 0.001f) || (Math.Abs(deltaend.y) > 0.001f)))
|
||||
if (((Math.Abs(deltastart.x) > 0.001) || (Math.Abs(deltastart.y) > 0.001)) &&
|
||||
((Math.Abs(deltaend.x) > 0.001) || (Math.Abs(deltaend.y) > 0.001)))
|
||||
{
|
||||
// Split line l with vertex v
|
||||
Linedef nl = l.Split(v);
|
||||
|
@ -3039,7 +3048,6 @@ namespace CodeImp.DoomBuilder.Map
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mxd. Remove lines, which are inside affected sectors
|
||||
if(mergemode == MergeGeometryMode.REPLACE && changedsectors.Count > 0)
|
||||
|
|
Loading…
Reference in a new issue