44 AInstancedFoliageActor* InstancedFoliageActor {
nullptr};
46 AProceduralFoliageVolume* ProceduralFoliageVolume {
nullptr};
48 TArray<std::shared_ptr<FTileMeshComponent>> TileMeshesCache {};
50 TArray<UMaterialInstanceDynamic*> MaterialInstanceDynamicCache {};
53 bool ContainsMesh(
const UInstancedStaticMeshComponent*)
const;
55 void UpdateTileMeshComponent(UInstancedStaticMeshComponent* NewInstancedStaticMeshComponent);
57 void UpdateMaterialCache(
const FLinearColor& Value,
bool DebugMaterials);
135 UFUNCTION(BlueprintCallable)
136 void UpdatePoolBasePosition();
140 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
141 bool DebugMaterials {
false};
144 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
145 float HideMaterialDistance {500.0f};
148 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
149 float ActiveActorDistance {500.0f};
152 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
153 bool SpawnBushes {
true};
156 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
157 bool SpawnTrees {
true};
160 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
161 bool SpawnRocks {
true};
164 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
165 bool SpawnPlants {
true};
168 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
169 float SpawnScale {1.0f};
172 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
173 int32 InitialPoolSize {10};
182 virtual void BeginPlay()
override;
184 virtual void Tick(
float DeltaTime)
override;
188 bool IsFoliageTypeEnabled(
const FString& Path)
const;
190 bool CheckForNewTiles()
const;
193 TArray<FString> GetTilesInUse();
198 TArray<FElementsToSpawn> GetElementsToSpawn(
FTileData* Tile);
200 void SpawnSkeletalFoliages(TArray<FElementsToSpawn>& ElementsToSpawn);
202 void DestroySkeletalFoliages();
204 void ActivePooledActors();
206 bool EnableActorFromPool(
207 const FTransform& Transform,
209 std::shared_ptr<FTileMeshComponent>& TileMeshComponent,
210 TArray<FPooledActor>& Pool);
213 void CreateOrUpdateTileCache(ULevel* InLevel);
215 void UpdateFoliageBlueprintCache(ULevel* InLevel);
217 void SetTileDataInternals(
FTileData& TileData);
219 void SetInstancedStaticMeshComponentCache(
FTileData& TileData);
221 void SetMaterialCache(
FTileData& TileData);
224 void FreeTileCache(ULevel* InLevel);
227 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
229 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
231 void PostWorldOriginOffset(UWorld*, FIntVector, FIntVector InDstOrigin);
243 float PoolTranslationTimer {30.0f};
245 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)};
251 TMap<FString, FFoliageBlueprint> FoliageBlueprintCache {};
253 TMap<FString, FTileData> TileCache {};
255 TMap<FString, TArray<FPooledActor>> ActorPool {};