Commit 2945a34c authored by Jan Möbius's avatar Jan Möbius
Browse files

Changed multipass rendering.

Added enum to count passes.
Added NOPASS flag

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8118 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9db0a07a
......@@ -73,8 +73,8 @@ unsigned int BaseNode::last_id_used__ = 0;
BaseNode::
BaseNode(BaseNode* _parent, std::string _name)
: multipassStatus_(0u),
multipassNode_(1u),
: multipassStatus_(ALLPASSES),
multipassNode_(PASS_1),
parent_(_parent),
name_(_name),
status_(Active),
......@@ -96,8 +96,8 @@ BaseNode(BaseNode* _parent, std::string _name)
BaseNode::
BaseNode(BaseNode* _parent, BaseNode* _child, std::string _name)
: multipassStatus_(1u),
multipassNode_(1u),
: multipassStatus_(ALLPASSES),
multipassNode_(PASS_1),
parent_(_parent),
name_(_name),
status_(Active),
......@@ -189,58 +189,67 @@ BaseNode::leavePick(GLState& _state, PickTarget /*_target*/, unsigned int _drawM
//----------------------------------------------------------------------------
void BaseNode::multipassStatusSetActive(const unsigned int _i, bool _active) {
assert(_i != 0);
if (_i == 0)
std::cerr << "Error: Render passes start with 1!" << std::endl;
if ( _i == NOPASS ) {
multipassStatus_ = NOPASS;
} else if ( _i == ALLPASSES ) {
if ( _active )
multipassStatus_ = ALLPASSES;
else
multipassStatus_ = NOPASS;
} else {
if ( _active )
multipassStatus_ |= (1 << (_i == 0 ? 0 : _i - 1));
else
multipassStatus_ &= ~(1 << (_i == 0 ? 0 : _i - 1));
}
if ( _active )
multipassStatus_ |= (1 << (_i == 0 ? 0 : _i - 1));
else
multipassStatus_ &= ~(1 << (_i == 0 ? 0 : _i - 1));
}
//----------------------------------------------------------------------------
bool BaseNode::multipassStatusActive(const unsigned int _i) const {
assert(_i != 0);
if (_i == 0)
std::cerr << "Error: Render passes start with 1!" << std::endl;
if ( multipassStatus_ == ALLPASSES )
if ( multipassStatus_ == NOPASS )
return false;
else if ( multipassStatus_ & ALLPASSES )
return true;
else
return ((1 << (_i == 0 ? 0 : _i - 1)) & multipassStatus_) != 0;
}
//----------------------------------------------------------------------------
void BaseNode::multipassNodeSetActive(const unsigned int _i , bool _active) {
assert(_i != 0);
if (_i == 0)
std::cerr << "Error: Render passes start with 1!" << std::endl;
if ( _i == NOPASS ) {
multipassNode_ = NOPASS;
} else if ( _i == ALLPASSES ) {
if ( _active )
multipassNode_ = ALLPASSES;
else
multipassNode_ = NOPASS;
} else {
if ( _active )
multipassNode_ |= (1 << (_i == 0 ? 0 : _i - 1));
else
multipassNode_ &= ~(1 << (_i == 0 ? 0 : _i - 1));
}
if ( _active )
multipassNode_ |= (1 << (_i == 0 ? 0 : _i - 1));
else
multipassNode_ &= ~(1 << (_i == 0 ? 0 : _i - 1));
}
//----------------------------------------------------------------------------
bool BaseNode::multipassNodeActive(const unsigned int _i) const {
assert(_i != 0);
if (_i == 0)
std::cerr << "Error: Render passes start with 1!" << std::endl;
if ( multipassNode_ == ALLPASSES )
if ( multipassNode_ == NOPASS )
return false;
else if ( multipassNode_ & ALLPASSES )
return true;
else
return ((1 << (_i == 0 ? 0 : _i - 1)) & multipassNode_) != 0;
}
//=============================================================================
......
......@@ -406,12 +406,25 @@ public:
/// Multipass pass bit mask type
typedef unsigned int MultipassBitMask;
/// This constant should be used to enable rendering of a node in all passes
static const unsigned int ALLPASSES = 0;
/// This enum should be used to enable rendering of a node in different
enum PASSES {
NOPASS = 0,
ALLPASSES = 1 << 0,
PASS_1 = 1 << 1,
PASS_2 = 1 << 2,
PASS_3 = 1 << 3,
PASS_4 = 1 << 4,
PASS_5 = 1 << 5,
PASS_6 = 1 << 6,
PASS_7 = 1 << 7,
PASS_8 = 1 << 8
};
/** \brief Get the current multipass settings for the nodes status functions
*
* Get a bitmask defining in which traverse pass the enter and leave nodes are used. (1-indexed)
* Get a bitmask defining in which traverse pass the enter and leave nodes are used. Use
* the PASSES enum above to control multipass rendering!
*
* @return Bitmask defining in which traverse pass the enter and leave nodes are used
*/
......@@ -420,7 +433,9 @@ public:
/** \brief Set multipass settings for the nodes status functions
*
* Set a bitmask defining in which traverse pass the enter and leave nodes are used. (1-indexed)
* Set a bitmask defining in which traverse pass the enter and leave nodes are used. Use
* the PASSES enum above to control multipass rendering!
*
* Set to ALLPASSES if you want to render in all passes
*
* @param _passStatus Bitmask defining in which traverse pass the enter and leave nodes are used
......@@ -430,7 +445,8 @@ public:
/** \brief Set multipass status to traverse in a specific pass
*
* Change multipass setting for the nodes status functions. The node will
* call its enter and leave functions in the given pass if its set active
* call its enter and leave functions in the given pass if its set active.
* Use the PASSES enum above to control multipass rendering!
*
* @param _i Pass in which the node should be rendered
* @param _active Activate or deactivate in this pass?
......@@ -440,7 +456,8 @@ public:
/** \brief Get multipass status to traverse in a specific pass
*
* Check multipass setting for the nodes status functions if they should
* be called in the given render pass.
* be called in the given render pass.
* Use the PASSES enum above to control multipass rendering!
*
* @param _i Check this pass if the nodes enter/leave functions are active
*/
......@@ -451,6 +468,7 @@ public:
/** \brief Get the current multipass settings for the node
*
* Get a bitmask defining in which traverse path an action is applied to the node. (1-indexed)
* Use the PASSES enum above to control multipass rendering!
*
* @return Bitmask defining in which traverse passes an action is applied to the node.
*/
......@@ -461,7 +479,8 @@ public:
/** \brief Set multipass settings for the node
*
* Set a bitmask defining in which traverse path an action is applied to the node. (1-indexed)
* Set to ALLPASSES if you want to render in all passes
* Set to ALLPASSES if you want to render in all passes.
* Use the PASSES enum above to control multipass rendering!
*
* @param _passNode Bitmask defining in which traverse passes an action is applied to the node.
*/
......@@ -471,6 +490,7 @@ public:
*
* Change multipass setting for the node. An action will be
* applied to this node in the given pass.
* Use the PASSES enum above to control multipass rendering!
*
* @param _i Pass in which the node should be rendered
* @param _active Enable or disable node in this pass?
......@@ -481,6 +501,7 @@ public:
*
* Check multipass setting for the node if an action will be
* applied in the given pass.
* Use the PASSES enum above to control multipass rendering!
*
* @param _i Check this pass if an action will be applied to the node.
*/
......
......@@ -346,7 +346,7 @@ traverse_multipass( BaseNode* _node,
unsigned int max_passes = _state.max_render_passes();
// Render all passes
for(unsigned int pass = 1; pass <= max_passes; ++pass) {
for(unsigned int pass = BaseNode::PASS_1; pass <= (BaseNode::PASS_1 + max_passes); ++pass) {
// Traverse scenegraph
traverse_multipass (_node, action, pass);
......@@ -436,8 +436,8 @@ class MultiPassInfoAction
public:
MultiPassInfoAction() :
statusPasses_(0u),
nodePasses_(0u)
statusPasses_(BaseNode::ALLPASSES),
nodePasses_(BaseNode::ALLPASSES)
{}
bool operator()(BaseNode* _node) {
......@@ -451,7 +451,11 @@ public:
// decimal value (0x001011 -> 4)
// Note: Same as (int)log2(bitmask)
unsigned int c = 0;
while(statusPass != 0u) {
// Skip the first one as this is the ALLPASSES flag
statusPass = statusPass >> 1;
while( statusPass != 0u ) {
statusPass = statusPass >> 1;
++c;
}
......@@ -468,6 +472,10 @@ public:
// decimal value (0x001011 -> 4)
// Note: Same as (int)log2(bitmask)
unsigned int c = 0;
// Skip the first one as this is the ALLPASSES flag
nodePass = nodePass >> 1;
while(nodePass != 0u) {
nodePass = nodePass >> 1;
++c;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment