Fixes Issue #718

Reset rocket's relative position when its absolute position is reset.
Make sure rocket has lifted off before setting launch rod as cleared.
This commit is contained in:
JoePfeiffer 2020-07-27 11:59:25 -06:00
parent 9a0ef5f8ed
commit 16d7ce7f1f

View File

@ -162,6 +162,7 @@ public class BasicEventSimulationEngine implements SimulationEngine {
// Avoid sinking into ground before liftoff
if (relativePosition.z < 0) {
currentStatus.setRocketPosition(origin);
relativePosition = Coordinate.ZERO;
currentStatus.setRocketVelocity(originVelocity);
}
// Detect lift-off
@ -181,7 +182,8 @@ public class BasicEventSimulationEngine implements SimulationEngine {
}
// Check for launch guide clearance
if (!currentStatus.isLaunchRodCleared() &&
if (currentStatus.isLiftoff() &&
!currentStatus.isLaunchRodCleared() &&
relativePosition.length() > currentStatus.getSimulationConditions().getLaunchRodLength()) {
addEvent(new FlightEvent(FlightEvent.Type.LAUNCHROD, currentStatus.getSimulationTime(), null));
}