Page 1 of 1

Getting compound shape`s child shape on a ray cast.

Posted: Sat May 14, 2016 8:27 pm
by StephenLynx
If I have a compound shape and hit it using a ray trace, is it possible to know which child shape of the compound shape was hit?

Re: Getting compound shape`s child shape on a ray cast.

Posted: Sat May 14, 2016 10:21 pm
by StephenLynx
Nvm, figured it using this:
http://www.bulletphysics.org/Bullet/php ... ray#p37118
I subclassed btCollisionWorld::ClosestRayResultCallback and put a field to store an in that is the index of what I hit.

Re: Getting compound shape`s child shape on a ray cast.

Posted: Sun May 15, 2016 9:08 am
by benelot
Hey StephenLynx,
It seems that you put some effort into this! Why don't you make a pull request to change the original raycast classes so that this information gets available?

Re: Getting compound shape`s child shape on a ray cast.

Posted: Sun May 15, 2016 1:08 pm
by Jez Hammond
StephenLynx wrote:Nvm, figured it using this:
http://www.bulletphysics.org/Bullet/php ... ray#p37118
I subclassed btCollisionWorld::ClosestRayResultCallback and put a field to store an in that is the index of what I hit.
Hi, there's a rare case nullptr bug in the mod, which should be tested for before using. I shall check previous project later and confirm which...(plus hopefully edit post from previous username)


EDIT: in btCollisionWorld.h addSingleResult(), use if (rayResult.m_localShapeInfo) m_childShapeID = ...

Re: Getting compound shape`s child shape on a ray cast.

Posted: Sat Jul 02, 2016 5:44 am
by hyyou
StephenLynx, thank a lot, for putting the link! It works! (m_localShapeInfo->m_triangleIndex)