On Thu, Jul 12, 2012 at 7:41 PM, Manuel Fernández
<[email protected]> wrote:
> Hi,
>
> As mentioned in other post i've struggling myself trying to get OSG 3.0.1
> working on my iMac. I've have simplified the problem a lot, so here it is.
> This is a simple pick handler (base on the one that you can see in OSG
> cookbook):
>
>
...
> Well, this is the rest of the code:
>
>
I'm not sure if this is your problem, but the way you've written this:
> Code:
> static osg::ref_ptr<osg::Group> i_create_scenegraph5(void)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> {
> osg::ref_ptr<osg::Group> root;
> osg::ref_ptr<osg::Geode> geometry;
> osg::ref_ptr<osg::ShapeDrawable> shape1, shape2, shape3;
>
> shape1 = new osg::ShapeDrawable();
> shape1->setShape(new osg::Box(osg::Vec3(-3, 0., 0.), 2., 2., 1.));
> shape1->setColor(osg::Vec4(0., 0., 1., 1.));
>
> shape2 = new osg::ShapeDrawable();
> shape2->setShape(new osg::Sphere(osg::Vec3(3., 0., 0.), 1.f));
>
> shape3 = new osg::ShapeDrawable();
> shape3->setShape(new osg::Cone(osg::Vec3(0., 0., 0.), 1., 1.));
>
> geometry = new osg::Geode();
> geometry->addDrawable(shape1.get());
> geometry->addDrawable(shape2.get());
> geometry->addDrawable(shape3.get());
>
> root = new osg::Group;
> root->addChild(geometry.get());
>
> return root.get();
and this^^^^^^^^^^^^^^
> }
>
is very sensitive to the order in which the destructors in the
function and the constructor for the return value are called. Usually
you do not keep your node return value from this kind of function in a
ref_ptr, and OSG convention is not to use ref_ptrs as return values
(usually). If you really want to keep root in a ref_ptr, you will need
to release() it before returning the pointer value.
Tim
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org