9 #include "GameFramework/Actor.h" 10 #include "ProceduralFoliageVolume.h" 11 #include "Components/InstancedStaticMeshComponent.h" 12 #include "Materials/MaterialInstanceDynamic.h" 13 #include "InstancedFoliageActor.h" 15 #include "Containers/Array.h" 16 #include "Containers/Map.h" 22 #include "VegetationManager.generated.h" 28 UInstancedStaticMeshComponent* InstancedStaticMeshComponent {
nullptr};
29 TArray<int32> IndicesInUse {};
30 bool bIsAlive =
false;
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);
52 FString BPFullClassName {};
53 TSubclassOf<AActor> SpawnedClass {
nullptr };
56 bool SetBPClassName(
const FString&
Path);
57 bool SetSpawnedClass();
65 bool IsActive {
false };
67 FTransform GlobalTransform {FTransform()};
69 std::shared_ptr<FTileMeshComponent> TileMeshComponent {
nullptr};
74 std::shared_ptr<FTileMeshComponent>& NewTileMeshComponent);
85 TArray<TPair<FTransform, int32>> TransformIndex;
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(
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);
170 void GetSketalTemplates();
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 {};
std::vector< cg::Location > Path
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
carla::SharedPtr< cc::Actor > Actor
FTimerHandle UpdatePoolInactiveTransformTimer
Base class for CARLA wheeled vehicles.
geom::Transform Transform