Description:
Fix issue with simulation.
Previously, if there was more than one tick being advanced at once, it would
overshoot how many ticks it covered. So if it was covering 5 ticks and each
tick happens every 100 units, rather than recording that it had simulated
through t= 500, it would increase the cumulative time for each tick, recording
that it had simulated through t=2500.
Add error message, too.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -441,6 +441,11 | |||||
|
441 |
|
441 | ||
|
442 | int advancesToSimulate = (int)((this.Elapsed - this.lastAdvance) / millisecondsPerAdvance); |
|
442 | int advancesToSimulate = (int)((this.Elapsed - this.lastAdvance) / millisecondsPerAdvance); |
|
443 |
|
443 | ||
|
|
444 | if (this.lastAdvance > this.Elapsed) | ||
|
|
445 | { | ||
|
|
446 | Logging.Error(String.Format("Last Advance is ahead of Elapsed by {0} ms. This should basically never happen.", (this.lastAdvance - this.Elapsed))); | ||
|
|
447 | } | ||
|
|
448 | |||
|
444 | for (int i = 0; i < advancesToSimulate; i++) |
|
449 | for (int i = 0; i < advancesToSimulate; i++) |
|
445 | { |
|
450 | { |
|
446 | this.advanceSimulation(); |
|
451 | this.advanceSimulation(); |
@@ -452,8 +457,8 | |||||
|
452 | //it's t=125, we have 2.5 steps to simulate. However, we only want to simulate |
|
457 | //it's t=125, we have 2.5 steps to simulate. However, we only want to simulate |
|
453 | //whole steps for simplicity's sake, so that means we'll simulate 2. But that means we've only simulated |
|
458 | //whole steps for simplicity's sake, so that means we'll simulate 2. But that means we've only simulated |
|
454 | //through t=120, so that's what we want to track in lastAdvance. |
|
459 | //through t=120, so that's what we want to track in lastAdvance. |
|
|
460 | } | ||
|
455 | this.lastAdvance += advancesToSimulate * millisecondsPerAdvance; |
|
461 | this.lastAdvance += advancesToSimulate * millisecondsPerAdvance; |
|
456 | } |
|
||
|
457 | } |
|
462 | } |
|
458 | } |
|
463 | } |
|
459 | } |
|
464 | } |
You need to be logged in to leave comments.
Login now