[osg-users] osgUtil::IntersectionVisitor eats all the memory

Robert Osfield robert.osfield at gmail.com
Tue Jan 9 04:23:39 PST 2018


Hi Nick,

This is really something you'd want to use a debug for - just run it
and break the app before anything untoward happens.

The code itself looks quite benign on a first reading, the only thing
I can think of that might cause a memory issue would be if your scene
graph had a circular reference in it so the traversal ends up in an
infinite loop.

Robert

On 9 January 2018 at 12:12, Trajce Nikolov NICK
<trajce.nikolov.nick at gmail.com> wrote:
> hi Robert, Community,
>
> I have the following code in a loop against very large quadtree based
> database. And this code is eating all the memory, progressively and then the
> system kills it . Any clue?
>
> Thanks a lot
>
> osg::ref_ptr<osgUtil::LineSegmentIntersector> picker;
> osg::ref_ptr<osgUtil::IntersectionVisitor> iv;
>
> osg::Vec3d getHOT(const osg::Vec3d& position, osgViewer::CompositeViewer&
> viewer, osg::Vec3& normal, bool& valid)
> {
>     osg::Vec3d result;
>
> osg::EllipsoidModel em;
> osg::Vec3d up = em.computeLocalUpVector(position.x(), position.y(),
> position.z());
> up.normalize();
>
> osg::Vec3d s = position + up * 100;
>     osg::Vec3d e = osg::Vec3d(0, 0, 0);
>
>     if (viewer.getView(0)->getSceneData())
>     {
> #if 1
> if (!picker.valid())
> {
> picker = new osgUtil::LineSegmentIntersector(s,e);
> iv = new  MyIntersectionVisitor(RANGE);
> }
> picker->setStart(s);
> picker->setEnd(e);
> picker->getIntersections().clear();
> iv->setIntersector(picker);
> iv->reset();
> iv->setUseKdTreeWhenAvailable(false);
> //iv->setLODSelectionMode(osgUtil::IntersectionVisitor::USE_EYE_POINT_FOR_LOD_LEVEL_SELECTION);
> viewer.getView(0)->getSceneData()->accept(*iv);
>
> if (picker->containsIntersections())
> {
> osgUtil::LineSegmentIntersector::Intersections           hitList =
> picker->getIntersections();
> osgUtil::LineSegmentIntersector::Intersections::iterator hit =
> hitList.begin();
>
> result = hit->getWorldIntersectPoint();
> normal = hit->getWorldIntersectNormal();
> valid = true;
>
> return result;
> }
> #endif
>     }
> valid = false;
>
>     return result;
> }
>
> --
> trajce nikolov nick
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>


More information about the osg-users mailing list