Skip to content

Commit

Permalink
fixed files form Math #7
Browse files Browse the repository at this point in the history
  • Loading branch information
tdurieux committed Mar 7, 2017
1 parent 9297f3a commit b1a9eff
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,10 @@ public int compare(EventState es0, EventState es1) {
final double[] eventY = interpolator.getInterpolatedState().clone();

// advance all event states to current time
currentEvent.stepAccepted(eventT, eventY);
isLastStep = currentEvent.stop();
for (final EventState state : eventsStates) {
state.stepAccepted(eventT, eventY);
isLastStep = isLastStep || state.stop();
}

// handle the first part of the step, up to the event
for (final StepHandler handler : stepHandlers) {
Expand All @@ -354,22 +356,19 @@ public int compare(EventState es0, EventState es1) {
if (isLastStep) {
// the event asked to stop integration
System.arraycopy(eventY, 0, y, 0, y.length);
for (final EventState remaining : occuringEvents) {
remaining.stepAccepted(eventT, eventY);
}
return eventT;
}

boolean needReset = currentEvent.reset(eventT, eventY);
boolean needReset = false;
for (final EventState state : eventsStates) {
needReset = needReset || state.reset(eventT, eventY);
}
if (needReset) {
// some event handler has triggered changes that
// invalidate the derivatives, we need to recompute them
System.arraycopy(eventY, 0, y, 0, y.length);
computeDerivatives(eventT, y, yDot);
resetOccurred = true;
for (final EventState remaining : occuringEvents) {
remaining.stepAccepted(eventT, eventY);
}
return eventT;
}

Expand Down

0 comments on commit b1a9eff

Please sign in to comment.