From b215f88a29fb36d66f3b38b559d3c28803697ab5 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sun, 17 Jul 2011 17:16:16 +0000 Subject: [PATCH] Now the anim is expanded to the whole length for non cycled anims. To demonstrate we have growing reed ... --- .../sources/graphics/interpolation.cpp | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/source/shared_lib/sources/graphics/interpolation.cpp b/source/shared_lib/sources/graphics/interpolation.cpp index 753b2644f..5d980f176 100644 --- a/source/shared_lib/sources/graphics/interpolation.cpp +++ b/source/shared_lib/sources/graphics/interpolation.cpp @@ -102,9 +102,22 @@ void InterpolationData::updateVertices(float t, bool cycle) { const Vec3f *meshVertices= mesh->getVertices(); //misc vars - uint32 prevFrame= min(static_cast(t*frameCount), frameCount-1); - uint32 nextFrame= cycle? (prevFrame+1) % frameCount: min(prevFrame+1, frameCount-1); - float localT= t*frameCount - prevFrame; + uint32 prevFrame; + uint32 nextFrame; + float localT; + + if(cycle == true) { + prevFrame= min(static_cast(t*frameCount), frameCount-1); + nextFrame= (prevFrame+1) % frameCount; + localT= t*frameCount - prevFrame; + } + else { + prevFrame= min (static_cast (t * (frameCount-1)), frameCount - 2); + nextFrame= min(prevFrame + 1, frameCount - 1); + localT= t * (frameCount-1) - prevFrame; + //printf(" prevFrame=%d nextFrame=%d localT=%f\n",prevFrame,nextFrame,localT); + } + uint32 prevFrameBase= prevFrame*vertexCount; uint32 nextFrameBase= nextFrame*vertexCount; @@ -145,9 +158,22 @@ void InterpolationData::updateNormals(float t, bool cycle){ const Vec3f *meshNormals= mesh->getNormals(); //misc vars - uint32 prevFrame= min(static_cast(t*frameCount), frameCount-1); - uint32 nextFrame= cycle? (prevFrame+1) % frameCount: min(prevFrame+1, frameCount-1); - float localT= t*frameCount - prevFrame; + uint32 prevFrame; + uint32 nextFrame; + float localT; + + if(cycle == true) { + prevFrame= min(static_cast(t*frameCount), frameCount-1); + nextFrame= (prevFrame+1) % frameCount; + localT= t*frameCount - prevFrame; + } + else { + prevFrame= min (static_cast (t * (frameCount-1)), frameCount - 2); + nextFrame= min(prevFrame + 1, frameCount - 1); + localT= t * (frameCount-1) - prevFrame; + //printf(" prevFrame=%d nextFrame=%d localT=%f\n",prevFrame,nextFrame,localT); + } + uint32 prevFrameBase= prevFrame*vertexCount; uint32 nextFrameBase= nextFrame*vertexCount;