/*****************************************************************************
 * $LastChangedDate: 2009-11-22 22:39:11 -0500 (Sun, 22 Nov 2009) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   OSG node masks (cull masks).
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef VIEW_NODE_MASKS_HH
#define VIEW_NODE_MASKS_HH 1

namespace view {
namespace defs {

//------------------------------------------------------------------------------
// OSG node masks (cull masks):
// First, node masks and cull masks are synonyms.
// When an OSG camera traverses the graph, it does a bitwise AND
// of its "cull mask" vs. the "node mask" of every node.
// If the result of AND is zero, then the node and its children
// are culled from the rendering of that camera.
// For example, to make only the main camera render a 3D model,
// assign its node mask with NODE_MASK_MAIN_CAMERA.
// Window::AddView() assigns a cull mask to an osg::Camera (main or non-main).
//
// Separate bit fields for main and aux views:
// Every view has its own shadow caster/receiver bits.
// If they were shared, the cull mask would incorrectly pass
// when rendering the main view but NODE_MASK_MAIN_VIEW=0 (v.v.)
// because of the caster/receiver bits being set.
//------------------------------------------------------------------------------

// Individual bits:
const osg::Node::NodeMask NODE_MASK_MAIN_VIEW_SHIFT           = 0;
const osg::Node::NodeMask NODE_MASK_MAIN_VIEW                 = (1<<0);
const osg::Node::NodeMask NODE_MASK_MAIN_VIEW_SHADOW_CASTER   = (1<<1);
const osg::Node::NodeMask NODE_MASK_MAIN_VIEW_SHADOW_RECEIVER = (1<<2);

const osg::Node::NodeMask NODE_MASK_AUX_VIEW_SHIFT            = 3;
const osg::Node::NodeMask NODE_MASK_AUX_VIEW                  = (1<<3);
const osg::Node::NodeMask NODE_MASK_AUX_VIEW_SHADOW_CASTER    = (1<<4);
const osg::Node::NodeMask NODE_MASK_AUX_VIEW_SHADOW_RECEIVER  = (1<<5);

// Composite bits:
const osg::Node::NodeMask NODE_MASK_MAIN_VIEW_ALL             = NODE_MASK_MAIN_VIEW
                                                              | NODE_MASK_MAIN_VIEW_SHADOW_CASTER
                                                              | NODE_MASK_MAIN_VIEW_SHADOW_RECEIVER;

const osg::Node::NodeMask NODE_MASK_AUX_VIEW_ALL              = NODE_MASK_AUX_VIEW
                                                              | NODE_MASK_AUX_VIEW_SHADOW_CASTER
                                                              | NODE_MASK_AUX_VIEW_SHADOW_RECEIVER;

const osg::Node::NodeMask NODE_MASK_ALL                       = NODE_MASK_MAIN_VIEW_ALL
                                                              | NODE_MASK_AUX_VIEW_ALL;

const osg::Node::NodeMask NODE_MASK_SHADOW_CASTER             = NODE_MASK_MAIN_VIEW_SHADOW_CASTER
                                                              | NODE_MASK_AUX_VIEW_SHADOW_CASTER;

const osg::Node::NodeMask NODE_MASK_SHADOW_RECEIVER           = NODE_MASK_MAIN_VIEW_SHADOW_RECEIVER
                                                              | NODE_MASK_AUX_VIEW_SHADOW_RECEIVER;

} // namespace defs
} // namespace view

#endif // VIEW_NODE_MASKS_HH
