From 0bddeb88c81736ecc8c71dd27fa5eb97b08d47fc Mon Sep 17 00:00:00 2001 From: Nite Luo Date: Thu, 15 Jan 2015 14:57:51 -0800 Subject: [PATCH] Disable 3D rendering support for commands that needs to execute in order --- cocos/2d/CCClippingNode.cpp | 8 ++++---- cocos/2d/CCNodeGrid.cpp | 6 +++--- cocos/renderer/CCCustomCommand.h | 2 +- cocos/renderer/CCGroupCommand.cpp | 8 -------- cocos/renderer/CCGroupCommand.h | 1 - cocos/ui/UILayout.cpp | 12 ++++++------ extensions/GUI/CCScrollView/CCScrollView.cpp | 5 ++--- .../Classes/ClippingNodeTest/ClippingNodeTest.cpp | 8 ++++---- .../Classes/NewRendererTest/NewRendererTest.cpp | 2 +- 9 files changed, 21 insertions(+), 31 deletions(-) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index c3384b5bce..4cb2180915 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -246,12 +246,12 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 //Add group command - _groupCommand.init(_globalZOrder, _modelViewTransform, flags); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmd.init(_globalZOrder, _modelViewTransform, flags); + _beforeVisitCmd.init(_globalZOrder); _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this); renderer->addCommand(&_beforeVisitCmd); if (_alphaThreshold < 1) @@ -274,7 +274,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 } _stencil->visit(renderer, _modelViewTransform, flags); - _afterDrawStencilCmd.init(_globalZOrder, _modelViewTransform, flags); + _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -306,7 +306,7 @@ void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32 this->draw(renderer, _modelViewTransform, flags); } - _afterVisitCmd.init(_globalZOrder, _modelViewTransform, flags); + _afterVisitCmd.init(_globalZOrder); _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this); renderer->addCommand(&_afterVisitCmd); diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 93fc60ddf5..ae1a403b88 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -91,7 +91,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t p _modelViewTransform = this->transform(parentTransform); _transformUpdated = false; - _groupCommand.init(_globalZOrder, _modelViewTransform, parentFlags); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); @@ -111,7 +111,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t p _nodeGrid->set2DProjection(); } - _gridBeginCommand.init(_globalZOrder, _modelViewTransform, parentFlags); + _gridBeginCommand.init(_globalZOrder); _gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); renderer->addCommand(&_gridBeginCommand); @@ -160,7 +160,7 @@ void NodeGrid::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t p director->setProjection(beforeProjectionType); } - _gridEndCommand.init(_globalZOrder, _modelViewTransform, parentFlags); + _gridEndCommand.init(_globalZOrder); _gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this); renderer->addCommand(&_gridEndCommand); diff --git a/cocos/renderer/CCCustomCommand.h b/cocos/renderer/CCCustomCommand.h index 94561f1f55..a1ab55fbf7 100644 --- a/cocos/renderer/CCCustomCommand.h +++ b/cocos/renderer/CCCustomCommand.h @@ -38,7 +38,7 @@ public: public: - void init(float globalZOrder, const Mat4& modelViewTransform, uint32_t flags); + CC_DEPRECATED_ATTRIBUTE void init(float globalZOrder, const Mat4& modelViewTransform, uint32_t flags); void init(float depth); void execute(); diff --git a/cocos/renderer/CCGroupCommand.cpp b/cocos/renderer/CCGroupCommand.cpp index f27b1cd902..576dab111e 100644 --- a/cocos/renderer/CCGroupCommand.cpp +++ b/cocos/renderer/CCGroupCommand.cpp @@ -77,14 +77,6 @@ GroupCommand::GroupCommand() _renderQueueID = Director::getInstance()->getRenderer()->getGroupCommandManager()->getGroupID(); } -void GroupCommand::init(float globalZOrder, const cocos2d::Mat4 &modelViewTransform, uint32_t flags) -{ - RenderCommand::init(globalZOrder, modelViewTransform, flags); - auto manager = Director::getInstance()->getRenderer()->getGroupCommandManager(); - manager->releaseGroupID(_renderQueueID); - _renderQueueID = manager->getGroupID(); -} - void GroupCommand::init(float globalOrder) { _globalOrder = globalOrder; diff --git a/cocos/renderer/CCGroupCommand.h b/cocos/renderer/CCGroupCommand.h index da14842f59..96fa8f70da 100644 --- a/cocos/renderer/CCGroupCommand.h +++ b/cocos/renderer/CCGroupCommand.h @@ -53,7 +53,6 @@ public: GroupCommand(); ~GroupCommand(); - void init(float globalZOrder, const Mat4& modelViewTransform, uint32_t flags); void init(float depth); inline int getRenderQueueID() const {return _renderQueueID;} diff --git a/cocos/ui/UILayout.cpp b/cocos/ui/UILayout.cpp index 23110b8b50..a9f953e865 100644 --- a/cocos/ui/UILayout.cpp +++ b/cocos/ui/UILayout.cpp @@ -251,18 +251,18 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); //Add group command - _groupCommand.init(_globalZOrder, _modelViewTransform, parentFlags); + _groupCommand.init(_globalZOrder); renderer->addCommand(&_groupCommand); renderer->pushGroup(_groupCommand.getRenderQueueID()); - _beforeVisitCmdStencil.init(_globalZOrder, _modelViewTransform, parentFlags); + _beforeVisitCmdStencil.init(_globalZOrder); _beforeVisitCmdStencil.func = CC_CALLBACK_0(Layout::onBeforeVisitStencil, this); renderer->addCommand(&_beforeVisitCmdStencil); _clippingStencil->visit(renderer, _modelViewTransform, flags); - _afterDrawStencilCmd.init(_globalZOrder, _modelViewTransform, parentFlags); + _afterDrawStencilCmd.init(_globalZOrder); _afterDrawStencilCmd.func = CC_CALLBACK_0(Layout::onAfterDrawStencil, this); renderer->addCommand(&_afterDrawStencilCmd); @@ -310,7 +310,7 @@ void Layout::stencilClippingVisit(Renderer *renderer, const Mat4& parentTransfor (*it)->visit(renderer, _modelViewTransform, flags); - _afterVisitCmdStencil.init(_globalZOrder, _modelViewTransform, parentFlags); + _afterVisitCmdStencil.init(_globalZOrder); _afterVisitCmdStencil.func = CC_CALLBACK_0(Layout::onAfterVisitStencil, this); renderer->addCommand(&_afterVisitCmdStencil); @@ -424,13 +424,13 @@ void Layout::onAfterVisitScissor() void Layout::scissorClippingVisit(Renderer *renderer, const Mat4& parentTransform, uint32_t parentFlags) { - _beforeVisitCmdScissor.init(_globalZOrder, _modelViewTransform, parentFlags); + _beforeVisitCmdScissor.init(_globalZOrder); _beforeVisitCmdScissor.func = CC_CALLBACK_0(Layout::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); ProtectedNode::visit(renderer, parentTransform, parentFlags); - _afterVisitCmdScissor.init(_globalZOrder, _modelViewTransform, parentFlags); + _afterVisitCmdScissor.init(_globalZOrder); _afterVisitCmdScissor.func = CC_CALLBACK_0(Layout::onAfterVisitScissor, this); renderer->addCommand(&_afterVisitCmdScissor); } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index d9a9071834..b72a45244a 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -516,7 +516,7 @@ void ScrollView::addChild(Node * child, int zOrder, const std::string &name) void ScrollView::beforeDraw() { //ScrollView don't support drawing in 3D space - _beforeDrawCommand.init(_globalZOrder, _modelViewTransform, 0); + _beforeDrawCommand.init(_globalZOrder); _beforeDrawCommand.func = CC_CALLBACK_0(ScrollView::onBeforeDraw, this); Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand); } @@ -553,8 +553,7 @@ void ScrollView::onBeforeDraw() void ScrollView::afterDraw() { - //ScrollView don't support drawing in 3D space - _afterDrawCommand.init(_globalZOrder, _modelViewTransform, 0); + _afterDrawCommand.init(_globalZOrder); _afterDrawCommand.func = CC_CALLBACK_0(ScrollView::onAfterDraw, this); Director::getInstance()->getRenderer()->addCommand(&_afterDrawCommand); } diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index e412116e0c..d8335d1d05 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -617,7 +617,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint3 auto iter = _renderCmds.begin(); - iter->init(_globalZOrder, transform, flags); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onEnableStencil, this); renderer->addCommand(&(*iter)); ++iter; @@ -633,7 +633,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint3 _sprites.at(i)->setPosition( spritePoint ); _spritesStencil.at(i)->setPosition( spritePoint ); - iter->init(_globalZOrder, transform, flags); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawClip, this, i, stencilPoint); renderer->addCommand(&(*iter)); ++iter; @@ -646,7 +646,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint3 _spritesStencil.at(i)->visit(renderer, _modelViewTransform, flags); director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); - iter->init(_globalZOrder, transform, flags); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onBeforeDrawSprite, this, i, winPoint); renderer->addCommand(&(*iter)); ++iter; @@ -657,7 +657,7 @@ void RawStencilBufferTest::draw(Renderer *renderer, const Mat4 &transform, uint3 director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); } - iter->init(_globalZOrder, transform, flags); + iter->init(_globalZOrder); iter->func = CC_CALLBACK_0(RawStencilBufferTest::onDisableStencil, this); renderer->addCommand(&(*iter)); } diff --git a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp index 9ffe83d527..3071bc6111 100644 --- a/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp +++ b/tests/cpp-tests/Classes/NewRendererTest/NewRendererTest.cpp @@ -245,7 +245,7 @@ SpriteInGroupCommand* SpriteInGroupCommand::create(const std::string &filename) void SpriteInGroupCommand::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { CCASSERT(renderer, "Render is null"); - _spriteWrapperCommand.init(_globalZOrder, transform, flags); + _spriteWrapperCommand.init(_globalZOrder); renderer->addCommand(&_spriteWrapperCommand); renderer->pushGroup(_spriteWrapperCommand.getRenderQueueID()); Sprite::draw(renderer, transform, flags);