From 705695b41da7c76db13f496c301b7135343856ba Mon Sep 17 00:00:00 2001 From: Julien Valentin Date: Wed, 30 Aug 2017 15:46:19 +0200 Subject: [PATCH] add a guard (if dirty) on uniform update --- src/osgAnimation/MorphTransformHardware.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/osgAnimation/MorphTransformHardware.cpp b/src/osgAnimation/MorphTransformHardware.cpp index 8b5351cea..86df7b465 100644 --- a/src/osgAnimation/MorphTransformHardware.cpp +++ b/src/osgAnimation/MorphTransformHardware.cpp @@ -187,11 +187,14 @@ void MorphTransformHardware::operator()(MorphGeometry& geom) if (_needInit) if (!init(geom)) return; - - ///upload new morph weights each update via uniform - int curimorph=0; - MorphGeometry::MorphTargetList & morphlist=geom.getMorphTargetList(); - for(MorphGeometry::MorphTargetList::const_iterator curmorph=morphlist.begin(); curmorph!=morphlist.end(); ++curmorph) - _uniformTargetsWeight->setElement(curimorph++, curmorph->getWeight()); - _uniformTargetsWeight->dirty(); + if (geom.isDirty()) + { + ///upload new morph weights each update via uniform + int curimorph=0; + MorphGeometry::MorphTargetList & morphlist=geom.getMorphTargetList(); + for(MorphGeometry::MorphTargetList::const_iterator curmorph=morphlist.begin(); curmorph!=morphlist.end(); ++curmorph) + _uniformTargetsWeight->setElement(curimorph++, curmorph->getWeight()); + _uniformTargetsWeight->dirty(); + geom.dirty(false); + } }