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::MultiThreadScheduler Class Reference

#include <MultiThreadScheduler.h>

Inherits EMotionFX::ActorUpdateScheduler.

Classes

struct  ScheduleStep
 

Public Types

enum  { TYPE_ID = 0x00000002 }
 

Public Member Functions

const char * GetName () const override
 
uint32 GetType () const override
 
void Execute (float timePassedInSeconds) override
 
void Print () override
 
void Clear () override
 
void RemoveEmptySteps ()
 
void RecursiveInsertActorInstance (ActorInstance *actorInstance, size_t startStep=0) override
 
void RecursiveRemoveActorInstance (ActorInstance *actorInstance, size_t startStep=0) override
 
size_t RemoveActorInstance (ActorInstance *actorInstance, size_t startStep=0) override
 
void Lock ()
 
void Unlock ()
 
const ScheduleStepGetScheduleStep (size_t index) const
 
size_t GetNumScheduleSteps () const
 
- Public Member Functions inherited from EMotionFX::ActorUpdateScheduler
virtual const char * GetName () const =0
 
virtual uint32 GetType () const =0
 
virtual void Execute (float timePassedInSeconds)=0
 
virtual void Clear ()=0
 
virtual void Print ()
 
virtual void RecursiveInsertActorInstance (ActorInstance *actorInstance, size_t startStep=0)=0
 
virtual void RecursiveRemoveActorInstance (ActorInstance *actorInstance, size_t startStep=0)=0
 
virtual size_t RemoveActorInstance (ActorInstance *actorInstance, size_t startStep=0)=0
 
size_t GetNumUpdatedActorInstances () const
 
size_t GetNumVisibleActorInstances () const
 
size_t GetNumSampledActorInstances () const
 
- 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 MultiThreadSchedulerCreate ()
 

Protected Member Functions

bool HasActorInstanceInSteps (const ActorInstance *actorInstance) const
 
 MultiThreadScheduler ()
 
virtual ~MultiThreadScheduler ()
 
bool CheckIfHasMatchingDependency (ActorInstance *instance, ScheduleStep *step) const
 
bool FindNextFreeItem (ActorInstance *actorInstance, size_t startStep, size_t *outStepNr)
 
void AddDependenciesToStep (ActorInstance *instance, ScheduleStep *outStep)
 
- Protected Member Functions inherited from EMotionFX::ActorUpdateScheduler
 ActorUpdateScheduler ()
 
virtual ~ActorUpdateScheduler ()
 
- Protected Member Functions inherited from EMotionFX::BaseObject
void Delete () override
 
virtual void Delete ()
 

Protected Attributes

AZStd::vector< ScheduleStepm_steps
 
float m_cleanTimer
 
MCore::MutexRecursive m_mutex
 
- Protected Attributes inherited from EMotionFX::ActorUpdateScheduler
MCore::AtomicSizeT m_numUpdated
 
MCore::AtomicSizeT m_numVisible
 
MCore::AtomicSizeT m_numSampled
 

Detailed Description

The multi processor scheduler. This class can manage the actor instances in such a way that multiple actor instances can be processed at the same time without getting any conflicts with shared memory. If however you wish to let EMotion FX only use one single CPU, or if the target system ahs only one CPU, it is recommended to use the SingleThreadScheduler class instead, as that will be faster in that specific case. Significant performance gains can be achieved by using this scheduler on multi-processor or multi-core systems though.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

The unique type ID of this scheduler, as returned by the GetType() method.

Constructor & Destructor Documentation

◆ MultiThreadScheduler()

EMotionFX::MultiThreadScheduler::MultiThreadScheduler ( )
protected

The constructor.

◆ ~MultiThreadScheduler()

virtual EMotionFX::MultiThreadScheduler::~MultiThreadScheduler ( )
protectedvirtual

The destructor.

Member Function Documentation

◆ AddDependenciesToStep()

void EMotionFX::MultiThreadScheduler::AddDependenciesToStep ( ActorInstance instance,
ScheduleStep outStep 
)
protected

Add the dependencies of a given actor instance to a specified scheduler step. This will also prevent any duplicated dependencies. So dependencies that are already inside the step will not be added again.

Parameters
instanceThe actor instance to add the dependencies from.
outStepThe scheduler step to add the dependencies to.

◆ CheckIfHasMatchingDependency()

bool EMotionFX::MultiThreadScheduler::CheckIfHasMatchingDependency ( ActorInstance instance,
ScheduleStep step 
) const
protected

