From 3e535d745648b31316db750af7518f7690a2c52a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 11 Mar 2009 11:58:31 +0000 Subject: [PATCH] Fixed crash due to Geometry::copyToAndOptimize(..) not handling cases where indices are present, but no arrays are assocaited with them. --- src/osg/Geometry.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 0ee9e8eb3..d668a5112 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -3084,7 +3084,7 @@ void Geometry::copyToAndOptimize(Geometry& target) if (!copyToSelf) target.getPrimitiveSetList() = getPrimitiveSetList(); // copy over attribute arrays. - if (getVertexIndices()) + if (getVertexIndices() && getVertexArray()) { ExpandIndexedArray eia(*(getVertexIndices()),target.getVertexArray()); getVertexArray()->accept(eia); @@ -3098,7 +3098,7 @@ void Geometry::copyToAndOptimize(Geometry& target) } target.setNormalBinding(getNormalBinding()); - if (getNormalIndices()) + if (getNormalIndices() && getNormalArray()) { ExpandIndexedArray eia(*(getNormalIndices()),target.getNormalArray()); getNormalArray()->accept(eia); @@ -3112,7 +3112,7 @@ void Geometry::copyToAndOptimize(Geometry& target) } target.setColorBinding(getColorBinding()); - if (getColorIndices()) + if (getColorIndices() && getColorArray()) { ExpandIndexedArray eia(*(getColorIndices()),target.getColorArray()); getColorArray()->accept(eia); @@ -3126,7 +3126,7 @@ void Geometry::copyToAndOptimize(Geometry& target) } target.setSecondaryColorBinding(getSecondaryColorBinding()); - if (getSecondaryColorIndices()) + if (getSecondaryColorIndices() && getSecondaryColorArray()) { ExpandIndexedArray eia(*(getSecondaryColorIndices()),target.getSecondaryColorArray()); getSecondaryColorArray()->accept(eia); @@ -3140,7 +3140,7 @@ void Geometry::copyToAndOptimize(Geometry& target) } target.setFogCoordBinding(getFogCoordBinding()); - if (getFogCoordIndices()) + if (getFogCoordIndices() && getFogCoordArray()) { ExpandIndexedArray eia(*(getFogCoordIndices()),target.getFogCoordArray()); getFogCoordArray()->accept(eia); @@ -3155,9 +3155,10 @@ void Geometry::copyToAndOptimize(Geometry& target) for(unsigned int ti=0;tiaccept(eia); target.setTexCoordArray(ti,eia._targetArray);