Jump to content

Scaling inertia tensor, or how to summon the Kraken with one silly trick.


Gotmachine

Recommended Posts

In some vain efforts to make PhysX joints to be more rigid when connecting parts of vastly inequal masses, KSP 2 is implementing a silly hack in the form of scaling the Rigidbodies inertia tensor according to the connected parts mass ratios.
This is a well known "trick" in the Unity community, however, this has the consequence of fundamentally breaking the physical behavior of Rigidbodies.
Excerpt from the PhysX documentation :

Quote

Mass Scaling

PhysX joints may apply scale to the mass and moment of inertia of the two connected bodies for the purposes of resolving a joint. For example, if you have two objects in a ragdoll of masses 1 and 10, PhysX will typically resolve the joint by changing the velocity of the lighter body much more than the heavier one. You can apply a mass scale of 10 to the first body to make PhysX change the velocity of both bodies by an equal amount. To ensure the same property holds for both linear and angular velocity, you should adjust the inertia scales in accordance with the bodies' inertias as well. Applying mass scales such that the joint sees similar effective masses and inertias makes the solver converge faster, which can make individual joints seem less rubbery or separated, and sets of jointed bodies appear less twitchy

Many applications that prioritize visual behavior over adherence to physical laws can benefit from tuning these scale values. But if you use this feature, bear in mind that mass and inertia scaling is fundamentally nonphysical. In general momentum will not be conserved, the energy of the system may increase, the force reported for the joint may be incorrect, and non-physical tuning of breakage thresholds and force limits may be required.

Now, I haven't tested what KSP 2 does in depth nor attempted to prove the consequences of KSP 2 scaling the inertia tensors, but given how many people are reporting issues with phantom torques/forces resulting in vessels spinning out of control randomly and orbit instability, it's tempting to connect the dots.
This could also explain why reaction wheels and RCS appear so weak compared to KSP 1, despite not having being nerfed. Since the parts providing RCS or RW torque are usually very light, they might be disproportionally affected by the inertia tensor scaling hack, resulting in their ability to provide torque being artificially reduced when connected to heavier parts.

For anyone that has some issues with stuff spinning out of control and other phantom forces issues, I would suggest disabling that KSP 2 "feature" and to report back if things seems better.

You can disable that feature by going to the KSP user data folder and editing the physics settings :

  • Paste the following in the windows explorer bar : %USERPROFILE%\AppData\LocalLow\Intercept Games\Kerbal Space Program 2\Global
  • Hit enter to navigate to the folder
  • Right-click on the PhysicsSettings.json file and select Open with... > Notepad
  • Locate the "ENABLE_INERTIA_TENSOR_SCALING": true, line
  • Change true to false
  • Save the changes and restart the game
Edited by Gotmachine
Link to comment
Share on other sites

13 hours ago, Joker58th said:

Reporting back.  Changing this setting to false made my rocket wobbly.  Setting it back to true, it was rigid again.  Very noticeable.

If you combine this with the Joint Rigidity hack (adding a bunch of zeroes to the existing value), does that help with the wobble? I'd test it myself but I'm at work, lol

Link to comment
Share on other sites

14 hours ago, Joker58th said:

Changing this setting to false made my rocket wobbly.  Setting it back to true, it was rigid again.  Very noticeable.

That is fully expected. The reason they did that inertia tensor scaling hack is because there is no other way (beside spamming more internal joints) to prevent PhysX joints from becoming loose springs when connecting Rigidbodies of largely varying mass.
The problem is that scaling the inertia tensor is basically breaking the laws of physics (conservation of energy), the result for the end user being random phantom forces/torques.

Edited by Gotmachine
Link to comment
Share on other sites

52 minutes ago, Gotmachine said:

That is fully expected. The reason they did that inertia tensor scaling hack is because there is no other way (beside spamming more internal joints) to prevent PhysX joints from becoming loose springs when connecting Rigidbodies of largely varying mass.
The problem is that scaling the inertia tensor is basically breaking the laws of physics (conservation of energy), the result for the end user being random phantom forces/torques.

Did KSP1 use PhysX and, if so, do you know if it also used this trick? If not, how did it work so well (assuming auto-strut was enabled)?

Link to comment
Share on other sites

56 minutes ago, Gotmachine said:

That is fully expected. The reason they did that inertia tensor scaling hack is because there is no other way (beside spamming more internal joints) to prevent PhysX joints from becoming loose springs when connecting Rigidbodies of largely varying mass.
The problem is that scaling the inertia tensor is basically breaking the laws of physics (conservation of energy), the result for the end user being random phantom forces/torques.

Ok, I went ahead and got the wobbly rocket to Mun orbit and still experience the same issue.  Also notice what happens to the PE when coming out of time warp.

https://clipchamp.com/watch/GDThiN0gcwL

Link to comment
Share on other sites

  • 2 weeks later...

  

On 3/3/2023 at 10:25 AM, whatsEJstandfor said:

Did KSP1 use PhysX and, if so, do you know if it also used this trick? If not, how did it work so well (assuming auto-strut was enabled)?

No, KSP1 did not use this.

Link to comment
Share on other sites

On 2/28/2023 at 1:51 PM, Gotmachine said:

In some vain efforts to make PhysX joints to be more rigid when connecting parts of vastly inequal masses, KSP 2 is implementing a silly hack in the form of scaling the Rigidbodies inertia tensor according to the connected parts mass ratios.
This is a well known "trick" in the Unity community, however, this has the consequence of fundamentally breaking the physical behavior of Rigidbodies.

I only worked with Unity when modding KSP and I cannot talk about how this works in other games. But my experience was, that the only way to make something more stable without creating a lot of new problems was to add joints. Scaling mass never worked for me. I tried this in KSP 1 for several days when I tried to find a new way to make rockets more stable.

Link to comment
Share on other sites

So it seems this is true even of regular buildable struts.  I put a couple struts on a supermaneuverable  neutrally-stable plane that could turn on a dime and now the thing handles like a schoolbus.

Link to comment
Share on other sites

×
×
  • Create New...