Open 3D Engine EMotionFX Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
EMotionFX::ActorManager Class Reference

#include <ActorManager.h>

Inherits EMotionFX::BaseObject.

Public Member Functions

void RegisterActor (ActorAssetData actorAsset)
 
void UnregisterAllActors ()
 
void UnregisterActor (AZ::Data::AssetId actorAssetID)
 
MCORE_INLINE size_t GetNumActors () const
 
ActorGetActor (size_t nr) const
 
ActorAssetData GetActorAsset (size_t nr) const
 
ActorFindActorByName (const char *actorName) const
 
ActorFindActorByFileName (const char *fileName) const
 
size_t FindActorIndex (AZ::Data::AssetId assetId) const
 
size_t FindActorIndex (const Actor *actor) const
 
size_t FindActorIndexByName (const char *actorName) const
 
size_t FindActorIndexByFileName (const char *filename) const
 
void RegisterActorInstance (ActorInstance *actorInstance)
 
MCORE_INLINE size_t GetNumActorInstances () const
 
MCORE_INLINE ActorInstanceGetActorInstance (size_t nr) const
 
ActorInstanceGetFirstEditorActorInstance () const
 
const AZStd::vector< ActorInstance * > & GetActorInstanceArray () const
 
size_t FindActorInstanceIndex (ActorInstance *actorInstance) const
 
ActorInstanceFindActorInstanceByID (uint32 id) const
 
ActorFindActorByID (uint32 id) const
 
AZ::Data::AssetId FindAssetIdByActorId (uint32 id) const
 
bool CheckIfIsActorInstanceRegistered (ActorInstance *actorInstance)
 
void UnregisterAllActorInstances ()
 
void UnregisterActorInstance (ActorInstance *instance)
 
void UnregisterActorInstance (size_t nr)
 
MCORE_INLINE size_t GetNumRootActorInstances () const
 
MCORE_INLINE ActorInstanceGetRootActorInstance (size_t nr) const
 
ActorUpdateSchedulerGetScheduler () const
 
void SetScheduler (ActorUpdateScheduler *scheduler, bool delExisting=true)
 
void UpdateActorInstanceStatus (ActorInstance *actorInstance, bool lock=true)
 
void UpdateActorInstances (float timePassedInSeconds)
 
void DestroyAllActorInstances ()
 
void DestroyAllActors ()
 
void LockActorInstances ()
 
void UnlockActorInstances ()
 
void LockActors ()
 
void UnlockActors ()
 
- Public Member Functions inherited from EMotionFX::BaseObject
 BaseObject ()
 
virtual ~BaseObject ()
 
- Public Member Functions inherited from MCore::MemoryObject
 MemoryObject ()
 
virtual ~MemoryObject ()
 
void IncreaseReferenceCount ()
 
void DecreaseReferenceCount ()
 
void Destroy ()
 
uint32 GetReferenceCount () const
 

Static Public Member Functions

static ActorManagerCreate ()
 

Friends

class Initializer
 
class EMotionFXManager
 

Additional Inherited Members

- Protected Member Functions inherited from EMotionFX::BaseObject
void Delete () override
 
virtual void Delete ()
 

Detailed Description

The actor manager. This class maintains a list of registered actors and actor instances that have been created. Also it stores a list of root actor instances, which are roots in the chains of attachments. For example if you attach a cowboy to a horse, the horse is the root actor instance.

Member Function Documentation

◆ CheckIfIsActorInstanceRegistered()

bool EMotionFX::ActorManager::CheckIfIsActorInstanceRegistered ( ActorInstance actorInstance)

Check if the given actor instance is registered.

Parameters
actorInstanceA pointer to the actor instance to be checked.
Returns
True if the actor instance has been found in the registered actor instances, false if not.

◆ FindActorByFileName()

Actor * EMotionFX::ActorManager::FindActorByFileName ( const char *  fileName) const

Find the given actor by filename.

Parameters
[in]fileNameThe filename of the actor.
Returns
A pointer to the actor with the given filename. nullptr in case the actor has not been found.

◆ FindActorByID()

