7 #include "CoreMinimal.h" 9 #include "GameFramework/Actor.h" 11 #include "Engine/LevelStreamingDynamic.h" 15 #include "LargeMapManager.generated.h" 29 const FTransform& InTransform)
30 : CarlaActor(InCarlaActor),
31 WorldLocation(
FDVector(InTransform.GetTranslation())),
32 Rotation(InTransform.GetRotation()) {}
41 USTRUCT(BlueprintType)
46 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category =
"Carla Map Tile")
50 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Carla Map Tile")
54 UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category =
"Carla Map Tile")
55 ULevelStreamingDynamic* StreamingLevel =
nullptr;
57 bool TilesSpawned = false;
76 virtual void BeginPlay()
override;
78 void PreWorldOriginOffset(UWorld* InWorld, FIntVector InSrcOrigin, FIntVector InDstOrigin);
79 void PostWorldOriginOffset(UWorld* InWorld, FIntVector InSrcOrigin, FIntVector InDstOrigin);
81 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
82 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
86 void RegisterInitialObjects();
90 UFUNCTION(Category=
"Large Map Manager")
91 void OnActorDestroyed(
AActor* DestroyedActor);
94 void Tick(
float DeltaTime) override;
96 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
97 void GenerateMap(FString InAssetsPath);
99 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
100 void GenerateLargeMap();
102 void GenerateMap(TArray<TPair<FString, FIntVector>> MapPathsIds);
104 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large Map Manager")
105 void ClearWorldAndTiles();
107 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large Map Manager")
108 void GenerateMap_Editor()
110 if (!LargeMapTilePath.IsEmpty()) GenerateMap(LargeMapTilePath);
115 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
116 FIntVector GetNumTilesInXY()
const;
118 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
119 int GetNumTiles()
const 121 return MapTiles.Num();
124 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
125 bool IsLevelOfTileLoaded(FIntVector InTileID)
const;
129 return CurrentTilesLoaded.Contains(TileId);
134 return IsTileLoaded(GetTileID(Location));
139 return IsTileLoaded(GetTileID(Location));
142 FTransform GlobalToLocalTransform(
const FTransform& InTransform)
const;
143 FVector GlobalToLocalLocation(
const FVector& InLocation)
const;
145 FTransform LocalToGlobalTransform(
const FTransform& InTransform)
const;
146 FVector LocalToGlobalLocation(
const FVector& InLocation)
const;
148 UPROPERTY(EditAnywhere, Category =
"Large Map Manager")
149 FString LargeMapTilePath = "/Game/Carla/Maps/testmap";
150 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
151 FString LargeMapName = "testmap";
153 void SetTile0Offset(const FVector& Offset);
155 void SetTileSize(
float Size);
159 FVector GetTile0Offset();
161 void SetLayerStreamingDistance(
float Distance);
163 void SetActorStreamingDistance(
float Distance);
165 float GetLayerStreamingDistance() const;
167 float GetActorStreamingDistance() const;
169 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
170 FIntVector GetTileVectorID(FVector TileLocation) const;
172 FIntVector GetTileVectorID(
FDVector TileLocation) const;
178 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
179 FVector GetTileLocation(FIntVector TileVectorID) const;
183 FDVector GetTileLocationD(FIntVector TileVectorID) const;
186 TileID GetTileID(FVector TileLocation) const;
190 TileID GetTileID(FIntVector TileVectorID) const;
196 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
207 void RemoveLandscapeCollisionIfHaveTerraMechanics(ULevel* InLevel);
209 void UpdateTilesState();
211 void RemovePendingActorsToRemove();
216 void CheckActiveActors();
219 void ConvertActiveToDormantActors();
224 void CheckDormantActors();
227 void ConvertDormantToActiveActors();
229 void CheckIfRebaseIsNeeded();
231 void GetTilesToConsider(
232 const
AActor* ActorToConsider,
233 TSet<
TileID>& OutTilesToConsider);
235 void GetTilesThatNeedToChangeState(
236 const TSet<
TileID>& InTilesToConsider,
237 TSet<
TileID>& OutTilesToBeVisible,
238 TSet<
TileID>& OutTilesToHidde);
240 void UpdateTileState(
241 const TSet<
TileID>& InTilesToUpdate,
242 bool InShouldBlockOnLoad,
243 bool InShouldBeLoaded,
244 bool InShouldBeVisible);
246 void UpdateCurrentTilesLoaded(
247 const TSet<
TileID>& InTilesToBeVisible,
248 const TSet<
TileID>& InTilesToHidde);
250 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
256 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
259 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
274 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
275 TSet<uint64> CurrentTilesLoaded;
278 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
279 FIntVector CurrentOriginInt{ 0 };
283 UPROPERTY(EditAnywhere, Category =
"Large Map Manager")
284 FVector Tile0Offset = FVector(0,0,0);
286 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
287 float TickInterval = 0.0f;
289 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
290 float LayerStreamingDistance = 3.0f * 1000.0f * 100.0f;
292 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
293 float ActorStreamingDistance = 2.0f * 1000.0f * 100.0f;
295 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
296 float RebaseOriginDistance = 2.0f * 1000.0f * 100.0f;
298 float LayerStreamingDistanceSquared = LayerStreamingDistance * LayerStreamingDistance;
299 float ActorStreamingDistanceSquared = ActorStreamingDistance * ActorStreamingDistance;
300 float RebaseOriginDistanceSquared = RebaseOriginDistance * RebaseOriginDistance;
302 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
303 float TileSide = 2.0f * 1000.0f * 100.0f;
305 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
306 FVector LocalTileOffset = FVector(0,0,0);
308 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
309 bool ShouldTilesBlockOnLoad = false;
312 void RegisterTilesInWorldComposition();
316 FString TileIDToString(TileID TileID);
318 void DumpTilesTable() const;
322 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
323 FString AssetsPath = "";
325 FString BaseTileMapPath = "/Game/Carla/Maps/LargeMap/EmptyTileBase";
327 FColor PositonMsgColor = FColor::Purple;
329 const int32 TilesDistMsgIndex = 100;
330 const int32 MaxTilesDistMsgIndex = TilesDistMsgIndex + 10;
332 const int32 ClientLocMsgIndex = 200;
333 const int32 MaxClientLocMsgIndex = ClientLocMsgIndex + 10;
335 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
336 float MsgTime = 1.0f;
338 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
339 bool bPrintMapInfo = true;
341 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
342 bool bPrintErrors = false;
344 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
345 bool bHasTerramechanics = false;
const FCarlaActor * CarlaActor
bool IsTileLoaded(FVector Location) const
FActiveActor(const FCarlaActor *InCarlaActor, const FTransform &InTransform)
bool IsTileLoaded(FDVector Location) const
Base class for CARLA wheeled vehicles.
geom::Transform Transform
bool IsTileLoaded(TileID TileId) const
A view over an actor and its properties.