setCMassLocalPose causing lag spikes


My Unreal Engine 4 game allows players to build vehicles from individual pieces without a hard coded limit to the complexity. Naturally players always want to build larger and with more pieces so at some point the performance had to suffer. The biggest problem in performance is still when a piece has to fall off from a large combined shape. I already changed the Unreal source code to decrease the amount of times shapes have to be updated to the absolute minimum. After a lot of debugging the last culprit seems to be the call to the function “setCMassLocalPose” of the PhysX API.

So the question is:
Why is setCMassLocalPose so slow (>400ms) when called on a rigid body that consists of thousands of shapes? Any steps I could take to improve this, maybe even change the PhysX source code? As comparison setMass and setMassSpaceInertiaTensor run way faster.

I know that’s quite a specific question, but who knows maybe someone here happens to be able to help me, that would be greatly appreciated :)

We made some optimizations to this code recently that should improve performance significantly.

The changes are available in the most recent PhysX GitHub release. It doesn’t look like the latest source code that Epic has on GitHub has this change yet.

That’s great news thanks a lot :)