Nebula
Loading...
Searching...
No Matches
Animation::AnimSequencer Class Reference

#include <animsequencer.h>

Detailed Description

An AnimSequencer object arranges AnimJobs along the time line to produce a single, priority-blended result.

AnimJobs which are overlapping on the time-line will be blended by the following rules:

  • AnimJobs with a higher blend priority dominate lower-priority anim jobs
  • if AnimJobs have the same blend priority, the start time of the anim job is used to determine blend priority (jobs which start later dominate jobs which start earlier)

(C) 2008 Radon Labs GmbH (C) 2013-2018 Individual contributors, see AUTHORS file

Public Member Functions

 AnimSequencer ()
 constructor
 
 ~AnimSequencer ()
 destructor
 
void Setup (const Ptr< CoreAnimation::AnimResource > &animResource)
 setup the animation controller
 
void Discard ()
 discard the anim sequencer
 
bool IsValid () const
 return true if between Setup/Discard
 
void SetDebugHudEnabled (bool b)
 enable/disable the debug hud
 
bool IsDebugHudEnabled () const
 get debug hud enabled state
 
void EnqueueAnimJob (const Ptr< AnimJob > &animJob)
 enqueue an anim job
 
void StopTrack (IndexT trackIndex, bool allowFadeOut=true)
 stop all anim jobs on given track
 
void StopAllTracks (bool allowFadeOut=true)
 stop all animations on all tracks
 
void PauseTrack (IndexT trackIndex, bool pause)
 pauses all anim jobs on a given track
 
void PauseAllTracks (bool pause)
 pauses all animations on all tracks
 
void SetTime (Timing::Tick time)
 sets time for all tracks in sequencer
 
void UpdateTime (Timing::Tick time)
 update the animation sequencer time
 
bool StartAsyncEvaluation (const Ptr< Jobs::JobPort > &jobPort)
 start asynchronous animation update, returns false if nothing had to be done
 
Timing::Tick GetTime () const
 get the currently set time
 
const Ptr< CoreAnimation::AnimSampleBuffer > & GetResult () const
 get the final sampled result of the last evaluation
 
const Ptr< CoreAnimation::AnimResource > & GetAnimResource () const
 get pointer to animation resource object
 
Util::Array< Ptr< AnimJob > > GetAllAnimJobs () const
 get all anim jobs
 
Util::Array< Ptr< AnimJob > > GetAnimJobsByTrackIndex (IndexT trackIndex) const
 get currently active anim jobs filtered by track index
 
Util::Array< Ptr< AnimJob > > GetAnimJobsByName (const Util::StringAtom &name) const
 get anim jobs by name
 
Util::Array< AnimEventInfoEmitAnimEvents (Timing::Tick startTime, Timing::Tick endTime, bool justDominatingJob, const Util::String &optionalCategory="") const
 FIXME FIXME FIXME: emit anim event infos.
 

Private Member Functions

void EnqueueAnimJobForStopping (const Ptr< AnimJob > &animJob)
 stop a single anim job allowing fade-out (private helper method)
 
void DiscardAnimJob (Ptr< AnimJob > animJob)
 discard a single anim job immediately from the sequencer
 
void InsertEnqueuedAnimJobs (Timing::Tick time)
 insert new anim jobs (called from UpdateTime)
 
void UpdateStoppedAnimJobs (Timing::Tick time)
 update stopped anim jobs (called from UpdateTime)
 
void RemoveExpiredAnimJobs (Timing::Tick time)
 delete expired anim jobs
 
void UpdateTimeActiveAnimJobs (Timing::Tick time)
 update active animjobs times
 
IndexT FindDominatingAnimJobIndex (Timing::Tick startTime, Timing::Tick endTime) const
 FIXME FIXME FIXME: helper method, for determining dominating job.
 
void DebugRenderHud (Timing::Tick time)
 render a graphical debug hud
 
void DebugGenAnimJobRectangle (Timing::Tick timeOrigin, const Ptr< AnimJob > &animJob, Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > &outVertices)
 generate a debug visualization rectangle for an anim job
 
CoreGraphics::RenderShape::RenderShapeVertex DebugViewSpaceCoord (Timing::Tick timeOrigin, Timing::Tick time, IndexT trackIndex)
 compute a screen coordinate (0..1) for a time and track index
 
void DebugRenderLineList (const Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > &vertices, const Math::float4 &color)
 debug visualization: render a line list (FIXME: something like this should be offered by the debug rendering system directly)
 
void DebugRenderAnimJobText (Timing::Tick timeOrigin, const Ptr< AnimJob > &animJob, const Math::float4 &color)
 debug visualization: render the anim job text
 
void DebugGenTrackLines (SizeT maxTracks, Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > &outVertices)
 debug visualization: generate the lines for the track list
 

Private Attributes

Timing::Tick time
 
Ptr< CoreAnimation::AnimResourceanimResource
 
Ptr< CoreAnimation::AnimSampleBufferdstSampleBuffer
 
Util::Array< Ptr< AnimJob > > enqueuedAnimJobs
 
Util::Array< Ptr< AnimJob > > stoppedAnimJobs
 
Util::Array< Ptr< AnimJob > > animJobs
 
Util::Array< Ptr< Jobs::Job > > jobChain
 
bool debugHudEnabled
 

Constructor & Destructor Documentation

◆ AnimSequencer()

Animation::AnimSequencer::AnimSequencer ( )

constructor

◆ ~AnimSequencer()

Animation::AnimSequencer::~AnimSequencer ( )

destructor

Member Function Documentation

◆ DebugGenAnimJobRectangle()

void Animation::AnimSequencer::DebugGenAnimJobRectangle ( Timing::Tick timeOrigin,
const Ptr< AnimJob > & animJob,
Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > & outVertices )
private

generate a debug visualization rectangle for an anim job

Generate vertices to render an anim job rectangle and append them to the provided vertex array.

◆ DebugGenTrackLines()

void Animation::AnimSequencer::DebugGenTrackLines ( SizeT maxTracks,
Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > & outVertices )
private

debug visualization: generate the lines for the track list

Generate the track lines for debug visualization.

◆ DebugRenderAnimJobText()

void Animation::AnimSequencer::DebugRenderAnimJobText ( Timing::Tick timeOrigin,
const Ptr< AnimJob > & animJob,
const Math::float4 & color )
private

debug visualization: render the anim job text

Render the debug text for an anim job.

FIXME: these coordinate transformations suck... the debug visualization subsystem should allow to render text either in screen space or world space.

◆ DebugRenderHud()

void Animation::AnimSequencer::DebugRenderHud ( Timing::Tick time)
private

render a graphical debug hud

Dump debug info about this frame's state.

Render a debug visualisation hud of the AnimSequencer. FIXME: hmm 2D visualization is tricky ATM.

◆ DebugRenderLineList()

void Animation::AnimSequencer::DebugRenderLineList ( const Util::Array< CoreGraphics::RenderShape::RenderShapeVertex > & vertices,
const Math::float4 & color )
private

debug visualization: render a line list (FIXME: something like this should be offered by the debug rendering system directly)

Render a debug line list.

FIXME: the DebugShapeRenderer should allow for a method like this!

◆ DebugViewSpaceCoord()

CoreGraphics::RenderShape::RenderShapeVertex Animation::AnimSequencer::DebugViewSpaceCoord ( Timing::Tick timeOrigin,
Timing::Tick time,
IndexT trackIndex )
private

compute a screen coordinate (0..1) for a time and track index

Debug visualization: convert a time value and track index into a view space coordinates.

Range is from -1.0 to +1.0 for x and y, and a negative value for z.

◆ Discard()

void Animation::AnimSequencer::Discard ( )

discard the anim sequencer

FIXME: do we have to wait for the anim jobs to finish here??

◆ DiscardAnimJob()

void Animation::AnimSequencer::DiscardAnimJob ( Ptr< AnimJob > animJob)
private

discard a single anim job immediately from the sequencer

Cancel an anim job, this will immediately remove the anim job from the sequencer.

This is a private helper method. The anim job may either reside in the animJobs or enqueuedAnimJobs array.

NOTE: the ref-by-copy argument is intended!

◆ EmitAnimEvents()

Util::Array< AnimEventInfo > Animation::AnimSequencer::EmitAnimEvents ( Timing::Tick startTime,
Timing::Tick endTime,
bool justDominatingJob,
const Util::String & optionalCatgeory = "" ) const

FIXME FIXME FIXME: emit anim event infos.

Collects all AnimEventInfos of all animjobs which are active in the given time range.

If justDominatingJob flag is set, just use the clip with most blend factor.

◆ EnqueueAnimJob()

void Animation::AnimSequencer::EnqueueAnimJob ( const Ptr< AnimJob > & animJob)

enqueue an anim job

Enqueue an anim job.

This will schedule the anim job for insertion in the next Evaluate(). This deferred handling is necessary because the actual base time of the anim job job is only known in Evaluate() (need to be careful to prevent those pesky one-frame problems).

◆ EnqueueAnimJobForStopping()

void Animation::AnimSequencer::EnqueueAnimJobForStopping ( const Ptr< AnimJob > & animJob)
private

stop a single anim job allowing fade-out (private helper method)

Stop an anim job (allow fade-out), this is a private helper method.

The anim job will simply be appended to the stoppedAnimJobs array, and it will be taken care of during the next UpdateStoppedAnimJobs().

NOTE: anim jobs which may already be stopping will be handled here as well, but those will be skipped in UpdateStoppedAnimJobs()!

◆ FindDominatingAnimJobIndex()

IndexT Animation::AnimSequencer::FindDominatingAnimJobIndex ( Timing::Tick startTime,
Timing::Tick endTime ) const
private

FIXME FIXME FIXME: helper method, for determining dominating job.

Find the dominating, active job.

◆ GetAllAnimJobs()

Array< Ptr< AnimJob > > Animation::AnimSequencer::GetAllAnimJobs ( ) const

get all anim jobs

◆ GetAnimJobsByName()

Array< Ptr< AnimJob > > Animation::AnimSequencer::GetAnimJobsByName ( const Util::StringAtom & name) const

get anim jobs by name

◆ GetAnimJobsByTrackIndex()

Array< Ptr< AnimJob > > Animation::AnimSequencer::GetAnimJobsByTrackIndex ( IndexT trackIndex) const

get currently active anim jobs filtered by track index

◆ GetAnimResource()

const Ptr< CoreAnimation::AnimResource > & Animation::AnimSequencer::GetAnimResource ( ) const
inline

get pointer to animation resource object

◆ GetResult()

const Ptr< CoreAnimation::AnimSampleBuffer > & Animation::AnimSequencer::GetResult ( ) const
inline

get the final sampled result of the last evaluation

◆ GetTime()

Timing::Tick Animation::AnimSequencer::GetTime ( ) const
inline

get the currently set time

◆ InsertEnqueuedAnimJobs()

void Animation::AnimSequencer::InsertEnqueuedAnimJobs ( Timing::Tick time)
private

insert new anim jobs (called from UpdateTime)

This method priority-inserts new anim jobs from the startedAnimJobs array into the animJobs array and sets the base time of the anim job so that it is properly synchronized with the current time.

This method is called from Evaluate().

Anim jobs will always be sorted behind existing jobs with the same track index. The base time will be set to the finish time of the last anim job on the same track.

There are 2 exceptions to the rule:

if an infinite animation track with the same track index exists (which is not currently stopping), then the new anim job will be dropped if another, active anim job with the same exclusive tag exists on the same track, the new anim job will be dropped

◆ IsDebugHudEnabled()

bool Animation::AnimSequencer::IsDebugHudEnabled ( ) const
inline

get debug hud enabled state

◆ IsValid()

bool Animation::AnimSequencer::IsValid ( ) const
inline

return true if between Setup/Discard

◆ PauseAllTracks()

void Animation::AnimSequencer::PauseAllTracks ( bool pause)

pauses all animations on all tracks

◆ PauseTrack()

void Animation::AnimSequencer::PauseTrack ( IndexT trackIndex,
bool pause )

pauses all anim jobs on a given track

◆ RemoveExpiredAnimJobs()

void Animation::AnimSequencer::RemoveExpiredAnimJobs ( Timing::Tick time)
private

delete expired anim jobs

Iterates through the currently attached anim jobs and removes all anim jobs which are expired.

This method is called from Evaluate().

◆ SetDebugHudEnabled()

void Animation::AnimSequencer::SetDebugHudEnabled ( bool b)
inline

enable/disable the debug hud

◆ SetTime()

void Animation::AnimSequencer::SetTime ( Timing::Tick time)

sets time for all tracks in sequencer

◆ Setup()

void Animation::AnimSequencer::Setup ( const Ptr< CoreAnimation::AnimResource > & animResource)

setup the animation controller

◆ StartAsyncEvaluation()

bool Animation::AnimSequencer::StartAsyncEvaluation ( const Ptr< Jobs::JobPort > & jobPort)

start asynchronous animation update, returns false if nothing had to be done

This method should be called once per-frame for each visible animated object AFTER UpdateTime() has been called.

Actual animation sampling and mixing happens here.

◆ StopAllTracks()

void Animation::AnimSequencer::StopAllTracks ( bool allowFadeOut = true)

stop all animations on all tracks

Stop or cancel all anim jobs in the sequencer.

◆ StopTrack()

void Animation::AnimSequencer::StopTrack ( IndexT trackIndex,
bool allowFadeOut = true )

stop all anim jobs on given track

Stop or cancel all anim jobs on a given track.

◆ UpdateStoppedAnimJobs()

void Animation::AnimSequencer::UpdateStoppedAnimJobs ( Timing::Tick time)
private

update stopped anim jobs (called from UpdateTime)

This method updates the duration of each new stopped anim job so that it will stop at "now + fadeOutTime".

This method is called from Evaluate() with the current evaluation time.

◆ UpdateTime()

void Animation::AnimSequencer::UpdateTime ( Timing::Tick curTime)

update the animation sequencer time

Update the current time of the sequencer.

This should be called exactly once per frame, even if the animated object is currently invisible (near the camera but outside the view volume). This will update the anim jobs which have been started or stopped this frame, and it will remove expired anim jobs, but will not sample the animation.

◆ UpdateTimeActiveAnimJobs()

void Animation::AnimSequencer::UpdateTimeActiveAnimJobs ( Timing::Tick time)
private

update active animjobs times

Member Data Documentation

◆ animJobs

Util::Array<Ptr<AnimJob> > Animation::AnimSequencer::animJobs
private

◆ animResource

Ptr<CoreAnimation::AnimResource> Animation::AnimSequencer::animResource
private

◆ debugHudEnabled

bool Animation::AnimSequencer::debugHudEnabled
private

◆ dstSampleBuffer

Ptr<CoreAnimation::AnimSampleBuffer> Animation::AnimSequencer::dstSampleBuffer
private

◆ enqueuedAnimJobs

Util::Array<Ptr<AnimJob> > Animation::AnimSequencer::enqueuedAnimJobs
private

◆ jobChain

Util::Array<Ptr<Jobs::Job> > Animation::AnimSequencer::jobChain
private

◆ stoppedAnimJobs

Util::Array<Ptr<AnimJob> > Animation::AnimSequencer::stoppedAnimJobs
private

◆ time

Timing::Tick Animation::AnimSequencer::time
private

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