Search code examples
c#unity-game-engine3dbounding-box

Check if non axis-aligned bounding box contains another one


I work with Unity3D and want to check for neighbouring meshes next to a given mesh.

The problem is, Unity's bounding boxes are axis-aligned, so after rotation, they look like the first image below and are considered neighbours.

Image1

I want them to look like this:

Image2

How can I achieve this and how to get objects and calculate intersections of the two boxes.


Solution

  • A bounding box is always world-axis-aligned. A non-aligned box is just a box.


    With that distincton made, you can use several methods to check if volumes intersect other volumes and/or points. Here are some: