- Optimization in CCClippingNode.

Disable visiting when no objects has to be drawn under stencil.
This commit is contained in:
teivaz 2014-11-11 21:09:58 +02:00
parent 6c67c6921d
commit 7c355a087b
2 changed files with 14 additions and 2 deletions

View File

@ -231,7 +231,7 @@ void ClippingNode::drawFullScreenQuadClearStencil()
void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
{
if(!_visible)
if (!_visible || !hasContent())
return;
uint32_t flags = processParentFlags(parentTransform, parentFlags);
@ -327,6 +327,11 @@ void ClippingNode::setStencil(Node *stencil)
_stencil = stencil;
}
bool ClippingNode::hasContent()
{
return _children.size() > 0;
}
GLfloat ClippingNode::getAlphaThreshold() const
{
return _alphaThreshold;

View File

@ -58,7 +58,14 @@ public:
*/
Node* getStencil() const;
void setStencil(Node *stencil);
/** If stencil has no childre it will not be drawn.
If you have custom stencil-based node with stencil drawing mechanics other then children-based,
then this method should return true every time you wish stencil to be visited.
By default returns true if has any children attached.
*/
virtual bool hasContent();
/** The alpha threshold.
The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold.
Should be a float between 0 and 1.