Agrarsense
InstancedRendererManager.h
Go to the documentation of this file.
1// Copyright (c) 2025 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
9#include "GameFramework/Actor.h"
10#include "InstancedActor.h"
12
13#include "InstancedRendererManager.generated.h"
14
19UCLASS()
20class AGRARSENSE_API AInstancedRendererManager : public AActor
21{
22 GENERATED_BODY()
23
24public:
25
26 AInstancedRendererManager(const FObjectInitializer& ObjectInitializer);
27
28 virtual void BeginPlay() override;
29
30 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
31
35 UFUNCTION(BlueprintCallable)
36 bool AddActorToInstancedRendering(AInstancedActor* InstancedActor);
37
41 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer Manager")
42 bool AppendISM(UInstancedStaticMeshComponent* ISM);
43
48 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer Manager")
49 bool AppendOrCreateISM(UInstancedStaticMeshComponent* ISM);
50
54 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer Manager")
55 void SpawnAllInstancesBackToActors();
56
64 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
65 bool SpawnInstanceBackToActor(UInstancedStaticMeshComponent* ISM, int32 Index, bool OnlyTree);
66
67 UFUNCTION(BlueprintCallable, Category = "Instanced Renderer")
68 void ExportTreesAsCSV();
69
76 void DestroyOverlappingInstancesBox(UInstancedStaticMeshComponent* ISM, FBox AreaBox, bool OnlyTrees);
77
81 void SetInstancedRendering(bool Visible);
82
83 UFUNCTION(BlueprintCallable,Category = "Instanced Renderer Manager")
84 TArray<AInstancedActorRenderer*> GetAllInstancedActorRendererActors() const;
85
86 UFUNCTION(BlueprintPure, Category = "Instanced Renderer Manager")
87 int32 GetTotalInstanceCount();
88
89protected:
90
91 UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
92 TArray<AInstancedActorRenderer*> InstancedRenderers;
93
94 UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
95 int32 TotalInstanceCount = 0;
96
97private:
98
99 static AInstancedRendererManager* Instance;
100
101};