Removed static variable of SavePath

This commit is contained in:
Aaron 2022-07-12 09:27:22 +02:00 committed by Axel1092
parent a8762db652
commit 79e54af4fa
2 changed files with 8 additions and 4 deletions

View File

@ -25,7 +25,6 @@
constexpr float ParticleDiameter = 0.04f;
constexpr float TerrainDepth = 0.40f;
static FString SavePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectSavedDir());
std::string FParticle::ToString() const{
return std::string(carla::rpc::FromFString(FString::Printf(TEXT("%.2lf %.2lf %.2lf %.2lf "),
@ -101,7 +100,7 @@ void FHeightMapData::Clear()
}
void FDenseTile::InitializeTile(float ParticleSize, float Depth,
FDVector TileOrigin, FDVector TileEnd, const FHeightMapData &HeightMap)
FDVector TileOrigin, FDVector TileEnd, const FString& SavePath, const FHeightMapData &HeightMap)
{
std::string FileName = std::string(TCHAR_TO_UTF8(*( SavePath + TileOrigin.ToString() + ".tile" ) ) );
@ -272,7 +271,7 @@ FDenseTile& FSparseHighDetailMap::InitializeRegion(uint64_t TileId)
Tile.InitializeTile(
ParticleDiameter, TerrainDepth,
TileCenter, TileCenter + FDVector(TileSize, TileSize, 0.f),
Heightmap);
SavePath, Heightmap);
return Tile;
}
@ -451,6 +450,7 @@ void UCustomTerrainPhysicsComponent::BeginPlay()
FString LevelName = GetWorld()->GetMapName();
LevelName.RemoveFromStart(GetWorld()->StreamingLevelsPrefix);
SavePath = FPaths::ConvertRelativePathToFull(FPaths::ProjectSavedDir()) + LevelName + "_Terrain/";
SparseMap.SavePath = SavePath;
// Creating the FileManager
IPlatformFile& FileManager = FPlatformFileManager::Get().GetPlatformFile();
#undef CreateDirectory
@ -497,6 +497,7 @@ void UCustomTerrainPhysicsComponent::TickComponent(float DeltaTime,
GetOwner()->SetActorLocation(LocationVector);
LastUpdatedPosition = GetOwner()->GetActorLocation();
SparseMap.Update( LastUpdatedPosition, Radius.X, Radius.Y );
for (ACarlaWheeledVehicle* Vehicle : Vehicles)

View File

@ -48,7 +48,7 @@ struct FHeightMapData
struct FDenseTile
{
void InitializeTile(float ParticleSize, float Depth,
FDVector TileOrigin, FDVector TileEnd, const FHeightMapData &HeightMap);
FDVector TileOrigin, FDVector TileEnd, const FString& SavePath, const FHeightMapData &HeightMap);
std::vector<FParticle*> GetParticlesInRadius(FDVector Position, float Radius);
// Format DenseTile to "PosX PosY PosZ\n Particles"
@ -96,6 +96,7 @@ public:
void Clear();
FString SavePath;
private:
std::unordered_map<uint64_t, FDenseTile> Map;
std::unordered_map<uint64_t, FDenseTile> TilesToWrite;
@ -159,6 +160,8 @@ public:
FString NeuralModelFile = "";
FVector LastUpdatedPosition;
FString SavePath;
private:
void ApplyForces();