Navigation
API > API/Runtime > API/Runtime/MeshDescription
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.
| Name | FMeshElementIndexer |
| Type | class |
| Header File | /Engine/Source/Runtime/MeshDescription/Public/MeshElementIndexer.h |
| Include Path | #include "MeshElementIndexer.h" |
Syntax
class FMeshElementIndexer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FMeshElementIndexer
(
const FMeshElementChannels* Key, |
MeshElementIndexer.h | ||
| Moving OK. | MeshElementIndexer.h | ||
FMeshElementIndexer
(
const FMeshElementIndexer& |
Copying not allowed as they reference elements of a MeshDescription of which they are normally a part. | MeshElementIndexer.h | |
| MeshElementIndexer.h |
Structs
| Name | Remarks |
|---|---|
| FChunk | We are modelling a one-to-many relationship, where a single key yields multiple indices, e.g. obtaining all the vertex instances which reference a given vertex ID (the key). |
| FIndexPerChannel |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bEverythingStale | bool | True if the entire data needs to be rebuilt | MeshElementIndexer.h | |
| bSuspended | bool | Whether indexing is temporarily suspended | MeshElementIndexer.h | |
| ChunkBits | uint32 | Chunk size | MeshElementIndexer.h | |
| ChunkMask | uint32 | MeshElementIndexer.h | ||
| InitialSize | int32 | The initial size for key chunks | MeshElementIndexer.h | |
| PerChannelIndices | TArray< FIndexPerChannel > | MeshElementIndexer.h | ||
| ReferencedElementType | const FMeshElementChannels * | The element type used as the key for this index | MeshElementIndexer.h | |
| ReferencingAttributeRef | TMeshAttributesRef< int, TArrayView< const int32 > > | The attribute ref used to reference the above key | MeshElementIndexer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddReferenceToKey
(
int32 KeyIndex, |
Add a reference to a key. | MeshElementIndexer.h | |
void Build() |
Build any stale indices | MeshElementIndexer.h | |
TArrayView< const ElementIDType > Find
(
int32 KeyIndex, |
MeshElementIndexer.h | ||
TArrayView< const int32 > Find
(
int32 KeyIndex, |
Retrieve all referencer indices whose named attribute refers to KeyIndex. | MeshElementIndexer.h | |
void ForceRebuild() |
Force the indexer to be completely rebuilt. | MeshElementIndexer.h | |
void RemoveKey
(
int32 KeyIndex, |
Remove the specified key from the indexer | MeshElementIndexer.h | |
void RemoveReferenceFromKey
(
int32 KeyIndex, |
Remove reference from key. This will take immediate effect. | MeshElementIndexer.h | |
void Reset() |
Resets the indexer | MeshElementIndexer.h | |
void Resume() |
Resume indexing and mark indexer as stale, but do not force an immediate rebuild | MeshElementIndexer.h | |
void Set
(
const FMeshElementChannels* Key, |
Set the parameters of this mesh element indexer | MeshElementIndexer.h | |
void SetChunkSize
(
int InChunkSize |
Sets the chunk size for the indexer, for optimization purposes. The default chunk size is 256. | MeshElementIndexer.h | |
void SetInitialNumReferences
(
int InInitialSize |
Sets the initial/expected number of references per key | MeshElementIndexer.h | |
void SetUnchunked () |
Configures the indexer not to use chunks. | MeshElementIndexer.h | |
void Suspend() |
Suspend indexing until the next rebuild | MeshElementIndexer.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| MeshElementIndexer.h | |||
FMeshElementIndexer & operator=
(
const FMeshElementIndexer& |
MeshElementIndexer.h |