-1

I have a system using bullet physics that uses compound rigid body physics,

a raycast striking the objects children, simply returns the object, (not a child object)

to work around this, I use the distance from the hitpoint to the child object, but this is a bit naive, as the collision volume can be a sphere, cube, capsule etc, that is scaled on 3 axis.

I can get the x,y, and z bound dimensons local to the object,

how would I use this information to detect which child object was hit by the ray?

I was thinking some sort of check against the point, and the bounds of the child shapes, but it needs to be pretty fast, and its using python.

2 Answers2

0

Two solutions that might do the trick.

Separate colliders

First, separate the colliders and give each a different object, then link the objects programmatically and move them alongside one another. This way there won't be a compound collider.


Iterative collision

Second option is perhaps more computationally expensive, when there is a collision, disable the colliders one by one and recast the ray untill you find which collider is the nearest.

j4hangir
  • 2,532
  • 1
  • 13
  • 14
0

unparent all pieces, cast ray -> find who was hit -> reparent all pieces seems like the only solution, but I am not sure how expensive it will be**

or build a BVH tree when assembled, where the faces are indexed to objects..... get hit face-> check index of vertex to get hitObject.....?