> For your own task I suspect the solution will not be to change the core, but 
> to address the problems so you don't generate scene graphs in a indeterminate 
> state. 
> 

The problem is that we don't have a way to differentiate between 
"indeterminate" and "empty" bounds, so there is currently no way for a 
determinate state in some cases.


> ideally you don't have scene graphs with invalid bounding volumes

osgAnimation, the official osg component does heavily make use of bone nodes 
which have generally an indeterminate (null) bounds by default. There is a 
legimitate need for a new core feature when one or more node kits could make 
good use of it.

How would you feel about adding support for a "null" bounding sphere? Users can 
then explicitely mark empty nodes to have "null" bounds by default so that they 
can be culled. Something akin to this:


Code:

diff --git a/include/osg/BoundingSphere b/include/osg/BoundingSphere
index 0b62c2c..73f37e5 100644
--- a/include/osg/BoundingSphere
+++ b/include/osg/BoundingSphere
@@ -63,6 +63,15 @@ class BoundingSphereImpl
           * otherwise. */
         inline bool valid() const { return _radius>=0.0; }
 
+        inline bool null() const { return _radius==0.0; }
+
+        /** Set the bounding sphere to null (i.e. empty). */
+        inline void setNull()
+        {
+            _center.set(0.0,0.0,0.0);
+            _radius = 0.0;
+        }
+
         inline bool operator == (const BoundingSphereImpl& rhs) const { return 
_center==rhs._center && _radius==rhs._radius; }
         inline bool operator != (const BoundingSphereImpl& rhs) const { return 
_center!=rhs._center || _radius==rhs._radius; }
 
@@ -181,10 +190,10 @@ template<typename VT>
 void BoundingSphereImpl<VT>::expandBy(const BoundingSphereImpl& sh)
 {
     // ignore operation if incoming BoundingSphere is invalid.
-    if (!sh.valid()) return;
+    if (!sh.valid() || sh.null()) return;
 
-    // This sphere is not set so use the inbound sphere
-    if (!valid())
+    // This sphere is not set or null so use the inbound sphere
+    if (!valid() || null())
     {
         _center = sh._center;
         _radius = sh._radius;
@@ -231,9 +240,9 @@ void BoundingSphereImpl<VT>::expandBy(const 
BoundingSphereImpl& sh)
 template<typename VT>
 void BoundingSphereImpl<VT>::expandRadiusBy(const BoundingSphereImpl& sh)
 {
-    if (sh.valid())
+    if (sh.valid() && !sh.null())
     {
-        if (valid())
+        if (valid() && !null())
         {
             value_type r = (sh._center-_center).length()+sh._radius;
             if (r>_radius) _radius = r;
@@ -253,7 +262,7 @@ void BoundingSphereImpl<VT>::expandBy(const 
BoundingBoxImpl<BBT>& bb)
 {
     if (bb.valid())
     {
-        if (valid())
+        if (valid() && !null())
         {
             BoundingBoxImpl<vec_type> newbb(bb);
 
@@ -284,7 +293,7 @@ void BoundingSphereImpl<VT>::expandRadiusBy(const 
BoundingBoxImpl<BBT>& bb)
 {
     if (bb.valid())
     {
-        if (valid())
+        if (valid() && !null())
         {
             for(unsigned int c=0;c<8;++c)
             {
diff --git a/include/osg/CullStack b/include/osg/CullStack
index f045a26..5f32254 100644
--- a/include/osg/CullStack
+++ b/include/osg/CullStack
@@ -109,9 +109,9 @@ class OSG_EXPORT CullStack : public osg::CullSettings
 
         inline bool isCulled(const osg::Node& node)
         {
-            if (node.getNumChildrenWithCullingDisabled() == 0 && 
node.getCullingActive())
+            if (node.isCullingActive())
             {
-                if (!node.getBound().valid())
+                if (node.getBound().null())
                     return true;
                 return getCurrentCullingSet().isCulled(node.getBound());
             }




A "null" bounding sphere could actually be useful for others cases. For 
example, I noticed with intersection visitors you can get NaN errors when going 
into 0-scaled nodes (something I've seen reported on this mailing list as 
well). Now, we'd have explict way to test for null bounds so we can prevent the 
intersection visitor from entering that node in the first place, preventing 
NaNs from popping up.

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65710#65710





_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org

Reply via email to