Fixed invalid left/right normal errors during level generation (I think). The voronoi cell generation logic ignored zero-length edges, but it was possible for an edge to be so short that the distance from the adjacent edge to the center of the short edge rounded down to zero in GenerateWallShapes.

This commit is contained in:
Joonas Rikkonen
2018-07-24 15:00:35 +03:00
parent bf0c12ce52
commit e21b756f29
2 changed files with 9 additions and 4 deletions

View File

@@ -183,7 +183,7 @@ namespace Barotrauma
foreach (GraphEdge ge in graphEdges)
{
if (ge.point1 == ge.point2) continue;
if (Vector2.DistanceSquared(ge.point1, ge.point2) < 0.001f) continue;
for (int i = 0; i < 2; i++)
{

View File

@@ -211,16 +211,16 @@ namespace Voronoi2
public VoronoiCell AdjacentCell(VoronoiCell cell)
{
if (cell1==cell)
if (cell1 == cell)
{
return cell2;
}
else if (cell2==cell)
else if (cell2 == cell)
{
return cell1;
}
return null;
return null;
}
/// <summary>
@@ -239,6 +239,11 @@ namespace Voronoi2
return normal;
}
public override string ToString()
{
return "GraphEdge (" + point1.ToString() + ", " + point2.ToString() + ")";
}
}
// للترتيب