[osg-users] [AKO Warning - Message fails DKIM verification] Re: Problems with osgViewer::View::computeIntersections()

Butler, Lee Mr CIV USA USAMC lee.butler at us.army.mil
Fri Nov 13 08:01:21 PST 2009


Robert,

Thanks for the reply.  I know the problem you speak of.  I'm skeptical that is the problem I am seeing.  Numerous events have been passed to the viewer at this stage. 

Let me see if I can be more clear in my description.

I have a simple application with 1 OSG rendering area based on the osgviewerQtWidget example.  My code hasn't created any cameras or views that didn't get created with the osgViewer.

When the scenegraph is loaded, all nodes get a nodemask of 0x01.  In the application, users can select which one of the first two bits of the nodeMask is set for any node(s).  Code assures that one and only one of these bits is set for any node.  Users can also turn on and off these bits in the camera cullMask.  This allows a concept of "selected" and "not selected" objects, and rendering behaviors of: "displaying selected", "displaying not selected", "displaying both selected an not selected".

I have two types of picking operation.  The first just picks from the set of things being displayed, and works flawlessly.  

For the second type of picking operation, I want to do intersection with all objects, regardless of their current display status.  This is the scenario that doesn't work as expected.  For example:  The user has some nodes that have the first bit set and others that have the second bit set.  Suppose that at this instant, only the first bit is set in the camera's cull mask, so only items with that nodeMask bit set are being displayed.  For this pick operation, I want to pick from ALL objects, not just those which are currently displayed (passed the last camera cull phase).  I pass a mask to computeIntersections which has both bits set (actually all bits set).  What I find is that only objects with the first bit set are found by computeIntersections.

Now if I alter the camera's cull mask so that both bits are set, and render the scene so that all objects are displayed, then the call to computeIntersections returns all objects on the line segment.

Based upon this experience, I tried the following in the event handler:

	osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa);

	// a little help to get things right for the IntersectionVisitor
	unsigned stash = getCamera()->getCullMask();
	getCamera()->setCullMask(~0);
	frame();
	getCamera()->setCullMask(stash);

	pick(view, event->x(), event->y());

With this code in place, the pick operation happens as I would have originally expected.  By contrast this code in the event handler does not produce the desired effect:

	unsigned stash = getCamera()->getCullMask();
	getCamera()->setCullMask(~0);

	pick(view, event->x(), event->y());

	getCamera()->setCullMask(stash);

This produces the same result as if only pick() was called without the mask manipulations around it.

My Speculation:
During rendering, there is a cull traversal that is performed.  Objects which pass this cull traversal are gathered into a set and that set of objects is rendered.  This set of objects might be retained and re-used by the IntersectionVisitor or Intersector class (a reasonable optimization).  As a result, if an object got culled last rendering pass, you can't intersect it.  I'm the unusual person who wants to perform intersection testing against something that didn't make it through the cull pass of the last frame.

So the question is:  What should I do to get the intersection computation done for an arbitrary cull mask, independent of the last rendering pass?  I'd prefer to avoid the overhead of the extra frame() when picking.  Much of my geometry stresses the rendering pass pretty hard as it is.

----- Original Message -----
From: Robert Osfield <robert.osfield at gmail.com>
Date: Friday, November 13, 2009 3:58
Subject: [AKO Warning - Message fails DKIM verification] Re: [osg-users] Problems with	osgViewer::View::computeIntersections()
To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>


> Hi Lee,
> 
> I can't really make sense of your email.  Interseciton testing uses no
> information from what is display during rendering - it's totally
> independent.   My best guess as to what problem is would be that you
> are coming across a problem I've seen with
> View::computeIntersection(..) where it computes which camera is active
> based on the last mouse event that passed into viewer, if no event has
> been passed in yet it can't determine which camera correctly.   Could
> it be that this is the issue you are seeing?
> 
> Robert.
> 
> On Thu, Nov 12, 2009 at 9:37 PM, Butler, Lee Mr CIV USA USAMC
> < wrote:
> > I'm having a problem with osgViewer::View::computeIntersections(x, y, i, m).
> > As I understand it, this takes a view position "x", "y", an intersection list
> > "i" which will be filled in, and a mask "m" with which traversal is done.
> >
> > I am running SingleThreaded with a compliation of HEAD, calling
> > computeIntersections() with a mask value of ~0.
> >
> > There are two scenarios:
> >
> > 1) When all items are being displayed just prior to calling computeIntersections()
> > the result returned is as expected.
> >
> > 2) If not all items are displayed (because some items mask didn't match the last display traversal cull mask) then just prior to calling computeIntersections(), I do some pre-processing to set the node masks on the things I want to intersect.  In the display refresh after the computeIntersections() call, everything is being displayed per the new mask settings.
> >
> > In this instance, only those items which had been displayed prior to the call to computeIntersections() are found.  It is as if computeIntersections() is not seeing the updated nodeMask values.
> >
> > I've tried setting the camera mask to ~0 before calling computeIntersections() to no avail.
> >
> > What am I missing?
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> _______________________________________________
> 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