Attempt to fix ThrowOrIgnoreBadComparer exception in LightSource.FindRaycastHits.

Couldn't reproduce the crash, but I'm guessing it could be caused by CompareCCW not returning 0 if comparing a position to itself. (and if not, at least the exception is caught now)
This commit is contained in:
Regalis
2017-04-05 21:36:31 +03:00
parent b3bbdbf589
commit 7cb88e39e9
2 changed files with 14 additions and 1 deletions
+13 -1
View File
@@ -352,7 +352,19 @@ namespace Barotrauma.Lights
points.AddRange(boundaryCorners);
var compareCCW = new CompareSegmentPointCW(drawPos);
points.Sort(compareCCW);
try
{
points.Sort(compareCCW);
}
catch (Exception e)
{
StringBuilder sb = new StringBuilder("Constructing light volumes failed! Light pos: "+drawPos+", Hull verts:\n");
foreach (SegmentPoint sp in points)
{
sb.AppendLine(sp.Pos.ToString());
}
DebugConsole.ThrowError(sb.ToString(), e);
}
List<Vector2> output = new List<Vector2>();
+1
View File
@@ -512,6 +512,7 @@ namespace Barotrauma
public static int Compare(Vector2 a, Vector2 b, Vector2 center)
{
if (a == b) return 0;
if (a.X - center.X >= 0 && b.X - center.X < 0) return -1;
if (a.X - center.X < 0 && b.X - center.X >= 0) return 1;
if (a.X - center.X == 0 && b.X - center.X == 0)