8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10#include "Engine/EngineTypes.h"
11#include "Engine/StaticMesh.h"
12#include "Materials/MaterialInterface.h"
13#include "Components/InstancedStaticMeshComponent.h"
22#include "InstancedRenderer.generated.h"
24class UStaticMeshComponent;
32 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
33 UInstancedStaticMeshComponent* InstancedStaticMeshComponent;
35 UPROPERTY(EditAnywhere, BlueprintReadWrite)
36 TSubclassOf<AActor> ActorClass;
38 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
39 TWeakObjectPtr<UStaticMesh> Mesh;
41 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
42 TArray<UMaterialInterface*> Materials;
44 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
45 int32 InstanceEntryIndex = 0;
47 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
48 int32 CustomDepthStencilValue = 0;
50 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
53 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
56 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
57 bool UsingProxy = false;
88 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
96 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
110 UFUNCTION(BlueprintPure, Category =
"Instanced Renderer")
111 bool IsRendering()
const
120 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
121 int32 GetTotalInstanceCount()
const
123 return TotalInstanceCount;
130 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
131 int32 GetUniqueInstancesCount()
const
133 return InstanceEntries.Num();
140 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
143 return InstanceEntries;
149 UFUNCTION(BlueprintCallable, Category =
"Instanced Renderer")
150 void SetInstancedRendering(
bool ShouldRender);
157 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
158 void SetComponentIndexVisibility(int32 Index,
bool Visible);
164 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
165 void SetRenderCustomDepth(
bool Enabled);
171 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
172 void SetWorldPositionOffsetDistance(int32 NewWPODistance);
178 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
179 void SetShadowCacheBehaviour(EShadowCacheInvalidationBehavior ShadowCacheInvalidationBehaviour);
185 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
186 void SetRenderWorldPositionOffet(
bool RenderWPO);
191 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
192 void LogInfo() const;
198 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
199 void DebugMaterialImpact(
bool SetUnrealDefaultMaterial);
204 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
205 void ToggleProxyMesh();
211 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
212 void SpawnAllInstancesBackActors();
218 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
219 void UpdateRenderDistances();
227 void DestroyOverlappingInstancesBox(UInstancedStaticMeshComponent* ISM, FBox AreaBox,
bool OnlyTrees);
236 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
237 bool SpawnInstanceBackToActor(UInstancedStaticMeshComponent* ISM, int32 Index,
bool OnlyTree);
250 UPROPERTY(VisibleAnywhere, AdvancedDisplay, BlueprintReadWrite)
253 UPROPERTY(BlueprintReadWrite)
254 TArray<UInstancedStaticMeshComponent*> InstancesStaticMeshComponents;
256 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
257 int32 TotalInstanceCount = 0;
261 TWeakObjectPtr<UStaticMesh> CubeMesh;
267 virtual
void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
284 int32 WorldPositionOffsetDistance = 30000;
288 bool Rendering = true;
290 bool RenderingWPO = false;
UStaticMeshComponent * StaticMeshComponent
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
bool AllowWorldPositionOffsetDisable
virtual void BeginPlay() override