FirstPersonKSP / RasterPropMonitor

Plugin for Kerbal Space Program
https://forum.kerbalspaceprogram.com/index.php?/topic/190737-18x-rasterpropmonitor-adopted/&tab=comments#comment-3723047
Other
24 stars 12 forks source link

Perf: Props in non-active internal models shouldn’t update #6

Open JonnyOThan opened 4 years ago

JonnyOThan commented 4 years ago

If you activate ProbeControlRoom and then leave it, all the MFDs and other props continue updating every frame (note that PCR’s internal model is not instantiated until you activate it).

This might mainly be a problem in my custom build of ProbeControlRoom, but I think you could force something similar to happen in the original by activating PCR in an empty ship and then having a kerbal board and use IVA mode.

Might be some strange interaction with the transparent pod tech, where you want to see props working from external view.

This also might be something that turns out to be specific to PCR, but should investigate whether internal props in other command pods are updating while IVA mode is active in a different pod.

MOARdV commented 4 years ago

JUtil.VesselIsInIVA(Vessel) is one of the methods used to determine whether the current camera is an IVA camera or not (search the code for "InIVA" to find where RPM cares about IVA mode ATM). There are a number of IVA components that shut off because of this, but, IIRC, monitors don't due to transparent pods. Even when disabled, the prop ,odule Update() and FixedUpdate() methods get called all the time (which is one of the main reasons I developed MAS), which means there's an inordinate amount of overhead doing no-op traversals.

JonnyOThan commented 4 years ago

By default, ProbeControlRoom cannot be used on a manned vessel - but I have a local build which changes that. So you press C once to go to IVA, then C again to go to PCR, then C to get back to flight mode. Both PCR and "regular" IVA use the Internal camera - but the PCR monitors are updating even when still in regular IVA.

This also might pop up if you have 100 command pods and enter IVA mode in one of them - do the other 99 spend time drawing stuff?

MOARdV commented 4 years ago

This also might pop up if you have 100 command pods and enter IVA mode in one of them - do the other 99 spend time drawing stuff?

I want to say that only the current IVA is supposed to update, but it's been a few years since I looked at the RPM code in much depth.

JonnyOThan commented 1 year ago

I can confirm that props in non-active IVAs are updating, via OnUpdate. Most of the RPM stuff will early-out if it's not the active part, but that can still be hundreds of props and that test isn't necessarily cheap.

Proposal: swap the list of props in the InternalModel with an empty one for parts that aren't the active one. Then none of the props will spend time updating. Swap the list back if the part becomes active.