Hi!
I'm creating a fixture shaped similar to a narrow rectangle, using the function
and I'm getting assert errors because my polygon is degenerated.
The problem is with the check of `b2_linearSlop` when welding vertices, that removes my vertices as duplicates, although they are separated enough. Currently it says (b2PolygonShape.cpp:141):
But that comparison makes no sense because `b2DistanceSquared` returns meters squared (m^2) while `b2_linearSlop` has a value of meters (m).
In my code, the vertices are separated `0.035` and `b2_linearSlop` is the default of `0.005`. The comparison results to `0.001225 < 0.0025` and the vertices are welded.
IMHO, it should be something along the lines of:
I'm not sure about the `0.5f` squared, though, so I'm just guessing there.
Best regards.
I'm creating a fixture shaped similar to a narrow rectangle, using the function
Code: Select all
void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
and I'm getting assert errors because my polygon is degenerated.
The problem is with the check of `b2_linearSlop` when welding vertices, that removes my vertices as duplicates, although they are separated enough. Currently it says (b2PolygonShape.cpp:141):
Code: Select all
if (b2DistanceSquared(v, ps[j]) < 0.5f * b2_linearSlop)
But that comparison makes no sense because `b2DistanceSquared` returns meters squared (m^2) while `b2_linearSlop` has a value of meters (m).
In my code, the vertices are separated `0.035` and `b2_linearSlop` is the default of `0.005`. The comparison results to `0.001225 < 0.0025` and the vertices are welded.
IMHO, it should be something along the lines of:
Code: Select all
if (b2DistanceSquared(v, ps[j]) < 0.5f * 0.5f * b2_linearSlop * b2_linearSlop)
I'm not sure about the `0.5f` squared, though, so I'm just guessing there.
Best regards.