New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staging #43
Comments
+1 vote for this. |
Could this be addressed the same way that for example Kerbal Engineer handles deltaV calcs for various staging in construction? or the way Mechjeb handles it in flight? I think they break the parts into stage groups and then do a simulation from there to find the estimated delta V in each stage. This should be simpler? because you don't need to iterate through active engines/thrust levels/blah blah. |
@PBscoots I'm affraid it's not that simple. This might have worked when the drag of a craft was the sum of the drag of the parts, but this is not the case anymore. Nowadays, the drag of a part depends on the parts attached to it. For example, a tank has less drag if there is a nose cone attached to it. Now imagine that you have a Spacecraft like this: Capsule, decoupler, tank, engine. From retrograde, the capsule is shielded by the whole stack and has very low drag. After you decouple it, the capsule is free and experiences full drag. If you were to predict the trajectory before decoupling, KSP would report much, much lower drag. |
I think I understand. What about looking at the stage in atmo as a whole new vessel? That way you can run the new vessel through the aero model. |
The critical thing here is a "new vessel". I don't think that you can create invisible/ghost/phantom vessels whenever you please. AFAIK what is happening now is this:
I am not sure that you can a just create magic vessels that allow their drag to be calculated but not be present physically. @PBscoots , after digging in the code, I am not 100% sure anymore that what I just wrote is true. You might wanna check up on me here: |
Good find! Maybe the _vessel that is passed to those functions could be a new sudoVessel which is basically just the current vessel, with the partlist overwritten with our current vessel partlist minus the parts the would be ejected through decouples. And to find that new partlist maybe we can iterate through the parts the same way KER or MechJeb does it and break them into stage groups. Incidently I found out while digging through mechjebs code that it also has a trajectory calculation module. I dont use mechjeb really so I never even knew it was there! haha I might try it out tonight for kicks. |
That's my point though: I'm not confident that we can just take copies of vessel objects and manipulate partlists on these copies without affecting a) the original vessel, b) creating a "physical" vessel in the game world and c) null-reffing all over the place. A bug happened once in another mod, where the author thought that the part list that he received was a copy, where it turned out it was just a reference. Upon sorting, the vessel ended up completely garbled up. You're welcome to prove me wrong of course - but in order to do so, you'd have to actually try this out and verify that the original vessel is not being manipulated. |
Hmmm although one sticking point might be that the part list might not be settable. It seems it might only be a get |
I doubt that it's possible to partially load a craft file. Also the idea of having ghost craft files lying around seems rather yucky. But like I said, you are welcome to try. ps.: Since KSP 1.2, there is an official API documentation available here: |
Maybe create a protovessel, then check all the parts to see if they are less than the selected stage using |
Hi there, A quick recapitulation of my thoughts on this subject (which are really just thoughts, you are welcome to experiment different approaches if you want):
|
So I just checked out the FAR API, it seems all of the API calls have both ActiveVessel... and Vessel... calls. So an ActiveVesselDynPres is obviously the active vessel, but VesselDynPres can be passed a vessel structure. It also has a function for InstanceCalcVesselAeroForces, which I think is for estimating future possible aero forces based on passed vessel, alt and velocity parameters. You probably already use it though |
Sorry guys, I don't have the time to implement this. If I get a magical PR flying my way, I will integrate it - but this looks way too complicated for me. |
I'm reopening this issue as a placeholder, I have a feeling I could implement staging after I finish the Multithreading #123 since a lot of data is cached and the math for the aero calculations is being reverse engineered and added for thread safety. dnSpy has been very useful in this task. 😁 It should be possible to only simulate the needed parts of a stage, I will have to find out how the occlusion of the detached parts is performed, after that all should be peachy (famous last words lol). I plan on adding a list of the stages to the GUI where the user can enter their desired deployment altitudes. |
Find some way to specify which stage will enter atmosphere, and don't use the parts that will be discarded during predictions. Also need to check if FAR aerodynamics is more complicated when staging than just ignoring the discarded parts.
The text was updated successfully, but these errors were encountered: