UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LightWeightInstanceStaticMeshManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Engine/StaticMesh.h"
9
10#include "LightWeightInstanceStaticMeshManager.generated.h"
11
13
14UCLASS(BlueprintType, Blueprintable, Experimental, MinimalAPI)
16{
18
19 ENGINE_API virtual void SetRepresentedClass(UClass* ActorClass) override;
20
21 // Sets the static mesh to use based on the info contained in InActor
22 ENGINE_API virtual void SetStaticMeshFromActor(AActor* InActor);
23
24 // Clears the static mesh used for rendering instances
25 ENGINE_API void ClearStaticMesh();
26
27 ENGINE_API virtual int32 ConvertCollisionIndexToInstanceIndex(int32 InIndex, const UPrimitiveComponent* RelevantComponent) const override;
28
29protected:
30 ENGINE_API virtual void AddNewInstanceAt(FLWIData* InitData, int32 Index) override;
31 ENGINE_API virtual void RemoveInstance(int32 Index) override;
32
33 ENGINE_API void AddInstanceToRendering(int32 DataIndex);
34 ENGINE_API void RemoveInstanceFromRendering(int32 DataIndex);
35
36 ENGINE_API void PostRemoveInstanceFromRendering();
37
38 // sets the parameters on the instanced static mesh component
39 ENGINE_API virtual void SetInstancedStaticMeshParams();
40
41 // Called when we set the static mesh
42 ENGINE_API void OnStaticMeshSet();
43
44 ENGINE_API virtual void OnRep_Transforms() override;
45
46 ENGINE_API virtual void PostActorSpawn(const FActorInstanceHandle& Handle) override;
47
48public:
49
50 ENGINE_API virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
51
52#if WITH_EDITORONLY_DATA
53 ENGINE_API virtual void PostLoad() override;
54#endif
55
56protected:
57
58 //~ ISMInstanceManager interface
59 ENGINE_API virtual FText GetSMInstanceDisplayName(const FSMInstanceId& InstanceId) const override;
60 ENGINE_API virtual FText GetSMInstanceTooltip(const FSMInstanceId& InstanceId) const override;
61 ENGINE_API virtual bool CanEditSMInstance(const FSMInstanceId& InstanceId) const override;
62 ENGINE_API virtual bool CanMoveSMInstance(const FSMInstanceId& InstanceId, const ETypedElementWorldType InWorldType) const override;
63 ENGINE_API virtual bool GetSMInstanceTransform(const FSMInstanceId& InstanceId, FTransform& OutInstanceTransform, bool bWorldSpace = false) const override;
64 ENGINE_API virtual bool SetSMInstanceTransform(const FSMInstanceId& InstanceId, const FTransform& InstanceTransform, bool bWorldSpace = false, bool bMarkRenderStateDirty = false, bool bTeleport = false) override;
65 ENGINE_API virtual void NotifySMInstanceMovementStarted(const FSMInstanceId& InstanceId) override;
66 ENGINE_API virtual void NotifySMInstanceMovementOngoing(const FSMInstanceId& InstanceId) override;
67 ENGINE_API virtual void NotifySMInstanceMovementEnded(const FSMInstanceId& InstanceId) override;
68 ENGINE_API virtual void NotifySMInstanceSelectionChanged(const FSMInstanceId& InstanceId, const bool bIsSelected) override;
69 ENGINE_API virtual bool DeleteSMInstances(TArrayView<const FSMInstanceId> InstanceIds) override;
70 ENGINE_API virtual bool DuplicateSMInstances(TArrayView<const FSMInstanceId> InstanceIds, TArray<FSMInstanceId>& OutNewInstanceIds) override;
71
72 ENGINE_API virtual void DuplicateLWIInstances(TArrayView<const int32> DataIndices, TArray<int32>& OutNewDataIndices);
73 ENGINE_API void GetLWIDataIndices(TArrayView<const FSMInstanceId> InstanceIds, TArray<int32>& OutDataIndices) const;
74
75 ENGINE_API virtual int32 ConvertInternalIndexToHandleIndex(int32 InternalIndex) const override;
76 ENGINE_API virtual int32 ConvertHandleIndexToInternalIndex(int32 HandleIndex) const override;
77
78protected:
79
80 UPROPERTY(EditInstanceOnly, BlueprintReadOnly, Category = Debug, ReplicatedUsing = OnRep_StaticMesh)
82 UFUNCTION()
83 ENGINE_API void OnRep_StaticMesh();
84
85#if WITH_EDITORONLY_DATA
87 UE_DEPRECATED(5.4, "Doesn't need a UHierarchicalInstancedStaticMeshComponent anymore but is replaced by UInstancedStaticMeshComponent (see ISMComponent property).")
88 UPROPERTY()
91#endif
92
93 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Debug, AdvancedDisplay, meta = (BlueprintProtected = "true", AllowPrivateAccess = "true"))
95
96 //
97 // Bookkeeping info
98 //
99
100 // keep track of the relationship between our data and the rendering data stored in the instanced static mesh component
102 TArray<int32> RenderingIndicesToDataIndices;
104 TArray<int32> DataIndicesToRenderingIndices;
105
106 // Data indices that we are going to delete later in the frame, we impose a small delay to group deletions to avoid cases where we might try to delete the same index multiple times in a frame.
107 TArray<int32> DataIndicesToBeDeleted;
108};
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam(ReturnValueType, DelegateName, Param1Type, Param1Name)
Definition DelegateCombinations.h:55
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
ETypedElementWorldType
Definition TypedElementWorldInterface.h:26
int32 InternalIndex
Definition VulkanMemory.cpp:4036
Definition Actor.h:257
Definition LightWeightInstanceManager.h:32
Definition LightWeightInstanceStaticMeshManager.h:16
Definition Text.h:385
Definition SMInstanceManager.h:26
Definition ArrayView.h:139
Definition Array.h:670
Definition Class.h:3793
Definition HierarchicalInstancedStaticMeshComponent.h:136
Definition InstancedStaticMeshComponent.h:158
Definition StaticMesh.h:593
Definition RobinHoodHashTable.h:18
U16 Index
Definition radfft.cpp:71
Definition ActorInstanceHandle.h:33
Definition LightWeightInstanceManager.h:25
Definition SMInstanceElementId.h:20
Definition ObjectPtr.h:488
Definition SoftObjectPtr.h:174