Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- / Detach a child from the specified slot and unload it in LANDED mode; i.e., place it on the ground.
- // slotNumber = payload slot number
- // Returns: true on success, false if the child refused to be detached or if no child is in the specified slot
- bool XRPayloadBay::DetachChildLanded(const int slotNumber)
- {
- _ASSERTE(slotNumber > 0);
- bool retVal = false;
- // see if there is a child in the requested slot
- VESSEL *pChild = GetChild(slotNumber);
- if (pChild != nullptr)
- {
- // Must obtain "move-to" coordinates while the child is still attached! The subclass needs the child's attachment point
- // to compute the proper coordinates.
- VECTOR3 deployToCoords = GetLandedDeployToCoords(slotNumber); // get from the subclass; these are ship-local coordinates
- // Detach the child vessel.
- DetachChild(slotNumber, 0.0); // no delta-V
- // obtain the child's coordinates
- VESSELSTATUS2 childVS;
- VESSEL3_EXT::GetStatusSafe(*pChild, childVS, false);
- // move the child to the deployToCoordinates by converting them (as a delta) from parent-local to GLOBAL coordinates
- VECTOR3 globalChildDeltaCoords;
- GetParentVessel().GlobalRot(deployToCoords, globalChildDeltaCoords);
- // now take the parent's rpos, apply the delta, and store it in the child's VS
- VESSELSTATUS2 parentVS;
- VESSEL3_EXT::GetStatusSafe(GetParentVessel(), parentVS, false);
- childVS.rpos = (parentVS.rpos + globalChildDeltaCoords);
- // WARNING: do not force status=1 (landed) here! It will cause the "bounce bug" and crash Orbiter.
- childVS.status = 0; // set to FREEFLIGHT
- pChild->DefSetStateEx(&childVS); // update the vessel's state with the new location
- retVal = true;
- }
- return retVal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement