From 5c66ecfc995ee21708063742e521a9be6c871c45 Mon Sep 17 00:00:00 2001 From: Laurens Voerman Date: Wed, 25 May 2016 13:27:06 +0200 Subject: [PATCH] RigTransformHardware fix: warn; don't crash if MAX_MATRIX not found --- src/osgAnimation/RigTransformHardware.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/osgAnimation/RigTransformHardware.cpp b/src/osgAnimation/RigTransformHardware.cpp index 82ae6b3e6..4cb5914eb 100644 --- a/src/osgAnimation/RigTransformHardware.cpp +++ b/src/osgAnimation/RigTransformHardware.cpp @@ -251,10 +251,16 @@ bool RigTransformHardware::init(RigGeometry& geom) std::string str = _shader->getShaderSource(); std::string toreplace = std::string("MAX_MATRIX"); std::size_t start = str.find(toreplace); - std::stringstream ss; - ss << getMatrixPaletteUniform()->getNumElements(); - str.replace(start, toreplace.size(), ss.str()); - _shader->setShaderSource(str); + if (std::string::npos != start) { + std::stringstream ss; + ss << getMatrixPaletteUniform()->getNumElements(); + str.replace(start, toreplace.size(), ss.str()); + _shader->setShaderSource(str); + } + else + { + OSG_WARN << "MAX_MATRIX not found in Shader! " << str << std::endl; + } OSG_INFO << "Shader " << str << std::endl; }