J-S,

If I follow the code and this thread correctly, I don't think this a
bug; I think it's a limitation of the current implementation.

For example...

If I have nodes masked by type (Craft, Planet, Debris, etc), and I
only want to pick nodes of certain types (Craft and Planet, but NOT
Debris), the system supports this.  None of my nodes will have a mask
set as both Craft and Planet, but either will qualify as pickable.  If
I restrict it to only nodes with both masks set, I'm probably not
going to be able pick anything.

The Pickable and Visible case would require the combined mask, but the
current implementation doesn't support that directly.

As Simon suggested, deriving new types and overriding the appropriate
virtual functions should allow the desired behavior.

The problem as I see it is the two situations I list here are mutually
exclusive.

If we wanted to provide both options, I think we would need to add a
flag somewhere to indicate what type of mask matching behavior we're
looking for (match any bit in the mask, OR match all bits in the
mask).  Deciding WHEN to set the flag to which mode is the user's real
problem, and I think Simon's derived type suggestion takes care of
that problem quite nicely without requiring a change to the current
implementation as the default behavior.

Then again, I could be totally off base, so feel free to correct me,
and I'll be happy to learn from the experience.  :)

I hope this helps...

D.J.

On Fri, May 7, 2010 at 9:22 AM, Jean-Sébastien Guay
<[email protected]> wrote:
> Hi Simon,
>
>> Yes, he wants to only pick objects which are pickable AND visible.
>> Which you can't do just using a node mask, you'll get anything which is
>> pickable OR visible.
>
> That's a bug IMHO. If I say this:
>
> int VISIBLE_MASK = 0x01;
> int PICKABLE_MASK = 0x02;
>
> // Render only what's visible
> view->getCamera()->setCullMask(VISIBLE_MASK);
>
> // Pick what's visible and pickable
> intersectionVisitor->setTraversalMask(VISIBLE_MASK | PICKABLE_MASK);
>
> visibleNode->setNodeMask(VISIBLE_MASK);
> pickableVisibleNode->setNodeMask(VISIBLE_MASK | PICKABLE_MASK);
> pickableNode->setNodeMask(PICKABLE_MASK);
>
> Then I should only see the nodes that have VISIBLE_MASK set (so visibleNode
> and pickableVisibleNode above), and I should only be able to pick nodes that
> have both VISIBLE_MASK and PICKABLE_MASK set (so only pickableVisibleNode
> above). The rendering works (I only see visibleNode and pickableVisibleNode)
> but the picking sees all three nodes.
>
> Here's a modified osgpick that shows this. In the 5 boxes on the left side
> of the window, the first is VISIBLE but not PICKABLE, the second is both,
> the third is PICKABLE but not VISIBLE, and the last two are both. Indeed we
> don't see the third, so that's fine, but we can still pick all 5.
>
> Instead of (traversalMask & nodeMask) != 0, perhaps the condition should be
> (traversalMask & nodeMask) == traversalMask... Or perhaps there's a
> rationale for being able to pick whatever has part of the traversal mask,
> but not the mask exactly, but I can't see it right now...
>
> I can't delve into this at present, but with an example that shows the
> problem perhaps others can fix it...
>
> J-S
> --
> ______________________________________________________
> Jean-Sebastien Guay    [email protected]
>                               http://www.cm-labs.com/
>                        http://whitestar02.webhop.org/
>
> _______________________________________________
> 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