fixed blockmap problems with straight lines along the edges of the 128 mp blocks

This commit is contained in:
codeimp 2009-01-21 09:16:26 +00:00
parent 4bf63e93e7
commit d2265287b4

View file

@ -329,6 +329,30 @@ namespace CodeImp.DoomBuilder.VisualModes
pos = GetBlockCoordinates(v1); pos = GetBlockCoordinates(v1);
end = GetBlockCoordinates(v2); end = GetBlockCoordinates(v2);
// Horizontal straight line?
if(pos.Y == end.Y)
{
// Simple loop
dirx = Math.Sign(v2.x - v1.x);
for(int x = pos.X; x != end.X; x += dirx)
{
GetBlock(new Point(x, pos.Y)).Lines.Add(line);
}
GetBlock(end).Lines.Add(line);
}
// Vertical straight line?
else if(pos.X == end.X)
{
// Simple loop
diry = Math.Sign(v2.y - v1.y);
for(int y = pos.Y; y != end.Y; y += diry)
{
GetBlock(new Point(pos.X, y)).Lines.Add(line);
}
GetBlock(end).Lines.Add(line);
}
else
{
// Add lines to this block // Add lines to this block
GetBlock(pos).Lines.Add(line); GetBlock(pos).Lines.Add(line);
@ -346,7 +370,12 @@ namespace CodeImp.DoomBuilder.VisualModes
diry = Math.Sign(v2.y - v1.y); diry = Math.Sign(v2.y - v1.y);
// Calculate offset and delta movement over x // Calculate offset and delta movement over x
if(dirx >= 0) if(dirx == 0)
{
posx = float.MaxValue;
deltax = float.MaxValue;
}
else if(dirx > 0)
{ {
posx = (cr - v1.x) / (v2.x - v1.x); posx = (cr - v1.x) / (v2.x - v1.x);
deltax = BLOCK_SIZE / (v2.x - v1.x); deltax = BLOCK_SIZE / (v2.x - v1.x);
@ -359,7 +388,12 @@ namespace CodeImp.DoomBuilder.VisualModes
} }
// Calculate offset and delta movement over y // Calculate offset and delta movement over y
if(diry >= 0) if(diry == 0)
{
posy = float.MaxValue;
deltay = float.MaxValue;
}
else if(diry > 0)
{ {
posy = (cb - v1.y) / (v2.y - v1.y); posy = (cb - v1.y) / (v2.y - v1.y);
deltay = BLOCK_SIZE / (v2.y - v1.y); deltay = BLOCK_SIZE / (v2.y - v1.y);
@ -392,6 +426,7 @@ namespace CodeImp.DoomBuilder.VisualModes
} }
} }
} }
}
#endregion #endregion
} }