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 AdjustSignsHeightToGround();
90 void RegisterInitialObjects();
94 UFUNCTION(Category=
"Large Map Manager")
95 void OnActorDestroyed(
AActor* DestroyedActor);
98 void Tick(
float DeltaTime) override;
100 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
101 void GenerateMap(FString InAssetsPath);
103 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
104 void GenerateLargeMap();
106 void GenerateMap(TArray<TPair<FString, FIntVector>> MapPathsIds);
108 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large Map Manager")
109 void ClearWorldAndTiles();
111 UFUNCTION(BlueprintCallable, CallInEditor, Category = "Large Map Manager")
112 void GenerateMap_Editor()
114 if (!LargeMapTilePath.IsEmpty()) GenerateMap(LargeMapTilePath);
117 void AddActorToUnloadedList(
const FCarlaActor& CarlaActor,
const FTransform& Transform);
119 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
120 FIntVector GetNumTilesInXY() const;
122 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
123 int GetNumTiles()
const
125 return MapTiles.Num();
128 UFUNCTION(BlueprintCallable, Category =
"Large Map Manager")
129 bool IsLevelOfTileLoaded(FIntVector InTileID) const;
133 return CurrentTilesLoaded.Contains(TileId);
138 return IsTileLoaded(GetTileID(Location));
143 return IsTileLoaded(GetTileID(Location));
146 FTransform GlobalToLocalTransform(
const FTransform& InTransform)
const;
147 FVector GlobalToLocalLocation(
const FVector& InLocation)
const;
149 FTransform LocalToGlobalTransform(
const FTransform& InTransform)
const;
150 FVector LocalToGlobalLocation(
const FVector& InLocation)
const;
152 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Large Map Manager")
153 FString LargeMapTilePath = "/Game/Carla/Maps/testmap";
154 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
155 FString LargeMapName = "testmap";
157 void SetTile0Offset(const FVector& Offset);
159 void SetTileSize(
float Size);
163 FVector GetTile0Offset();
165 void SetLayerStreamingDistance(
float Distance);
167 void SetActorStreamingDistance(
float Distance);
169 float GetLayerStreamingDistance() const;
171 float GetActorStreamingDistance() const;
173 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
174 FIntVector GetTileVectorID(FVector TileLocation) const;
176 FIntVector GetTileVectorID(
FDVector TileLocation) const;
182 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
183 FVector GetTileLocation(FIntVector TileVectorID) const;
187 FDVector GetTileLocationD(FIntVector TileVectorID) const;
190 TileID GetTileID(FVector TileLocation) const;
194 TileID GetTileID(FIntVector TileVectorID) const;
200 UFUNCTION(BlueprintCallable, Category = "Large Map Manager")
203 FCarlaMapTile* GetCarlaMapTilePointer(FIntVector TileVectorID);
213 bool SpectatorAsEgo = false;
214 void ConsiderSpectatorAsEgo(
bool _SpectatorAsEgo);
218 void RemoveLandscapeCollisionIfHaveTerraMechanics(ULevel* InLevel);
220 void UpdateTilesState();
222 void RemovePendingActorsToRemove();
227 void CheckActiveActors();
230 void ConvertActiveToDormantActors();
235 void CheckDormantActors();
238 void ConvertDormantToActiveActors();
240 void CheckIfRebaseIsNeeded();
242 void GetTilesToConsider(
243 const
AActor* ActorToConsider,
244 TSet<
TileID>& OutTilesToConsider);
246 void GetTilesThatNeedToChangeState(
247 const TSet<
TileID>& InTilesToConsider,
248 TSet<
TileID>& OutTilesToBeVisible,
249 TSet<
TileID>& OutTilesToHidde);
251 void UpdateTileState(
252 const TSet<
TileID>& InTilesToUpdate,
253 bool InShouldBlockOnLoad,
254 bool InShouldBeLoaded,
255 bool InShouldBeVisible);
257 void UpdateCurrentTilesLoaded(
258 const TSet<
TileID>& InTilesToBeVisible,
259 const TSet<
TileID>& InTilesToHidde);
261 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
267 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
270 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
285 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
286 TSet<uint64> CurrentTilesLoaded;
289 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
290 FIntVector CurrentOriginInt{ 0 };
294 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Large Map Manager")
295 FVector Tile0Offset = FVector(0,0,0);
297 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
298 float TickInterval = 0.0f;
300 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
301 float LayerStreamingDistance = 3.0f * 1000.0f * 100.0f;
303 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
304 float ActorStreamingDistance = 2.0f * 1000.0f * 100.0f;
306 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
307 float RebaseOriginDistance = 2.0f * 1000.0f * 100.0f;
309 float LayerStreamingDistanceSquared = LayerStreamingDistance * LayerStreamingDistance;
310 float ActorStreamingDistanceSquared = ActorStreamingDistance * ActorStreamingDistance;
311 float RebaseOriginDistanceSquared = RebaseOriginDistance * RebaseOriginDistance;
313 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
314 float TileSide = 2.0f * 1000.0f * 100.0f;
316 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
317 FVector LocalTileOffset = FVector(0,0,0);
319 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
320 bool ShouldTilesBlockOnLoad = false;
323 void RegisterTilesInWorldComposition();
329 void DumpTilesTable() const;
333 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Large Map Manager")
334 FString AssetsPath = "";
336 FString BaseTileMapPath = "/Game/Carla/Maps/LargeMap/EmptyTileBase";
338 FColor PositonMsgColor = FColor::Purple;
340 const int32 TilesDistMsgIndex = 100;
341 const int32 MaxTilesDistMsgIndex = TilesDistMsgIndex + 10;
343 const int32 ClientLocMsgIndex = 200;
344 const int32 MaxClientLocMsgIndex = ClientLocMsgIndex + 10;
346 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
347 float MsgTime = 1.0f;
349 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
350 bool bPrintMapInfo = true;
352 UPROPERTY(EditAnywhere, Category = "Large Map Manager")
353 bool bPrintErrors = false;
355 UPROPERTY(VisibleAnywhere, Category = "Large Map Manager")
356 bool bHasTerramechanics = false;