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

Post Reply
StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

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

Post 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?
StephenLynx
Posts: 9
Joined: Tue May 10, 2016 1:42 am

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

Post 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.
benelot
Posts: 350
Joined: Sat Jul 04, 2015 10:33 am
Location: Bern, Switzerland
Contact:

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

Post 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?
Jez Hammond
Posts: 7
Joined: Tue Apr 12, 2016 12:53 pm

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

Post 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 = ...
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

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

Post by hyyou »

StephenLynx, thank a lot, for putting the link! It works! (m_localShapeInfo->m_triangleIndex)
Post Reply