Navigation
API > API/Runtime > API/Runtime/MovieScene
FEntityAllocation is the authoritative storage of entity-component data within an FEntityManager. It stores component data in separate contiguous arrays, aligned to a cache line. Storing component data in this way allows for cache-efficient and concurrent access to each component array in isolation. It also allows for write access to component arrays at the same time as concurrent read-access to other component arrays within the same entity allocation.
FEntityAllocations are custom allocated according to the size of its component capacity, which is loosely computed as sizeof(FEntityAllocation) + sizeof(ComponentData), not simply sizeof(FEntityAllocation).
A typical allocation will look like this in memory:
uint32 {UniqueID}, uint16 {NumComponents}, uint16 {Size}, uint16 {Capacity}, uint16 {MaxCapacity}, uint32 {SerialNumber}, FMovieSceneEntityID* {EntityIDs}, < points to FMovieSceneEntityID array at end of structure FComponentHeader[NumComponents], < each component header contains a component array ptr that points to its corresponding type array below (padding) FMovieSceneEntityID[Capacity], (padding) ComponentType1[Capacity], (padding) ComponentType2[Capacity], (padding) ComponentType3[Capacity],
| Name | FEntityAllocation |
| Type | struct |
| Header File | /Engine/Source/Runtime/MovieScene/Public/EntitySystem/MovieSceneEntitySystemTypes.h |
| Include Path | #include "EntitySystem/MovieSceneEntitySystemTypes.h" |
Syntax
struct FEntityAllocation
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FEntityAllocation
(
const FEntityAllocation& |
Entity allocations are non-copyable | EntitySystem/MovieSceneEntitySystemTypes.h | |
| Constructor that initializes the defaults for this structure. | EntitySystem/MovieSceneEntitySystemTypes.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FEntityAllocation() |
Manually invoked destructor that calls the destructor of each component header according to the number of components | EntitySystem/MovieSceneEntitySystemTypes.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ComponentHeaders | FComponentHeader * | Pointer to array of the component headers of size NumComponents (stored in the end padding of this structure). | EntitySystem/MovieSceneEntitySystemTypes.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Capacity | uint16 | The maximum number of entities currently allocated within this block including slack. | EntitySystem/MovieSceneEntitySystemTypes.h | |
| ComponentData | uint8 * | Pointer to separately allocated data buffer for components. | EntitySystem/MovieSceneEntitySystemTypes.h | |
| EntityIDs | FMovieSceneEntityID * | Pointer to the entity ID array (stored in the end padding of this structure). | EntitySystem/MovieSceneEntitySystemTypes.h | |
| LockMode | EComponentHeaderLockMode | Lock mode for access - under threading models this will be set to EComponentHeaderLockMode::Mutex, EComponentHeaderLockMode::LockFree otherwise | EntitySystem/MovieSceneEntitySystemTypes.h | |
| MaxCapacity | uint16 | The maximum number of entities that this entity is allowed to reallocate to accomodate for. | EntitySystem/MovieSceneEntitySystemTypes.h | |
| NumComponents | uint16 | The number of component and tag types in this allocation (also defines the number of ComponentHeaders). | EntitySystem/MovieSceneEntitySystemTypes.h | |
| SerialNumber | uint64 | Assigned to FEntityManager::GetSystemSerial whenever this allocation is written to | EntitySystem/MovieSceneEntitySystemTypes.h | |
| Size | uint16 | The number of entities currently allocated within this block. | EntitySystem/MovieSceneEntitySystemTypes.h | |
| UniqueID | uint32 | Unique Identifier within this allocation's FEntityManager. | EntitySystem/MovieSceneEntitySystemTypes.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FComponentHeader * FindComponentHeader
(
FComponentTypeID ComponentTypeID |
Find a component header by its type | EntitySystem/MovieSceneEntitySystemTypes.h | |
const FComponentHeader * FindComponentHeader
(
FComponentTypeID ComponentTypeID |
Find a component header by its type | EntitySystem/MovieSceneEntitySystemTypes.h | |
int32 GetCapacity() |
Retrieve the number of entities this allocation can currently house without reallocation | EntitySystem/MovieSceneEntitySystemTypes.h | |
const void * GetComponentDataAddress () |
Retrieve the address of this allocation's component data. | EntitySystem/MovieSceneEntitySystemTypes.h | |
FComponentHeader & GetComponentHeaderChecked
(
FComponentTypeID ComponentTypeID |
Get a reference to a component header by its type. Will fail an assertion if it does not exist. | EntitySystem/MovieSceneEntitySystemTypes.h | |
const FComponentHeader & GetComponentHeaderChecked
(
FComponentTypeID ComponentTypeID |
Get a reference to a component header by its type. Will fail an assertion if it does not exist. | EntitySystem/MovieSceneEntitySystemTypes.h | |
TArrayView< const FComponentHeader > GetComponentHeaders () |
Retrieve all of this allocation's component and tag headers. | EntitySystem/MovieSceneEntitySystemTypes.h | |
| Retrieve all of this allocation's component and tag headers. | EntitySystem/MovieSceneEntitySystemTypes.h | ||
EComponentHeaderLockMode GetCurrentLockMode() |
Get this allocation's current lock mode | EntitySystem/MovieSceneEntitySystemTypes.h | |
TArrayView< const FMovieSceneEntityID > GetEntityIDs() |
Retrieve all of this allocation's entity IDs | EntitySystem/MovieSceneEntitySystemTypes.h | |
int32 GetMaxCapacity() |
Retrieve the maximum number of entities that this allocation is allowed to grow to until a new one must be made | EntitySystem/MovieSceneEntitySystemTypes.h | |
int32 GetNumComponentTypes() |
Get the number of component types and tags that exist within this allocation | EntitySystem/MovieSceneEntitySystemTypes.h | |
const FMovieSceneEntityID * GetRawEntityIDs() |
Retrieve all of this allocation's entity IDs as a raw ptr | EntitySystem/MovieSceneEntitySystemTypes.h | |
int32 GetSlack() |
Retrieve the amount of empty space within this allocation | EntitySystem/MovieSceneEntitySystemTypes.h | |
uint32 GetUniqueID () |
Get the unique identifier for this allocation. | EntitySystem/MovieSceneEntitySystemTypes.h | |
bool HasComponent
(
FComponentTypeID ComponentTypeID |
Check whether this allocation has the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
bool HasStructureChangedSince
(
uint64 InSystemVersion |
Retrieve this allocation's serial number. | EntitySystem/MovieSceneEntitySystemTypes.h | |
int32 Num() |
Retrieve the number of entities in this allocation | EntitySystem/MovieSceneEntitySystemTypes.h | |
void PostModifyStructure
(
FEntityAllocationWriteContext InWriteContext |
EntitySystem/MovieSceneEntitySystemTypes.h | ||
void PostModifyStructureExcludingHeaders
(
FEntityAllocationWriteContext InWriteContext |
Called when this allocation has been modified. | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< TRead< T > > ReadComponents
(
TComponentTypeID< T > ComponentType |
Read typed component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< FReadErased > ReadComponentsErased
(
FComponentTypeID ComponentType |
Read type-erased component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< TReadOptional< T > > TryReadComponents
(
TComponentTypeID< T > ComponentType |
Write typed component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< FReadErasedOptional > TryReadComponentsErased
(
FComponentTypeID ComponentType |
Attempt to read type-erased component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< TWriteOptional< T > > TryWriteComponents
(
TComponentTypeID< T > ComponentType, |
Attempt to write typed component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< FWriteErasedOptional > TryWriteComponentsErased
(
FComponentTypeID ComponentType, |
Attempt to write type-erased component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< TWrite< T > > WriteComponents
(
TComponentTypeID< T > ComponentType, |
Write typed component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h | |
TComponentLock< FWriteErased > WriteComponentsErased
(
FComponentTypeID ComponentType, |
Write type-erased component data for the specified component type | EntitySystem/MovieSceneEntitySystemTypes.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FEntityAllocation & operator=
(
const FEntityAllocation& |
EntitySystem/MovieSceneEntitySystemTypes.h |