Skip to content

Commit

Permalink
Merge pull request #4385 from zimmy87/fix-4350
Browse files Browse the repository at this point in the history
fix scaling of pause period in car mode
  • Loading branch information
Jonathan authored Mar 31, 2022
2 parents efa1873 + 8a78b5c commit 9208ce4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions AirLib/include/common/ClockBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ namespace airlib
return elapsed;
}

virtual TTimePoint stepBy(TTimeDelta amount)
{
unused(amount);
return step();
}

virtual TTimePoint step()
{
//by default step doesn't do anything
Expand Down
2 changes: 1 addition & 1 deletion AirLib/include/common/SteppableClock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace airlib

virtual ~SteppableClock() {}

TTimePoint stepBy(TTimeDelta amount)
virtual TTimePoint stepBy(TTimeDelta amount) override
{
current_ = addTo(current_, amount);
return current_;
Expand Down
5 changes: 4 additions & 1 deletion Unreal/Plugins/AirSim/Source/Vehicles/Car/SimModeCar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void ASimModeCar::initializePauseState()
void ASimModeCar::continueForTime(double seconds)
{
pause_period_start_ = ClockFactory::get()->nowNanos();
pause_period_ = seconds;
pause_period_ = seconds * current_clockspeed_;
pause(false);
}

Expand All @@ -54,6 +54,9 @@ void ASimModeCar::Tick(float DeltaSeconds)
{
Super::Tick(DeltaSeconds);

if (!isPaused())
ClockFactory::get()->stepBy(DeltaSeconds);

if (pause_period_start_ > 0) {
if (ClockFactory::get()->elapsedSince(pause_period_start_) >= pause_period_) {
if (!isPaused())
Expand Down

0 comments on commit 9208ce4

Please sign in to comment.