37 AInstancedFoliageActor* InstancedFoliageActor {
nullptr};
38 AProceduralFoliageVolume* ProceduralFoliageVolume {
nullptr};
39 TArray<std::shared_ptr<FTileMeshComponent>> TileMeshesCache {};
40 TArray<UMaterialInstanceDynamic*> MaterialInstanceDynamicCache {};
42 bool ContainsMesh(
const UInstancedStaticMeshComponent*)
const;
43 void UpdateTileMeshComponent(UInstancedStaticMeshComponent* NewInstancedStaticMeshComponent);
44 void UpdateMaterialCache(
const FLinearColor& Value,
bool DebugMaterials);
97 UFUNCTION(BlueprintCallable)
98 void UpdatePoolBasePosition();
101 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
102 bool DebugMaterials {
false};
104 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
105 float HideMaterialDistance {500.0f};
107 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
108 float ActiveActorDistance {500.0f};
111 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
112 bool SpawnBushes {
true};
114 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
115 bool SpawnTrees {
true};
117 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
118 bool SpawnRocks {
true};
120 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
121 bool SpawnPlants {
true};
123 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
124 float SpawnScale {1.0f};
126 UPROPERTY(Category =
"CARLA Vegetation Spawner", EditDefaultsOnly)
127 int32 InitialPoolSize {10};
135 virtual void BeginPlay()
override;
136 virtual void Tick(
float DeltaTime)
override;
139 bool IsFoliageTypeEnabled(
const FString& Path)
const;
140 bool CheckForNewTiles()
const;
142 TArray<FString> GetTilesInUse();
145 TArray<FElementsToSpawn> GetElementsToSpawn(
FTileData* Tile);
146 void SpawnSkeletalFoliages(TArray<FElementsToSpawn>& ElementsToSpawn);
147 void DestroySkeletalFoliages();
148 void ActivePooledActors();
149 bool EnableActorFromPool(
150 const FTransform& Transform,
152 std::shared_ptr<FTileMeshComponent>& TileMeshComponent,
153 TArray<FPooledActor>& Pool);
155 void CreateOrUpdateTileCache(ULevel* InLevel);
156 void UpdateFoliageBlueprintCache(ULevel* InLevel);
157 void SetTileDataInternals(
FTileData& TileData);
158 void SetInstancedStaticMeshComponentCache(
FTileData& TileData);
159 void SetMaterialCache(
FTileData& TileData);
161 void FreeTileCache(ULevel* InLevel);
163 void OnLevelAddedToWorld(ULevel* InLevel, UWorld* InWorld);
164 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
165 void PostWorldOriginOffset(UWorld*, FIntVector, FIntVector InDstOrigin);
173 float PoolTranslationTimer {30.0f};
174 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)};
179 TMap<FString, FFoliageBlueprint> FoliageBlueprintCache {};
180 TMap<FString, FTileData> TileCache {};
182 TMap<FString, TArray<FPooledActor>> ActorPool {};