Actor * EMotionFX::ActorManager::FindActorByID ( uint32  id) const

Find an actor inside the actor manager by its id.

Parameters
[in]idThe unique identification number of the actor to be searched.
Returns
A pointer to the actor, nullptr in case the actor hasn't been found.

◆ FindActorByName()

Actor * EMotionFX::ActorManager::FindActorByName ( const char *  actorName) const

Find the given actor by name.

Parameters
[in]actorNameThe name of the actor.
Returns
A pointer to the actor with the given name. nullptr in case the actor has not been found.

◆ FindActorIndex()

size_t EMotionFX::ActorManager::FindActorIndex ( AZ::Data::AssetId  assetId) const

Find the actor number for a given Actor object. This will find the actor number for the Actor object that you passed to RegisterActor before.

Parameters
actorThe actor object you once passed to RegisterActor.
Returns
Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.

◆ FindActorIndexByFileName()

size_t EMotionFX::ActorManager::FindActorIndexByFileName ( const char *  filename) const

Find the actor number for a given actor filename. This will find the actor number for the Actor object that you passed to RegisterActor before.

Parameters
filenameThe filename of the actor.
Returns
Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.

◆ FindActorIndexByName()

size_t EMotionFX::ActorManager::FindActorIndexByName ( const char *  actorName) const

Find the actor number for a given actor name. This will find the actor number for the Actor object that you passed to RegisterActor before.

Parameters
actorNameThe name of the actor.
Returns
Returns the actor number, which is in range of [0..GetNumActors()-1], or returns MCORE_INVALIDINDEX32 when not found.

◆ FindActorInstanceByID()

ActorInstance * EMotionFX::ActorManager::FindActorInstanceByID ( uint32  id) const

Find an actor instance inside the actor manager by its id.

Parameters
[in]idThe unique identification number of the actor instance to be searched.
Returns
A pointer to the actor instance, nullptr in case the actor instance hasn't been found.

◆ FindActorInstanceIndex()

size_t EMotionFX::ActorManager::FindActorInstanceIndex ( ActorInstance actorInstance) const

Find the given actor instance inside the actor manager and return its index.

Parameters
actorInstanceA pointer to the actor instance to be searched.
Returns
The actor instance index for the actor manager, MCORE_INVALIDINDEX32 in case the actor instance hasn't been found.

◆ GetActor()

Actor * EMotionFX::ActorManager::GetActor ( size_t  nr) const

Get a given actor. This will return a Actor object that contains an array of Actor objects. The first Actor in this array will be the actor you passed to RegisterActor. The following Actor objects in the array will be the created clones, if there are any.

Parameters
nrThe actor number, which must be in range of [0..GetNumActors()-1].
Returns
A reference to the actor object that contains the array of Actor objects.

◆ GetActorInstance()

MCORE_INLINE ActorInstance * EMotionFX::ActorManager::GetActorInstance ( size_t  nr) const
inline

Get a given registered actor instance.

Parameters
nrThe actor instance number, which must be in range of [0..GetNumActorInstances()-1].
Returns
A pointer to the actor instance.

◆ GetActorInstanceArray()

const AZStd::vector< ActorInstance * > & EMotionFX::ActorManager::GetActorInstanceArray ( ) const

Get the array of actor instances.

Returns
The const reference to the actor instance array.

◆ GetFirstEditorActorInstance()

ActorInstance * EMotionFX::ActorManager::GetFirstEditorActorInstance ( ) const

Get a given registered actor instance owned by editor (not owned by runtime).

Returns
A pointer to the actor instance.

◆ GetNumActorInstances()

MCORE_INLINE size_t EMotionFX::ActorManager::GetNumActorInstances ( ) const
inline

Get the number of actor instances that currently are registered.

Returns
The number of registered actor instances.

◆ GetNumActors()

MCORE_INLINE size_t EMotionFX::ActorManager::GetNumActors ( ) const
inline

Get the number of registered actors. This does not include the clones that have been optionally created.

Returns
The number of registered actors.

◆ GetNumRootActorInstances()

MCORE_INLINE size_t EMotionFX::ActorManager::GetNumRootActorInstances ( ) const
inline

