0
\$\begingroup\$

I am trying to make a game where the player can make vehicles out of parts. To apply proper physics to the vehicles, like drag and buoyancy, I would like to get the outer hull of the various parts placed in arbitrary positions, scalings, and rotations. The hull will most likely be concave, not convex.

How can I detect which faces (or parts of faces) would be on the interior of the vehicle so I can ignore them? Or alternatively, which faces are not on the interior of the vehicle and therefore make up the outer hull?

Some use cases that I am trying to handle are:

  1. Two cubes placed right next to each other, like in a grid. two cubes of the same size

  2. Two cubes placed next to each other, but of different sizes two cubes of different size

  3. A cube and a sphere (or other shape) overlapping each other. a cube and a sphere

One method that I have tried but not yet got to work is to voxelize the parts using raycasting or SDFs and then using marching cubes or dual contouring to make the hull mesh. That has issues when there are sharp angles and it can create a lot of triangles, a lot more than the original mesh. Are there other methods that I should try?

Can binary space partitioning (BSP) or a k-d tree be used for this or is that the wrong approach?

I am working in Unity / C#, but can translate from other languages.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.