Rewrote the osg::Drawable::AttributeFunctor and PrimtiveFunctor to make
them more consistent with each other. This does mean an API change, so dependanct code in the OSG has been updated accordingly.
This commit is contained in:
@@ -449,7 +449,7 @@ bool IntersectVisitor::intersect(Drawable& drawable)
|
||||
|
||||
TriangleFunctor<TriangleIntersect> ti;
|
||||
ti.set(*sitr->second);
|
||||
drawable.applyPrimitiveOperation(ti);
|
||||
drawable.accept(ti);
|
||||
if (ti._hit)
|
||||
{
|
||||
|
||||
|
||||
@@ -99,8 +99,7 @@ class TransformFunctor : public osg::Drawable::AttributeFunctor
|
||||
osg::Matrix _m;
|
||||
osg::Matrix _im;
|
||||
|
||||
TransformFunctor(const osg::Matrix& m):
|
||||
osg::Drawable::AttributeFunctor(osg::Drawable::COORDS|osg::Drawable::NORMALS)
|
||||
TransformFunctor(const osg::Matrix& m)
|
||||
{
|
||||
_m = m;
|
||||
_im.invert(_m);
|
||||
@@ -108,28 +107,26 @@ class TransformFunctor : public osg::Drawable::AttributeFunctor
|
||||
|
||||
virtual ~TransformFunctor() {}
|
||||
|
||||
virtual bool apply(osg::Drawable::AttributeBitMask abm,osg::Vec3* begin,osg::Vec3* end)
|
||||
virtual void apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3* begin)
|
||||
{
|
||||
if (abm == osg::Drawable::COORDS)
|
||||
if (type == osg::Drawable::VERTICES)
|
||||
{
|
||||
osg::Vec3* end = begin+count;
|
||||
for (osg::Vec3* itr=begin;itr<end;++itr)
|
||||
{
|
||||
(*itr) = (*itr)*_m;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (abm == osg::Drawable::NORMALS)
|
||||
else if (type == osg::Drawable::NORMALS)
|
||||
{
|
||||
osg::Vec3* end = begin+count;
|
||||
for (osg::Vec3* itr=begin;itr<end;++itr)
|
||||
{
|
||||
// note post mult by inverse for normals.
|
||||
(*itr) = osg::Matrix::transform3x3(_im,(*itr));
|
||||
(*itr).normalize();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
@@ -455,7 +452,7 @@ void Optimizer::FlattenStaticTransformsVisitor::doTransform(osg::Object* obj,osg
|
||||
if (drawable)
|
||||
{
|
||||
TransformFunctor tf(matrix);
|
||||
drawable->applyAttributeOperation(tf);
|
||||
drawable->accept(tf);
|
||||
drawable->dirtyBound();
|
||||
return;
|
||||
}
|
||||
@@ -498,7 +495,7 @@ void Optimizer::FlattenStaticTransformsVisitor::doTransform(osg::Object* obj,osg
|
||||
for(unsigned int i=0;i<billboard->getNumDrawables();++i)
|
||||
{
|
||||
billboard->setPos(i,billboard->getPos(i)*matrix);
|
||||
billboard->getDrawable(i)->applyAttributeOperation(tf);
|
||||
billboard->getDrawable(i)->accept(tf);
|
||||
}
|
||||
|
||||
billboard->dirtyBound();
|
||||
@@ -717,7 +714,7 @@ void Optimizer::RemoveLowestStaticTransformsVisitor::doTransform(osg::Object* ob
|
||||
if (drawable)
|
||||
{
|
||||
TransformFunctor tf(matrix);
|
||||
drawable->applyAttributeOperation(tf);
|
||||
drawable->accept(tf);
|
||||
drawable->dirtyBound();
|
||||
return;
|
||||
}
|
||||
@@ -760,7 +757,7 @@ void Optimizer::RemoveLowestStaticTransformsVisitor::doTransform(osg::Object* ob
|
||||
for(unsigned int i=0;i<billboard->getNumDrawables();++i)
|
||||
{
|
||||
billboard->setPos(i,billboard->getPos(i)*matrix);
|
||||
billboard->getDrawable(i)->applyAttributeOperation(tf);
|
||||
billboard->getDrawable(i)->accept(tf);
|
||||
}
|
||||
|
||||
billboard->dirtyBound();
|
||||
|
||||
@@ -191,7 +191,7 @@ bool RenderBin::getStats(osg::Statistics* primStats)
|
||||
if (dw)
|
||||
{
|
||||
// then tot up the primtive types and no vertices.
|
||||
dw->applyPrimitiveOperation(*primStats); // use sub-class to find the stats for each drawable
|
||||
dw->accept(*primStats); // use sub-class to find the stats for each drawable
|
||||
}
|
||||
}
|
||||
somestats=true;
|
||||
|
||||
@@ -111,7 +111,7 @@ void SmoothingVisitor::smooth(osg::Geometry& geom)
|
||||
TriangleFunctor<SmoothTriangleFunctor> stf;
|
||||
stf.set(&(coords->front()),coords->size(),&(normals->front()));
|
||||
|
||||
geom.applyPrimitiveOperation(stf);
|
||||
geom.accept(stf);
|
||||
|
||||
for(nitr= normals->begin();
|
||||
nitr!=normals->end();
|
||||
|
||||
@@ -82,7 +82,7 @@ void TriStripVisitor::stripify(Geometry& geom)
|
||||
case(Primitive::QUADS):
|
||||
case(Primitive::QUAD_STRIP):
|
||||
case(Primitive::POLYGON):
|
||||
(*itr)->applyPrimitiveOperation(taf);
|
||||
(*itr)->accept(taf);
|
||||
break;
|
||||
default:
|
||||
new_primitives.push_back(*itr);
|
||||
|
||||
Reference in New Issue
Block a user