From 14f04c5c352643ec98fc954065eeb65651414feb Mon Sep 17 00:00:00 2001 From: titiger Date: Sun, 15 Mar 2015 01:46:49 +0100 Subject: [PATCH] fix for mesh bound particles --- source/glest_game/type_instances/unit.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index bce185dc..8d312724 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -4178,7 +4178,13 @@ void Unit::setMeshPosInParticleSystem(UnitParticleSystem *ups){ if(ups->getMeshName()!=""){ string meshName=ups->getMeshName(); Model *model= getCurrentModelPtr(); - model->updateInterpolationVertices(getAnimProgressAsFloat(), isAlive() && !isAnimProgressBound()); + + // as it can happen that anim progress is a bit out of range we correct it to get something valid for the particle positions. + float currentAnimProgress=getAnimProgressAsFloat(); + if( currentAnimProgress>1.f || currentAnimProgress<0.f) { + currentAnimProgress=0.f; + } + model->updateInterpolationVertices(currentAnimProgress, isAlive() && !isAnimProgressBound()); bool foundMesh=false; for(unsigned int i=0; igetMeshCount() ; i++){