Chaos: Movable ISM components register instance bodies as static

Hello,

While debugging performance issues with Chaos in our project we noticed that a movable actor was dirtying the static TAABBTree. The actor is fully movable and all of its components are set to movable.

Upon closer inspection we found that this movable actor had an ISM component, which was also set to movable, however the instance bodies were still registered in the static tree, and not the dynamic tree.

Tracking this down, this seems to come from UInstancedStaticMeshComponent::CreateAllInstanceBodies, specifically

Instance->InitBody(BodySetup, InstanceTM, this, PhysScene, nullptr );

The nullptr being passed in into the implicit constructor sets the bStaticPhysics inside the FInitBodySpawnParams to true, because it’s nullptr.

When we change the InitBody to pass in “this” instead, it seems to work as intended and the bodies are part of the dynamic tree.

It mostly seems like this would be a bug because the function is specifically checking Mobility == EComponentMobility::Movable before initializing the body.

To this I have two questions:

Can you confirm whether this is an oversight/bug or if this is somehow intentional?

And secondly, should ISM components, where we expect to be moving the instances with UpdateInstanceTransform, be set to movable, even when the component itself is unlikely to move? If the above is really a bug, then with this change I would expect that ISM components that are likely to move its bodies are better off to be set to movable to avoid dirtying the static tree all the time.

Thank you for your time,

Kind regards,

Céleste Neukirchen

Steps to Reproduce

Hi Celeste, and thank you for raising this.

I’ve taken a look through the code, and this appears to be an oversight.

If you expect to be moving the mesh regularly, then it should be set to movable. In Chaos the default settings will separate out static bodies and dynamic bodies into different structures. This way we don’t need to update the static side each frame and improves performance. You can update static bodies in Chaos, but it has to rebuild the tree when that happens, so isn’t recommended unless rebuilding levels or that scope of work.

I’ll take a look into getting a fix raised for this, and will keep this open for the second while I get it looked into.

All the best

Geoff Stacey

Developer Relations

EPIC Games