DanielChappuis / reactphysics3d

Open source C++ physics engine library in 3D
http://www.reactphysics3d.com
zlib License
1.54k stars 223 forks source link

SATAlgorithm collision assert, v0.7.0 #78

Closed aliasdevelopment closed 5 years ago

aliasdevelopment commented 5 years ago

Hi Daniel

I have some information regarding a collision assert in a sceen consisting of spheres and boxes. I am using reactphysics v0.7.0

It seems to be related to an invalid normalWorld having the value of (0, 0, 0) in SATAlgorithm.cpp because minEdgeVsEdgeSeparatingAxisPolyhedron2Space is (0, 0, 0).

Seems as if there are code branches where the default value of minEdgeVsEdgeSeparatingAxisPolyhedron2Space is not overwritten.

I can see that the master branch implements this differently. This may be resolved.

The assert is here: src/collision/ContactPointInfo.h:82 82 assert(contactNormal.lengthSquare() > decimal(0.8));

Previous frame give a hint: src/collision/narrowphase/SAT/SATAlgorithm.cpp:788 788 narrowPhaseInfo->addContactPoint(normalWorld, minPenetrationDepth, (gdb) info locals closestPointPolyhedron1Edge = {x = -0.107749328, y = -0.114340529, z = 0.0996963903} closestPointPolyhedron2Edge = {x = -0.107500002, y = -0.107500002, z = 0.107500002} closestPointPolyhedron1EdgeLocalSpace = {x = -0.107499987, y = 0.107499994, z = 0.0485341512} normalWorld = {x = 0, y = 0, z = 0} __PRETTY_FUNCTION__ = "bool reactphysics3d::SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(reactphysics3d::NarrowPhaseInfo*, bool) const" polyhedron1 = 0x128cdc0 polyhedron2 = 0x135a510 polyhedron1ToPolyhedron2 = {mPosition = {x = -0.0606153756, y = -0.248037606, z = 0.172987223}, mOrientation = {x = 0.0901728719, y = -0.695854664, z = -0.104953676, w = 0.704726756}} polyhedron2ToPolyhedron1 = {mPosition = {x = -0.233627692, y = 0.192646205, z = -0.058540415}, mOrientation = {x = -0.0901728719, y = 0.695854664, z = 0.104953676, w = 0.704726756}} minPenetrationDepth = 3.40282347e+38 minFaceIndex = 0 isMinPenetrationFaceNormal = false isMinPenetrationFaceNormalPolyhedron1 = false minSeparatingEdge1Index = 20 minSeparatingEdge2Index = 12 separatingEdge1A = {x = -0.166697651, y = -0.113221914, z = 0.10059917} separatingEdge1B = {x = 0.0482384562, y = -0.117300585, z = 0.0973074734} separatingEdge2A = {x = -0.107500002, y = -0.107500002, z = 0.107500002} separatingEdge2B = {x = 0.107500002, y = -0.107500002, z = 0.107500002} minEdgeVsEdgeSeparatingAxisPolyhedron2Space = {x = 0, y = 0, z = 0} isTemporalCoherenceValid = true lastFrameCollisionInfo = 0x1354b88

DanielChappuis commented 5 years ago

I think this has been fixed in the master branch. Do you have this issue in the master branch also or only in the v0.7.0 branch ?

aliasdevelopment commented 5 years ago

I have only seen this issue on v0.7.0 until now.

DanielChappuis commented 5 years ago

Yes, I think this bug has been fixed in the commit 45f86ea543503babd2614dc65a855afe0e561f7e and is not an issue anymore in the current master branch. Therefore, I am closing this issue.

Do not hesitate to report it in case it happens in the master branch.