summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscrawl <scrawl@baseoftrash.de>2016-12-15 22:39:21 +0100
committerscrawl <scrawl@baseoftrash.de>2016-12-15 22:39:21 +0100
commitc0faeea938e9132cb548c9783004e85cf2c44a87 (patch)
tree2234b39d19619e9ff2910ec492c63f22fdd61e31
parent81b9b07820aebebe44359aebf553b65d07ec0d3e (diff)
RigGeometry check if mesh has normals (Fixes #3667)
-rw-r--r--components/sceneutil/riggeometry.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp
index 3af5176..297dc69 100644
--- a/components/sceneutil/riggeometry.cpp
+++ b/components/sceneutil/riggeometry.cpp
@@ -120,13 +120,17 @@ void RigGeometry::setSourceGeometry(osg::ref_ptr<osg::Geometry> sourceGeometry)
setVertexArray(vertexArray);
}
- osg::ref_ptr<osg::Array> normalArray = osg::clone(from.getNormalArray(), osg::CopyOp::DEEP_COPY_ALL);
- if (normalArray)
+ if (osg::Array* normals = from.getNormalArray())
{
- normalArray->setVertexBufferObject(vbo);
- setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX);
+ osg::ref_ptr<osg::Array> normalArray = osg::clone(normals, osg::CopyOp::DEEP_COPY_ALL);
+ if (normalArray)
+ {
+ normalArray->setVertexBufferObject(vbo);
+ setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX);
+ }
}
+
if (osg::Vec4Array* tangents = dynamic_cast<osg::Vec4Array*>(from.getTexCoordArray(7)))
{
mSourceTangents = tangents;
@@ -273,7 +277,8 @@ void RigGeometry::update(osg::NodeVisitor* nv)
{
unsigned short vertex = *vertexIt;
(*positionDst)[vertex] = resultMat.preMult((*positionSrc)[vertex]);
- (*normalDst)[vertex] = osg::Matrix::transform3x3((*normalSrc)[vertex], resultMat);
+ if (normalDst)
+ (*normalDst)[vertex] = osg::Matrix::transform3x3((*normalSrc)[vertex], resultMat);
if (tangentDst)
{
osg::Vec4f srcTangent = (*tangentSrc)[vertex];
@@ -284,7 +289,8 @@ void RigGeometry::update(osg::NodeVisitor* nv)
}
positionDst->dirty();
- normalDst->dirty();
+ if (normalDst)
+ normalDst->dirty();
if (tangentDst)
tangentDst->dirty();
}