diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-17 17:16:06 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:08 +0000 |
commit | 6961c308fb9d98006c98654a8131593f390c89a8 (patch) | |
tree | ceca08b394bd3a66d63df6c1873f7a4871e35247 /src/animation/backend/lerpclipblend.cpp | |
parent | 1da93b2fcf57dc442952b65d599db4e209faa59f (diff) |
Add virtual doBlend to ClipBlendNode and subclasses
This is called by the non virtual performBlend (will be renamed
once old implementation is removed). The key here is that all
nodes in the blend tree will have the exact same layout for the
ClipResults for a given animator. This means we don't need to have
a mapping data structure for every node in the tree. This really
simplifies the blending implementation and will allow us to
parallelise this much better in the future as each blend node
could make use of a parallel_for() or map() type operation.
To achieve this we will need to perform a gather operation that
maps the ClipResults coming straight out of an animation clip
to the ClipResults layout used by the blend tree as described
above. This will be done in a follow up commit.
Change-Id: I389383d3b9197a6ef36b529f44ac89cb5c593023
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/backend/lerpclipblend.cpp')
-rw-r--r-- | src/animation/backend/lerpclipblend.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/animation/backend/lerpclipblend.cpp b/src/animation/backend/lerpclipblend.cpp index 7b1efbf50..7e61a35ca 100644 --- a/src/animation/backend/lerpclipblend.cpp +++ b/src/animation/backend/lerpclipblend.cpp @@ -75,6 +75,19 @@ float LerpClipBlend::blend(float value1, float value2) const return ((1.0f - m_blendFactor) * value1) + (m_blendFactor * value2); } +ClipResults LerpClipBlend::doBlend(const QVector<ClipResults> &blendData) const +{ + Q_ASSERT(blendData.size() == 2); + Q_ASSERT(blendData[0].size() == blendData[1].size()); + const int elementCount = blendData.first().size(); + ClipResults blendResults(elementCount); + + for (int i = 0; i < elementCount; ++i) + blendResults[i] = (1.0f - m_blendFactor) * blendData[0][i] + (m_blendFactor * blendData[1][i]); + + return blendResults; +} + void LerpClipBlend::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) { ClipBlendNode::initializeFromPeer(change); |