diff --git a/include/osg/ClusterCullingCallback b/include/osg/ClusterCullingCallback index 9efe9ffcf..da03c7ff1 100644 --- a/include/osg/ClusterCullingCallback +++ b/include/osg/ClusterCullingCallback @@ -34,7 +34,7 @@ class SG_EXPORT ClusterCullingCallback : public Drawable::CullCallback /** compute the control point, normal and deviation from the contents of the drawable.*/ void computeFrom(const osg::Drawable* drawable); - void set(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation); + void set(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation, float radius); void setControlPoint(const osg::Vec3& controlPoint) { _controlPoint = controlPoint; } const osg::Vec3& getControlPoint() const { return _controlPoint; } diff --git a/src/osg/ClusterCullingCallback.cpp b/src/osg/ClusterCullingCallback.cpp index 11c33372e..c719d0aef 100644 --- a/src/osg/ClusterCullingCallback.cpp +++ b/src/osg/ClusterCullingCallback.cpp @@ -134,17 +134,18 @@ void ClusterCullingCallback::computeFrom(const osg::Drawable* drawable) _radius = sqrtf(cdf._radius2); } -void ClusterCullingCallback::set(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation) +void ClusterCullingCallback::set(const osg::Vec3& controlPoint, const osg::Vec3& normal, float deviation, float radius) { _controlPoint = controlPoint; _normal = normal; _deviation = deviation; + _radius = radius; } bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::State*) const { - return false; +// return false; if (_deviation<=-1.0f) { @@ -153,8 +154,12 @@ bool ClusterCullingCallback::cull(osg::NodeVisitor* nv, osg::Drawable* , osg::St } osg::Vec3 eye_cp = nv->getEyePoint() - _controlPoint; + float radius = eye_cp.length(); - float deviation = (eye_cp * _normal)/eye_cp.length(); + if (radius<_radius) return false; + + + float deviation = (eye_cp * _normal)/radius; // osg::notify(osg::NOTICE)<<"ClusterCullingCallback::cull() _normal="<<_normal<<" _controlPointtest="<<_controlPoint<<" eye_cp="<