76 File.seekg(0, std::ios::beg);
92 std::streampos Current =
File.tellg();
116 File.seekg(Current, std::ios::beg);
121 std::string Filename,
124 uint32_t ThisFollowId,
125 const FTransform& Offset,
128 std::string MapOverride)
130 std::stringstream Info;
142 Info <<
"Replaying File: " << Filename2 << std::endl;
145 File.open(Filename2, std::ios::binary);
148 Info <<
"File " << Filename2 <<
" not found on server\n";
156 if (!MapOverride.empty())
164 Info <<
"Could not load mapfile " << TCHAR_TO_UTF8(*
RecInfo.
Mapfile) << std::endl;
168 Info <<
"Loading map " << TCHAR_TO_UTF8(*
RecInfo.
Mapfile) << std::endl;
169 Info <<
"Replayer will start after map is loaded..." << std::endl;
186 Info <<
"Total time recorded: " <<
TotalTime << std::endl;
189 if (TimeStart < 0.0f)
192 if (TimeStart < 0.0f)
202 Info <<
"Replaying from " << TimeStart <<
" s - " <<
TimeToStop <<
" s (" <<
TotalTime <<
" s) at " <<
203 std::setprecision(1) << std::fixed <<
TimeFactor <<
"x" << std::endl;
206 Info <<
"Ignoring Hero vehicle" << std::endl;
209 Info <<
"Ignoring Spectator camera" << std::endl;
261 if (TimeStart < 0.0f)
264 if (TimeStart < 0.0f)
297 bool bFrameFound =
false;
298 bool bExitAtNextFrame =
false;
299 bool bExitLoop =
false;
310 while (!
File.eof() && !bExitLoop)
489 for (i = 0; i < Total; ++i)
503 switch (Result.first)
507 UE_LOG(LogCarla, Log, TEXT(
"actor could not be created"));
525 UE_LOG(LogCarla, Log, TEXT(
"ignoring actor from replayer (Hero or Spectator)"));
531 if (Result.first > 0 && Result.first < 3)
535 for (
const auto &Item :
EventAdd.Description.Attributes)
537 if (Item.Id ==
"role_name" && Item.Value ==
"hero")
555 for (i = 0; i < Total; ++i)
568 std::stringstream Info;
572 for (i = 0; i < Total; ++i)
583 std::stringstream Info;
587 for (i = 0; i < Total; ++i)
596 TEXT(
"callback state traffic light %d called but didn't work"),
606 std::stringstream Info;
610 for (i = 0; i < Total; ++i)
633 for (i = 0; i < Total; ++i)
651 std::stringstream Info;
655 for (i = 0; i < Total; ++i)
671 std::stringstream Info;
674 for (i = 0; i < Total; ++i)
692 for (uint16_t i = 0; i < Total; ++i)
711 for (uint16_t i = 0; i < Total; ++i)
730 for (uint16_t i = 0; i < Total; ++i)
747 for (uint16_t i = 0; i < Total; ++i)
765 for (i = 0; i < Total; ++i)
776 UE_LOG(LogCarla, Log, TEXT(
"Actor not found when trying to move from replayer (id. %d)"), Pos.
DatabaseId);
777 CurrPos.push_back(std::move(Pos));
791 std::stringstream Info;
795 for (i = 0; i < Total; ++i)
810 uint32_t NewFollowId = 0;
811 std::unordered_map<int, int> TempMap;
814 for (i = 0; i <
PrevPos.size(); ++i)
816 TempMap[
PrevPos[i].DatabaseId] = i;
825 NewFollowId = NewId->second;
837 auto Result = TempMap.find(Pos.DatabaseId);
838 if (Result != TempMap.end())
857 if (NewFollowId != 0)
865 std::unordered_map<uint32_t, const CarlaRecorderAnimWheels *> PrevWheelsById;
868 PrevWheelsById[Wheels.DatabaseId] = &Wheels;
870 std::unordered_map<uint32_t, const CarlaRecorderPosition *> PrevPosById, CurrPosById;
873 PrevPosById[Pos.DatabaseId] = &Pos;
877 CurrPosById[Pos.DatabaseId] = &Pos;
887 auto Prev = PrevWheelsById.find(Wheels.DatabaseId);
888 if (Prev == PrevWheelsById.end())
897 auto Pos1 = PrevPosById.find(Wheels.DatabaseId);
898 auto Pos2 = CurrPosById.find(Wheels.DatabaseId);
899 if (Pos1 != PrevPosById.end() && Pos2 != CurrPosById.end())
901 const FVector Forward = FRotator::MakeFromEuler(Pos1->second->Rotation).Vector();
902 Travel = FVector::DotProduct(Pos2->second->Location - Pos1->second->Location, Forward);
std::string GetRecorderFilename(std::string Filename)
void ReadValue(std::istream &InFile, T &OutObj)
void ProcessReplayerWalkerBones(const CarlaRecorderWalkerBones &Walker)
bool ProcessReplayerFinish(bool bApplyAutopilot, bool bIgnoreHero, std::unordered_map< uint32_t, bool > &IsHero)
void ProcessReplayerAnimVehicleWheels(const CarlaRecorderAnimWheels &Wheels1, const CarlaRecorderAnimWheels &Wheels2, double Per, float Travel)
void ProcessReplayerLightScene(CarlaRecorderLightScene LightScene)
void ProcessReplayerDoorVehicle(CarlaRecorderDoorVehicle DoorVehicle)
void ProcessReplayerAnimWalker(CarlaRecorderAnimWalker Walker)
bool ProcessReplayerStateTrafficLight(CarlaRecorderStateTrafficLight State)
bool ProcessReplayerEventParent(uint32_t ChildId, uint32_t ParentId)
void ProcessReplayerAnimVehicle(CarlaRecorderAnimVehicle Vehicle)
bool ProcessReplayerEventDel(uint32_t DatabaseId)
void ProcessReplayerLightVehicle(CarlaRecorderLightVehicle LightVehicle)
std::pair< int, uint32_t > ProcessReplayerEventAdd(FVector Location, FVector Rotation, CarlaRecorderActorDescription Description, uint32_t DesiredId, bool bIgnoreHero, bool bIgnoreSpectator, bool ReplaySensors)
void ProcessReplayerAnimBiker(CarlaRecorderAnimBiker Biker)
bool ProcessReplayerPosition(CarlaRecorderPosition Pos1, CarlaRecorderPosition Pos2, double Per, double DeltaTime)
void ProcessReplayerWeather(const CarlaRecorderWeather &Weather)
bool SetCameraPosition(uint32_t Id, FVector Offset, FQuat Rotation)
void ProcessEventsDel(void)
void ProcessDoorVehicle(void)
std::vector< CarlaRecorderPosition > PrevPos
void ProcessVisualTime(void)
void ProcessLightVehicle(void)
double GetTotalTime(void)
std::vector< CarlaRecorderPosition > CurrPos
std::vector< CarlaRecorderAnimWheels > PrevWheels
void InterpolatePosition(const CarlaRecorderPosition &Start, const CarlaRecorderPosition &End, double Per, double DeltaTime)
void ProcessAnimVehicle(void)
void ProcessWalkerBones(void)
void ProcessPositions(bool IsFirstTime=false)
void ProcessEventsParent(void)
std::string ReplayFile(std::string Filename, double TimeStart=0.0f, double Duration=0.0f, uint32_t FollowId=0, const FTransform &Offset=FTransform(), bool ReplaySensors=false, bool ReplayWeather=false, std::string MapOverride="")
void ProcessWeather(void)
void UpdatePositions(double Per, double DeltaTime)
void ProcessEventsAdd(void)
void DestroySpawnedActors(void)
Destroys the actors this replayer spawned that are still alive, even when the replay already ended by...
static PlayAfterLoadMap Autoplay
void UpdateWheels(double Per)
void ProcessAnimWalker(void)
void ProcessAnimBiker(void)
std::vector< CarlaRecorderAnimWheels > CurrWheels
CarlaRecorderInfo RecInfo
CarlaReplayerHelper Helper
void ProcessLightScene(void)
std::unordered_set< uint32_t > SpawnedIds
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 ProcessAnimVehicleWheels(bool IsFirstTime=false)
const FString & GetMapName() const
void SetVisualGameTime(double Time)
bool LoadNewEpisode(const FString &MapString, bool ResetSettings=true)
Load a new map and start a new episode.
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)