Jump to content

-3037904.50608881 Kelvin on the KSC runway. Whut?


Recommended Posts

So, while loading config nodes I explosively ran into this little problem:

One of the things I'm working on, the atmospheric temperature plays a vital role.  I discovered that while quicksaving and reloading that some things weren't quite... ummm... right.  During the first few cycles of FixedUpdate this.vessel.atmosphericTemperature =

-3037904.50608881

or 

-4566205.7098681

or

temperatures exceeding 9 million degrees Kelvin.

Since those temperatures and my math causes my parts to explode... at exactly what point can I expect to get ACCURATE information from this.vessel because it seems FixedUpdate is running well before that info is set?

And this is occuring after - if (!HighLogic.LoadedSceneIsFlight) return; - comes back true

 

I've looked at changing this to:

FlightGlobals.getExternalTemperature(FlightGlobals.ActiveVessel.altitude, FlightGlobals.currentMainBody)

But there's issues with that. That appears to return an 'ideal' temperature that doesn't change unless the altitude does.  The difference between that reading and the one from this.vessel... well, I'm seeing 15 degree variations.  

*edit

Also ran a check to make sure that this.vessel.loaded was true before allowing a FixedUpdate with the assumption that if it were loaded then it should have accurate info.  Not so.

Edited by Fengist
Link to comment
Share on other sites

On 8/27/2018 at 5:49 PM, DMagic said:

Have you tried waiting for FlightGlobals.ready? Or waiting for OnStart or OnStartFinished (if this is a Part Module).

I guess you could also just ignore/wait out impossible temperatures like that.

I have not tried that.  But, flight globals I do know are coming back with reasonably correct numbers.  Therefore they should be loaded.  I haven't tried checking for OnStartFinished, I will look into that.  For now, I did the laziest thing I could do.  I set up a delta time of 1 second in the fixedUpdate.  Prior to that 1 second, it uses temperatures from FlightGlobals.  After that, it switches to vessel.atmosphericTemperature. Although there is a difference between the two, it's not 9 MILLION degrees out of whack and blowing up my parts ;).

Thanks for the suggestions.

7 hours ago, DoctorDavinci said:

@Fengist if (FlightGlobals.ready) and if (!this.vessel.HoldPhysics) should help

I get the same issue when spawning kerbals into the flight scene and my location is outside of physics range or if I don't wait until the vessel is no longer HoldPhysics

I'll check those.  As I mentioned above, FlightGlobals is giving me somewhat correct answers.  I just blindly assumed that if FixedUpdate was running (which is supposed to be for physics) that all of the physics was ready.  Guess not.

Link to comment
Share on other sites

  • 1 month later...

A bit of a post necro, but : when loading a vessel, several physics related things are initialized in the first few fixedUpdates. For a lot of things, checking FlightsGlobals.ready is not enough.

The thermal handling of vessel is done by the FlightIntegrator class. It's a VesselModule and can be accessed trough the Vessel.vesselModules List. It can be fully initialized rather late after vessel loading. If you have any code that has to do with thermal properties, you need to check those two conditions first :

  • FlightIntegrator.isRunning is equal to true
  • FlightIntegrator.firstFrame is equal to false
Link to comment
Share on other sites

I've noticed temperature anomalies in the first few frames of a vessel's lifecycle, even if it's long after the flight scene has been initialized - for instance, when decoupling parts, a new vessel is created, and parts on that vessel report anomalous temperatures for a few frames.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...