I found what appears to be another bug/limitation in ShadowMap.cpp.  When 
traversing the nodes which cast shadows, it uses this code:

cv.setTraversalMask( traversalMask & 
   getShadowedScene()->getCastsShadowTraversalMask() );

'traversalMask' here is the sceneview's draw mask, which defaults to 
0xffffffff, but can be set to other values depending on the application's needs.

Consider the case:
ReceivesShadow = 0x1
CastsShadow = 0x2
Scene's DrawMask = 0x4

For a node which is drawn and fully shadowed, such as the default mask, these 
are all set, so its node mask includes the bits 0x7.

Now ShadowMap comes along, and the above code computes (0x4 & 0x2) == 0.  A 
visitor mask of 0 finds nothing.  That's not right.

I can only imagine the ShadowMap author meant, they wanted to traverse nodes 
with _both_ bits set, both visible and casting.  But, AFAIK, NodeVisitor 
doesn't do AND, it only does OR.  That is, a traversal will always proceed when 
_any_ bit matches, not when _all_ bits match.  So the above is a bug from 
misunderstanding how NodeVisitor works.

To replace the code with this, would at least fix the general case:

cv.setTraversalMask( getShadowedScene()->getCastsShadowTraversalMask() );

However, that doesn't correctly omit nodes which are casting but not drawn, 
e.g. mask=0x3 using the values above.  Perhaps it's just not possible for node 
traversal to do the correct thing?  Or maybe, there is some more powerful 
visitor capability in OSG that would save the day here?

-Ben


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to