Some debug assertions to help figure out the cause for the body.FixtureList==null & GetHullsInRange crash reports
This commit is contained in:
@@ -770,6 +770,8 @@ namespace Barotrauma
|
||||
|
||||
if (body == null || !body.Enabled) return;
|
||||
|
||||
System.Diagnostics.Debug.Assert(body.FarseerBody.FixtureList != null);
|
||||
|
||||
if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f)
|
||||
{
|
||||
Submarine prevSub = Submarine;
|
||||
|
||||
@@ -44,13 +44,24 @@ namespace Barotrauma.Lights
|
||||
|
||||
class ConvexHullList
|
||||
{
|
||||
private List<ConvexHull> list;
|
||||
|
||||
public readonly Submarine Submarine;
|
||||
public List<ConvexHull> List;
|
||||
public List<ConvexHull> List
|
||||
{
|
||||
get { return list; }
|
||||
set
|
||||
{
|
||||
Debug.Assert(value != null);
|
||||
Debug.Assert(!list.Contains(null));
|
||||
list = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ConvexHullList(Submarine submarine)
|
||||
{
|
||||
Submarine = submarine;
|
||||
List = new List<ConvexHull>();
|
||||
list = new List<ConvexHull>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -164,15 +164,15 @@ namespace Barotrauma.Lights
|
||||
|
||||
private List<ConvexHull> GetHullsInRange(Submarine sub)
|
||||
{
|
||||
//find the current list of hulls in range
|
||||
var chList = hullsInRange.Find(x => x.Submarine == sub);
|
||||
|
||||
//not found -> create one
|
||||
if (chList == null)
|
||||
{
|
||||
chList = new ConvexHullList(sub);
|
||||
hullsInRange.Add(chList);
|
||||
}
|
||||
List<ConvexHull> list = chList.List;
|
||||
|
||||
|
||||
Vector2 lightPos = position;
|
||||
if (ParentSub == null)
|
||||
@@ -183,15 +183,12 @@ namespace Barotrauma.Lights
|
||||
if (NeedsHullUpdate)
|
||||
{
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
|
||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
chList.List = list;
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
}
|
||||
}
|
||||
//light is outside, convexhull inside a sub
|
||||
else
|
||||
{
|
||||
//todo: check
|
||||
lightPos -= sub.Position;
|
||||
|
||||
Rectangle subBorders = sub.Borders;
|
||||
@@ -201,7 +198,7 @@ namespace Barotrauma.Lights
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
||||
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -215,15 +212,13 @@ namespace Barotrauma.Lights
|
||||
if (NeedsHullUpdate)
|
||||
{
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
|
||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
chList.List = list;
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
}
|
||||
}
|
||||
//light and convexhull are inside different subs
|
||||
else
|
||||
{
|
||||
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return list;
|
||||
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return chList.List;
|
||||
|
||||
lightPos -= (sub.Position - ParentSub.Position);
|
||||
|
||||
@@ -234,12 +229,11 @@ namespace Barotrauma.Lights
|
||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
||||
|
||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
chList.List = list;
|
||||
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
return chList.List;
|
||||
}
|
||||
|
||||
public static List<ConvexHull> GetHullsInRange(Vector2 position, float range, Submarine ParentSub)
|
||||
|
||||
Reference in New Issue
Block a user