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

#include <MeshElementIndexer.h>

Public Member Functions

 FMeshElementIndexer ()=default
 
MESHDESCRIPTION_API FMeshElementIndexer (const FMeshElementChannels *Key, const FMeshElementChannels *Referencer, FName AttributeName, int32 ReferencerChannelIndex=0)
 
 FMeshElementIndexer (const FMeshElementIndexer &)=delete
 
FMeshElementIndexeroperator= (const FMeshElementIndexer &)=delete
 
 FMeshElementIndexer (FMeshElementIndexer &&)=default
 
FMeshElementIndexeroperator= (FMeshElementIndexer &&)=default
 
MESHDESCRIPTION_API void Set (const FMeshElementChannels *Key, const FMeshElementChannels *Referencer, FName AttributeName, int32 ReferencerChannelIndex=0)
 
void SetInitialNumReferences (int InInitialSize)
 
void SetChunkSize (int InChunkSize)
 
void SetUnchunked ()
 
MESHDESCRIPTION_API void Reset ()
 
TArrayView< const int32Find (int32 KeyIndex, int32 KeyChannelIndex=0)
 
template<typename ElementIDType >
TArrayView< const ElementIDTypeFind (int32 KeyIndex, int32 KeyChannelIndex=0)
 
MESHDESCRIPTION_API void RemoveKey (int32 KeyIndex, int32 KeyChannelIndex=0)
 
MESHDESCRIPTION_API void RemoveReferenceFromKey (int32 KeyIndex, int32 ReferenceIndex, int32 KeyChannelIndex=0)
 
MESHDESCRIPTION_API void AddReferenceToKey (int32 KeyIndex, int32 ReferenceIndex, int32 KeyChannelIndex=0)
 
void Suspend ()
 
void Resume ()
 
MESHDESCRIPTION_API void ForceRebuild ()
 
MESHDESCRIPTION_API void Build ()
 

Detailed Description

This is an efficient container for holding back references to mesh elements from attributes. Typically this will be a one-to-many relationship, where a given key has many different references.

Naively this would be implemented as an array of arrays, but we want to minimise allocations and fragmentation as much as possible. This is achieved in two ways:

1) Arrays representing the list of references are consolidated into chunks of a user-specified size. This reduces the number of individual allocations which need to be made. By default, 256 keys are consolidated into a single chunk.

2) The arrays are lazily updated. The most expensive aspect of consolidating adjacent keys' values into a single chunk of data is having to insert new space into the middle of the chunk. If a new value can't be immediately added into a chunk without inserting, the key is marked as stale and the referencer is remembered. If a stale key is queried, the indexer will be updated first, building all stale keys by getting back references from the remembered referencers.

There is also a way to fully rebuild an indexer, which will perform optimally few allocations, and collect all back references at once. It may sometimes be desirable to suspend an indexer, build a mesh description with indexing suspended, and then perform an indexer rebuild for additional speed and allocation efficiency.

Some element relationships don't lend themselves to chunking, for example polygon groups to triangles. In this case, there are generally few polygon groups compared to many triangles. Chunking can be turned off for such indexers, resulting in a more simple array representation which can be arbitrarily grown without requiring elements to be inserted.

Constructor & Destructor Documentation

◆ FMeshElementIndexer() [1/4]

FMeshElementIndexer::FMeshElementIndexer ( )
default

◆ FMeshElementIndexer() [2/4]

FMeshElementIndexer::FMeshElementIndexer ( const FMeshElementChannels Key,
const FMeshElementChannels Referencer,
FName  AttributeName,
int32  ReferencerChannelIndex = 0 
)

◆ FMeshElementIndexer() [3/4]

FMeshElementIndexer::FMeshElementIndexer ( const FMeshElementIndexer )
delete

◆ FMeshElementIndexer() [4/4]

FMeshElementIndexer::FMeshElementIndexer ( FMeshElementIndexer &&  )
default

Member Function Documentation

◆ AddReferenceToKey()

void FMeshElementIndexer::AddReferenceToKey ( int32  KeyIndex,
int32  ReferenceIndex,
int32  KeyChannelIndex = 0 
)

Add a reference to a key. This will be queued and take effect in batch when an affected key is looked up. This is preferable to regenerating the index entirely.

◆ Build()

void FMeshElementIndexer::Build ( )

Build any stale indices

◆ Find() [1/2]

TArrayView< const int32 > FMeshElementIndexer::Find ( int32  KeyIndex,
int32  KeyChannelIndex = 0 
)
inline

Retrieve all referencer indices whose named attribute refers to KeyIndex. Non-const because finding a stale index might cause a rebuild.

◆ Find() [2/2]

template<typename ElementIDType >
TArrayView< const ElementIDType > FMeshElementIndexer::Find ( int32  KeyIndex,
int32  KeyChannelIndex = 0 
)
inline

◆ ForceRebuild()

void FMeshElementIndexer::ForceRebuild ( )

Force the indexer to be completely rebuilt.

◆ operator=() [1/2]

FMeshElementIndexer & FMeshElementIndexer::operator= ( const FMeshElementIndexer )
delete

◆ operator=() [2/2]

FMeshElementIndexer & FMeshElementIndexer::operator= ( FMeshElementIndexer &&  )
default

◆ RemoveKey()

void FMeshElementIndexer::RemoveKey ( int32  KeyIndex,
int32  KeyChannelIndex = 0 
)

Remove the specified key from the indexer

◆ RemoveReferenceFromKey()

void FMeshElementIndexer::RemoveReferenceFromKey ( int32  KeyIndex,
int32  ReferenceIndex,
int32  KeyChannelIndex = 0 
)

Remove reference from key. This will take immediate effect.

◆ Reset()

void FMeshElementIndexer::Reset ( )

Resets the indexer

◆ Resume()

void FMeshElementIndexer::Resume ( )
inline

Resume indexing and mark indexer as stale, but do not force an immediate rebuild

◆ Set()

void FMeshElementIndexer::Set ( const FMeshElementChannels Key,
const FMeshElementChannels Referencer,
FName  AttributeName,
int32  ReferencerChannelIndex = 0 
)

Set the parameters of this mesh element indexer

◆ SetChunkSize()

void FMeshElementIndexer::SetChunkSize ( int  InChunkSize)
inline

Sets the chunk size for the indexer, for optimization purposes. The default chunk size is 256.

◆ SetInitialNumReferences()

void FMeshElementIndexer::SetInitialNumReferences ( int  InInitialSize)
inline

Sets the initial/expected number of references per key

◆ SetUnchunked()

void FMeshElementIndexer::SetUnchunked ( )
inline

Configures the indexer not to use chunks. This is desirable if there are very few keys with a lot of references, e.g. polygon groups to polygons

◆ Suspend()

void FMeshElementIndexer::Suspend ( )
inline

Suspend indexing until the next rebuild


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