From Tim Moore, "This patch fixes some performance problems with the DXF loader. It removes some unnecessary copies of vertex coordinates (which were causing an exponential explosion). It also replaces BIND_PER_PRIMITIVE normals with BIND_PER_VERTEX so that the resulting geometry will be on the fast path."
This commit is contained in:
@@ -165,14 +165,11 @@ void scene::addQuads(const std::string & l, unsigned short color, std::vector<Ve
|
||||
n.normalize();
|
||||
short cindex = correctedColorIndex(l, color);
|
||||
ly->_quadnorms[cindex].push_back( n );
|
||||
MapVList mvl = ly->_quads;
|
||||
VList vl = mvl[cindex];
|
||||
VList& vl = ly->_quads[cindex];
|
||||
vl.push_back(addVertex(*a));
|
||||
vl.push_back(addVertex(*b));
|
||||
vl.push_back(addVertex(*c));
|
||||
vl.push_back(addVertex(*d));
|
||||
mvl[cindex] = vl;
|
||||
ly->_quads = mvl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ osg::Geometry* createTriGeometry( osg::Vec3Array* vertices, osg::Vec3Array* norm
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ osg::Geometry* createQuadGeometry( osg::Vec3Array* vertices, osg::Vec3Array* nor
|
||||
geom->setColorArray(colors);
|
||||
geom->setColorBinding(osg::Geometry::BIND_OVERALL);
|
||||
geom->setNormalArray(normals);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
return geom;
|
||||
}
|
||||
|
||||
@@ -252,11 +252,13 @@ protected:
|
||||
coords->push_back(v);
|
||||
}
|
||||
osg::Vec3Array *norms = new osg::Vec3Array;
|
||||
VList normlist = _trinorms[mitr->first];
|
||||
VList& normlist = _trinorms[mitr->first];
|
||||
for (itr = normlist.begin();
|
||||
itr != normlist.end(); ++itr)
|
||||
{
|
||||
norms->push_back(osg::Vec3(itr->x(), itr->y(), itr->z()));
|
||||
osg::Vec3 norm(itr->x(), itr->y(), itr->z());
|
||||
for (int i = 0; i < 3; ++i)
|
||||
norms->push_back(norm);
|
||||
}
|
||||
root->addChild(createModel(_name, createTriGeometry(coords, norms, getColor(mitr->first))));
|
||||
}
|
||||
@@ -275,10 +277,12 @@ protected:
|
||||
coords->push_back(v);
|
||||
}
|
||||
osg::Vec3Array *norms = new osg::Vec3Array;
|
||||
VList normlist = _quadnorms[mitr->first];
|
||||
VList& normlist = _quadnorms[mitr->first];
|
||||
for (itr = normlist.begin();
|
||||
itr != normlist.end(); ++itr) {
|
||||
norms->push_back(osg::Vec3(itr->x(), itr->y(), itr->z()));
|
||||
osg::Vec3 norm(itr->x(), itr->y(), itr->z());
|
||||
for (int i = 0; i < 4; ++i)
|
||||
norms->push_back(norm);
|
||||
}
|
||||
root->addChild(createModel(_name, createQuadGeometry(coords, norms, getColor(mitr->first))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user