KSPModdingLibs / KSPCommunityFixes

Community patches for bugs in the KSP codebase
49 stars 17 forks source link

Returning to space center when the vessel is far from the homeworld will break the camera #157

Open JonnyOThan opened 1 year ago

JonnyOThan commented 1 year ago

If your vessel is very farm from kerbin (or whatever your homeworld is) and you press escape -> return to space center, this can happen (or worse): https://imgur.com/ccaWYrA

I have a hunch that this is what's responsible for all those pictures of "flooded" KSC.

I broke in with the debugger and the floating origin offset is very large, which means the transform math that unity is doing to get the camera near the KSC is completely breaking down. I suspect fixing this is as simple as calling FloatingOrigin.fetch.ResetOffset when returning to the KSC view (but this is probably not a complete solution because it seems to be hardcoded to the launchpad).

R-T-B commented 1 year ago

"I broke in with the debugger and the floating origin offset is very large, which means the transform math that unity is doing to get the camera near the KSC is completely breaking down. I suspect fixing this is as simple as calling FloatingOrigin.fetch.ResetOffset when returning to the KSC view (but this is probably not a complete solution because it seems to be hardcoded to the launchpad)."

Kopernicus has offered a solution to this using exactly that for some time. It's called "ResetFloatingOriginOnKSCReturn" boolean option in Kopernicus_Config.cfg or the GUI, default false because as you suspected, it's imperfect and breaks some mods (ones that move the KSC, or KK in particular).

I think it should remain in Kopernicus as it's largely applicable to modded systems but I'd welcome PR's to improve it.

gotmachine commented 1 year ago

Is this reproducible in stock / at stock planetary system distances ? If so, it might be worthwhile to handle it from KSPCF In the other case, I agree with @R-T-B that letting Kopernicus handle such issues is a better option to avoid useless stock behavior changes that might interact badly with something else.

R-T-B commented 1 year ago

AFAIK it's only applicable to extreme modded distances.

JonnyOThan commented 10 months ago

https://www.reddit.com/r/KerbalSpaceProgram/comments/17yzpsx/what_happens_if_you_send_a_voyager_probe_then/

R-T-B commented 10 months ago

That's a fairly extreme modded distance, yes. Has the user there tried the Kopernicus option I mentioned as a workaround?

JonnyOThan commented 10 months ago

@R-T-B that post doesn’t mention the distance or mods, just that it was a “voyager” craft - so I assume on an escape trajectory out of the system.

I’ve been using the kopernicus option and it helps, but it’s not always sufficient because it only does one iteration of resetting the origin. Because of the math involved, it’s possible for there to still be a large offset after calling that function.

R-T-B commented 10 months ago

Ah, I assumed "Voyager" meant an RSS-style replica of Voyager. Which would be pretty far out there.

Anyways, I know my fix is imperfect but to date I've yet to find a better fix.