Unstable 1.2.4.0
This commit is contained in:
@@ -133,6 +133,8 @@ namespace Barotrauma.Lights
|
||||
|
||||
public Rectangle BoundingBox { get; private set; }
|
||||
|
||||
public bool IsInvalid { get; private set; }
|
||||
|
||||
public ConvexHull(Rectangle rect, bool isHorizontal, MapEntity parent)
|
||||
{
|
||||
shadowEffect ??= new BasicEffect(GameMain.Instance.GraphicsDevice)
|
||||
@@ -481,15 +483,34 @@ namespace Barotrauma.Lights
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vertices[i].WorldPos = vertices[i].Pos;
|
||||
ValidateVertex(vertices[i].WorldPos, "vertices[i].Pos");
|
||||
segments[i].Start.WorldPos = segments[i].Start.Pos;
|
||||
ValidateVertex(segments[i].Start.WorldPos, "segments[i].Start.Pos");
|
||||
segments[i].End.WorldPos = segments[i].End.Pos;
|
||||
ValidateVertex(segments[i].End.WorldPos, "segments[i].End.Pos");
|
||||
}
|
||||
if (ParentEntity == null || ParentEntity.Submarine == null) { return; }
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vertices[i].WorldPos += ParentEntity.Submarine.DrawPosition;
|
||||
ValidateVertex(vertices[i].WorldPos, "vertices[i].WorldPos");
|
||||
segments[i].Start.WorldPos += ParentEntity.Submarine.DrawPosition;
|
||||
ValidateVertex(segments[i].Start.WorldPos, "segments[i].Start.WorldPos");
|
||||
segments[i].End.WorldPos += ParentEntity.Submarine.DrawPosition;
|
||||
ValidateVertex(segments[i].End.WorldPos, "segments[i].End.WorldPos");
|
||||
}
|
||||
|
||||
void ValidateVertex(Vector2 vertex, string debugName)
|
||||
{
|
||||
if (!MathUtils.IsValid(vertex))
|
||||
{
|
||||
IsInvalid = true;
|
||||
string errorMsg = $"Invalid vertex on convex hull ({debugName}: {vertex}, parent entity: {ParentEntity?.ToString() ?? "null"}).";
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError(errorMsg);
|
||||
#endif
|
||||
GameAnalyticsManager.AddErrorEventOnce("ConvexHull.RefreshWorldPositions:InvalidVertex", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user