Only set timestep to 0 if we both have no events in the queue and we're sitting on the ground. Otherwise we end up with a timestep of .001 throughout the coast phase of the flight (as .001 is a hard "minimum step size")
This commit is contained in:
parent
948b6ebe9d
commit
39eb2bf5bf
@ -130,12 +130,16 @@ public class BasicEventSimulationEngine implements SimulationEngine {
|
|||||||
double oldAlt = currentStatus.getRocketPosition().z;
|
double oldAlt = currentStatus.getRocketPosition().z;
|
||||||
|
|
||||||
if (SimulationListenerHelper.firePreStep(currentStatus)) {
|
if (SimulationListenerHelper.firePreStep(currentStatus)) {
|
||||||
// Step at most to the next event. If there is no next event, don't step time
|
// Step at most to the next event
|
||||||
double maxStepTime = 0.0;
|
double maxStepTime = Double.MAX_VALUE;
|
||||||
FlightEvent nextEvent = currentStatus.getEventQueue().peek();
|
FlightEvent nextEvent = currentStatus.getEventQueue().peek();
|
||||||
|
|
||||||
if (nextEvent != null) {
|
if (nextEvent != null) {
|
||||||
maxStepTime = MathUtil.max(nextEvent.getTime() - currentStatus.getSimulationTime(), 0.001);
|
maxStepTime = MathUtil.max(nextEvent.getTime() - currentStatus.getSimulationTime(), 0.001);
|
||||||
|
} else if (currentStatus.isLanded()) {
|
||||||
|
maxStepTime = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.trace("Taking simulation step at t=" + currentStatus.getSimulationTime() + " altitude " + oldAlt);
|
log.trace("Taking simulation step at t=" + currentStatus.getSimulationTime() + " altitude " + oldAlt);
|
||||||
currentStepper.step(currentStatus, maxStepTime);
|
currentStepper.step(currentStatus, maxStepTime);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user