Function animate

Synopsis

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

bool animate(RenderContext *pContext, double currentTime)

Description

Run the animation

Returns
true if a change occurred, otherwise false

Source

Lines 114-152 in Source/Falcor/Scene/Animation/AnimationController.cpp. Line 94 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)
    {
        double time = (mLoopAnimations == true) ? std::fmod(currentTime, mGlobalAnimationLength) : currentTime;
        for (auto& pAnimation : mAnimations)
        {
            uint32_t nodeID = pAnimation->getNodeID();
            mLocalMatrices[nodeID] = pAnimation->animate(time);
            mMatricesChanged[nodeID] = true;
        }
    }
    swap(mpPrevWorldMatricesBuffer, mpWorldMatricesBuffer);
    updateMatrices();
    bindBuffers();
    executeSkinningPass(pContext);
    return true;
}





Add Discussion as Guest

Log in