Get the number of root actor instances. A root actor instance is an actor instance that is no attachment. So if you have a gun attached to a cowboy, where the cowboy is attached to a horse, then the horse is the root attachment instance.

Returns
Returns the number of root actor instances.

◆ GetRootActorInstance()

MCORE_INLINE ActorInstance * EMotionFX::ActorManager::GetRootActorInstance ( size_t  nr) const
inline

Get a given root actor instance. A root actor instance is an actor instance that is no attachment. So if you have a gun attached to a cowboy, where the cowboy is attached to a horse, then the horse is the root attachment instance.

Parameters
nrThe root actor instance number, which must be in range of [0..GetNumRootActorInstances()-1].
Returns
A pointer to the actor instance that is a root.

◆ GetScheduler()

ActorUpdateScheduler * EMotionFX::ActorManager::GetScheduler ( ) const

Get the currently used actor update scheduler.

Returns
A pointer to the actor update scheduler that is currently used.

◆ RegisterActor()

void EMotionFX::ActorManager::RegisterActor ( ActorAssetData  actorAsset)

Register an actor.

Parameters
actorThe actor to register.

◆ SetScheduler()

void EMotionFX::ActorManager::SetScheduler ( ActorUpdateScheduler scheduler,
bool  delExisting = true 
)

Set the scheduler to use. EMotion FX provides two different scheduler implementations: A single threaded scheduler (SingleThreadScheduler) and a multithreaded scheduler (MultiThreadScheduler, the default). The current scheduler will automatically be deleted at application shutdown. The schedulers are responsible for figuring out the update order.

Parameters
schedulerThe new scheduler to use.
delExistingWhen set to true, the existing scheduler, as returned by GetScheduler() will be deleted from memory.

◆ UnregisterActor()

void EMotionFX::ActorManager::UnregisterActor ( AZ::Data::AssetId  actorAssetID)

Unregister a specific actor.

Parameters
actorThe actor you passed to the RegisterActor function sometime before.

◆ UnregisterActorInstance() [1/2]

void EMotionFX::ActorManager::UnregisterActorInstance ( ActorInstance instance)

Unregister a specific actor instance. This does not delete the actual actor instance from memory. When you delete an actor instance, it automatically will unregister itself from the manager. So you will most likely not be calling this method, unless you have a special reason for this.

Parameters
instanceThe actor instance to unregister.

◆ UnregisterActorInstance() [2/2]

void EMotionFX::ActorManager::UnregisterActorInstance ( size_t  nr)

Unregister a given actor instance. This does not delete the actual actor instance from memory. When you delete an actor instance, it automatically will unregister itself from the manager.

Parameters
nrThe actor instance number, which has to be in range of [0..GetNumActorInstances()-1].

◆ UnregisterAllActorInstances()

void EMotionFX::ActorManager::UnregisterAllActorInstances ( )

Unregister all actor instances. Please note that this is already done automatically at application shutdown. The actor instance objects will not be deleted from memory though. When you delete an actor instance, it automatically will unregister itself from the manager.

◆ UnregisterAllActors()

void EMotionFX::ActorManager::UnregisterAllActors ( )

Unregister all actors. This does not release/delete the actual actor objects, but just clears the internal array of actor instances. This method is automatically called at shutdown of your application.

◆ UpdateActorInstances()

void EMotionFX::ActorManager::UpdateActorInstances ( float  timePassedInSeconds)

The main method that will execute the scheduler which will on its turn updates all the actor instances.

Parameters
timePassedInSecondsThe time, in seconds, since the last time you called the Update method.

◆ UpdateActorInstanceStatus()

void EMotionFX::ActorManager::UpdateActorInstanceStatus ( ActorInstance actorInstance,
bool  lock = true 
)

Update the actor instance status for a given actor instance. This checks if the actor instance is still a root actor instance or not and it makes sure that it is registered internally as root actor instance when needed. So this method is being called when attachments change. This is handled automatically.

Parameters
actorInstanceThe actor instance to update the status for.
lockSet to true if you want to automatically call LockActorInstances().

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