62 File.seekg(0, std::ios::beg);
78 std::streampos Current =
File.tellg();
102 File.seekg(Current, std::ios::beg);
107 uint32_t ThisFollowId,
bool ReplaySensors)
109 std::stringstream
Info;
121 Info <<
"Replaying File: " << Filename2 << std::endl;
124 File.open(Filename2, std::ios::binary);
127 Info <<
"File " << Filename2 <<
" not found on server\n";
145 Info <<
"Replayer will start after map is loaded..." << std::endl;
163 if (TimeStart < 0.0f)
166 if (TimeStart < 0.0f)
177 std::setprecision(1) << std::fixed <<
TimeFactor <<
"x" << std::endl;
180 Info <<
"Ignoring Hero vehicle" << std::endl;
183 Info <<
"Ignoring Spectator camera" << std::endl;
192 Helper.RemoveStaticProps();
233 if (TimeStart < 0.0f)
236 if (TimeStart < 0.0f)
254 Helper.RemoveStaticProps();
267 bool bFrameFound =
false;
268 bool bExitAtNextFrame =
false;
269 bool bExitLoop =
false;
280 while (!
File.eof() && !bExitLoop)
452 ReadValue<uint16_t>(
File, Total);
453 for (i = 0; i < Total; ++i)
458 auto Result =
Helper.ProcessReplayerEventAdd(
467 switch (Result.first)
471 UE_LOG(LogCarla, Log, TEXT(
"actor could not be created"));
488 UE_LOG(LogCarla, Log, TEXT(
"ignoring actor from replayer (Hero or Spectator)"));
494 if (Result.first > 0 && Result.first < 3)
498 for (
const auto &Item :
EventAdd.Description.Attributes)
500 if (Item.Id ==
"role_name" && Item.Value ==
"hero")
517 ReadValue<uint16_t>(
File, Total);
518 for (i = 0; i < Total; ++i)
530 std::stringstream
Info;
533 ReadValue<uint16_t>(
File, Total);
534 for (i = 0; i < Total; ++i)
545 std::stringstream
Info;
548 ReadValue<uint16_t>(
File, Total);
549 for (i = 0; i < Total; ++i)
554 if (!
Helper.ProcessReplayerStateTrafficLight(StateTrafficLight))
558 TEXT(
"callback state traffic light %d called but didn't work"),
568 std::stringstream
Info;
571 ReadValue<uint16_t>(
File, Total);
572 for (i = 0; i < Total; ++i)
589 ReadValue<uint16_t>(
File, Total);
590 for (i = 0; i < Total; ++i)
607 std::stringstream
Info;
610 ReadValue<uint16_t>(
File, Total);
611 for (i = 0; i < Total; ++i)
618 Helper.ProcessReplayerAnimWalker(Walker);
627 std::stringstream
Info;
629 ReadValue<uint16_t>(
File, Total);
630 for (i = 0; i < Total; ++i)
636 Helper.ProcessReplayerAnimBiker(Biker);
647 ReadValue<uint16_t>(
File, Total);
648 for (uint16_t i = 0; i < Total; ++i)
655 Helper.ProcessReplayerLightVehicle(LightVehicle);
666 ReadValue<uint16_t>(
File, Total);
667 for (uint16_t i = 0; i < Total; ++i)
674 Helper.ProcessReplayerDoorVehicle(DoorVehicle);
685 ReadValue<uint16_t>(
File, Total);
686 for (uint16_t i = 0; i < Total; ++i)
689 Helper.ProcessReplayerLightScene(LightScene);
701 ReadValue<uint16_t>(
File, Total);
704 for (i = 0; i < Total; ++i)
715 UE_LOG(LogCarla, Log, TEXT(
"Actor not found when trying to move from replayer (id. %d)"), Pos.
DatabaseId);
716 CurrPos.push_back(std::move(Pos));
730 std::stringstream
Info;
733 ReadValue<uint16_t>(
File, Total);
734 for (i = 0; i < Total; ++i)
741 Helper.ProcessReplayerWalkerBones(Walker);
749 uint32_t NewFollowId = 0;
750 std::unordered_map<int, int> TempMap;
753 for (i = 0; i <
PrevPos.size(); ++i)
755 TempMap[
PrevPos[i].DatabaseId] = i;
764 NewFollowId = NewId->second;
776 auto Result = TempMap.find(Pos.DatabaseId);
777 if (Result != TempMap.end())
795 if (NewFollowId != 0)
797 if (NewFollowId == Pos.DatabaseId)
798 Helper.SetCameraPosition(NewFollowId, FVector(-1000, 0, 500), FQuat::MakeFromEuler({0, -25, 0}));
UE_LOG(LogCarla, Log, TEXT("UActorDispatcher::Destroying actor: '%s' %x"), *Id, Actor)
TSharedPtr< const FActorInfo > Info
std::string GetRecorderFilename(std::string Filename)
void ProcessEventsDel(void)
void ProcessDoorVehicle(void)
std::vector< CarlaRecorderPosition > PrevPos
void ProcessVisualTime(void)
void ProcessLightVehicle(void)
double GetTotalTime(void)
std::vector< CarlaRecorderPosition > CurrPos
void ProcessAnimVehicleWheels(void)
void InterpolatePosition(const CarlaRecorderPosition &Start, const CarlaRecorderPosition &End, double Per, double DeltaTime)
void ProcessAnimVehicle(void)
std::string ReplayFile(std::string Filename, double TimeStart=0.0f, double Duration=0.0f, uint32_t FollowId=0, bool ReplaySensors=false)
void ProcessWalkerBones(void)
void ProcessPositions(bool IsFirstTime=false)
void ProcessEventsParent(void)
void UpdatePositions(double Per, double DeltaTime)
void ProcessEventsAdd(void)
static PlayAfterLoadMap Autoplay
void ProcessAnimWalker(void)
void ProcessAnimBiker(void)
CarlaRecorderInfo RecInfo
CarlaReplayerHelper Helper
void ProcessLightScene(void)
void CheckPlayAfterMapLoaded(void)
std::unordered_map< uint32_t, bool > IsHeroMap
void ProcessToTime(double Time, bool IsFirstTime=false)
std::unordered_map< uint32_t, uint32_t > MappedId
void Stop(bool KeepActors=false)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &File)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::istream &InFile)
void Read(std::ifstream &InFile)
void Read(std::ifstream &InFile)