Jump to content

[1.5] VesselDeltaV Class (as there is an "Instance" for the VesselConstruct)


Recommended Posts

I assume you mean the ShipConstruct in the Editor?

It's accessible through:

EditorLogic.fetch.ship.vesselDeltaV

If you are working on making the DeltaV visible in the editor - I am also working on this and have a working prototype which is almost ready for release.

Edited by severedsolo
Link to comment
Share on other sites

21 minutes ago, severedsolo said:

 

If you are working on making the DeltaV visible in the editor - I am also working on this and have a working prototype which is almost ready for release.

Care to share the code at some point? My idea is to not only show it in the Editor, but also in the ship Resource Panel. Like a consumable resource.

My original question was more about the API of that class, though. I can see it in autocomplete and it's mentioned in the API docs.

Edited by Thygrrr
Link to comment
Share on other sites

3 hours ago, Benjamin Kerman said:

@severedsolo I think what he was asking (and I'm wondering too) was how you found the members of the VesselDeltaV class. On the official API there's no link to another page with the info.

Oh I just used Object Browser in my IDE (VS 2017 in this case):

There's nothing in there that isn't really obvious what it does. - agree though does seem odd that it's not at least got something in the Docs even if its not documented.

bMv3wjt.png

Edited by severedsolo
Link to comment
Share on other sites

The Vessel class also has a VesselDeltaV instance attached to it in flight, but it seems to be very fussy during launch.  Reading out its totalDeltaV values (actual, ASL, and vac), and comparing results to MechJeb's total DV count, the launch-pad actual dV was fairly close to what MechJeb decided (1% difference).  However, as the vessel climbed through the atmosphere, the actual dV reported by VDV did not seem to account for ISP correctly - the reported actual dV was still about 40 m/s different than the sea-level dV, while MJ reported a number very close to the VDV vac dV.  Once the vessel was in orbit, the actual dV simply reported ASL dV (not vac dV) for quite a while before it suddenly switched to reporting vac dV.

There were also quite a few times when it reported dV of 0 for all cases without clearing the isReady flag.  It might be that I need to kick the SetCalcsDirty() method in VDV fairly regularly - I never called that method, since I didn't know if Squad was already doing that somewhere.  I'm going to go back and see if kicking it every now and then makes a difference.

Link to comment
Share on other sites

5 hours ago, MOARdV said:

It might be that I need to kick the SetCalcsDirty() method in VDV fairly regularly - I never called that method, since I didn't know if Squad was already doing that somewhere.  I'm going to go back and see if kicking it every now and then makes a difference.

From what I can tell it updates the values for all stages in a coroutine about every 4 seconds, and I think the active stage every 0.2 seconds (and tossing out a big garbage dump for each stage :mad:).

There are multiple dv related items in the settings file (look under DELTAV*), I'm not sure if they are available to change in-game.

All of this seems fairly pitiful given that both MJ and KER can do this without bogging down the main thread or generating garbage (I assume, for KER), and while keeping the values more up-to-date. I can't imagine either dev/maintainer switching to the stock method, which means most people will experience the stock dV calculations as nothing but unneeded overhead. Has anyone figured out if they can be turned off easily (turning off the burn time setting doesn't change anything about the dV calculations)?

Edited by DMagic
Link to comment
Share on other sites

7 minutes ago, DMagic said:

Has anyone figured out if they can be turned off easily (turning off the burn time setting doesn't change anything about the dV calculations)?

Not really easy but it seems to run on a FixedUpdate so you "just" have to disable the object. 

Link to comment
Share on other sites

So now we just need to feed the disabled VesselDeltaV object the correct values from a better calculator. Then the stock burn time indicator (which is very nice) could still work as indented. 

Edited by DMagic
Link to comment
Share on other sites

2 hours ago, DMagic said:

I can't imagine either dev/maintainer switching to the stock method

Yeah, that's what I was hoping for.  Well, not switching to the stock method, but having a fallback for when neither KER nor MJ are installed, since I don't want to have to duplicate the total-vessel dV calculations myself when that wheel's been invented a couple of times over in other mods.

Even calling SetCalcsDirty() every 16 FixedUpdates didn't help - although it did cause the 0 total dV to be reported much more frequently.  Apparently the 'isReady' flag isn't getting updated correctly.  Once you're a few kilometers up, the total dV doesn't track actual ISP changes.  Nice idea, and probably good enough for static cases (pre-launch, using atmo dV, and in orbit, using vacuum dV), but not up to the task of in-atmosphere live updates.

Link to comment
Share on other sites

Just a couple of points:
The VesselDeltaV class is not published in the API docs for KSP 1.5.0 on purpose. It is expected these classes will have changes in the future.
The DV calculations and classes are currently only optimized to support the Burn Indicator feature that is part of KSP 1.5.0.
Whilst they are in other scenes - they are not optimized nor would we recommend you create mods that use them in KSP 1.5.0.
Calling SetCalcsDirty() will create more garbage and degrade performance of the game.
A good point was raised about being able to disable VesselDeltaV processing and allow mods to inject their own values into the class - so it will be taken under consideration.

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...