Hi,

Wonderful. Our code is full of:
  if the object is a drawable then
    do something for the drawable
  else
    do something for the node

For the getBound problem, I think there is no solution. The return type
is not included in the function prototype.

Lionel.


On 13/05/2014 17:13, Robert Osfield wrote:
Hi All,

Over the last day I have been experimenting with changing
osg::Drawable so that it is subclassed from osg::Node rather than
osg::Object.  The motivation behind this change is to make it simpler
to build scene graphs that only contain a single geometry and enabling
one to just directly attach a Geometry to the scene graph, without the
need for decorating it with a Geode first.

I have got the OSG build and running fine with this change, but I had
to make more changes to code that accessed Drawable than I'd have
liked, and this concerns me about the impact it may have on end users
that will be forced to update their code toI  ideally I'd get things
to a point where very few users need to do anything more than a
recompile against the new version of the OSG.  With this goal in mind
I'd like feedback from the community about what solutions

The problem area is the overlap between the Node::getBound() that
returns a BoundingSphere and the Drawable::getBound() that returns a
BoundingBox.  Any code that gets the bounding box from the Drawable
using the getBound() method will now fail to compile as it'll be
getting a BoundingSphere back in place.  My current workaround to this
is to have a Drawable::getBoundingBox() method that the can be used to
directly access the Drawable's BoundingBox.   This tweak is perfectly
valid implementation but it does require calling code to be modified.

Might there be alternatives that C++ can help us with?  In a perfect
world we'd be able to select the appropriate getBound() implementation
depending upon what type it's being assigned to ie.:

     // get the bounding sphere of the Drawable
     const BoundingSphere& bs = drawable->getBound();

     // but we also want the old code to keep compiling where we want
the bounding box
     const BoundingBox& bb = drawable->getBound();

I'm currently trying to think of ways to solve this conundrum.  There
might be a simple C++ trick that I've overlooked, which is why having
a nice big community of C++ programmers is an asset :-)

So.... what's solutions can you think of?

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


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

Reply via email to