Boris-Barboris

[Solved] Removing ModuleGimbal lag in 1.4.5

Recommended Posts

Posted (edited)

Gentlemen, my old nemesis is haunting me again after a couple of KSP patches.

ModuleGimbal was tap-delayed in KSP at least as long as I can remember. That happens because it is a separate module and not part of the ModuleEngine(FX).

Standard situation for engines: physx update -> user alters joystick position -> vessel control state updated -> engines FixedUpdate() (thrust applied) -> gimbal FixedUpdate() (here thrust is rotated, but it's too late, so it goes to the next frame) -> physx update
Compare it to control surfaces that do not suffer from this: physx update -> user alters joystick position -> vessel control state updated -> controlSurface FixedUpdate() that first reacts to control state and then applies aero forces -> physx update

Thanks to the advice of The One I circumvented this in previous versions of KSP by moving ModuleGimbal to the very beginning of part config node. This way gimbal's FixedUpdate was called before engine's. How exactly did that work is still unknown to me, but it worked.

Old code that did reordering: https://github.com/Boris-Barboris/AtmosphereAutopilot/blob/master/AtmosphereAutopilot/GimbalRearranger.cs#L52

Now it does not. Rearrangement of nodes does complete, but it is not reflected in the actual module instantiation order or module node order in save or craft files. I can only assume that the config I'm modifying is no longer the source of truth.

I am once again seeking public council. Remember that the end goal is to make ModuleGimbal FixedUpdate be called strictly before ModuleEngine. I would gladly throw config node manipulation out of the window if there is a more elegant way.

Edited by Boris-Barboris

Share this post


Link to post
Share on other sites

Ok, solved it. DLC added new LoadingSystem - Expansions.ExpansionsLoader.

That's why I had to properly inject my loaders right before PartLoader, and not in the second from the tail position in loader list.

Share this post


Link to post
Share on other sites
On 8/18/2018 at 11:47 PM, Boris-Barboris said:

Ok, solved it. DLC added new LoadingSystem - Expansions.ExpansionsLoader.

That's why I had to properly inject my loaders right before PartLoader, and not in the second from the tail position in loader list.

Could you please provide a link to the source code containing the fix?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now