add MDI support

This commit is contained in:
Julien Valentin
2017-08-02 22:10:02 +02:00
parent 7f292c3fb5
commit 35eb53cc95

View File

@@ -1,3 +1,4 @@
#include <osg/PrimitiveSetIndirect>
#include <osgUtil/DrawElementTypeSimplifier>
#include <osg/Geode>
@@ -61,6 +62,44 @@ void DrawElementTypeSimplifier::simplify(osg::Geometry & geometry) const
break;
}
case osg::PrimitiveSet::DrawElementsUShortIndirectPrimitiveType:
{
osg::DrawElementsIndirectUShort & de = *static_cast<osg::DrawElementsIndirectUShort*>(it->get());
max = getMax<osg::DrawElementsIndirectUShort>(de);
if (max < 255) *it = copy<osg::DrawElementsIndirectUShort, osg::DrawElementsIndirectUByte>(de);
break;
}
case osg::PrimitiveSet::DrawElementsUIntIndirectPrimitiveType:
{
osg::DrawElementsIndirectUInt & de = *static_cast<osg::DrawElementsIndirectUInt*>(it->get());
max = getMax<osg::DrawElementsIndirectUInt>(de);
if (max < 256) *it = copy<osg::DrawElementsIndirectUInt, osg::DrawElementsIndirectUByte>(de);
else if (max < 65536) *it = copy<osg::DrawElementsIndirectUInt, osg::DrawElementsIndirectUShort>(de);
break;
}
case osg::PrimitiveSet::MultiDrawElementsUShortIndirectPrimitiveType:
{
osg::MultiDrawElementsIndirectUShort & de = *static_cast<osg::MultiDrawElementsIndirectUShort*>(it->get());
max = getMax<osg::MultiDrawElementsIndirectUShort>(de);
if (max < 255) *it = copy<osg::MultiDrawElementsIndirectUShort, osg::MultiDrawElementsIndirectUByte>(de);
break;
}
case osg::PrimitiveSet::MultiDrawElementsUIntIndirectPrimitiveType:
{
osg::MultiDrawElementsIndirectUInt & de = *static_cast<osg::MultiDrawElementsIndirectUInt*>(it->get());
max = getMax<osg::MultiDrawElementsIndirectUInt>(de);
if (max < 256) *it = copy<osg::MultiDrawElementsIndirectUInt, osg::MultiDrawElementsIndirectUByte>(de);
else if (max < 65536) *it = copy<osg::MultiDrawElementsIndirectUInt, osg::MultiDrawElementsIndirectUShort>(de);
break;
}
default: break;
}
}