Don't add empty PrimitiveSets (prevent undefined behaviour)

pull/578/head
AnyOldName3 5 years ago
parent 4167bdf319
commit 1cf2036386

@ -85,6 +85,8 @@ namespace SceneUtil
osg::ref_ptr<osg::Geometry> gridGeometry = new osg::Geometry();
if (PointIndexCount || EdgeIndexCount)
{
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
osg::ref_ptr<osg::DrawElementsUShort> pointIndices =
@ -166,10 +168,12 @@ namespace SceneUtil
gridGeometry->setVertexArray(vertices);
gridGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
if (PointIndexCount)
gridGeometry->addPrimitiveSet(pointIndices);
if (EdgeIndexCount)
gridGeometry->addPrimitiveSet(lineIndices);
gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
return gridGeometry;
}
@ -184,6 +188,8 @@ namespace SceneUtil
osg::ref_ptr<osg::Geometry> wireframeGeometry = new osg::Geometry();
if (IndexCount)
{
osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
osg::ref_ptr<osg::DrawElementsUShort> indices =
@ -221,7 +227,7 @@ namespace SceneUtil
wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
wireframeGeometry->addPrimitiveSet(indices);
wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
}
return wireframeGeometry;
}

Loading…
Cancel
Save