# FBodyInstance::GetBodyBounds fails for static bodies

**URL:** <https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541>\
**Category:** World Creation\
**Tags:** physx, unreal-engine, bug-report, question, CPP\
**Created:** [November 24, 2015, 3:07pm UTC](https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541 "2015-11-24T15:07:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e1690214](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e1690214](https://forums.unrealengine.com/u/anonymous_user_e1690214)\
**Post date:** [November 24, 2015, 3:07pm UTC](https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541/1 "2015-11-24T15:07:52Z")

</div>

`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);
});

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [November 27, 2015, 9:35pm UTC](https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541/2 "2015-11-27T21:35:45Z")

</div>

Hi Sneftel,

It looks like you already have a suggested fix in mind for the issue that you described. Would you like to submit that on GitHub as a Pull Request? We can then have a developer review your suggestion and add it into the source code.

If you don’t want to, or are unable to, submit a Pull Request, I can enter a ticket internally to have this segment of code investigated.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e1690214](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e1690214](https://forums.unrealengine.com/u/anonymous_user_e1690214)\
**Post date:** [November 28, 2015, 4:53pm UTC](https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541/3 "2015-11-28T16:53:07Z")

</div>

I’m afraid my branch has diverged too far from the mainline to make a pull request practical.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b666e59e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b666e59e](https://forums.unrealengine.com/u/anonymous_user_b666e59e)\
**Post date:** [December 3, 2015, 9:40pm UTC](https://forums.unrealengine.com/t/fbodyinstance-getbodybounds-fails-for-static-bodies/339541/4 "2015-12-03T21:40:44Z")

</div>

Hi Sneftel,

I have entered a report of the issue that you described to have it investigated further (UE-24089).