Check if a given update step has any similar dependencies than the specified actor instance. If this is the case, the specified actor instance can't be inserted inside the same scheduler step, as it would conflict with the other actor instances inside it.

Parameters
instanceThe acotr instance to test.
stepThe scheduler step to test.
Returns
Returns true when there are matching dependencies, otherwise false is returned.

◆ Clear()

void EMotionFX::MultiThreadScheduler::Clear ( )
overridevirtual

Clear the schedule.

Implements EMotionFX::ActorUpdateScheduler.

◆ Create()

static MultiThreadScheduler * EMotionFX::MultiThreadScheduler::Create ( )
static

The constructor.

◆ Execute()

void EMotionFX::MultiThreadScheduler::Execute ( float  timePassedInSeconds)
overridevirtual

The main method which will execute all callbacks, which on their turn will check for visibilty, perform updates and render.

Parameters
timePassedInSecondsThe time passed, in seconds, since the last call to the update.

Implements EMotionFX::ActorUpdateScheduler.

◆ FindNextFreeItem()

bool EMotionFX::MultiThreadScheduler::FindNextFreeItem ( ActorInstance actorInstance,
size_t  startStep,
size_t *  outStepNr 
)
protected

Find the next free spot in the schedule where we can insert a given actor instance.

Parameters
actorInstanceThe actor instance we are trying to insert.
startStepThe step offset in the scheduler, to start searching from.
outStepNrThis will contain the step number in which we can insert the actor instance.
Returns
Returns false when there is no step where we can insert in. A new step will have to be added.

◆ GetName()

const char * EMotionFX::MultiThreadScheduler::GetName ( ) const
inlineoverridevirtual

Get the name of this class, or a description.

Returns
The string containing the name of the scheduler.

Implements EMotionFX::ActorUpdateScheduler.

◆ GetType()

uint32 EMotionFX::MultiThreadScheduler::GetType ( ) const
inlineoverridevirtual

Get the unique type ID of the scheduler type. All schedulers will have another ID, so that you can use this to identify what scheduler you are dealing with.

Returns
The unique ID of the scheduler type.

Implements EMotionFX::ActorUpdateScheduler.

◆ Print()

void EMotionFX::MultiThreadScheduler::Print ( )
overridevirtual

LOG the schedule using the LOG method. This can for example show the update order, in which order the actor instances will be updated.

Reimplemented from EMotionFX::ActorUpdateScheduler.

◆ RecursiveInsertActorInstance()

void EMotionFX::MultiThreadScheduler::RecursiveInsertActorInstance ( ActorInstance actorInstance,
size_t  startStep = 0 
)
overridevirtual

Recursively insert an actor instance into the schedule, including all its attachments.

Parameters
actorInstanceThe actor instance to insert.
startStepAn offset in the schedule where to start trying to insert the actor instances.

Implements EMotionFX::ActorUpdateScheduler.

◆ RecursiveRemoveActorInstance()

void EMotionFX::MultiThreadScheduler::RecursiveRemoveActorInstance ( ActorInstance actorInstance,
size_t  startStep = 0 
)
overridevirtual

Recursively remove an actor instance and its attachments from the schedule.

Parameters
actorInstanceThe actor instance to remove.
startStepAn offset in the schedule where to start trying to remove from.

Implements EMotionFX::ActorUpdateScheduler.

◆ RemoveActorInstance()

size_t EMotionFX::MultiThreadScheduler::RemoveActorInstance ( ActorInstance actorInstance,
size_t  startStep = 0 
)
overridevirtual

Remove a single actor instance from the schedule. This will not remove its attachments.

Parameters
actorInstanceThe actor instance to remove.
startStepAn offset in the schedule where to start trying to remove from.
Returns
Returns the offset in the schedule where the actor instance was removed.

Implements EMotionFX::ActorUpdateScheduler.

◆ RemoveEmptySteps()

void EMotionFX::MultiThreadScheduler::RemoveEmptySteps ( )

Remove all empty scheduler steps.

Member Data Documentation

◆ m_cleanTimer

float EMotionFX::MultiThreadScheduler::m_cleanTimer
protected

The time passed since the last automatic call to the Optimize method.

◆ m_steps

AZStd::vector< ScheduleStep > EMotionFX::MultiThreadScheduler::m_steps
protected

An array of update steps, that together form the schedule.


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