Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlightIntegratorPerf patch breaks Persistent Rotation during timewarp #277

Open
dok377 opened this issue Oct 23, 2024 · 4 comments
Open
Labels
mod-compat Compatibity issue with another mod

Comments

@dok377
Copy link

dok377 commented Oct 23, 2024

Describe your problem with KSPCF : When this patch is active, Persistent Rotation doesn't rotate crafts during timewarp. It resumes rotation after the timewarp stops. When the patch is disabled everything works as it should.

Video of the bug: https://youtu.be/-btIv3-Q63o

KSP version : 1.12.4 with only KSPCF, Persistent Rotation and its dependencies
Link to your KSP.log file : https://drive.google.com/file/d/1gOqtxYFgfzef2Nq5nQnipWrmyoHgvM3G

@gotmachine gotmachine added the mod-compat Compatibity issue with another mod label Oct 23, 2024
@gotmachine
Copy link
Contributor

gotmachine commented Oct 23, 2024

This is because we are fixing a KSP inconsistency where the vessel calculated MOI (and angular momentum) was still available on packed vessels, but only when that vessel has previously been unpacked at least once. Meaning that vessels being initially loaded out of unpacking range would have those values set to zero, but vessels going out of packing range or entering non-phys warp would still have access to (stale) values.

The stock code is trying to reset those values, but fails to do so due to a silly mistake.

For reference, here the KSPCF code where this happens :

if (vessel.angularVelocityD == Vector3d.zero && vessel.packed)
{
vessel.MOI.MutateZero();
vessel.angularMomentum.MutateZero();
}

and
vessel.MOI.MutateZero();
vessel.angularMomentum.MutateZero();

And for completeness, do note that we are also fixing the same issue for rb_velocity and angularVelocity. Note that the double backed versions of those were already correctly set to zero, as the Vector3d.Zero() method doesn't suffer from the same issue.

vessel.rb_velocity.MutateZero();
vessel.rb_velocityD.MutateZero();
vessel.velocityD.MutateZero();
vessel.angularVelocity.MutateZero();
vessel.angularVelocityD.MutateZero();

I'm a bit torn on what to do, TBH. Technically, we are just exposing more consistently a bug in Persistent Rotation, which shouldn't be using those fields while the vessels are packed.

In stock, an easy way to reproduce the same PR issue is to launch and teleport two vessels in orbit at a 250m distance from each other (this is easily done with the stock rendezvous cheat, in the "set orbit" tab of the ALT-F12 menu). Make one of the vessels rotate, switch to the other, quick-save and quick-load : the other vessel won't be rotating anymore (you don't even need to engage timewarp), as long as it doesn't get close enough from the active vessel (unpacking range in stock is 200m).

And for reference, the problematic code in PR :
https://github.com/linuxgurugamer/PersistentRotation/blob/dc1fd8de0bbac625234aad560d9249fa79f065ab/Source/Main.cs#L361-L363

@dok377
Copy link
Author

dok377 commented Oct 23, 2024

So this is technically not an issue with KSPCF. Maybe I should also notify LGG? He might take a look at it and see if anything can be done.

@dok377
Copy link
Author

dok377 commented Oct 23, 2024

Created an issue there, maybe there's something that can be done on PR's side. IF LGG is still active, that is.

@linuxgurugamer
Copy link

Not sure if it can be fixed, I'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod-compat Compatibity issue with another mod
Development

No branches or pull requests

3 participants