[osg-users] RayIntersector with KdTree causes a crash

Robert Osfield robert.osfield at gmail.com
Tue Sep 4 07:38:35 PDT 2018

Hi Ale,

I have invested the issue further, focusing on why the sphere appears
fine when the KdTree isn't build, but disappears when it is.  I
tracked this issue down to the ShapeDrawable::setShape() being invoked
by the KdTreeBuilder that creates a KdTree for a ShapeDrawable then
assigns this KdTree to the ShapeDrawable via the Drawable::setShape()
method which in turn invokes the ShapeDrawable::build() method that
attempts to build a geometry from the KdTree.  It's a bit of circular
reference - KdTree wasn't ever meant to work with ShapeDrawable, it's
only now working because of the change of ShapeDrawable from
subclassing from Drawable to subclassing from Geometry.

To prevent the unintended rebuild I have disable the
ShapeDrawable::build() from doing anything when the shape assigned is
a KdTree.


There is still a bit of mismatch in that KdTree is a special case of a
Shape, but still a valid use.  Shape's were always intended to be used
for intersection testing and physics, but never originally intended to
support a ShapeDrawable.  The ShapeDrawable was a quick and easy thing
to add to help visualize primitive shapes but in hindsight I should
never have implemented it as it's misused too much by the community as
a serious means for drawing objects.  It's not possible to remove
ShapeDrawable without breaking lots of user applications so it's still
part of the OSG.  Please consider it just there for backwards

The above change is now checked into master and the OpenSceneGraph-3.6
branch. so it will be part of the 3.6.3 release I'll make this month.

Testing of these changes would be appreciated.


More information about the osg-users mailing list