Cleaned up usage of BIND_PER_PRIMITIVE where possible.
This commit is contained in:
parent
9c127c2bca
commit
df075ef9bb
@ -22,6 +22,11 @@
|
||||
* exist in the triangulation.
|
||||
*/
|
||||
|
||||
#include <osg/Config>
|
||||
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
|
||||
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
|
||||
#endif
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
#include <osgUtil/Optimizer>
|
||||
#include <osgViewer/Viewer>
|
||||
|
@ -33,6 +33,10 @@
|
||||
// example uses a NodeVisitor to try to find worthwhile locations
|
||||
// for OcclusionQueryNodes in your the scene graph.
|
||||
|
||||
#include <osg/Config>
|
||||
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
|
||||
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
|
||||
#endif
|
||||
|
||||
|
||||
#include <osg/NodeVisitor>
|
||||
|
@ -235,7 +235,9 @@ class OSG_EXPORT Geometry : public Drawable
|
||||
BIND_OFF=0,
|
||||
BIND_OVERALL=1,
|
||||
BIND_PER_PRIMITIVE_SET=2,
|
||||
#if defined(OSG_USE_DEPRECATED_GEOMETRY_METHODS)
|
||||
BIND_PER_PRIMITIVE=3, /// no longer supported
|
||||
#endif
|
||||
BIND_PER_VERTEX=4
|
||||
};
|
||||
|
||||
|
@ -153,7 +153,7 @@ void Geometry::setFogCoordArray(Array* array)
|
||||
} \
|
||||
if (array->getBinding() == static_cast<osg::Array::Binding>(ab)) return; \
|
||||
array->setBinding(static_cast<osg::Array::Binding>(ab));\
|
||||
if (ab==BIND_PER_PRIMITIVE) _containsDeprecatedData = true;
|
||||
if (ab==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) _containsDeprecatedData = true;
|
||||
|
||||
|
||||
#define GET_BINDING(array) (array!=0 ? static_cast<AttributeBinding>(array->getBinding()) : BIND_OFF)
|
||||
@ -1352,19 +1352,19 @@ void Geometry::fixDeprecatedData()
|
||||
osg::IndexArray* indices = getIndexArray(_vertexArray.get());
|
||||
if (indices) setVertexArray(expandIndexArray(_vertexArray.get(), indices));
|
||||
|
||||
if (getNormalBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true;
|
||||
if (getNormalBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
|
||||
indices = getIndexArray(_normalArray.get());
|
||||
if (indices) setNormalArray(expandIndexArray(getNormalArray(), indices));
|
||||
|
||||
if (getColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true;
|
||||
if (getColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
|
||||
indices = getIndexArray(_colorArray.get());
|
||||
if (indices) setColorArray(expandIndexArray(getColorArray(), indices));
|
||||
|
||||
if (getSecondaryColorBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true;
|
||||
if (getSecondaryColorBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
|
||||
indices = getIndexArray(_secondaryColorArray.get());
|
||||
if (indices) setSecondaryColorArray(expandIndexArray(getSecondaryColorArray(), indices));
|
||||
|
||||
if (getFogCoordBinding()==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true;
|
||||
if (getFogCoordBinding()==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
|
||||
indices = getIndexArray(_fogCoordArray.get());
|
||||
if (indices) setFogCoordArray(expandIndexArray(getFogCoordArray(), indices));
|
||||
|
||||
@ -1376,7 +1376,7 @@ void Geometry::fixDeprecatedData()
|
||||
|
||||
for(unsigned int vi=0;vi<_vertexAttribList.size();++vi)
|
||||
{
|
||||
if (getVertexAttribBinding(vi)==osg::Geometry::BIND_PER_PRIMITIVE) containsBindPerPrimitive = true;
|
||||
if (getVertexAttribBinding(vi)==3 /*osg::Geometry::BIND_PER_PRIMITIVE*/) containsBindPerPrimitive = true;
|
||||
indices = getIndexArray(_vertexAttribList[vi].get());
|
||||
if (indices) setVertexAttribArray(vi, expandIndexArray(getVertexAttribArray(vi), indices));
|
||||
}
|
||||
|
@ -1,3 +1,8 @@
|
||||
#include <osg/Config>
|
||||
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
|
||||
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
|
||||
#endif
|
||||
|
||||
#include "ConvertFromInventor.h"
|
||||
|
||||
#include "PendulumCallback.h"
|
||||
|
@ -587,12 +587,12 @@ osg::Quat DataInputStream::readQuat(){
|
||||
osg::Geometry::AttributeBinding DataInputStream::readBinding(){
|
||||
char c = readChar();
|
||||
|
||||
if (_verboseOutput) std::cout<<"read/writeBinding() ["<<(int)c<<"]"<<std::endl;
|
||||
if (_verboseOutput) std::cout<<"readBinding() ["<<(int)c<<"]"<<std::endl;
|
||||
|
||||
switch((int)c){
|
||||
case 0: return osg::Geometry::BIND_OFF;
|
||||
case 1: return osg::Geometry::BIND_OVERALL;
|
||||
case 2: return osg::Geometry::BIND_PER_PRIMITIVE;
|
||||
case 2: return 3 /*osg::Geometry::BIND_PER_PRIMITIVE*/;
|
||||
case 3: return osg::Geometry::BIND_PER_PRIMITIVE_SET;
|
||||
case 4: return osg::Geometry::BIND_PER_VERTEX;
|
||||
default:
|
||||
|
@ -509,11 +509,11 @@ void DataOutputStream::writeQuat(const osg::Quat& q){
|
||||
|
||||
void DataOutputStream::writeBinding(osg::Geometry::AttributeBinding b){
|
||||
switch(b){
|
||||
case osg::Geometry::BIND_OFF: writeChar((char) 0); break;
|
||||
case osg::Geometry::BIND_OVERALL: writeChar((char) 1); break;
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE: writeChar((char) 2); break;
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break;
|
||||
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
|
||||
case osg::Geometry::BIND_OFF: writeChar((char) 0); break;
|
||||
case osg::Geometry::BIND_OVERALL: writeChar((char) 1); break;
|
||||
case static_cast<osg::Geometry::AttributeBinding>(3): writeChar((char) 2); break; /*osg::Geometry::BIND_PER_PRIMITIVE*/
|
||||
case osg::Geometry::BIND_PER_PRIMITIVE_SET: writeChar((char) 3); break;
|
||||
case osg::Geometry::BIND_PER_VERTEX: writeChar((char) 4); break;
|
||||
default: throwException("Unknown binding in DataOutputStream::writeBinding()");
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
|
||||
Geometry *geom = dynamic_cast<Geometry *>(geode.getDrawable(i));
|
||||
if( geom )
|
||||
{
|
||||
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
|
||||
|
||||
Vec3Array *coords = dynamic_cast<Vec3Array*>(geom->getVertexArray());
|
||||
if( coords == 0L )
|
||||
continue;
|
||||
@ -85,7 +87,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
|
||||
_local_coords->push_back( v );
|
||||
_local_coords->push_back( (v + n));
|
||||
}
|
||||
else // BIND_PER_PRIMITIVE_SET, BIND_PER_PRIMITIVE, BIND_PER_VERTEX
|
||||
else // BIND_PER_PRIMITIVE_SET, BIND_PER_VERTEX
|
||||
{
|
||||
Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
|
||||
Geometry::PrimitiveSetList::iterator itr;
|
||||
@ -121,10 +123,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
|
||||
{
|
||||
_processPrimitive( 3, coord_index, normals_index, binding );
|
||||
coord_index += 3;
|
||||
if( binding == Geometry::BIND_PER_PRIMITIVE )
|
||||
normals_index++;
|
||||
else
|
||||
normals_index+=3;
|
||||
normals_index+=3;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -150,10 +149,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
|
||||
{
|
||||
_processPrimitive( 4, coord_index, normals_index, binding );
|
||||
coord_index += 4;
|
||||
if( binding == Geometry::BIND_PER_PRIMITIVE )
|
||||
normals_index++;
|
||||
else
|
||||
normals_index+=4;
|
||||
normals_index +=4;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -169,11 +165,7 @@ void Normals::MakeNormalsVisitor::apply( Geode &geode )
|
||||
//OSG_WARN << "j=" << j << " num_prim=" << num_prim << std::endl;
|
||||
_processPrimitive(num_prim, coord_index, normals_index, binding);
|
||||
coord_index += num_prim;
|
||||
if (binding == Geometry::BIND_PER_PRIMITIVE) {
|
||||
++normals_index;
|
||||
} else {
|
||||
normals_index += num_prim;
|
||||
}
|
||||
normals_index += num_prim;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -198,13 +190,9 @@ void Normals::MakeNormalsVisitor::_processPrimitive( unsigned int nv,
|
||||
{
|
||||
Vec3 v(0,0,0);
|
||||
Vec3 n(0,0,0);
|
||||
if( _mode == SurfaceNormals || binding == Geometry::BIND_PER_PRIMITIVE )
|
||||
if( _mode == SurfaceNormals )
|
||||
{
|
||||
if( binding == Geometry::BIND_PER_PRIMITIVE )
|
||||
{
|
||||
n = *(normals++);
|
||||
}
|
||||
else if( binding == Geometry::BIND_PER_VERTEX )
|
||||
if( binding == Geometry::BIND_PER_VERTEX )
|
||||
{
|
||||
for( unsigned int i = 0; i < nv; i++ )
|
||||
n += *(normals++);
|
||||
|
@ -136,8 +136,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
|
||||
write(i2);
|
||||
write(i3);
|
||||
_fout << std::endl;
|
||||
// not sure if this is correct?
|
||||
if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex;
|
||||
}
|
||||
|
||||
// operator for lines
|
||||
@ -147,8 +145,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
|
||||
write(i1);
|
||||
write(i2);
|
||||
_fout << std::endl;
|
||||
// not sure if this is correct?
|
||||
if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex;
|
||||
}
|
||||
|
||||
// operator for points
|
||||
@ -157,8 +153,6 @@ class ObjPrimitiveIndexWriter : public osg::PrimitiveIndexFunctor {
|
||||
_fout << "p ";
|
||||
write(i1);
|
||||
_fout << std::endl;
|
||||
// not sure if this is correct?
|
||||
if(_geo->getNormalBinding() && _geo->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) ++_normalIndex;
|
||||
}
|
||||
|
||||
virtual void begin(GLenum mode)
|
||||
@ -524,6 +518,8 @@ void OBJWriterNodeVisitor::processGeometry(osg::Geometry* geo, osg::Matrix& m) {
|
||||
_fout << std::endl;
|
||||
_fout << "o " << getUniqueName( geo->getName().empty() ? geo->className() : geo->getName() ) << std::endl;
|
||||
|
||||
if (geo->containsDeprecatedData()) geo->fixDeprecatedData();
|
||||
|
||||
processStateSet(_currentStateSet.get());
|
||||
|
||||
processArray("v", geo->getVertexArray(), m, false);
|
||||
|
@ -97,17 +97,41 @@ private:
|
||||
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry;
|
||||
|
||||
geom->setVertexArray(_vertex.get());
|
||||
geom->setNormalArray(_normal.get());
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, _numFacets * 3));
|
||||
|
||||
|
||||
if (_normal.valid())
|
||||
{
|
||||
// need to convert per triangle normals to per vertex
|
||||
osg::ref_ptr<osg::Vec3Array> perVertexNormals = new osg::Vec3Array;
|
||||
perVertexNormals->reserveArray(_normal->size() * 3);
|
||||
for(osg::Vec3Array::iterator itr = _normal->begin();
|
||||
itr != _normal->end();
|
||||
++itr)
|
||||
{
|
||||
perVertexNormals->push_back(*itr);
|
||||
}
|
||||
|
||||
geom->setNormalArray(perVertexNormals.get());
|
||||
geom->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
}
|
||||
|
||||
if (_color.valid())
|
||||
{
|
||||
// need to convert per triangle colours to per vertex
|
||||
OSG_INFO << "STL file with color" << std::endl;
|
||||
geom->setColorArray(_color.get());
|
||||
geom->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
|
||||
osg::ref_ptr<osg::Vec4Array> perVertexColours = new osg::Vec4Array;
|
||||
perVertexColours->reserveArray(_color->size() * 3);
|
||||
for(osg::Vec4Array::iterator itr = _color->begin();
|
||||
itr != _color->end();
|
||||
++itr)
|
||||
{
|
||||
perVertexColours->push_back(*itr);
|
||||
}
|
||||
geom->setColorArray(perVertexColours.get());
|
||||
geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
|
||||
}
|
||||
|
||||
geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, 0, _numFacets * 3));
|
||||
|
||||
osgUtil::TriStripVisitor tristripper;
|
||||
tristripper.stripify(*geom);
|
||||
|
||||
|
@ -268,6 +268,8 @@ void ToVRML::apply(osg::Drawable* drawable) {
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
void ToVRML::apply(osg::Geometry* geom) {
|
||||
|
||||
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
|
||||
|
||||
// are all primitives faces or line ?
|
||||
GLenum mode;
|
||||
osg::PrimitiveSet::Type type;
|
||||
@ -1128,12 +1130,6 @@ void ToVRML::writeNormal(osg::Geometry* geom, std::vector<int>& primitiveSetFace
|
||||
_fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n";
|
||||
}
|
||||
|
||||
} else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE) {
|
||||
for (unsigned int j = 0; j < (*nArray).size(); j++) {
|
||||
n = (*nArray)[j];
|
||||
_fout << indent() << n[0] << " " << n[1] << " " << n[2] << ",\n";
|
||||
}
|
||||
|
||||
} else if (geom->getNormalBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) {
|
||||
for (unsigned int j = 0; j < (*nArray).size(); j++) {
|
||||
n = (*nArray)[j];
|
||||
@ -1282,12 +1278,6 @@ void ToVRML::writeColor(osg::Geometry* geom, std::vector<int>& primitiveSetFaces
|
||||
_fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n";
|
||||
}
|
||||
|
||||
} else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE) {
|
||||
for (unsigned int j = 0; j < (*cArray).size(); j++) {
|
||||
c = (*cArray)[j];
|
||||
_fout << indent() << c[0] << " " << c[1] << " " << c[2] << ",\n";
|
||||
}
|
||||
|
||||
} else if (geom->getColorBinding() == osg::Geometry::BIND_PER_PRIMITIVE_SET) {
|
||||
for (unsigned int j = 0; j < (*cArray).size(); j++) {
|
||||
c = (*cArray)[j];
|
||||
|
@ -1,3 +1,8 @@
|
||||
#include <osg/Config>
|
||||
#ifndef OSG_USE_DEPRECATED_GEOMETRY_METHODS
|
||||
#define OSG_USE_DEPRECATED_GEOMETRY_METHODS 1
|
||||
#endif
|
||||
|
||||
#include <osgSim/ScalarBar>
|
||||
#include <osgText/Text>
|
||||
#include <osg/Geometry>
|
||||
|
@ -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;
|
||||
|
@ -6,8 +6,8 @@
|
||||
BEGIN_USER_TABLE( AttributeBinding, osg::Geometry );
|
||||
ADD_USER_VALUE( BIND_OFF );
|
||||
ADD_USER_VALUE( BIND_OVERALL );
|
||||
ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET );
|
||||
ADD_USER_VALUE( BIND_PER_PRIMITIVE );
|
||||
ADD_USER_VALUE( BIND_PER_PRIMITIVE_SET );
|
||||
lookup->add("BIND_PER_PRIMITIVE",3); //ADD_USER_VALUE( BIND_PER_PRIMITIVE );
|
||||
ADD_USER_VALUE( BIND_PER_VERTEX );
|
||||
END_USER_TABLE()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user