UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FInstanceDataManager Class Reference

#include <InstanceDataManager.h>

+ Inheritance diagram for FInstanceDataManager:

Public Types

enum class  ETrackingState : uint8 { Initial , Tracked , Disabled , Optimized }
 

Public Member Functions

ENGINE_API FInstanceDataManager (UPrimitiveComponent *InPrimitiveComponent)
 
FPrimitiveInstanceId Add (int32 InInstanceAddAtIndex)
 
void RemoveAtSwap (int32 InstanceIndex)
 
void RemoveAt (int32 InstanceIndex)
 
void TransformChanged (int32 InstanceIndex)
 
void TransformChanged (FPrimitiveInstanceId InstanceId)
 
void TransformsChangedAll ()
 
void CustomDataChanged (int32 InstanceIndex)
 
void BakedLightingDataChanged (int32 InstanceIndex)
 
void BakedLightingDataChangedAll ()
 
void NumCustomDataChanged ()
 
void PrimitiveTransformChanged ()
 
void ClearInstances ()
 
ENGINE_API bool HasAnyInstanceChanges () const
 
bool HasAnyChanges () const
 
ENGINE_API bool FlushChanges (FInstanceDataManagerSourceDataDesc &&ComponentData)
 
void ClearChangeTracking ()
 
int32 GetMaxAllocatedInstanceId () const
 
ETrackingState GetState () const
 
ENGINE_API TSharedPtr< FInstanceDataSceneProxy, ESPMode::ThreadSafeGetOrCreateProxy ()
 
ENGINE_API TSharedPtr< FInstanceDataSceneProxy, ESPMode::ThreadSafeGetProxy ()
 
void ValidateMapping () const
 
void ReadCookedRenderData (FArchive &Ar)
 
void Serialize (FArchive &Ar, bool bCooked)
 
TArray< int32Optimize (FInstanceDataManagerSourceDataDesc &&ComponentData, bool bShouldRetainIdMap)
 
ENGINE_API SIZE_T GetAllocatedSize () const
 
- Public Member Functions inherited from FInstanceIdIndexMap
 FInstanceIdIndexMap ()=default
 
bool IsIdentity () const
 
int32 GetMaxInstanceId () const
 
int32 GetMaxInstanceIndex () const
 
bool IsValidId (FPrimitiveInstanceId InstanceId) const
 
int32 IdToIndex (FPrimitiveInstanceId InstanceId) const
 
FPrimitiveInstanceId IndexToId (int32 InstanceIndex) const
 
void SetInvalid (FPrimitiveInstanceId InstanceId)
 
void Update (FPrimitiveInstanceId InstanceId, int32 InstanceIndex)
 
ENGINE_API void Reset (int32 InNumInstances)
 
ENGINE_API void ResizeExplicit (int32 InNumInstances, int32 MaxInstanceId)
 
ENGINE_API void CreateExplicitIdentityMapping ()
 
ENGINE_API void Serialize (FArchive &Ar)
 
ENGINE_API void RebuildFromIndexToIdMap (TArray< FPrimitiveInstanceId > &&InIndexToIdMap, int32 MaxInstanceId)
 

Protected Types

using EChangeFlag = FInstanceAttributeTracker::EFlag
 

Protected Member Functions

void CreateExplicitIdentityMapping ()
 
template<EChangeFlag Flag>
void MarkChangeHelper (int32 InstanceIndex)
 
template<EChangeFlag Flag>
void MarkChangeHelper (FPrimitiveInstanceId InstanceId)
 
void MarkComponentRenderInstancesDirty ()
 
bool HasIdentityMapping () const
 
void FreeInstanceId (FPrimitiveInstanceId InstanceId)
 
void GatherDefaultData (const FInstanceDataManagerSourceDataDesc &ComponentData, FInstanceUpdateChangeSet &ChangeSet) const
 
void InitChangeSet (const FInstanceDataManagerSourceDataDesc &ComponentData, FInstanceUpdateChangeSet &ChangeSet) const
 
void InitChangeSet (const struct FChangeDesc2 &ChangeDesc, const FInstanceDataManagerSourceDataDesc &ComponentData, FInstanceUpdateChangeSet &ChangeSet)
 
TSharedPtr< class FUpdatableInstanceDataSceneProxy, ESPMode::ThreadSafeGetOrCreateProxyInternal ()
 
- Protected Member Functions inherited from FInstanceIdIndexMap
ENGINE_API void RebuildFromIndexToIdMap (int32 MaxInstanceId)
 

Static Protected Member Functions

static bool ShouldUsePrecomputed ()
 

Protected Attributes

FInstanceAttributeTracker InstanceUpdateTracker
 
TBitArray ValidInstanceIdMask
 
int32 IdSearchStartIndex = 0
 
ETrackingState TrackingState = ETrackingState::Initial
 
