Function animate

Synopsis

#include <Source/Falcor/Scene/Animation/AnimationController.h>

bool animate(RenderContext *pContext, double currentTime)

Description

Run the animation

Return
true if a change occurred, otherwise false

Source

Lines 85-124 in Source/Falcor/Scene/Animation/AnimationController.cpp. Line 85 in Source/Falcor/Scene/Animation/AnimationController.h.

bool AnimationController::animate(RenderContext* pContext, double currentTime)
{
    PROFILE("animate");
    mMatricesChanged.assign(mMatricesChanged.size(), false);
    if (mAnimationChanged == false)
    {
        if (!mEnabled || !hasAnimations()) return false;
        if (mLastAnimationTime == currentTime)
        {
            // Copy the current matrices to the previous matrices. We can do that only once, but not sure if it we'll help perf (it only occures when the animation is paused)
            pContext->copyResource(mpPrevWorldMatricesBuffer.get(), mpWorldMatricesBuffer.get());
            return false;
        }
    }
    else initLocalMatrices();
    mAnimationChanged = false;
    mLastAnimationTime = currentTime;
    if (mEnabled)
    {
        for (auto& pAnimation : mAnimations)
        {
            pAnimation->animate(currentTime, mLocalMatrices);
            for (uint32_t i = 0; i < pAnimation->getChannelCount(); i++)
            {
                mMatricesChanged[pAnimation->getChannelMatrixID(i)] = true;
            }
        }
    }
    swap(mpPrevWorldMatricesBuffer, mpWorldMatricesBuffer);
    updateMatrices();
    bindBuffers();
    executeSkinningPass(pContext);
    return true;
}





Add Discussion as Guest

Log in to DocsForge