Getting the bounding box of a static mesh collision data

I have a static mesh imported into my project, which includes simple and complex collision data. I can see both fine in the UE4 mesh editor. Now I want the bounding box of the simple collision data of a given UStaticMeshComponent in C++. Is there an easy way to achieve this?

The collision data is storing @UBodySetup->AggGeom

You can access these data through:
Actor->GetStaticMeshComponent()->GetBodySetup()->AggGeom;

1 Like

The member “BoxElems” is exactly the bounding box data.

Ok, that works, thanks. I am doing the following:

FBoxSphereBounds bsBounds;
StaticMeshComp->GetBodySetup()->AggGeom.CalcBoxSphereBounds(bsBounds, FTransform());

However, that gives me the bounds at center 0,0,0 - how can I get the correct world space location, what do I have to use as transform?

1 Like

Of course you get the bounds at the origin. Cause FTransform(), the default constructor, construct a ZERO translation. The second params of CalcBoxSphereBounds is LocalToWorld transformation.

Try
AggGeom->CalcBoxSphereBounds(sb, FTransform(FVector(100.0f, 100.0f, 100.0f)));
You will find the origin of the box is translated to (100.0f, 100.0f, 100.0f)

:slight_smile:

Ahh I see, that works, thanks a lot!