Download

How to get bounding box of several components?

I have several components in the world. They are part of the same actor (they’re a subset of the actor’s components).

I would like to display the bounding box of these components, but I can’t seem to find a method that does that.

I tried attaching all components to one and using the “Bounds” member of SceneComponent on the “parent component”, but it doesn’t seem to consider the children when computing the bounds…

Nevermind, I found a way. If anyone that needs this comes by, here’s how I’m doing it:



FBoxSphereBounds bounds;

for(int i = 0; i < components.Num(); ++i)
{
    // For each component we have we add up its bounds to the ones already computed
	USceneComponent *comp = components*;
	bounds = bounds + comp->Bounds;
}

// Drawing a sphere that is centered "between" the components
DrawDebugSphere(GetWorld(), bounds.GetSphere().Center, bounds.SphereRadius, 30, FColor::Red, false, 3);


In the example I’m drawing the bounding sphere, but also the bounding box is computed