FBodyInstance::GetBodyBounds()
is meant to return the box bounds of the instance, which it does by grabbing the data from PhysX:
ExecuteOnPxRigidBodyReadOnly(this, [&](const PxRigidBody* PRigidBody)
{
PxBounds3 PBounds = PRigidBody->getWorldBounds();
Bounds.Min = P2UVector(PBounds.minimum);
Bounds.Max = P2UVector(PBounds.maximum);
});
However, ExecuteOnPxRigidBodyReadOnly
is a no-op if RigidActorSync
is a PxRigidStatic
(as PxRigidStatic
does not subclass PxRigidBody
). That leads to returning uninitialized data. The correct code reads:
ExecuteOnPxRigidActorReadOnly(this, [&](const PxRigidActor* PRigidActor)
{
PxBounds3 PBounds = PRigidActor->getWorldBounds();
Bounds.Min = P2UVector(PBounds.minimum);
Bounds.Max = P2UVector(PBounds.maximum);
});