C++ get Mesh size

Hello, I just started working with UE and i created a
My_Mesh = CreateDefaultSubobject(TEXT(“MyMesh”));
Is there a way i can get the size of mesh ? i need to get x,y,z to subdivide the map into squares, triangles and hexagones to create my own custom navigation mesh.

I found out about these
GetComponentBounds” for components
GetActorBounds” for Actors.
And i dont understand how to use them.

What about My_Mesh->CalcBounds()? Basically the same as GetComponentBounds but in C++.

it returns an FTransform, where can i get the size?
Or it returns an FBoxSphereBounds… that i checked and its x,y,z are null

Have you tried calling My_Mesh->UpdateBounds() before? Also, are My_Mesh->CalcBounds().BoxExtent and My_Mesh->CalcBounds().SphereRadius both zero?

1 Like

FTransform transform ;
FVector vector = My_Mesh->CalcBounds(transform ).GetBox().GetSize();
this returns negative values. I am not sure if this is the correct way of getting the size. Also what is the transform needed for, is it the a transform that will get a value when i call calcBounds, or is the function CalcBonds calculating the bounds of the transform ?

SphereRadius returned 536870912
and BoxExtent returned negative values

When you call UStaticMeshComponent::CalcBounds(FTransform& LocalToWorld), first the bounds of the mesh are fetched, and then they are transformed by the LocalToWorld transform. So when you have a transform with a location and a rotation, the bounds are translated and rotated.

Also notice that the mesh of the UStaticMeshComponent must be set first.

Thank you all for your help.
Was the solution to get the distance.

1 Like