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:
@@ -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>();
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user