Archive 17/01/2023.

Composite collision detection

QBkGames

I’d like to have an object, for example a car, that conceptually is made up of a number of parts (e.g. wheels, doors, roof, bumper bars, hood, bonnet, etc). Physically it should behave as a single rigid body (maybe based on the Raycast Vehicle). However when colliding, I would like to know exactly which of it’s parts was involved in the collision, so that I may change the mesh of that part to one that shows some damage and also I like to keep track of the damaged parts so that later on, when the player enters a garage they are given the option the replace/repair the damaged parts.

Ideally, I would have a node that has a single rigid body and multiple collision shapes, but I couldn’t figure out how to determine which of the collision shapes was involved in the collision.

Any ideas? Thanks.

stark7

The raycast result gives you the mesh that was hit, the distance and the node it belongs to, it doesn’t use the physics bodies.

QBkGames

Thanks for the idea.
So, I should get the collision data from the physics world and use it to create an Octree raycast query to get the specific child node and mesh. A bit convoluted but could work.

Bananaft

Compound collision shape won’t tell you which of it’s parts is colliding.

I would recommend the following: Making your car collision a single convex shape to keep things fast and simple, then, when it detects collision, you take a position of collision point and check what part it belongs “by hand” by checking it’s intersection with part’s bounding boxes, or finding a closest part to a collision point.

SirNate0

Based off of some earlier searching, I’m pretty sure you can also make a few modifications to Bullet so that it will tell you which shape in the compound shape was hit.

If you want, I can try to find those links, but if you’d prefer not modifying the engine I’d go with the other solutions.