Pass acceleration data to post listeners
Also, existing code wouldn't call calculation post-listeners if pre-listeners had been called. Fixes that.
This commit is contained in:
parent
7a2ede6e24
commit
7bafe94f23
@ -283,11 +283,17 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
|
|||||||
throws SimulationException {
|
throws SimulationException {
|
||||||
RK4Parameters params = new RK4Parameters();
|
RK4Parameters params = new RK4Parameters();
|
||||||
|
|
||||||
// if (dataStore == null) {
|
// Call pre-listeners
|
||||||
// dataStore = new DataStore();
|
store.accelerationData = SimulationListenerHelper.firePreAccelerationCalculation(status);
|
||||||
// }
|
|
||||||
|
// Calculate acceleration (if not overridden by pre-listeners)
|
||||||
|
if (store.accelerationData == null) {
|
||||||
|
store.accelerationData = calculateAcceleration(status, dataStore);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call post-listeners
|
||||||
|
store.accelerationData = SimulationListenerHelper.firePostAccelerationCalculation(status, store.accelerationData);
|
||||||
|
|
||||||
calculateAcceleration(status, dataStore);
|
|
||||||
params.a = dataStore.linearAcceleration;
|
params.a = dataStore.linearAcceleration;
|
||||||
params.ra = dataStore.angularAcceleration;
|
params.ra = dataStore.angularAcceleration;
|
||||||
params.v = status.getRocketVelocity();
|
params.v = status.getRocketVelocity();
|
||||||
@ -312,13 +318,7 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
|
|||||||
* @param status the status of the rocket.
|
* @param status the status of the rocket.
|
||||||
* @throws SimulationException
|
* @throws SimulationException
|
||||||
*/
|
*/
|
||||||
private void calculateAcceleration(RK4SimulationStatus status, DataStore store) throws SimulationException {
|
private AccelerationData calculateAcceleration(RK4SimulationStatus status, DataStore store) throws SimulationException {
|
||||||
|
|
||||||
// Call pre-listeners
|
|
||||||
store.accelerationData = SimulationListenerHelper.firePreAccelerationCalculation(status);
|
|
||||||
if (store.accelerationData != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute the forces affecting the rocket
|
// Compute the forces affecting the rocket
|
||||||
calculateForces(status, store);
|
calculateForces(status, store);
|
||||||
@ -404,8 +404,7 @@ public class RK4SimulationStepper extends AbstractSimulationStepper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call post-listeners
|
return new AccelerationData(null, null, store.linearAcceleration, store.angularAcceleration, status.getRocketOrientationQuaternion());
|
||||||
store.accelerationData = SimulationListenerHelper.firePostAccelerationCalculation(status, store.accelerationData);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user