![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <MeshElementIndexer.h>
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.
|
default |
| FMeshElementIndexer::FMeshElementIndexer | ( | const FMeshElementChannels * | Key, |
| const FMeshElementChannels * | Referencer, | ||
| FName | AttributeName, | ||
| int32 | ReferencerChannelIndex = 0 |
||
| ) |
|
delete |
|
default |
| 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.
| void FMeshElementIndexer::Build | ( | ) |
Build any stale indices
|
inline |
Retrieve all referencer indices whose named attribute refers to KeyIndex. Non-const because finding a stale index might cause a rebuild.
|
inline |
| void FMeshElementIndexer::ForceRebuild | ( | ) |
Force the indexer to be completely rebuilt.
|
delete |
|
default |
Remove the specified key from the indexer
| void FMeshElementIndexer::RemoveReferenceFromKey | ( | int32 | KeyIndex, |
| int32 | ReferenceIndex, | ||
| int32 | KeyChannelIndex = 0 |
||
| ) |
Remove reference from key. This will take immediate effect.
| void FMeshElementIndexer::Reset | ( | ) |
Resets the indexer
|
inline |
Resume indexing and mark indexer as stale, but do not force an immediate rebuild
| void FMeshElementIndexer::Set | ( | const FMeshElementChannels * | Key, |
| const FMeshElementChannels * | Referencer, | ||
| FName | AttributeName, | ||
| int32 | ReferencerChannelIndex = 0 |
||
| ) |
Set the parameters of this mesh element indexer
|
inline |
Sets the chunk size for the indexer, for optimization purposes. The default chunk size is 256.
|
inline |
Sets the initial/expected number of references per key
|
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
|
inline |
Suspend indexing until the next rebuild