Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SATAlgorithm/ContactPointInfo assert when pos/quat is uninitialized, master #84

Closed
aliasdevelopment opened this issue Jan 18, 2019 · 8 comments

Comments

@aliasdevelopment
Copy link

aliasdevelopment commented Jan 18, 2019

This happens when pos/quat are uninitilized for the rigidbody.
If I initilize the pos/quat with some proper defaults, then all work as expected.

Assume this to be an usage issue and not a library issue.

I do not know if you want input asserts to check user input to the various interface calls. I guess it would be easier to debug, but then again always remember to initialize :)

This was found on commit c2aeda9

(gdb) frame 10
#10 0x000000000064ad07 in reactphysics3d::DynamicsWorld::update (this=0x7a88a0, timeStep=0.0166666675) at /source/reactphysics3d/src/engine/DynamicsWorld.cpp:126
126 mCollisionDetection.computeCollisionDetection();
(gdb) frame 9
#9 0x00000000006368ba in reactphysics3d::CollisionDetection::computeCollisionDetection (this=0x7a8908) at /source/reactphysics3d/src/collision/CollisionDetection.cpp:83
83 computeNarrowPhase();
(gdb) info locals
No locals.
(gdb) frame 8
#8 0x00000000006371b8 in reactphysics3d::CollisionDetection::computeNarrowPhase (this=0x7a8908) at /source/reactphysics3d/src/collision/CollisionDetection.cpp:275
275 if (narrowPhaseAlgorithm->testCollision(currentNarrowPhaseInfo, true, mMemoryManager.getSingleFrameAllocator())) {
(gdb) info locals
lastCollisionFrameInfo = 0xa1f538
shape1Type = reactphysics3d::CollisionShapeType::CONVEX_POLYHEDRON
shape2Type = reactphysics3d::CollisionShapeType::CONVEX_POLYHEDRON
narrowPhaseAlgorithm = 0x7a8948
narrowPhaseInfoToDelete = 0x7fffffffcd10
currentNarrowPhaseInfo = 0x7ffff752b148
(gdb) frame 7
#7 0x000000000065b345 in reactphysics3d::ConvexPolyhedronVsConvexPolyhedronAlgorithm::testCollision (this=0x7a8948, narrowPhaseInfo=0x7ffff752b148, reportContacts=true, memoryAllocator=...)
at /source/reactphysics3d/src/collision/narrowphase/ConvexPolyhedronVsConvexPolyhedronAlgorithm.cpp:53
53 bool isColliding = satAlgorithm.testCollisionConvexPolyhedronVsConvexPolyhedron(narrowPhaseInfo, reportContacts);
(gdb) info locals
satAlgorithm = {static SAME_SEPARATING_AXIS_BIAS = 0.00100000005, mMemoryAllocator = @0x792ba0}
lastFrameCollisionInfo = 0xa1f538
isColliding = false
(gdb) frame 6
#6 0x000000000066bfdd in reactphysics3d::SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron (this=0x7fffffffcc68, narrowPhaseInfo=0x7ffff752b148, reportContacts=true)
at /source/reactphysics3d/src/collision/narrowphase/SAT/SATAlgorithm.cpp:820
820 narrowPhaseInfo->addContactPoint(normalWorld, minPenetrationDepth,
(gdb) info locals
closestPointPolyhedron1Edge = {x = 0, y = 0, z = 0}
normalWorld = {x = -nan(0x7fa310), y = -nan(0x7fa310), z = -nan(0x7fa310)}
closestPointPolyhedron2Edge = {x = 0, y = 0, z = 0}
closestPointPolyhedron1EdgeLocalSpace = {x = -nan(0x7fa310), y = -nan(0x7fa310), z = -nan(0x7fa310)}
normal = {x = nan(0x7fa310), y = nan(0x7fa310), z = nan(0x7fa310)}
PRETTY_FUNCTION = "bool reactphysics3d::SATAlgorithm::testCollisionConvexPolyhedronVsConvexPolyhedron(reactphysics3d::NarrowPhaseInfo*, bool) const"
polyhedron1 = 0x9dc110
polyhedron2 = 0x9e33f0
polyhedron1ToPolyhedron2 = {mPosition = {x = nan(0x7fa310), y = nan(0x7fa310), z = nan(0x7fa310)}, mOrientation = {x = nan(0x7fa310), y = nan(0x7fa310), z = nan(0x7fa310), w = -nan(0x7fa310)}}
polyhedron2ToPolyhedron1 = {mPosition = {x = -nan(0x7fa310), y = -nan(0x7fa310), z = -nan(0x7fa310)}, mOrientation = {x = -nan(0x7fa310), y = -nan(0x7fa310), z = -nan(0x7fa310), w = -nan(0x7fa310)}}
minPenetrationDepth = 3.40282347e+38
minFaceIndex = 0
isMinPenetrationFaceNormal = false
isMinPenetrationFaceNormalPolyhedron1 = false
minSeparatingEdge1Index = 0
minSeparatingEdge2Index = 0
separatingEdge1A = {x = 0, y = 0, z = 0}
separatingEdge1B = {x = 0, y = 0, z = 0}
separatingEdge2A = {x = 0, y = 0, z = 0}
separatingEdge2B = {x = 0, y = 0, z = 0}
minEdgeVsEdgeSeparatingAxisPolyhedron2Space = {x = 0, y = 0, z = 0}
isShape1Triangle = false
lastFrameCollisionInfo = 0xa1f538
faceIndex = 4294953488
penetrationDepth = 3.40282347e+38
(gdb) frame 5
#5 0x000000000063d366 in reactphysics3d::NarrowPhaseInfo::addContactPoint (this=0x7ffff752b148, contactNormal=..., penDepth=3.40282347e+38, localPt1=..., localPt2=...)
at /source/reactphysics3d/src/collision/NarrowPhaseInfo.cpp:74
74 ContactPointInfo(contactNormal, penDepth, localPt1, localPt2);
(gdb) info locals
PRETTY_FUNCTION = "void reactphysics3d::NarrowPhaseInfo::addContactPoint(const reactphysics3d::Vector3&, reactphysics3d::decimal, const reactphysics3d::Vector3&, const reactphysics3d::Vector3&)"
allocator = @0x792ba0: {_vptr.MemoryAllocator = 0x6ce258 <vtable for reactphysics3d::DefaultSingleFrameAllocator+16>}
contactPointInfo = 0x4096d0 <_start>
(gdb) frame 4
#4 0x000000000063d584 in reactphysics3d::ContactPointInfo::ContactPointInfo (this=0x7ffff752b1b0, contactNormal=..., penDepth=3.40282347e+38, localPt1=..., localPt2=...)
at /source/reactphysics3d/src/collision/ContactPointInfo.h:82
82 assert(contactNormal.lengthSquare() > decimal(0.8));
(gdb) info locals
PRETTY_FUNCTION = "reactphysics3d::ContactPointInfo::ContactPointInfo(const reactphysics3d::Vector3&, reactphysics3d::decimal, const reactphysics3d::Vector3&, const reactphysics3d::Vector3&)"
(gdb)

@DanielChappuis
Copy link
Owner

Thanks a lot for reporting this.

Can I ask you what do you mean by "pos/quat are uninitilized for the rigidbody" ? Are you talking about the initial transform when you call createRigidBody() ? How can the transform be "uninitialized" ?

@aliasdevelopment
Copy link
Author

I got a representation of the positions and orientation which is passed to rp3d::Transform for the rigid body creation. I the above case my representation was not initialize correctly hence some foobar values was passed on to rp3d::Transform. I assume this, since the issue disappeared as soon as I initialized my passed representation.

@DanielChappuis
Copy link
Owner

When you say not initialized, you mean that you pass a transform where its constructor has not been called ?

I mean the following code should work without issue:

rp3d::Transform transform;
world->createRigidBody(transform);

@aliasdevelopment
Copy link
Author

aliasdevelopment commented Jan 20, 2019

No. As in the pos and ori not being initialized correctly which are passed to the transform constructor. Pos is a glm::vec3 and ori is a glm::quat

rp3d::Vector3 initPosition_internal = rp3d::Vector3( pos[0], pos[1], pos[2] );    
rp3d::Quaternion initOrientation = rp3d::Quaternion( ori[0], ori[1], ori[2], ori[3] ); 
rp3d::Transform transform(initPosition_internal, initOrientation);

@DanielChappuis
Copy link
Owner

Do you have an example for the values of "pos" and "ori" that raises the assert ? If some of the values are not numbers but NaN for instance at initialization, I guess it's OK that it raises an assert at some point in the code.

@aliasdevelopment
Copy link
Author

I will instrument my physics creation code to catch any invalid values passed to reactphysics

@aliasdevelopment
Copy link
Author

I have instrumented my code and all works as expected when my passed values to reactphysics are initialized correctly.

@DanielChappuis
Copy link
Owner

Ok perfect thanks for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants