Nebula
|
#include <animsequencer.h>
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:
(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< AnimEventInfo > | EmitAnimEvents (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::AnimResource > | animResource |
Ptr< CoreAnimation::AnimSampleBuffer > | dstSampleBuffer |
Util::Array< Ptr< AnimJob > > | enqueuedAnimJobs |
Util::Array< Ptr< AnimJob > > | stoppedAnimJobs |
Util::Array< Ptr< AnimJob > > | animJobs |
Util::Array< Ptr< Jobs::Job > > | jobChain |
bool | debugHudEnabled |
Animation::AnimSequencer::AnimSequencer | ( | ) |
constructor
Animation::AnimSequencer::~AnimSequencer | ( | ) |
destructor
|
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.
|
private |
debug visualization: generate the lines for the track list
Generate the track lines for debug visualization.
|
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.
|
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.
|
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!
|
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.
void Animation::AnimSequencer::Discard | ( | ) |
discard the anim sequencer
FIXME: do we have to wait for the anim jobs to finish here??
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!
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.
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).
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()!
|
private |
FIXME FIXME FIXME: helper method, for determining dominating job.
Find the dominating, active job.
Array< Ptr< AnimJob > > Animation::AnimSequencer::GetAnimJobsByName | ( | const Util::StringAtom & | name | ) | const |
get anim jobs by name
Array< Ptr< AnimJob > > Animation::AnimSequencer::GetAnimJobsByTrackIndex | ( | IndexT | trackIndex | ) | const |
get currently active anim jobs filtered by track index
|
inline |
get pointer to animation resource object
|
inline |
get the final sampled result of the last evaluation
|
inline |
get the currently set 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
|
inline |
get debug hud enabled state
|
inline |
return true if between Setup/Discard
void Animation::AnimSequencer::PauseAllTracks | ( | bool | pause | ) |
pauses all animations on all tracks
void Animation::AnimSequencer::PauseTrack | ( | IndexT | trackIndex, |
bool | pause ) |
pauses all anim jobs on a given track
|
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().
|
inline |
enable/disable the debug hud
void Animation::AnimSequencer::SetTime | ( | Timing::Tick | time | ) |
sets time for all tracks in sequencer
void Animation::AnimSequencer::Setup | ( | const Ptr< CoreAnimation::AnimResource > & | animResource | ) |
setup the animation controller
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.
void Animation::AnimSequencer::StopAllTracks | ( | bool | allowFadeOut = true | ) |
stop all animations on all tracks
Stop or cancel all anim jobs in the sequencer.
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.
|
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.
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.
|
private |
update active animjobs times
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |