Bugfixes about recorder:

1) Fixing camera following when a car is loaded by the recorder.
2) Fixing positions at start of replayer (actors were sliding from its current position).
This commit is contained in:
bernatx 2019-04-15 12:08:12 +02:00 committed by nsubiron
parent 2c8f55ad36
commit a0c94e0974
2 changed files with 16 additions and 10 deletions

View File

@ -22,7 +22,7 @@ void CarlaReplayer::Stop(bool bKeepActors)
// destroy actors if event was recorded?
if (!bKeepActors)
{
ProcessToTime(TotalTime);
ProcessToTime(TotalTime, false);
}
// callback
@ -146,7 +146,7 @@ std::string CarlaReplayer::ReplayFile(std::string Filename, double TimeStart, do
Autoplay.Mapfile = RecInfo.Mapfile;
Autoplay.TimeStart = TimeStart;
Autoplay.Duration = Duration;
Autoplay.FollowId = FollowId;
Autoplay.FollowId = ThisFollowId;
Autoplay.TimeFactor = TimeFactor;
}
@ -178,7 +178,7 @@ std::string CarlaReplayer::ReplayFile(std::string Filename, double TimeStart, do
if (!Autoplay.Enabled)
{
// process all events until the time
ProcessToTime(TimeStart);
ProcessToTime(TimeStart, true);
// mark as enabled
Enabled = true;
}
@ -237,13 +237,13 @@ void CarlaReplayer::CheckPlayAfterMapLoaded(void)
TimeFactor = Autoplay.TimeFactor;
// process all events until the time
ProcessToTime(TimeStart);
ProcessToTime(TimeStart, true);
// mark as enabled
Enabled = true;
}
void CarlaReplayer::ProcessToTime(double Time)
void CarlaReplayer::ProcessToTime(double Time, bool IsFirstTime)
{
double Per = 0.0f;
double NewTime = CurrentTime + Time;
@ -305,7 +305,7 @@ void CarlaReplayer::ProcessToTime(double Time)
// positions
case static_cast<char>(CarlaRecorderPacketId::Position):
if (bFrameFound)
ProcessPositions();
ProcessPositions(IsFirstTime);
else
SkipPacket();
break;
@ -485,7 +485,7 @@ void CarlaReplayer::ProcessStates(void)
}
}
void CarlaReplayer::ProcessPositions(void)
void CarlaReplayer::ProcessPositions(bool IsFirstTime)
{
uint16_t i, Total;
@ -510,6 +510,12 @@ void CarlaReplayer::ProcessPositions(void)
UE_LOG(LogCarla, Log, TEXT("Actor not found when trying to move from replayer (id. %d)"), Pos.DatabaseId);
CurrPos.push_back(std::move(Pos));
}
// check to copy positions the first time
if (IsFirstTime)
{
PrevPos.clear();
}
}
void CarlaReplayer::UpdatePositions(double Per)
@ -582,7 +588,7 @@ void CarlaReplayer::Tick(float Delta)
// check if there are events to process
if (Enabled)
{
ProcessToTime(Delta * TimeFactor);
ProcessToTime(Delta * TimeFactor, false);
}
// UE_LOG(LogCarla, Log, TEXT("Replayer tick"));

View File

@ -119,13 +119,13 @@ private:
void Rewind(void);
// processing packets
void ProcessToTime(double Time);
void ProcessToTime(double Time, bool IsFirstTime = false);
void ProcessEventsAdd(void);
void ProcessEventsDel(void);
void ProcessEventsParent(void);
void ProcessPositions(void);
void ProcessPositions(bool IsFirstTime = false);
void ProcessStates(void);