I was running a Box2D simulation in a C++ program, when this error aborted the program:
a.out: ./Box2D/Dynamics/Contacts/b2ContactSolver.cpp:96: b2ContactSolver::b2ContactSolver(b2Contact**, int32, b2StackAllocator*, float32): Assertion `kNormal > 1.19209289550781250000e-7F' failed.
I don't have any further context that could relate to the issue.
The assert means at least three things:
One: You're running a debug build of Box2D.
Two: You're running an older version of Box2D than the source code hosted at Erin's Box2D GitHub repo.
After searching around, it seems that the most recent source code that was released by Erin which has this assert in it is Box2D_v2.1.2. The uploaded date for this zip file is April 17, 2010.
The source code for b2ContactSolver.cpp
from this older Box2D version 2.1.2 that you're running, shows the following relevant code surrounding the assert on line 96:
float32 kNormal = bodyA->m_invMass + bodyB->m_invMass + bodyA->m_invI * rnA + bodyB->m_invI * rnB;
b2Assert(kNormal > b2_epsilon);
ccp->normalMass = 1.0f / kNormal;
Three: The sum of the inverse masses of body A and body B and their effective inverse rotational-based masses, is not greater than b2_epsilon
where in this release of Box2D b2_epsilon
is set to FLT_EPSILON
(in b2Settings.h
).
This could happen for a variety of reasons like both bodies somehow having zero inverse masses. If any of the component values of kNormal
was NaN
for instance, I believe the greater-than check would also fail. kNormal
being less than zero would of course also cause this check to fail.
As for what you could do to further asses and fix the problem, here's some ideas that come to mind...