class AnimationScene

Keeps track of all active animations in a single scene instance.

Queues animation thread tasks and synchronizes data between main, render and animation threads.

Public

Constructors

AnimationScene

AnimationScene()

Methods

SetPaused

void SetPaused(bool paused)

Pauses or resumes the animation evaluation.

SetUpdateRate

void SetUpdateRate(u32 fps)

Determines how often to evaluate animations.

If rendering is not running at adequate framerate the animation could end up being evaluated less times than specified here.

fps
Number of frames per second to evaluate the animation. Default is 60.

Update

const EvaluatedAnimationData *Update(bool async = true)

Evaluates animations for all animated objects, and returns the evaluated skeleton bone poses and morph shape meshes that can be passed along to the renderer.

async
If true the method returns immediately while the animation gets evaluated in the background. The returned evaluated data will be the data from the previous frame. Therefore note that this introduces a one frame latency on the animation. If the latency is not acceptable set this to false, at a potential performance impact.

Returns: Evaluated animation data for this frame (if is false), or the previous frame (if is true). Note that the system re-uses the returned buffers, and the returned buffer should stop being used after every second call to Update(). This is enough to have one buffer be processed by the render thread, one queued for future rendering and one that's being written to.

staticCreate

static SPtr<AnimationScene> Create()

Creates a new empty animation scene.

Internal

Methods

SetOwner

void SetOwner(const SPtr<SceneInstance> &scene)

Scene instance that owns this animation scene.

Private

Methods

RegisterAnimation

u64 RegisterAnimation(Animation *animation)

Registers a new animation and returns a unique ID for it.

Must be called whenever an Animation is constructed.

UnregisterAnimation

void UnregisterAnimation(u64 id)

Unregisters an animation with the specified ID.

Must be called before an Animation is destroyed.

EvaluateAnimation

void EvaluateAnimation(AnimationProxy *anim, u32 &outBoneIndex)

Evaluates animation for a single object and writes the result in the currently active write buffer.

anim
Proxy representing the animation to evaluate.
outBoneIndex
Index in the output buffer in which to write evaluated bone information. This will be automatically advanced by the number of written bone transforms.

Fields

mNextId

u64 mNextId

mAnimations

UnorderedMap<u64, Animation *> mAnimations

mUpdateRate

float mUpdateRate

mAnimationTime

float mAnimationTime

mLastAnimationUpdateTime

float mLastAnimationUpdateTime

mNextAnimationUpdateTime

float mNextAnimationUpdateTime

mLastAnimationDeltaTime

float mLastAnimationDeltaTime

mPaused

bool mPaused

mBlendShapeVertexDescription

SPtr<VertexDescription> mBlendShapeVertexDescription

mProxies

Vector<SPtr<AnimationProxy>> mProxies

mCullFrustums

Vector<ConvexVolume> mCullFrustums

mAnimData

mPoseReadBufferIndex

u32 mPoseReadBufferIndex

mPoseWriteBufferIndex

u32 mPoseWriteBufferIndex

mMutex

Mutex mMutex

mWorkerWaitGroup

WaitGroup mWorkerWaitGroup

mSwapBuffers

bool mSwapBuffers

mOwner

WeakSPtr<SceneInstance> mOwner