Cost calculation run even during flight
siimav opened this issue ยท 1 comments
This can cause a significant performance impact when the user has tons of mods. Calls to Part.GetModuleCosts means that KSP iterates over all the PartModules that the part has to find the ones that implement IPartCostModifier. To make matters worse, some mods can have quite substantial functionality inside the cost modifer code.
I would suggest not querying the part costs inside the simulations because that info is not relevant inside the flight scene anyway.
Here's the stack where KER queries the part cost:
at Part.GetModuleCosts(Single defaultCost, ModifierStagingSituation sit)
at KerbalEngineer.Extensions.PartExtensions.GetCostDry(.Part part)
at KerbalEngineer.VesselSimulator.PartSim.New(.Part p, Int32 id, Double atmosphere, KerbalEngineer.LogMsg log)
at KerbalEngineer.VesselSimulator.Simulation.PrepareSimulation(KerbalEngineer.LogMsg _log, System.Collections.Generic.List`1 parts, Double theGravity, Double theAtmosphere, Double theMach, Boolean dumpTree, Boolean vectoredThrust, Boolean fullThrust)
at KerbalEngineer.VesselSimulator.SimManager.StartSimulation()
at KerbalEngineer.VesselSimulator.SimManager.TryStartSimulation()
at KerbalEngineer.Editor.BuildAdvanced.Update()