From 756278bb815da62d54907e7470cbee72c16717a0 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 24 Jul 2018 15:43:26 +0300 Subject: [PATCH] Increased the minimum distance between verts in level collider generation code. Should make the "invalid triangle created by CaveGenerator" errors less frequent. (See #311) --- .../BarotraumaShared/Source/Map/Levels/CaveGenerator.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs b/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs index 7325965ff..3b2086d0c 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Levels/CaveGenerator.cs @@ -421,9 +421,9 @@ namespace Barotrauma { //don't create a triangle if any of the vertices are too close to each other //(apparently Farseer doesn't like polygons with a very small area, see Shape.ComputeProperties) - if (Vector2.Distance(triangles[i][0], triangles[i][1]) < 0.05f || - Vector2.Distance(triangles[i][0], triangles[i][2]) < 0.05f || - Vector2.Distance(triangles[i][1], triangles[i][2]) < 0.05f) continue; + if (Vector2.DistanceSquared(triangles[i][0], triangles[i][1]) < 0.006f || + Vector2.DistanceSquared(triangles[i][0], triangles[i][2]) < 0.006f || + Vector2.DistanceSquared(triangles[i][1], triangles[i][2]) < 0.006f) continue; Vertices bodyVertices = new Vertices(triangles[i]); var newFixture = FixtureFactory.AttachPolygon(bodyVertices, 5.0f, cellBody);