Removed DrawArrays optimization to simplify the code and open the door to adding primitive combining.
git-svn-id: http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk@14530 16af8721-9629-0410-8352-f15c8da7e697
This commit is contained in:
@@ -463,37 +463,18 @@ void TriStripVisitor::stripify(Geometry& geom)
|
|||||||
indices.push_back(pitr->Indices[(min_pos+3)%4]);
|
indices.push_back(pitr->Indices[(min_pos+3)%4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inOrder = true;
|
unsigned int maxValue = *(std::max_element(indices.begin(),indices.end()));
|
||||||
unsigned int previousValue = indices.front();
|
if (maxValue>=65536)
|
||||||
for(IndexList::iterator qi_itr=indices.begin()+1;
|
|
||||||
qi_itr!=indices.end() && inOrder;
|
|
||||||
++qi_itr)
|
|
||||||
{
|
{
|
||||||
inOrder = (previousValue+1)==*qi_itr;
|
osg::DrawElementsUInt* elements = new osg::DrawElementsUInt(GL_QUADS);
|
||||||
previousValue = *qi_itr;
|
std::copy(indices.begin(),indices.end(),std::back_inserter(*elements));
|
||||||
}
|
new_primitives.push_back(elements);
|
||||||
|
|
||||||
|
|
||||||
if (inOrder)
|
|
||||||
{
|
|
||||||
new_primitives.push_back(new osg::DrawArrays(GL_QUADS,indices.front(),indices.size()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int maxValue = *(std::max_element(indices.begin(),indices.end()));
|
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(GL_QUADS);
|
||||||
|
std::copy(indices.begin(),indices.end(),std::back_inserter(*elements));
|
||||||
if (maxValue>=65536)
|
new_primitives.push_back(elements);
|
||||||
{
|
|
||||||
osg::DrawElementsUInt* elements = new osg::DrawElementsUInt(GL_QUADS);
|
|
||||||
std::copy(indices.begin(),indices.end(),std::back_inserter(*elements));
|
|
||||||
new_primitives.push_back(elements);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(GL_QUADS);
|
|
||||||
std::copy(indices.begin(),indices.end(),std::back_inserter(*elements));
|
|
||||||
new_primitives.push_back(elements);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -505,37 +486,20 @@ void TriStripVisitor::stripify(Geometry& geom)
|
|||||||
{
|
{
|
||||||
if (!_generateFourPointPrimitivesQuads || pitr->Indices.size()!=4)
|
if (!_generateFourPointPrimitivesQuads || pitr->Indices.size()!=4)
|
||||||
{
|
{
|
||||||
bool inOrder = true;
|
unsigned int maxValue = *(std::max_element(pitr->Indices.begin(),pitr->Indices.end()));
|
||||||
unsigned int previousValue = pitr->Indices.front();
|
if (maxValue>=65536)
|
||||||
for(triangle_stripper::indices::iterator qi_itr=pitr->Indices.begin()+1;
|
|
||||||
qi_itr!=pitr->Indices.end() && inOrder;
|
|
||||||
++qi_itr)
|
|
||||||
{
|
{
|
||||||
inOrder = (previousValue+1)==*qi_itr;
|
osg::DrawElementsUInt* elements = new osg::DrawElementsUInt(pitr->Type);
|
||||||
previousValue = *qi_itr;
|
elements->reserve(pitr->Indices.size());
|
||||||
}
|
std::copy(pitr->Indices.begin(),pitr->Indices.end(),std::back_inserter(*elements));
|
||||||
|
new_primitives.push_back(elements);
|
||||||
if (inOrder)
|
|
||||||
{
|
|
||||||
new_primitives.push_back(new osg::DrawArrays(pitr->Type,pitr->Indices.front(),pitr->Indices.size()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int maxValue = *(std::max_element(pitr->Indices.begin(),pitr->Indices.end()));
|
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(pitr->Type);
|
||||||
if (maxValue>=65536)
|
elements->reserve(pitr->Indices.size());
|
||||||
{
|
std::copy(pitr->Indices.begin(),pitr->Indices.end(),std::back_inserter(*elements));
|
||||||
osg::DrawElementsUInt* elements = new osg::DrawElementsUInt(pitr->Type);
|
new_primitives.push_back(elements);
|
||||||
elements->reserve(pitr->Indices.size());
|
|
||||||
std::copy(pitr->Indices.begin(),pitr->Indices.end(),std::back_inserter(*elements));
|
|
||||||
new_primitives.push_back(elements);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osg::DrawElementsUShort* elements = new osg::DrawElementsUShort(pitr->Type);
|
|
||||||
elements->reserve(pitr->Indices.size());
|
|
||||||
std::copy(pitr->Indices.begin(),pitr->Indices.end(),std::back_inserter(*elements));
|
|
||||||
new_primitives.push_back(elements);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user