From Sukender, "Here is a tiny fix which adds missing virtual methods in osgUtil::TransformAttributeFunctor, to handle Vec3d."

This commit is contained in:
Robert Osfield 2011-05-12 13:12:07 +00:00
parent 5c7b68e63f
commit b380387f53
2 changed files with 23 additions and 0 deletions

View File

@ -34,6 +34,7 @@ class OSGUTIL_EXPORT TransformAttributeFunctor : public osg::Drawable::Attribute
/** Do the work of transforming vertex and normal attributes. */ /** Do the work of transforming vertex and normal attributes. */
virtual void apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3* begin); virtual void apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3* begin);
virtual void apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3d* begin);
osg::Matrix _m; osg::Matrix _m;
osg::Matrix _im; osg::Matrix _im;

View File

@ -46,3 +46,25 @@ void TransformAttributeFunctor::apply(osg::Drawable::AttributeType type,unsigned
} }
} }
} }
void TransformAttributeFunctor::apply(osg::Drawable::AttributeType type,unsigned int count,osg::Vec3d* begin)
{
if (type == osg::Drawable::VERTICES)
{
osg::Vec3d* end = begin+count;
for (osg::Vec3d* itr=begin;itr<end;++itr)
{
(*itr) = (*itr)*_m;
}
}
else if (type == osg::Drawable::NORMALS)
{
osg::Vec3d* end = begin+count;
for (osg::Vec3d* itr=begin;itr<end;++itr)
{
// note post mult by inverse for normals.
(*itr) = osg::Matrix::transform3x3(_im,(*itr));
(*itr).normalize();
}
}
}