FInstanceDataFlags AllChangedFlags
 
uint8 bNumCustomDataChanged: 1
 
uint8 bTransformChangedAllInstances: 1
 
uint8 bPrimitiveTransformChanged: 1
 
uint8 bAnyInstanceChange: 1
 
TSharedPtr< class FUpdatableInstanceDataSceneProxy, ESPMode::ThreadSafeInstanceDataProxy
 
TWeakObjectPtr< UPrimitiveComponent > PrimitiveComponent = nullptr
 
FPrecomputedInstanceSpatialHashDataPtr PrecomputedOptimizationData
 
FInstanceDataFlags Flags
 
int32 NumCustomDataFloats = 0
 
float AbsMaxDisplacement = 0.0f
 
FRenderBounds MeshBounds
 
- Protected Attributes inherited from FInstanceIdIndexMap
TArray< FPrimitiveInstanceIdIndexToIdMap
 
TArray< int32IdToIndexMap
 
int32 NumInstances = 0
 

Detailed Description

Manager class that tracks changes to instance data within the component, and is responsible for dispatching updates of the proxy. Tracks instance index changes to be able to maintain a persistent ID mapping for use on the render thread. The ID mapping is not serialized and will be reset when the proxy is recreated. Not responsible for storing the component representation of the instance data. NOTE/TODO: This is tied to the ISM use-case, mostly because of legacy (HISM) interactions. Will be refactored and sub-classed or something. Also: Still somewhat tied to the UComponent, which also can be refactored a bit to make it more general.

Member Typedef Documentation

◆ EChangeFlag

Member Enumeration Documentation

◆ ETrackingState

Current tracking state,

Enumerator
Initial 
Tracked 
Disabled 
Optimized 

Constructor & Destructor Documentation

◆ FInstanceDataManager()

FInstanceDataManager::FInstanceDataManager ( UPrimitiveComponent *  InPrimitiveComponent)

Member Function Documentation

◆ Add()

FPrimitiveInstanceId FInstanceDataManager::Add ( int32  InInstanceAddAtIndex)

Tracking functions that mirror what is done to each instance in the source instance data array.

◆ BakedLightingDataChanged()

void FInstanceDataManager::BakedLightingDataChanged ( int32  InstanceIndex)

◆ BakedLightingDataChangedAll()

void FInstanceDataManager::BakedLightingDataChangedAll ( )

◆ ClearChangeTracking()

void FInstanceDataManager::ClearChangeTracking ( )

Clear all tracked changes (will result in a full update when next one is flushed)

◆ ClearInstances()

void FInstanceDataManager::ClearInstances ( )

◆ CreateExplicitIdentityMapping()

void FInstanceDataManager::CreateExplicitIdentityMapping ( )
protected

◆ CustomDataChanged()

void FInstanceDataManager::CustomDataChanged ( int32  InstanceIndex)

◆ FlushChanges()

bool FInstanceDataManager::FlushChanges ( FInstanceDataManagerSourceDataDesc &&  ComponentData)

Queries the tracker for changes and builds an update build command to enqueue to the render thread. The ComponentData supplies source data through a callback as needed.

◆ FreeInstanceId()

void FInstanceDataManager::FreeInstanceId ( FPrimitiveInstanceId  InstanceId)
protected

◆ GatherDefaultData()

void FInstanceDataManager::GatherDefaultData ( const FInstanceDataManagerSourceDataDesc ComponentData,
FInstanceUpdateChangeSet ChangeSet 
) const
protected

◆ GetAllocatedSize()

SIZE_T FInstanceDataManager::GetAllocatedSize ( ) const

◆ GetMaxAllocatedInstanceId()

int32 FInstanceDataManager::GetMaxAllocatedInstanceId ( ) const

◆ GetOrCreateProxy()

TSharedPtr< FInstanceDataSceneProxy, ESPMode::ThreadSafe > FInstanceDataManager::GetOrCreateProxy ( )

◆ GetOrCreateProxyInternal()

TSharedPtr< FUpdatableInstanceDataSceneProxy, ESPMode::ThreadSafe > FInstanceDataManager::GetOrCreateProxyInternal ( )
protected

◆ GetProxy()

TSharedPtr< FInstanceDataSceneProxy, ESPMode::ThreadSafe > FInstanceDataManager::GetProxy ( )

◆ GetState()

ETrackingState FInstanceDataManager::GetState ( ) const
inline

◆ HasAnyChanges()

bool FInstanceDataManager::HasAnyChanges ( ) const
inline

Returns true if there are explicitly tracked instance changes, or the state is not tracked (because no proxy has been created yet), and the tracking state is not Disabled.

◆ HasAnyInstanceChanges()

bool FInstanceDataManager::HasAnyInstanceChanges ( ) const

◆ HasIdentityMapping()

