Closed robertocapuano closed 5 months ago
Is the sqrt() really needed? Why not compare the difference of closestPointsDistanceSquare and sumRadiusSquare with an epsilon instead?
I tried with
if ( fabsf(closestPointsDistanceSquare - sumRadius * sumRadius )<eps )
with different values for eps:
but after few seconds of simulation I always get
assert(penDepth > decimal(0.0));
in NarrowPhaseInfoBatch::addContactPoint
After reading a second time, what about something like
std::max(sumRadius - closestPointsDistance, MACHINE_EPSILON)
in
https://github.com/DanielChappuis/reactphysics3d/blob/c2201c50ea57ec4ed6c8e718981f0df56dfa9450/src/collision/narrowphase/CapsuleVsCapsuleAlgorithm.cpp#L192
It works well, I tried it for a few minutes without errors.
Reverted the previous change and pushed the fix on this branch.
Thanks a lot for your pull request.
I have merged your first commit into the develop
branch and refactored it a bit myself before your last two commits.
Are you able to try the develop
branch with your test and see if the issue is now fixed?
Just tried it for a few minutes: it works. Thank you.
Just tried it for a few minutes: it works. Thank you.
Thanks a lot for your feedback. That's very helpful.
Sometimes assertion fails in NarrowPhaseInfoBatch::addContactPoint():
assert(penDepth > decimal(0.0));
This happens for Capsule/Capsule collision check.Probable cause is float approssimation in
bool CapsuleVsCapsuleAlgorithm::testCollision(NarrowPhaseInfoBatch& narrowPhaseInfoBatch, uint32 batchStartIndex, uint32 batchNbItems, MemoryAllocator& /*memoryAllocator*/) ;
I inserted a double check on penetrationDepth.
if (penetrationDepth > 0)
The logic is the same of SphereVsSphereAlgorithm::testCollision().