diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index 895ff7e34..a934b8745 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -128,13 +128,15 @@ void RigGeometry::setSourceGeometry(osg::ref_ptr sourceGeometry) setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); } - if (from.getTexCoordArray(7) && dynamic_cast(from.getTexCoordArray(7))) + if (osg::Vec4Array* tangents = dynamic_cast(from.getTexCoordArray(7))) { - // tangents - osg::ref_ptr tangentArray = osg::clone(from.getTexCoordArray(7), osg::CopyOp::DEEP_COPY_ALL); + mSourceTangents = tangents; + osg::ref_ptr tangentArray = osg::clone(tangents, osg::CopyOp::DEEP_COPY_ALL); tangentArray->setVertexBufferObject(vbo); setTexCoordArray(7, tangentArray, osg::Array::BIND_PER_VERTEX); } + else + mSourceTangents = NULL; } osg::ref_ptr RigGeometry::getSourceGeometry() @@ -245,7 +247,7 @@ void RigGeometry::update(osg::NodeVisitor* nv) // skinning osg::Vec3Array* positionSrc = static_cast(mSourceGeometry->getVertexArray()); osg::Vec3Array* normalSrc = static_cast(mSourceGeometry->getNormalArray()); - osg::Vec4Array* tangentSrc = static_cast(mSourceGeometry->getTexCoordArray(7)); + osg::Vec4Array* tangentSrc = mSourceTangents; osg::Vec3Array* positionDst = static_cast(getVertexArray()); osg::Vec3Array* normalDst = static_cast(getNormalArray()); diff --git a/components/sceneutil/riggeometry.hpp b/components/sceneutil/riggeometry.hpp index 8ce753402..fbd22427b 100644 --- a/components/sceneutil/riggeometry.hpp +++ b/components/sceneutil/riggeometry.hpp @@ -53,6 +53,7 @@ namespace SceneUtil private: osg::ref_ptr mSourceGeometry; + osg::ref_ptr mSourceTangents; Skeleton* mSkeleton; osg::NodePath mSkelToGeomPath;