Has this been solved by anyone?
I am trying to derive user parameters (game material, etc.) from collision callback and running into similar issue.
It feels like the part/index passing mechanism is unfinished as it appears inconsistent.
Providing callstack below to help understand what kind of shapes/algorithms are involved.
(A). Sphere vs btBvhTriangleMeshShape:
- Receiving part index (not sure of the exact wording here) which seems to correspond to the addIndexedMesh() calls order
- Receiving triangle index in 'index0'/'index1'
I am happy with that!
Code: Select all
> wip.exe!`MyHitCallback::addSingleResult(btManifoldPoint & pt, const btCollisionObject * colObj0, int partId0, int index0, const btCollisionObject * colObj1, int partId1, int index1) Line 832 C++
wip.exe!btBridgedManifoldResult::addContactPoint(const btVector3 & normalOnBInWorld, const btVector3 & pointInWorld, float depth) Line 1095 + 0x4a bytes C++
wip.exe!SphereTriangleDetector::getClosestPoints(const btDiscreteCollisionDetectorInterface::ClosestPointInput & input, btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * debugDraw, bool swapResults) Line 58 C++
wip.exe!btSphereTriangleCollisionAlgorithm::processCollision(btCollisionObject * col0, btCollisionObject * col1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 70 C++
wip.exe!btConvexTriangleCallback::processTriangle(btVector3 * triangle, int partId, int triangleIndex) Line 126 C++
wip.exe!`btBvhTriangleMeshShape::processAllTriangles'::`2'::MyNodeOverlapCallback::processNode(int nodeSubPart, int nodeTriangleIndex) Line 316 C++
wip.exe!btQuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback * nodeCallback, unsigned short * quantizedQueryAabbMin, unsigned short * quantizedQueryAabbMax, int startNodeIndex, int endNodeIndex) Line 716 C++
wip.exe!btQuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3 & aabbMin, const btVector3 & aabbMax) Line 329 C++
wip.exe!btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback * callback, const btVector3 & aabbMin, const btVector3 & aabbMax) Line 329 C++
wip.exe!btConvexConcaveCollisionAlgorithm::processCollision(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 190 C++
wip.exe!btSingleContactCallback::process(const btBroadphaseProxy * proxy) Line 1134 C++
wip.exe!BroadphaseAabbTester::Process(const btDbvtNode * leaf) Line 265 C++
wip.exe!btDbvt::collideTV<BroadphaseAabbTester>(const btDbvtNode * root, const btDbvtAabbMm & vol, BroadphaseAabbTester & policy) Line 941 C++
wip.exe!btDbvtBroadphase::aabbTest(const btVector3 & aabbMin, const btVector3 & aabbMax, btBroadphaseAabbCallback & aabbCallback) Line 275 C++
wip.exe!btCollisionWorld::contactTest(btCollisionObject * colObj, btCollisionWorld::ContactResultCallback & resultCallback) Line 1152 C++
(B). Sphere vs Compound Shape made of simple Shapes (not mesh)
- part is -1
- Receiving child shape index in 'index0'/'index1' - that's within the compound shape (not sure how it works with hierarchical shape, I have no hierarchy within my compound here).
Also happy with that.
Code: Select all
> wip.exe!`MyHitCallback::addSingleResult(btManifoldPoint & pt, const btCollisionObject * colObj0, int partId0, int index0, const btCollisionObject * colObj1, int partId1, int index1) Line 832 C++
wip.exe!btBridgedManifoldResult::addContactPoint(const btVector3 & normalOnBInWorld, const btVector3 & pointInWorld, float depth) Line 1095 + 0x4a bytes C++
wip.exe!btGjkPairDetector::getClosestPointsNonVirtual(const btDiscreteCollisionDetectorInterface::ClosestPointInput & input, btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * debugDraw) Line 452 C++
wip.exe!btGjkPairDetector::getClosestPoints(const btDiscreteCollisionDetectorInterface::ClosestPointInput & input, btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * debugDraw, bool swapResults) Line 77 C++
wip.exe!btConvexConvexAlgorithm::processCollision(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 755 C++
wip.exe!btCompoundLeafCallback::ProcessChildShape(btCollisionShape * childShape, int index) Line 156 C++
wip.exe!btCompoundLeafCallback::Process(const btDbvtNode * leaf) Line 184 C++
wip.exe!btDbvt::collideTV<btCompoundLeafCallback>(const btDbvtNode * root, const btDbvtAabbMm & vol, btCompoundLeafCallback & policy) Line 941 C++
wip.exe!btCompoundCollisionAlgorithm::processCollision(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 254 C++
wip.exe!btSingleContactCallback::process(const btBroadphaseProxy * proxy) Line 1134 C++
wip.exe!BroadphaseAabbTester::Process(const btDbvtNode * leaf) Line 265 C++
wip.exe!btDbvt::collideTV<BroadphaseAabbTester>(const btDbvtNode * root, const btDbvtAabbMm & vol, BroadphaseAabbTester & policy) Line 941 C++
wip.exe!btDbvtBroadphase::aabbTest(const btVector3 & aabbMin, const btVector3 & aabbMax, btBroadphaseAabbCallback & aabbCallback) Line 275 C++
wip.exe!btCollisionWorld::contactTest(btCollisionObject * colObj, btCollisionWorld::ContactResultCallback & resultCallback) Line 1152 C++
(C). But now, Sphere vs compound shape containing a btBvhTriangleMeshShape:
I get the same information as in A but no way to tell which collision shape within the compound shape has been hit. .
Within the callstack you can see btCompoundLeafCallback::ProcessChildShape(), which is storing the child shape index by calling 'm_resultOut->setShapeIdentifiersA(-1,index);' (or 'setShapeIdentifiersB') but as the point of digging within the triangle mesh that data is not passed through.
Code: Select all
> wip.exe!`MyHitCallback::addSingleResult(btManifoldPoint & pt, const btCollisionObject * colObj0, int partId0, int index0, const btCollisionObject * colObj1, int partId1, int index1) Line 832 C++
wip.exe!btBridgedManifoldResult::addContactPoint(const btVector3 & normalOnBInWorld, const btVector3 & pointInWorld, float depth) Line 1095 + 0x4a bytes C++
wip.exe!SphereTriangleDetector::getClosestPoints(const btDiscreteCollisionDetectorInterface::ClosestPointInput & input, btDiscreteCollisionDetectorInterface::Result & output, btIDebugDraw * debugDraw, bool swapResults) Line 58 C++
wip.exe!btSphereTriangleCollisionAlgorithm::processCollision(btCollisionObject * col0, btCollisionObject * col1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 70 C++
wip.exe!btConvexTriangleCallback::processTriangle(btVector3 * triangle, int partId, int triangleIndex) Line 126 C++
wip.exe!`btBvhTriangleMeshShape::processAllTriangles'::`2'::MyNodeOverlapCallback::processNode(int nodeSubPart, int nodeTriangleIndex) Line 316 C++
wip.exe!btQuantizedBvh::walkStacklessQuantizedTree(btNodeOverlapCallback * nodeCallback, unsigned short * quantizedQueryAabbMin, unsigned short * quantizedQueryAabbMax, int startNodeIndex, int endNodeIndex) Line 716 C++
wip.exe!btQuantizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback * nodeCallback, const btVector3 & aabbMin, const btVector3 & aabbMax) Line 329 C++
wip.exe!btBvhTriangleMeshShape::processAllTriangles(btTriangleCallback * callback, const btVector3 & aabbMin, const btVector3 & aabbMax) Line 329 C++
wip.exe!btConvexConcaveCollisionAlgorithm::processCollision(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 190 C++
wip.exe!btCompoundLeafCallback::ProcessChildShape(btCollisionShape * childShape, int index) Line 156 C++
wip.exe!btCompoundLeafCallback::Process(const btDbvtNode * leaf) Line 184 C++
wip.exe!btDbvt::collideTV<btCompoundLeafCallback>(const btDbvtNode * root, const btDbvtAabbMm & vol, btCompoundLeafCallback & policy) Line 941 C++
wip.exe!btCompoundCollisionAlgorithm::processCollision(btCollisionObject * body0, btCollisionObject * body1, const btDispatcherInfo & dispatchInfo, btManifoldResult * resultOut) Line 254 C++
wip.exe!btSingleContactCallback::process(const btBroadphaseProxy * proxy) Line 1134 C++
wip.exe!BroadphaseAabbTester::Process(const btDbvtNode * leaf) Line 265 C++
wip.exe!btDbvt::collideTV<BroadphaseAabbTester>(const btDbvtNode * root, const btDbvtAabbMm & vol, BroadphaseAabbTester & policy) Line 941 C++
wip.exe!btDbvtBroadphase::aabbTest(const btVector3 & aabbMin, const btVector3 & aabbMax, btBroadphaseAabbCallback & aabbCallback) Line 275 C++
wip.exe!btCollisionWorld::contactTest(btCollisionObject * colObj, btCollisionWorld::ContactResultCallback & resultCallback) Line 1152 C++
It seems like to be more consistent and allow for passing of those data, the "part"/"index" duo of variables which should be a trio, adding a consistent way to retrieve the btCollisionShape (perhaps a direct btCollisionShape* pointer passed to the addSingleResult() callback along with part/index.
I may attempt to change this within Bullet if it seems to makes sense? Erwin what do you think?