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;
|
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)
|
if (Math.Abs(body.LinearVelocity.X) > 0.01f || Math.Abs(body.LinearVelocity.Y) > 0.01f)
|
||||||
{
|
{
|
||||||
Submarine prevSub = Submarine;
|
Submarine prevSub = Submarine;
|
||||||
|
|||||||
@@ -44,13 +44,24 @@ namespace Barotrauma.Lights
|
|||||||
|
|
||||||
class ConvexHullList
|
class ConvexHullList
|
||||||
{
|
{
|
||||||
|
private List<ConvexHull> list;
|
||||||
|
|
||||||
public readonly Submarine Submarine;
|
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)
|
public ConvexHullList(Submarine submarine)
|
||||||
{
|
{
|
||||||
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)
|
private List<ConvexHull> GetHullsInRange(Submarine sub)
|
||||||
{
|
{
|
||||||
|
//find the current list of hulls in range
|
||||||
var chList = hullsInRange.Find(x => x.Submarine == sub);
|
var chList = hullsInRange.Find(x => x.Submarine == sub);
|
||||||
|
|
||||||
|
//not found -> create one
|
||||||
if (chList == null)
|
if (chList == null)
|
||||||
{
|
{
|
||||||
chList = new ConvexHullList(sub);
|
chList = new ConvexHullList(sub);
|
||||||
hullsInRange.Add(chList);
|
hullsInRange.Add(chList);
|
||||||
}
|
}
|
||||||
List<ConvexHull> list = chList.List;
|
|
||||||
|
|
||||||
|
|
||||||
Vector2 lightPos = position;
|
Vector2 lightPos = position;
|
||||||
if (ParentSub == null)
|
if (ParentSub == null)
|
||||||
@@ -183,15 +183,12 @@ namespace Barotrauma.Lights
|
|||||||
if (NeedsHullUpdate)
|
if (NeedsHullUpdate)
|
||||||
{
|
{
|
||||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||||
|
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
|
||||||
chList.List = list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//light is outside, convexhull inside a sub
|
//light is outside, convexhull inside a sub
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//todo: check
|
|
||||||
lightPos -= sub.Position;
|
lightPos -= sub.Position;
|
||||||
|
|
||||||
Rectangle subBorders = sub.Borders;
|
Rectangle subBorders = sub.Borders;
|
||||||
@@ -201,7 +198,7 @@ namespace Barotrauma.Lights
|
|||||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
||||||
|
|
||||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
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
|
else
|
||||||
@@ -215,15 +212,13 @@ namespace Barotrauma.Lights
|
|||||||
if (NeedsHullUpdate)
|
if (NeedsHullUpdate)
|
||||||
{
|
{
|
||||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
||||||
|
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
||||||
list = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
|
|
||||||
chList.List = list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//light and convexhull are inside different subs
|
//light and convexhull are inside different subs
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return list;
|
if (sub.DockedTo.Contains(ParentSub) && !NeedsHullUpdate) return chList.List;
|
||||||
|
|
||||||
lightPos -= (sub.Position - ParentSub.Position);
|
lightPos -= (sub.Position - ParentSub.Position);
|
||||||
|
|
||||||
@@ -234,12 +229,11 @@ namespace Barotrauma.Lights
|
|||||||
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
if (!MathUtils.CircleIntersectsRectangle(lightPos, range, subBorders)) return null;
|
||||||
|
|
||||||
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
|
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));
|
||||||
chList.List = list;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return chList.List;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ConvexHull> GetHullsInRange(Vector2 position, float range, Submarine ParentSub)
|
public static List<ConvexHull> GetHullsInRange(Vector2 position, float range, Submarine ParentSub)
|
||||||
|
|||||||
Reference in New Issue
Block a user