From a7de33ee556726b4a3ce70ccba35a005253ae726 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 6 Jul 2007 13:33:40 +0000 Subject: [PATCH] From Brede Johansen, "Attached is a fix that returns a default color (white) if an invalid index to the color palette is used." --- src/osgPlugins/OpenFlight/Pools.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/osgPlugins/OpenFlight/Pools.cpp b/src/osgPlugins/OpenFlight/Pools.cpp index b7d348b24..3765475c1 100644 --- a/src/osgPlugins/OpenFlight/Pools.cpp +++ b/src/osgPlugins/OpenFlight/Pools.cpp @@ -20,8 +20,14 @@ osg::Vec4 ColorPool::getColor(int indexIntensity) const // bit 12 fixed intensity bit bool fixedIntensity = (indexIntensity & 0x1000) ? true : false; unsigned int index = (fixedIntensity) ? (indexIntensity & 0x0fff)+(4096>>7) : indexIntensity >> 7; - assert(index=size()) + { + // color index not available. + return osg::Vec4(1,1,1,1); + } + + osg::Vec4 col = operator[](index); if (!fixedIntensity) { float intensity = (float)(indexIntensity & 0x7f)/127.f; @@ -35,15 +41,15 @@ osg::Vec4 ColorPool::getColor(int indexIntensity) const { // bit 0-6: intensity // bit 7-15 color index - int index = indexIntensity >> 7; + unsigned int index = indexIntensity >> 7; - if (index<0 || index>=(int)size()) + if (index>=size()) { // color index not available. return osg::Vec4(1,1,1,1); } - osg::Vec4 col = at(index); + osg::Vec4 col = operator[](index); float intensity = (float)(indexIntensity & 0x7f)/127.f; col[0] *= intensity; col[1] *= intensity;