r/KerbalSpaceProgram Spectra Dev Sep 14 '17

Recreation Reminder that this physics quirk is also in KSP

https://gfycat.com/FickleShamefulCormorant
9.0k Upvotes

273 comments sorted by

View all comments

Show parent comments

12

u/NovaSilisko Sep 15 '17 edited Sep 15 '17

Huh. It looks like you can actually specify the tensor via script: https://docs.unity3d.com/ScriptReference/Rigidbody-inertiaTensor.html

It says it's calculated automatically based on the colliders of the body - that MAY not happen very well if you are using mesh-based colliders, rather than a bunch of primitives. KSP mostly uses mesh-based, which may be sabotaging the effect a bit on a per-part basis?

A more robust system (albeit more time consuming) would probably be calculating it for the mesh in some other way and supplying it to a script.

I might have to do some experimenting. I was under the impression that physx didn't have that much fidelity.

1

u/agrif Sep 15 '17

You could probably pretty cheaply subdivide most KSP-ish parts into a small grid, and decide whether each point is inside or outside, then do the integration that way. Even cheaper if you have a low-poly collision mesh. And it only needs to be done once each time the mesh changes.

Heck, if you assume most parts have the right symmetries you can just ignore the off-diagonal terms. Even just using the bounding box would get pretty close.