KSP-RO / ContractConfigurator

A config file based solution for creating new contracts for Kerbal Space Program.
https://forum.kerbalspaceprogram.com/index.php?/topic/91625-1
Other
8 stars 10 forks source link

Fix rotation of spawned vessels #44

Closed IO5 closed 3 months ago

IO5 commented 4 months ago

Not sure how this is went unnoticed for so long, but the rotation of landed vessels created via SpawnVessel is completely bogus. With heading, pitch and roll set to 0 my craft was spawned on the side with a seemingly random heading.

At some point I tried to spawn a vessel with a clamp attached and it turned out to be very nice for debugging. Clamp allowed me to keep the rotation a given vessel was spawned with.

Anyway, (0, 0, 0) heading, pitch and roll before the fix: image

The main problem, turns out, was the incorrect order of operations: rotation * normal -> normal * rotation. Changing that fixed the (0, 0, 0) case, but for non-zero it was still bogus.

The original code made a distinction between spawned part, the SPH and the VAB, and I'm not sure that's a good thing. Let's say I have a pod in the default orientation in the VAB, in the SPH, or spawned from a single part. If I then specify heading etc as (h, p, r) I expect the navball to point to (h, p, r) when I switch to said pod. I find it more natural than rotating VAB vessels 90 degrees up. On the other hand if we don't do that, then VAB vessels will spawn on their bellies by default.

For now I left the distinction and 90 degrees rotation for the VAB, so it shouldn't negatively affect legacy.