Project

General

Profile

Bug #3364

Inconsisten values in OnLoad due to it called at different point in time when reverting to launch cf. when first launching from VAB/SPH/KSC

Added by Biotronic about 10 years ago. Updated over 8 years ago.

Status:
Closed
Severity:
Low
Assignee:
-
Category:
Plugins/Add-Ons
Target version:
-
Start date:
10/13/2014
% Done:

100%

Version:
Platform:
Win32
Expansion:
Language:
English (US)
Mod Related:
No
Votes:
Arrow u r green
Arrow d r red

Description

Background: I am the developer of TweakScale - Rescale Everything![0]. Apparently my mod triggers (or contains, depending on your view) a bug when changing camera modes1 [2].

The specific bug manifests as the camera zooming out to ridiculous distances when changing camera modes.
I was able to locate the reason for my problem, in OnLoad.

When first launching from VAB, I get this stack trace from my mod's OnLoad function (case A):

TweakScale.TweakScale:OnLoad(ConfigNode)
PartModule:Load(ConfigNode)
Part:LoadModule(ConfigNode, Int32&)
ShipConstruct:LoadShip(ConfigNode)
ShipConstruction:LoadShip(String)
FlightDriver:Start()

When I later revert to launch, OnLoad is called again, with a different stack trace (case B):

TweakScale.TweakScale:OnLoad(ConfigNode)
PartModule:Load(ConfigNode)
Part:LoadModule(ConfigNode, Int32&)
ProtoPartModuleSnapshot:Load(Part, Int32&)
ProtoPartSnapshot:Load(Vessel, Boolean)
ProtoVessel:LoadObjects()
Vessel:Load()
Vessel:MakeActive()
FlightGlobals:setActiveVessel(Vessel, Boolean)
FlightGlobals:SetActiveVessel(Vessel)
FlightDriver:Start()

As it turns out, part.transform.GetChild(0).localScale has not yet been set when OnLoad is called after reverting to launch.
That is, for the Mk1 Cockpit, part.transform.GetChild(0).localScale is (1.3, 1.3, 1.3) in case A. In case B, it is (1.0, 1.0, 1.0). If I check localScale again in the first call to Update, it is changed to (1.3, 1.3, 1.3).

If there is anything more I can do to help, please do tell.

[0]: http://forum.kerbalspaceprogram.com/threads/80234
[1]: http://forum.kerbalspaceprogram.com/threads/94844
[2]: https://youtu.be/Y0iWYDtjqTM

History

#1 Updated by Brusura about 10 years ago

  • Status changed from New to Confirmed
  • % Done changed from 0 to 10

#2 Updated by Squelch over 9 years ago

  • Platform Win32 added
  • Platform deleted (Windows)

#3 Updated by TriggerAu over 8 years ago

  • Status changed from Confirmed to Needs Clarification
  • % Done changed from 10 to 0

#4 Updated by pellinor over 8 years ago

This problem was traced back to a wrong usage of the API, see #9444, and can be closed.

The report assumes that part.transform.GetChild(0) always leads to the same object (the "model" transform), which is not true. If the transform is accessed by its name, both part scaling and the camera work fine.

#5 Updated by TriggerAu over 8 years ago

  • Status changed from Needs Clarification to Closed
  • % Done changed from 0 to 100

Closing this report out for now. If you find it is still occuring in the latest version of KSP please open a new report (and this one can be linked to it.) For best results, the wiki contains really useful info for when creating a report http://bugs.kerbalspaceprogram.com/projects/ksp/wiki.

You can also ask questions about the bug cleanup in the forum here: http://forum.kerbalspaceprogram.com/index.php?/topic/143980-time-to-clean-up-the-bug-tracker/ and tag @TriggerAu to get my attention

Also available in: Atom PDF