NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 276 forks source link

Inertia scaling gives weird results #127

Open danielkrakowiak opened 4 years ago

danielkrakowiak commented 4 years ago

Hey, I'm using Unreal and trying to scale a cylinder's inertia tensor in one, specific axis. If I scale inertia tensor's z-axis it does resist rotation as expected. However, if I scale any of the other two axes, it also does resist rotation (even more seemingly). I would expect other two axes to not impact the shown rotation at all.

Here is the video.

I know this is Unreal, not pure PhysX, but maybe you could still help me. The cylinder is a triangle mesh, so the underlying physics representation is a convex shape. Can that affect initial inertia calculation and lead to inertia tensor components not being aligned with object coordinate space? Can they be misaligned somehow? I don't see any inertia tensor rotation in the interface so I assume that's not the case. Any ideas on what could be causing this?

Edit: I tried to print the value of Body->getMassSpaceInertiaTensor(). It's weird, because the more I scale Z-axis, the longer X, Y become and the shorter Z becomes in the vector returned by it. It also doesn't seem to change linearly with the scale provided.

Edit2: I read the code in PxMassProperties::scaleInertia and it seems that changing the inertia along one axis has impact on inertia in other axes. Maybe that's a law of nature that I don't intuitively grasp. Is there a good way to understand that?