mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 16:11:37 -04:00
Don't add empty PrimitiveSets (prevent undefined behaviour)
This commit is contained in:
parent
4167bdf319
commit
1cf2036386
@ -85,6 +85,8 @@ namespace SceneUtil
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> gridGeometry = new osg::Geometry();
|
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::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
|
||||||
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
|
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
|
||||||
osg::ref_ptr<osg::DrawElementsUShort> pointIndices =
|
osg::ref_ptr<osg::DrawElementsUShort> pointIndices =
|
||||||
@ -166,10 +168,12 @@ namespace SceneUtil
|
|||||||
|
|
||||||
gridGeometry->setVertexArray(vertices);
|
gridGeometry->setVertexArray(vertices);
|
||||||
gridGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
gridGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
||||||
|
if (PointIndexCount)
|
||||||
gridGeometry->addPrimitiveSet(pointIndices);
|
gridGeometry->addPrimitiveSet(pointIndices);
|
||||||
|
if (EdgeIndexCount)
|
||||||
gridGeometry->addPrimitiveSet(lineIndices);
|
gridGeometry->addPrimitiveSet(lineIndices);
|
||||||
gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
gridGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
}
|
||||||
return gridGeometry;
|
return gridGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +188,8 @@ namespace SceneUtil
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Geometry> wireframeGeometry = new osg::Geometry();
|
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::Vec3Array> vertices = new osg::Vec3Array(VertexCount);
|
||||||
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
|
osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array(ColorCount);
|
||||||
osg::ref_ptr<osg::DrawElementsUShort> indices =
|
osg::ref_ptr<osg::DrawElementsUShort> indices =
|
||||||
@ -221,7 +227,7 @@ namespace SceneUtil
|
|||||||
wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
wireframeGeometry->setColorArray(colors, osg::Array::BIND_PER_VERTEX);
|
||||||
wireframeGeometry->addPrimitiveSet(indices);
|
wireframeGeometry->addPrimitiveSet(indices);
|
||||||
wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
wireframeGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
}
|
||||||
return wireframeGeometry;
|
return wireframeGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user