39 AInstancedFoliageActor* InstancedFoliageActor {
nullptr};
40 AProceduralFoliageVolume* ProceduralFoliageVolume {
nullptr};
41 TArray<std::shared_ptr<FTileMeshComponent>> TileMeshesCache {};
42 TArray<UMaterialInstanceDynamic*> MaterialInstanceDynamicCache {};
44 bool ContainsMesh(
const UInstancedStaticMeshComponent*)
const;
45 void UpdateTileMeshComponent(UInstancedStaticMeshComponent* NewInstancedStaticMeshComponent);
46 void UpdateMaterialCache(
const FLinearColor& Value,
bool DebugMaterials);
103 UFUNCTION(BlueprintCallable)
104 void UpdatePoolBasePosition();
107 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
108 bool DebugMaterials {
false};
110 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
111 float HideMaterialDistance {500.0f};
113 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
114 float ActiveActorDistance {500.0f};
117 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
118 bool SpawnBushes {
true};
120 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
121 bool SpawnTrees {
true};
123 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
124 bool SpawnRocks {
true};
126 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
127 bool SpawnPlants {
true};
129 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
130 float SpawnScale {1.0f};
132 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
133 int32 InitialPoolSize {10};
141 virtual void BeginPlay()
override;
142 virtual void Tick(
float DeltaTime)
override;
145 bool IsFoliageTypeEnabled(
const FString& Path)
const;
146 bool CheckForNewTiles()
const;
148 TArray<FString> GetTilesInUse();
151 TArray<FElementsToSpawn> GetElementsToSpawn(
FTileData* Tile);
152 void SpawnSkeletalFoliages(TArray<FElementsToSpawn>& ElementsToSpawn);
153 void DestroySkeletalFoliages();
154 void ActivePooledActors();
155 bool EnableActorFromPool(
156 const FTransform& Transform,
158 std::shared_ptr<FTileMeshComponent>& TileMeshComponent,
159 TArray<FPooledActor>& Pool);
161 void CreateOrUpdateTileCache(ULevel* InLevel);
162 void UpdateFoliageBlueprintCache(ULevel* InLevel);
163 void SetTileDataInternals(
FTileData& TileData);
164 void SetInstancedStaticMeshComponentCache(
FTileData& TileData);
165 void SetMaterialCache(
FTileData& TileData);
167 void FreeTileCache(ULevel* InLevel);
169 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
170 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
171 void PostWorldOriginOffset(UWorld*, FIntVector, FIntVector InDstOrigin);
179 float PoolTranslationTimer {30.0f};
180 FTransform InactivePoolTransform { FQuat(1.0f, 1.0f, 1.0f, 1.0f), FVector(1.0f, 1.0f, 1.0f), FVector(1.0f, 1.0f, 1.0f)};
185 TMap<FString, FFoliageBlueprint> FoliageBlueprintCache {};
186 TMap<FString, FTileData> TileCache {};
188 TMap<FString, TArray<FPooledActor>> ActorPool {};