bool FInstanceDataManager::HasIdentityMapping ( ) const
protected

◆ InitChangeSet() [1/2]

void FInstanceDataManager::InitChangeSet ( const FInstanceDataManagerSourceDataDesc ComponentData,
FInstanceUpdateChangeSet ChangeSet 
) const
protected

Initialize a chage set from the component data & manager state but not using any delta information or updating tracked state.

◆ InitChangeSet() [2/2]

void FInstanceDataManager::InitChangeSet ( const struct FChangeDesc2 ChangeDesc,
const FInstanceDataManagerSourceDataDesc ComponentData,
FInstanceUpdateChangeSet ChangeSet 
)
protected

◆ MarkChangeHelper() [1/2]

void FInstanceDataManager::MarkChangeHelper ( FPrimitiveInstanceId  InstanceId)
inlineprotected

◆ MarkChangeHelper() [2/2]

void FInstanceDataManager::MarkChangeHelper ( int32  InstanceIndex)
inlineprotected

◆ MarkComponentRenderInstancesDirty()

void FInstanceDataManager::MarkComponentRenderInstancesDirty ( )
protected

◆ NumCustomDataChanged()

void FInstanceDataManager::NumCustomDataChanged ( )

◆ Optimize()

TArray< int32 > FInstanceDataManager::Optimize ( FInstanceDataManagerSourceDataDesc &&  ComponentData,
bool  bShouldRetainIdMap 
)

Compute the instance order used to build the instance hierarchy (spatial hashes) and return the reordering needed for this. This should be used by the data source (i.e., UComponent etc) to reorder the source instance buffers. Returns a reordering table where each index stores the old index for the given new index.

◆ PrimitiveTransformChanged()

void FInstanceDataManager::PrimitiveTransformChanged ( )

◆ ReadCookedRenderData()

void FInstanceDataManager::ReadCookedRenderData ( FArchive Ar)

◆ RemoveAt()

void FInstanceDataManager::RemoveAt ( int32  InstanceIndex)

◆ RemoveAtSwap()

void FInstanceDataManager::RemoveAtSwap ( int32  InstanceIndex)

◆ Serialize()

void FInstanceDataManager::Serialize ( FArchive Ar,
bool  bCooked 
)

◆ ShouldUsePrecomputed()

bool FInstanceDataManager::ShouldUsePrecomputed ( )
staticprotected

◆ TransformChanged() [1/2]

void FInstanceDataManager::TransformChanged ( FPrimitiveInstanceId  InstanceId)

◆ TransformChanged() [2/2]

void FInstanceDataManager::TransformChanged ( int32  InstanceIndex)

◆ TransformsChangedAll()

void FInstanceDataManager::TransformsChangedAll ( )

◆ ValidateMapping()

void FInstanceDataManager::ValidateMapping ( ) const
inline

Member Data Documentation

◆ AbsMaxDisplacement

float FInstanceDataManager::AbsMaxDisplacement = 0.0f
protected

◆ AllChangedFlags

FInstanceDataFlags FInstanceDataManager::AllChangedFlags
protected

◆ bAnyInstanceChange

uint8 FInstanceDataManager::bAnyInstanceChange
protected

◆ bNumCustomDataChanged

uint8 FInstanceDataManager::bNumCustomDataChanged
protected

◆ bPrimitiveTransformChanged

uint8 FInstanceDataManager::bPrimitiveTransformChanged
protected

◆ bTransformChangedAllInstances

uint8 FInstanceDataManager::bTransformChangedAllInstances
protected

◆ Flags

FInstanceDataFlags FInstanceDataManager::Flags
protected

◆ IdSearchStartIndex

int32 FInstanceDataManager::IdSearchStartIndex = 0
protected

◆ InstanceDataProxy

TSharedPtr<class FUpdatableInstanceDataSceneProxy, ESPMode::ThreadSafe> FInstanceDataManager::InstanceDataProxy
protected

◆ InstanceUpdateTracker

FInstanceAttributeTracker FInstanceDataManager::InstanceUpdateTracker
protected

◆ MeshBounds

FRenderBounds FInstanceDataManager::MeshBounds
protected

◆ NumCustomDataFloats

int32 FInstanceDataManager::NumCustomDataFloats = 0
protected

◆ PrecomputedOptimizationData

FPrecomputedInstanceSpatialHashDataPtr FInstanceDataManager::PrecomputedOptimizationData
protected

◆ PrimitiveComponent

TWeakObjectPtr<UPrimitiveComponent> FInstanceDataManager::PrimitiveComponent = nullptr
protected

◆ TrackingState

ETrackingState FInstanceDataManager::TrackingState = ETrackingState::Initial
protected

◆ ValidInstanceIdMask

TBitArray FInstanceDataManager::ValidInstanceIdMask
protected

The documentation for this class was generated from the following files: