I have a BoundingBox object which holds two Vector3's (x, y, z), one for the minimum point and one for the maximum point. (-1.5 0 9 | 1.5 3 10)
What is the best way to check for any intersection or overlap of two BoundingBoxes?
The test for intersection will happen more often than not when there are no points actually intersecting, just faces.
The code that I currently am using is:
bb1.max_.x_ > bb2.min_.x_ && bb1.min_.x_ < bb2.max_.x_ && bb1.max_.y_ > bb2.min_.y_ && bb1.min_.y_ < bb2.max_.y_ && bb1.max_.z_ > bb2.min_.z_ && bb1.min_.z_ < bb2.max_.z_;
However this leads to problems when points are, for example -1.5 0 9 | 1.5 3 10
intersecting with -0.5 0 8.5 | 0.5 1.8 10.5
... The Z minimum and maximum points for the second object laying entirely outside of the Z min and max for the first object.