Generalised the osg::ClusterCullingCallback so that it coud be attached

to Node as well as Drawables.

Changed the osgTerrain::DataSet so that it moves the ClusterCullingCallback
up to the Node level.

Added support to the .ive plugin for attaching the ClusterCullingCallback to nodes.
This commit is contained in:
Robert Osfield
2004-10-21 09:36:34 +00:00
parent bba69b288b
commit 93c439ba01
5 changed files with 153 additions and 12 deletions

View File

@@ -143,6 +143,13 @@ void ClusterCullingCallback::set(const osg::Vec3& controlPoint, const osg::Vec3&
_radius = radius;
}
void ClusterCullingCallback::transform(const osg::Matrixd& matrix)
{
_controlPoint = Vec3d(_controlPoint)*matrix;
_normal = Matrixd::transform3x3(Matrixd::inverse(matrix),Vec3d(_normal));
_normal.normalize();
}
bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const
{
@@ -162,7 +169,10 @@ bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::St
osg::Vec3 eye_cp = nv->getEyePoint() - _controlPoint;
float radius = eye_cp.length();
if (radius<_radius) return false;
if (radius<_radius)
{
return false;
}
float deviation = (eye_cp * _normal)/radius;
@@ -172,3 +182,14 @@ bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::St
return deviation < _deviation;
}
void ClusterCullingCallback::operator()(Node* node, NodeVisitor* nv)
{
if (nv)
{
if (cull(nv,0,0)) return;
traverse(node,nv);
}
}