I have individual bounding boxes around objects in my world, I'm trying to find one larger bounding box that encompasses all the bounding boxes of the small objects. How would I do that considering that my current bounding box is defined as such:
struct _bounding_box
{
XMFLOAT3 center;
float xExtent;
float yExtent;
float zExtent;
};
Also it's worth noting that all the bounding boxes are axis aligned.
At the moment what I'm doing is converting the (center, extent) representation into individual vertices and then finding the smallest and largest vertex, but this involves me decomposing each individual box into 8 verticies as such:
Vertex v1, v2, v3, v4, v5, v6, v7, v8;
v1.pos = center + xAxis*xExtent + yAxis*yExent;
v2.pos = center + xAxis*(-xExtent) + yAxis*yExtent;
v3.pos = center + xAxis*xExent - yAxis*yExtent;
//.. and so on
I feel like there might be some solution that allows me to directly use the (center, extent) representation of the boxes directly to find the overall bounding box. Is there?