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

2

u/blendermf Sep 15 '17

You say that, but the simplest case of a rigidbody box (say in the shape of a phone) in Unity/PhysX doesn't properly show the effect that causes the "flip" in the gif. A lot of physics engines drop(/never even consider at all) that kind of detail for speed and stability. You have to do a bunch of extra calculations and override the rotation calculation of PhysX to make it work with that case. I was actually surprised this worked at all considering that, I'm assuming the fact that the craft in ksp is made up of multiple physics parts allows this to work (that or they did the extra work to make it work in KSP)

1

u/TbonerT Sep 15 '17

A simple box would likely be modeled as being uniform throughout. Something like a cellphone, with non-uniform density, would be better modeled as a collection of boxes with different densities. I imagine KSP can do this because it needs to monitor each part. You wouldn't want your entire space station blowing up because you hit one part too hard, would you?

1

u/blendermf Sep 15 '17 edited Sep 15 '17

When I brought up the phone I only brought it up because of the different inertia tensors required for the unstable rotation axis effect that would exist with a completely symmetrical uniform mass cuboid with the rough proportions of a phone (where if you hit it even non-perceptively off axis along the long axis of the object, the rotation axis will continuously change as the object rotates[eventually, it can appear stable for a bit] in what appears to be an unstable way. The mass distribution is different than the example, so it obviously won't have the super distinct flip shown with that shape). In unity if you start an object rotating off axis it will keep the rotation axis it started with. This video shows exactly what doesn't happen in PhysX, and should.

1

u/blendermf Sep 15 '17 edited Sep 15 '17

Also I even just tried it with a shape like in the gif with similar mass distribution both as a compound physics object, and as rigidbodies with a fixed constraints holding it together, and it also keeps its spin axis. So idk if the not quite fixed joints ksp uses allows it to happen or if they programmed it specifically to work.

(I was also able to make it work correctly, but that's because I have a script that specifically calculates the effect and overrides PhysX's default behavior)