Cleaned up usage of BIND_PER_PRIMITIVE where possible.
This commit is contained in:
@@ -85,8 +85,6 @@ struct GeometryArrayGatherer
|
||||
if (array)
|
||||
_arrayList.push_back(array);
|
||||
}
|
||||
else if (binding == osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
_useDrawElements = false;
|
||||
}
|
||||
|
||||
void accept(osg::ArrayVisitor& av)
|
||||
@@ -231,17 +229,15 @@ typedef osg::TriangleIndexFunctor<MyTriangleOperator> MyTriangleIndexFunctor;
|
||||
|
||||
void IndexMeshVisitor::makeMesh(Geometry& geom)
|
||||
{
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.containsDeprecatedData()) geom.fixDeprecatedData();
|
||||
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
// no point optimizing if we don't have enough vertices.
|
||||
if (!geom.getVertexArray() || geom.getVertexArray()->getNumElements()<3) return;
|
||||
|
||||
@@ -609,6 +609,8 @@ void Tessellator::reduceArray(osg::Array * cold, const unsigned int nnu)
|
||||
|
||||
void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int originalIndex)
|
||||
{
|
||||
if (geom.containsDeprecatedData()) geom.fixDeprecatedData();
|
||||
|
||||
osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geom.getVertexArray());
|
||||
VertexPtrToIndexMap vertexPtrToIndexMap;
|
||||
|
||||
@@ -625,16 +627,14 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original
|
||||
{
|
||||
osg::Vec3Array* normals = NULL; // GWM Sep 2002 - add normals for extra facets
|
||||
int iprim=0;
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
normals = dynamic_cast<osg::Vec3Array*>(geom.getNormalArray()); // GWM Sep 2002
|
||||
}
|
||||
// GWM Dec 2003 - needed to add colours for extra facets
|
||||
osg::Vec4Array* cols4 = NULL; // GWM Dec 2003 colours are vec4
|
||||
osg::Vec3Array* cols3 = NULL; // GWM Dec 2003 colours are vec3
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET)
|
||||
{
|
||||
Array* colours = geom.getColorArray(); // GWM Dec 2003 - need to duplicate face colours
|
||||
switch (colours->getType()) {
|
||||
@@ -708,10 +708,7 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original
|
||||
if (primItr==_primList.begin())
|
||||
{ // first primitive so collect primitive normal & colour.
|
||||
if (normals) {
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
norm=(*normals)[originalIndex + _extraPrimitives];
|
||||
else
|
||||
norm=(*normals)[iprim]; // GWM Sep 2002 the flat shaded normal
|
||||
norm=(*normals)[iprim]; // GWM Sep 2002 the flat shaded normal
|
||||
}
|
||||
if (cols4) {
|
||||
primCol4=(*cols4)[iprim]; // GWM Dec 2003 the flat shaded rgba colour
|
||||
@@ -730,13 +727,7 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original
|
||||
{ // later primitives use same colour
|
||||
if (normals)
|
||||
{
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE)
|
||||
{
|
||||
_extraPrimitives++;
|
||||
normals->insert(normals->begin() + originalIndex + _extraPrimitives, norm);
|
||||
}
|
||||
else
|
||||
normals->push_back(norm); // GWM Sep 2002 add flat shaded normal for new facet
|
||||
normals->push_back(norm); // GWM Sep 2002 add flat shaded normal for new facet
|
||||
}
|
||||
if (cols4 && _index>=cols4->size()) {
|
||||
cols4->push_back(primCol4); // GWM Dec 2003 add flat shaded colour for new facet
|
||||
@@ -745,14 +736,12 @@ void Tessellator::collectTessellation(osg::Geometry &geom, unsigned int original
|
||||
if (cols3) cols3->push_back(primCol3); // GWM Dec 2003 add flat shaded colour for new facet
|
||||
}
|
||||
if (prim->_mode==GL_TRIANGLES) {
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET ||
|
||||
geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) { // need one per triangle? Not one per set.
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set.
|
||||
for (int ii=1; ii<ntris; ii++) {
|
||||
if (normals) normals->push_back(norm); // GWM Sep 2002 add flat shaded normal for new facet
|
||||
}
|
||||
}
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET ||
|
||||
geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) { // need one per triangle? Not one per set.
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) { // need one per triangle? Not one per set.
|
||||
for (int ii=1; ii<ntris; ii++) {
|
||||
if (cols3 && _index>=cols3->size()) {
|
||||
if (cols3) cols3->push_back(primCol3);
|
||||
|
||||
@@ -214,18 +214,15 @@ typedef osg::TriangleIndexFunctor<MyTriangleOperator> MyTriangleIndexFunctor;
|
||||
|
||||
void TriStripVisitor::stripify(Geometry& geom)
|
||||
{
|
||||
if (geom.containsDeprecatedData()) geom.fixDeprecatedData();
|
||||
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE ||
|
||||
geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
if (geom.getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE_SET) return;
|
||||
|
||||
// no point tri stripping if we don't have enough vertices.
|
||||
if (!geom.getVertexArray() || geom.getVertexArray()->getNumElements()<3) return;
|
||||
|
||||
Reference in New Issue
Block a user