mirror of https://github.com/axmolengine/axmol.git
add camera mask check to visit
This commit is contained in:
parent
96500a17d6
commit
76329f9e53
|
@ -261,6 +261,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
|||
renderer->addCommand(&_afterDrawStencilCmd);
|
||||
|
||||
int i = 0;
|
||||
bool visibleByCamera = checkCameraMask();
|
||||
|
||||
if(!_children.empty())
|
||||
{
|
||||
|
@ -276,12 +277,13 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32
|
|||
break;
|
||||
}
|
||||
// self draw
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
if (visibleByCamera)
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
|
||||
(*it)->visit(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
else
|
||||
else if (visibleByCamera)
|
||||
{
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
|
|
@ -1053,7 +1053,7 @@ void Label::drawTextSprite(Renderer *renderer, uint32_t parentFlags)
|
|||
|
||||
void Label::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
if (! _visible || _originalUTF8String.empty())
|
||||
if (! _visible || _originalUTF8String.empty() || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1225,6 +1225,13 @@ uint32_t Node::processParentFlags(const Mat4& parentTransform, uint32_t parentFl
|
|||
return flags;
|
||||
}
|
||||
|
||||
bool Node::checkCameraMask() const
|
||||
{
|
||||
auto camera = Camera::getVisitingCamera();
|
||||
bool visibleByCamera = camera ? (unsigned short)camera->getCameraFlag() & _cameraMask : true;
|
||||
return visibleByCamera;
|
||||
}
|
||||
|
||||
void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
|
@ -1242,8 +1249,7 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t paren
|
|||
director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
auto camera = Camera::getVisitingCamera();
|
||||
bool visibleByCamera = camera ? (unsigned short)camera->getCameraFlag() & _cameraMask : true;
|
||||
bool visibleByCamera = checkCameraMask();
|
||||
|
||||
int i = 0;
|
||||
|
||||
|
@ -1267,10 +1273,9 @@ void Node::visit(Renderer* renderer, const Mat4 &parentTransform, uint32_t paren
|
|||
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
|
||||
(*it)->visit(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
else
|
||||
else if (visibleByCamera)
|
||||
{
|
||||
if (visibleByCamera)
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
|
|
@ -1521,6 +1521,9 @@ protected:
|
|||
bool doEnumerate(std::string name, std::function<bool (Node *)> callback) const;
|
||||
bool doEnumerateRecursive(const Node* node, const std::string &name, std::function<bool (Node *)> callback) const;
|
||||
|
||||
//check whether this camera mask is visible by the current visiting camera
|
||||
bool checkCameraMask() const;
|
||||
|
||||
#if CC_USE_PHYSICS
|
||||
void updatePhysicsBodyTransform(Scene* layer);
|
||||
virtual void updatePhysicsBodyPosition(Scene* layer);
|
||||
|
|
|
@ -126,6 +126,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t p
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
bool visibleByCamera = checkCameraMask();
|
||||
|
||||
if(!_children.empty())
|
||||
{
|
||||
|
@ -141,13 +142,14 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t p
|
|||
break;
|
||||
}
|
||||
// self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
if (visibleByCamera)
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
|
||||
for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) {
|
||||
(*it)->visit(renderer, _modelViewTransform, dirty);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (visibleByCamera)
|
||||
{
|
||||
this->draw(renderer, _modelViewTransform, dirty);
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ void ParticleBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, u
|
|||
// The alternative is to have a void Sprite#visit, but
|
||||
// although this is less maintainable, is faster
|
||||
//
|
||||
if (!_visible)
|
||||
if (!_visible || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -318,7 +318,8 @@ void ProtectedNode::visit(Renderer* renderer, const Mat4 &parentTransform, uint3
|
|||
//
|
||||
// draw self
|
||||
//
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
if (checkCameraMask())
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
//
|
||||
// draw children and protectedChildren zOrder >= 0
|
||||
|
|
|
@ -393,7 +393,7 @@ void RenderTexture::visit(Renderer *renderer, const Mat4 &parentTransform, uint3
|
|||
{
|
||||
// override visit.
|
||||
// Don't call visit on its children
|
||||
if (!_visible)
|
||||
if (!_visible || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ void SpriteBatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uin
|
|||
// The alternative is to have a void Sprite#visit, but
|
||||
// although this is less maintainable, is faster
|
||||
//
|
||||
if (! _visible)
|
||||
if (! _visible || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ void Armature::onExit()
|
|||
void Armature::visit(cocos2d::Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
if (!_visible || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ void BatchNode::removeChild(Node* child, bool cleanup)
|
|||
void BatchNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags)
|
||||
{
|
||||
// quick return if not visible. children won't be drawn.
|
||||
if (!_visible)
|
||||
if (!_visible || !checkCameraMask())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -774,7 +774,8 @@ y+=ytranslate; \
|
|||
//
|
||||
// draw self
|
||||
//
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
if (checkCameraMask())
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
//
|
||||
// draw children and protectedChildren zOrder >= 0
|
||||
|
|
|
@ -581,6 +581,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t
|
|||
director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);
|
||||
|
||||
this->beforeDraw();
|
||||
bool visibleByCamera = checkCameraMask();
|
||||
|
||||
if (!_children.empty())
|
||||
{
|
||||
|
@ -601,7 +602,8 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t
|
|||
}
|
||||
|
||||
// this draw
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
if (visibleByCamera)
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
|
||||
// draw children zOrder >= 0
|
||||
for( ; i < _children.size(); i++ )
|
||||
|
@ -611,7 +613,7 @@ void ScrollView::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t
|
|||
}
|
||||
|
||||
}
|
||||
else
|
||||
else if (visibleByCamera)
|
||||
{
|
||||
this->draw(renderer, _modelViewTransform, flags);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue