Hey,
I am seeing an infinite loop in Aether. I believe it can be avoided by preventing two bodies from initially sharing the same location, but I am concerned about the presence of such a hang generally.
This is using a .NET standard 2.0 build of Aether. It is optimized. I do not see it happen with a debug build, or I have not yet. This is using two dynamic bodies. They each have one fixture in the shape of a square. They have velocity, angular velocity, and are rotated. When the objects share the same position or overlap significantly (I think), it locks up in the following code on this line:
s = EdgeSeparation(poly1, ref xf1To2, edge, poly2);
This is the loop:
// Perform a local search for the best edge normal.
for (; ; )
{
if (increment == -1)
edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
else
edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;
s = EdgeSeparation(poly1, ref xf1To2, edge, poly2);
if (s > bestSeparation)
{
bestEdge = edge;
bestSeparation = s;
}
else
{
break;
}
}
Note that because this is a release build, more detail is not available. The trace for Aether is here ( I removed the prefix for readability):
.Collision.Collision.FindMaxSeparation(out int edgeIndex, .Shapes.PolygonShape poly1, ref Transform xf1, .Shapes.PolygonShape poly2, ref Transform xf2) Unknown
.Collision.Collision.CollidePolygons(ref .Manifold manifold, .Shapes.PolygonShape polyA, ref Transform transformA, .Shapes.PolygonShape polyB, ref Transform transformB) Unknown
.Dynamics.Contacts.Contact.Evaluate(ref .Manifold manifold, ref Transform transformA, ref Transform transformB) Unknown
.Dynamics.Contacts.Contact.Update(tainicom.Aether.Physics2D.Dynamics.ContactManager contactManager) Unknown
.Dynamics.ContactManager.Collide() Unknown
.Dynamics.World.Step(float dt, ref tainicom.Aether.Physics2D.Dynamics.SolverIterations iterations) Unknown
.Dynamics.World.Step(float dt) Unknown
Here is the available state info:
edgeIndex 0 int
poly1 {Collision.Shapes.PolygonShape} Collision.Shapes.PolygonShape
ChildCount 1 int
Density 4.5 float
MassData {Collision.Shapes.MassData} Collision.Shapes.MassData
Normals Count = 4 Vertices = "{X:0.7071068 Y:0.7071068} {X:-0.7071068 Y:0.7071068} {X:-0.7071068 Y:-0.7071068} {X:0.7071068 Y:-0.7071068}" Vertices
Radius 0.01 float
ShapeType Polygon Collision.Shapes.ShapeType
Vertices Count = 4 Vertices = "{X:0.09375 Y:0} {X:0 Y:0.09375} {X:-0.09375 Y:0} {X:0 Y:-0.09375}" Vertices
_2radius 0 float
_density 4.5 float
_normals Count = 4 Vertices = "{X:0.7071068 Y:0.7071068} {X:-0.7071068 Y:0.7071068} {X:-0.7071068 Y:-0.7071068} {X:0.7071068 Y:-0.7071068}" Vertices
_radius 0.01 float
_vertices Count = 4 Vertices = "{X:0.09375 Y:0} {X:0 Y:0.09375} {X:-0.09375 Y:0} {X:0 Y:-0.09375}" Vertices
poly2 {Collision.Shapes.PolygonShape} Collision.Shapes.PolygonShape
ChildCount 1 int
Density 4.5 float
MassData {Collision.Shapes.MassData} Collision.Shapes.MassData
Normals Count = 4 Vertices = "{X:0.7071068 Y:0.7071068} {X:-0.7071068 Y:0.7071068} {X:-0.7071068 Y:-0.7071068} {X:0.7071068 Y:-0.7071068}" Vertices
Radius 0.01 float
ShapeType Polygon Collision.Shapes.ShapeType
Vertices Count = 4 Vertices = "{X:0.09375 Y:0} {X:0 Y:0.09375} {X:-0.09375 Y:0} {X:0 Y:-0.09375}" Vertices
_2radius 0 float
_density 4.5 float
_normals Count = 4 Vertices = "{X:0.7071068 Y:0.7071068} {X:-0.7071068 Y:0.7071068} {X:-0.7071068 Y:-0.7071068} {X:0.7071068 Y:-0.7071068}" Vertices
_radius 0.01 float
_vertices Count = 4 Vertices = "{X:0.09375 Y:0} {X:0 Y:0.09375} {X:-0.09375 Y:0} {X:0 Y:-0.09375}" Vertices
count1 4 int
edge 0 int
bestEdge 3 int
increment 1 int
Any thoughts? The world is conditioned with a ratio of 128 physics units to 1 pixel.