From aad617e2005580db811f23a3862fd52311fb9b14 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Dec 2013 10:50:31 +0800 Subject: [PATCH 01/26] add class GridNode --- cocos/2d/CCGridNode.cpp | 96 +++++++++++++++++++++++++++++++++++++++++ cocos/2d/CCGridNode.h | 39 +++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 cocos/2d/CCGridNode.cpp create mode 100644 cocos/2d/CCGridNode.h diff --git a/cocos/2d/CCGridNode.cpp b/cocos/2d/CCGridNode.cpp new file mode 100644 index 0000000000..2aedfeaed0 --- /dev/null +++ b/cocos/2d/CCGridNode.cpp @@ -0,0 +1,96 @@ + +#include "CCGridNode.h" +#include "CCGrid.h" + +#include "kazmath/GL/matrix.h" + +NS_CC_BEGIN + +GridNode* GridNode::create() +{ + GridNode * pRet = new GridNode(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + +GridNode::GridNode() +:Node() +,_nodeGrid(nullptr) +{ + +} + +GridNode::~GridNode() +{ + CC_SAFE_RELEASE(_nodeGrid); +} + +bool GridNode::init() +{ + return Node::init(); +} + +void GridNode::visit() +{ + // quick return if not visible. children won't be drawn. + if (!_visible) + { + return; + } + + kmGLPushMatrix(); + + if (_nodeGrid && _nodeGrid->isActive()) + { + _nodeGrid->beforeDraw(); + } + + this->transform(); + int i = 0; + + if(!_children.empty()) + { + sortAllChildren(); + // draw children zOrder < 0 + for( ; i < _children.size(); i++ ) + { + auto node = _children.at(i); + + if ( node && node->getZOrder() < 0 ) + node->visit(); + else + break; + } + // self draw + this->draw(); + + // Uses std::for_each to improve performance. + std::for_each(_children.cbegin()+i, _children.cend(), [](Node* node){ + node->visit(); + }); + } + else + { + this->draw(); + } + + // reset for next frame + _orderOfArrival = 0; + + if (_nodeGrid && _nodeGrid->isActive()) + { + _nodeGrid->afterDraw(this); + } + + kmGLPopMatrix(); +} + + +NS_CC_END diff --git a/cocos/2d/CCGridNode.h b/cocos/2d/CCGridNode.h new file mode 100644 index 0000000000..825a9ba108 --- /dev/null +++ b/cocos/2d/CCGridNode.h @@ -0,0 +1,39 @@ +#ifndef __MISCNODE_CCGRID_NODE_H__ +#define __MISCNODE_CCGRID_NODE_H__ + +#include "CCNode.h" + +NS_CC_BEGIN + +class GridBase; + +class GridNode : public Node +{ +public: + static GridNode* create(); + + GridBase* getNodeGrid() { return _nodeGrid; } + /** + * @js NA + */ + const GridBase* getNodeGrid() const { return _nodeGrid; } + + /** + * Changes a grid object that is used when applying effects + * + * @param grid A Grid object that is used when applying effects + */ + void setNodeGrid(GridBase *grid); + + virtual bool init(); + virtual void visit(); +protected: + GridNode(); + virtual ~GridNode(); + +protected: + GridBase* _nodeGrid; +}; +NS_CC_END + +#endif \ No newline at end of file From 6300ce73d1075c6d9c297307f75e007ce937ce13 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Dec 2013 11:47:40 +0800 Subject: [PATCH 02/26] EffectTest can run --- .../Classes/EffectsTest/EffectsTest.cpp | 20 +++++++++---------- .../TestCpp/Classes/EffectsTest/EffectsTest.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp index bc08aa37b4..81fea0595c 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -1,6 +1,6 @@ #include "EffectsTest.h" #include "../testResource.h" - +#include "CCGridNode.h" enum { kTagTextLayer = 1, @@ -342,25 +342,25 @@ TextLayer::TextLayer(void) LayerColor *background = LayerColor::create( Color4B(32,128,32,255) ); this->addChild(background,-20); - auto node = Node::create(); + auto _gridNodeTarget = GridNode::create(); auto effect = getAction(); - node->runAction(effect); - addChild(node, 0, kTagBackground); + _gridNodeTarget->runAction(effect); + addChild(_gridNodeTarget, 0, kTagBackground); auto bg = Sprite::create(s_back3); - node->addChild(bg, 0); + _gridNodeTarget->addChild(bg, 0); // bg->setAnchorPoint( Point::ZERO ); bg->setPosition(VisibleRect::center()); auto grossini = Sprite::create(s_pathSister2); - node->addChild(grossini, 1); + _gridNodeTarget->addChild(grossini, 1); grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); auto sc = ScaleBy::create(2, 5); auto sc_back = sc->reverse(); grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); auto tamara = Sprite::create(s_pathSister1); - node->addChild(tamara, 1); + _gridNodeTarget->addChild(tamara, 1); tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3,VisibleRect::center().y) ); auto sc2 = ScaleBy::create(2, 5); auto sc2_back = sc2->reverse(); @@ -377,9 +377,9 @@ TextLayer::TextLayer(void) void TextLayer::checkAnim(float dt) { - auto s2 = getChildByTag(kTagBackground); - if ( s2->getNumberOfRunningActions() == 0 && s2->getGrid() != NULL) - s2->setGrid(NULL);; + //auto s2 = getChildByTag(kTagBackground); + if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != NULL) + _gridNodeTarget->setGrid(NULL);; } diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h index 2f65c73711..e7acd531a2 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h @@ -14,7 +14,7 @@ class TextLayer : public BaseTest { protected: //UxString _title; - + GridNode* _gridNodeTarget; public: TextLayer(void); ~TextLayer(void); From 8bcbf8d1866502b582ed17edf7ee24322f80d5ce Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Tue, 10 Dec 2013 11:51:25 +0800 Subject: [PATCH 03/26] Fix EffectTest Crash --- samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp index 81fea0595c..8d50659031 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -342,7 +342,7 @@ TextLayer::TextLayer(void) LayerColor *background = LayerColor::create( Color4B(32,128,32,255) ); this->addChild(background,-20); - auto _gridNodeTarget = GridNode::create(); + _gridNodeTarget = GridNode::create(); auto effect = getAction(); _gridNodeTarget->runAction(effect); addChild(_gridNodeTarget, 0, kTagBackground); @@ -378,8 +378,8 @@ TextLayer::TextLayer(void) void TextLayer::checkAnim(float dt) { //auto s2 = getChildByTag(kTagBackground); - if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != NULL) - _gridNodeTarget->setGrid(NULL);; + if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getNodeGrid() != NULL) + _gridNodeTarget->setNodeGrid(NULL);; } From 503918db0224c8411ae024829d611aeecf4e231d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 11 Dec 2013 13:39:34 +0800 Subject: [PATCH 04/26] Fix EffectAdvancedTest Crash --- .../EffectsAdvancedTest.cpp | 77 +++++++++++-------- .../EffectsAdvancedTest/EffectsAdvancedTest.h | 4 + 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index d0d7f7c593..e5c182586e 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -20,7 +20,7 @@ void Effect1::onEnter() { EffectAdvanceTextLayer::onEnter(); - auto target = getChildByTag(kTagBackground); + //auto target = getChildByTag(kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: @@ -37,8 +37,8 @@ void Effect1::onEnter() auto orbit = OrbitCamera::create(5, 1, 2, 0, 180, 0, -90); auto orbit_back = orbit->reverse(); - target->runAction( RepeatForever::create( Sequence::create( orbit, orbit_back, NULL) ) ); - target->runAction( Sequence::create(lens, delay, reuse, waves, NULL) ); + //_bgNode->runAction( RepeatForever::create( Sequence::create( orbit, orbit_back, NULL) ) ); + _bgNode->runAction( Sequence::create(lens, delay, reuse, waves, NULL) ); } std::string Effect1::title() @@ -55,7 +55,7 @@ void Effect2::onEnter() { EffectAdvanceTextLayer::onEnter(); - auto target = getChildByTag(kTagBackground); + //auto target = getChildByTag(kTagBackground); // To reuse a grid the grid size and the grid type must be the same. // in this case: @@ -78,8 +78,8 @@ void Effect2::onEnter() // id orbit = [OrbitCamera::create:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; // id orbit_back = [orbit reverse]; // -// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]]; - target->runAction(Sequence::create( shaky, delay, reuse, shuffle, delay->clone(), turnoff, turnon, NULL) ); +// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]]; + _bgNode->runAction(Sequence::create( shaky, delay, reuse, shuffle, delay->clone(), turnoff, turnon, NULL) ); } std::string Effect2::title() @@ -96,20 +96,18 @@ std::string Effect2::title() void Effect3::onEnter() { EffectAdvanceTextLayer::onEnter(); - - auto bg = getChildByTag(kTagBackground); - auto target1 = bg->getChildByTag(kTagSprite1); - auto target2 = bg->getChildByTag(kTagSprite2); - + //auto bg = getChildByTag(kTagBackground); + //auto target1 = bg->getChildByTag(kTagSprite1); + //auto target2 = bg->getChildByTag(kTagSprite2); auto waves = Waves::create(5, Size(15,10), 5, 20, true, false); auto shaky = Shaky3D::create(5, Size(15,10), 4, false); - target1->runAction( RepeatForever::create( waves ) ); - target2->runAction( RepeatForever::create( shaky ) ); + _target1->runAction( RepeatForever::create( waves ) ); + _target2->runAction( RepeatForever::create( shaky ) ); // moving background. Testing issue #244 auto move = MoveBy::create(3, Point(200,0) ); - bg->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) )); + _bgNode->runAction(RepeatForever::create( Sequence::create(move, move->reverse(), NULL) )); } std::string Effect3::title() @@ -156,7 +154,8 @@ private: void Effect4::onEnter() { EffectAdvanceTextLayer::onEnter(); - + //Node* gridNode = GridNode::create(); + auto lens = Lens3D::create(10, Size(32,24), Point(100,180), 150); auto move = JumpBy::create(5, Point(380,0), 100, 4); auto move_back = move->reverse(); @@ -171,9 +170,11 @@ void Effect4::onEnter() auto pTarget = Lens3DTarget::create(lens); // Please make sure the target been added to its parent. this->addChild(pTarget); + //gridNode->addChild(pTarget); director->getActionManager()->addAction(seq, pTarget, false); - this->runAction( lens ); + + _bgNode->runAction( lens ); } std::string Effect4::title() @@ -202,8 +203,8 @@ void Effect5::onEnter() // [[effect copy] autorelease], NULL); - auto bg = getChildByTag(kTagBackground); - bg->runAction(stopEffect); + //auto bg = getChildByTag(kTagBackground); + _bgNode->runAction(stopEffect); } std::string Effect5::title() @@ -230,8 +231,8 @@ void Issue631::onEnter() auto effect = Sequence::create( DelayTime::create(2.0f), Shaky3D::create(5.0f, Size(5, 5), 16, false), NULL); // cleanup - auto bg = getChildByTag(kTagBackground); - removeChild(bg, true); + //auto bg = getChildByTag(kTagBackground); + removeChild(_bgNode, true); // background auto layer = LayerColor::create( Color4B(255,0,0,255) ); @@ -241,15 +242,17 @@ void Issue631::onEnter() layer->addChild(sprite, 10); // foreground + auto layer2BaseGrid = GridNode::create(); auto layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) ); auto fog = Sprite::create("Images/Fog.png"); BlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; fog->setBlendFunc(bf); layer2->addChild(fog, 1); - addChild(layer2, 1); + addChild(layer2BaseGrid, 1); + layer2BaseGrid->addChild(layer2); - layer2->runAction( RepeatForever::create(effect) ); + layer2BaseGrid->runAction( RepeatForever::create(effect) ); } std::string Issue631::title() @@ -335,23 +338,37 @@ void EffectAdvanceTextLayer::onEnter(void) { BaseTest::onEnter(); + _bgNode = GridNode::create(); + _bgNode->setAnchorPoint(Point(0.5,0.5)); + addChild(_bgNode); + //_bgNode->setPosition( VisibleRect::center() ); auto bg = Sprite::create("Images/background3.png"); - addChild(bg, 0, kTagBackground); bg->setPosition( VisibleRect::center() ); - + //addChild(bg, 0, kTagBackground); + //bg->setPosition( VisibleRect::center() ); + _bgNode->addChild(bg); + + _target1 = GridNode::create(); + _target1->setAnchorPoint(Point(0.5,0.5)); auto grossini = Sprite::create("Images/grossinis_sister2.png"); - bg->addChild(grossini, 1, kTagSprite1); - grossini->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); + _target1->addChild(grossini); + _bgNode->addChild(_target1); + _target1->setPosition( Point(VisibleRect::left().x+VisibleRect::getVisibleRect().size.width/3.0f, VisibleRect::bottom().y+ 200) ); auto sc = ScaleBy::create(2, 5); auto sc_back = sc->reverse(); - grossini->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); + _target1->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); + + _target2 = GridNode::create(); + _target2->setAnchorPoint(Point(0.5,0.5)); auto tamara = Sprite::create("Images/grossinis_sister1.png"); - bg->addChild(tamara, 1, kTagSprite2); - tamara->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); + _target2->addChild(tamara); + _bgNode->addChild(_target2); + _target2->setPosition( Point(VisibleRect::left().x+2*VisibleRect::getVisibleRect().size.width/3.0f,VisibleRect::bottom().y+200) ); auto sc2 = ScaleBy::create(2, 5); auto sc2_back = sc2->reverse(); - tamara->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) ); + _target2->runAction( RepeatForever::create(Sequence::create(sc2, sc2_back, NULL) ) ); + } EffectAdvanceTextLayer::~EffectAdvanceTextLayer(void) diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h index b64d48dc9e..c04c6c546b 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.h @@ -12,6 +12,10 @@ protected: std::string _title; + Node* _bgNode; + Node* _target1; + Node* _target2; + public: virtual void onEnter(); ~EffectAdvanceTextLayer(void); From 349724b6fdfa9f15895ab4359179acd5d0f22370 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 11 Dec 2013 13:40:04 +0800 Subject: [PATCH 05/26] Fix ArmatureSceneTest Crash --- .../CocoStudioArmatureTest/ArmatureScene.cpp | 14 ++++++++------ .../CocoStudioArmatureTest/ArmatureScene.h | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 8bd9af7a80..45ad60914e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -573,6 +573,7 @@ void TestAnimationEvent::callback2() void TestFrameEvent::onEnter() { ArmatureTestLayer::onEnter(); + _gridNode = GridNode::create(); Armature *armature = Armature::create("HeroAnimation"); armature->getAnimation()->play("attack"); armature->getAnimation()->setSpeedScale(0.5); @@ -584,7 +585,8 @@ void TestFrameEvent::onEnter() */ armature->getAnimation()->setFrameEventCallFunc(this, frameEvent_selector(TestFrameEvent::onFrameEvent)); - addChild(armature); + _gridNode->addChild(armature); + addChild(_gridNode); schedule( schedule_selector(TestFrameEvent::checkAction) ); } @@ -597,19 +599,19 @@ void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIn CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex); - if (!this->getActionByTag(FRAME_EVENT_ACTION_TAG) || this->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone()) + if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone()) { - this->stopAllActions(); + _gridNode->stopAllActions(); ActionInterval *action = ShatteredTiles3D::create(0.2f, Size(16,12), 5, false); action->setTag(FRAME_EVENT_ACTION_TAG); - this->runAction(action); + _gridNode->runAction(action); } } void TestFrameEvent::checkAction(float dt) { - if ( this->getNumberOfRunningActions() == 0 && this->getGrid() != nullptr) - this->setGrid(nullptr); + if ( _gridNode->getNumberOfRunningActions() == 0 && _gridNode->getNodeGrid() != nullptr) + _gridNode->setNodeGrid(nullptr); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index dc0eed2493..09fba2c74e 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -165,6 +165,8 @@ public: virtual std::string title(); void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex); void checkAction(float dt); +protected: + GridNode* _gridNode; }; From 09a9b1f5579f6e8ed6cb71678731e9477615ac0d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 11 Dec 2013 13:41:05 +0800 Subject: [PATCH 06/26] remove setGrid getGrid in class Node --- cocos/2d/CCNode.cpp | 12 ++++++------ cocos/2d/CCNode.h | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index aafec6fd47..ad2a7730d7 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -412,12 +412,12 @@ Camera* Node::getCamera() } /// grid setter -void Node::setGrid(GridBase* pGrid) -{ - CC_SAFE_RETAIN(pGrid); - CC_SAFE_RELEASE(_grid); - _grid = pGrid; -} +// void Node::setGrid(GridBase* pGrid) +// { +// CC_SAFE_RETAIN(pGrid); +// CC_SAFE_RELEASE(_grid); +// _grid = pGrid; +// } /// isVisible getter diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 8a82c1bfa3..c82e7647c8 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -714,18 +714,18 @@ public: * @return A Grid object that is used when applying effects * @js NA */ - virtual GridBase* getGrid() { return _grid; } + //virtual GridBase* getGrid() { return _grid; } /** * @js NA */ - virtual const GridBase* getGrid() const { return _grid; } + //virtual const GridBase* getGrid() const { return _grid; } /** * Changes a grid object that is used when applying effects * * @param grid A Grid object that is used when applying effects */ - virtual void setGrid(GridBase *grid); + //virtual void setGrid(GridBase *grid); /// @} end of Grid From ea9d744d79f1da2c4e58b0eb928853d3ea8c3c11 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 12 Dec 2013 13:21:14 +0800 Subject: [PATCH 07/26] add setGridTarget method, grid node now can affect its target and its child --- cocos/2d/CCGridNode.cpp | 15 +++++++++++++++ cocos/2d/CCGridNode.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/cocos/2d/CCGridNode.cpp b/cocos/2d/CCGridNode.cpp index 2aedfeaed0..90e9d06ac6 100644 --- a/cocos/2d/CCGridNode.cpp +++ b/cocos/2d/CCGridNode.cpp @@ -23,13 +23,22 @@ GridNode* GridNode::create() GridNode::GridNode() :Node() ,_nodeGrid(nullptr) +,_gridTarget(nullptr) { } +void GridNode::setGridTarget(Node* target) +{ + CC_SAFE_RELEASE(_gridTarget); + CC_SAFE_RETAIN(target); + _gridTarget = target; +} + GridNode::~GridNode() { CC_SAFE_RELEASE(_nodeGrid); + CC_SAFE_RELEASE(_gridTarget); } bool GridNode::init() @@ -53,6 +62,12 @@ void GridNode::visit() } this->transform(); + + if(_gridTarget) + { + _gridTarget->visit(); + } + int i = 0; if(!_children.empty()) diff --git a/cocos/2d/CCGridNode.h b/cocos/2d/CCGridNode.h index 825a9ba108..dc85703dbe 100644 --- a/cocos/2d/CCGridNode.h +++ b/cocos/2d/CCGridNode.h @@ -27,11 +27,14 @@ public: virtual bool init(); virtual void visit(); + + void setGridTarget(Node *target); protected: GridNode(); virtual ~GridNode(); protected: + Node* _gridTarget; GridBase* _nodeGrid; }; NS_CC_END From f1cac00dd7ba40654e136287c9d77317a6dc7008 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 12 Dec 2013 13:44:29 +0800 Subject: [PATCH 08/26] TransitionPageTurn can work now --- cocos/2d/CCTransitionPageTurn.cpp | 40 ++++++++++++++++++++++++------- cocos/2d/CCTransitionPageTurn.h | 5 ++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index e291bcd84e..ec98ff60b9 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -29,6 +29,7 @@ THE SOFTWARE. #include "CCActionInstant.h" #include "CCActionGrid.h" #include "CCActionPageTurn3D.h" +#include "CCGridNode.h" NS_CC_BEGIN @@ -37,10 +38,14 @@ float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f; TransitionPageTurn::TransitionPageTurn() { + _inSceneProxy = nullptr; + _outSceneProxy = nullptr; } TransitionPageTurn::~TransitionPageTurn() { + CC_SAFE_RELEASE(_inSceneProxy); + CC_SAFE_RELEASE(_outSceneProxy); } /** creates a base transition with duration and incoming scene */ @@ -75,17 +80,17 @@ void TransitionPageTurn::draw() Scene::draw(); if( _isInSceneOnTop ) { - _outScene->visit(); + _outSceneProxy->visit(); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); - _inScene->visit(); + _inSceneProxy->visit(); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } else { - _inScene->visit(); + _inSceneProxy->visit(); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(POLYGON_OFFSET_FACTOR, POLYGON_OFFSET_UNITS); - _outScene->visit(); + _outSceneProxy->visit(); glDisable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0, 0); } @@ -94,6 +99,19 @@ void TransitionPageTurn::draw() void TransitionPageTurn::onEnter() { TransitionScene::onEnter(); + _inSceneProxy = GridNode::create(); + _outSceneProxy = GridNode::create(); + + CCASSERT(_inSceneProxy && _outSceneProxy, "TransitionPageTurn proxy scene can not be nullptr"); + _inSceneProxy->retain(); + _outSceneProxy->retain(); + + _inSceneProxy->setGridTarget(_inScene); + _outSceneProxy->setGridTarget(_outScene); + + _inSceneProxy->onEnter(); + _outSceneProxy->onEnter(); + Size s = Director::getInstance()->getWinSize(); int x,y; if (s.width > s.height) @@ -111,7 +129,7 @@ void TransitionPageTurn::onEnter() if (! _back ) { - _outScene->runAction + _outSceneProxy->runAction ( Sequence::create ( @@ -125,8 +143,8 @@ void TransitionPageTurn::onEnter() else { // to prevent initial flicker - _inScene->setVisible(false); - _inScene->runAction + _inSceneProxy->setVisible(false); + _inSceneProxy->runAction ( Sequence::create ( @@ -139,7 +157,13 @@ void TransitionPageTurn::onEnter() ); } } - +void TransitionPageTurn::onExit() +{ + _outSceneProxy->onExit(); + _inSceneProxy->onExit(); + + TransitionScene::onExit(); +} ActionInterval* TransitionPageTurn:: actionWithSize(const Size& vector) { diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index 3f0eca219d..e5e316aec1 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -30,6 +30,8 @@ THE SOFTWARE. NS_CC_BEGIN +class GridNode; + /** * @addtogroup transition * @{ @@ -83,11 +85,14 @@ public: // Overrides // virtual void onEnter() override; + virtual void onExit() override; protected: virtual void sceneOrder() override; protected: + GridNode* _inSceneProxy; + GridNode* _outSceneProxy; bool _back; static float POLYGON_OFFSET_FACTOR; static float POLYGON_OFFSET_UNITS; From 256fe13d3f0970836f49d386021604558dd718d7 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 12 Dec 2013 14:56:06 +0800 Subject: [PATCH 09/26] other grid scene transitions can work now --- cocos/2d/CCTransition.cpp | 91 ++++++++++++++++++++++++++++++++++++--- cocos/2d/CCTransition.h | 15 +++++-- 2 files changed, 98 insertions(+), 8 deletions(-) diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 4477c9a41a..c1f3b7dd16 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -35,6 +35,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCLayer.h" #include "CCRenderTexture.h" +#include "CCGridNode.h" NS_CC_BEGIN @@ -1346,10 +1347,12 @@ void TransitionCrossFade::onExit() // TransitionTurnOffTiles::TransitionTurnOffTiles() { + _outSceneProxy = nullptr; } TransitionTurnOffTiles::~TransitionTurnOffTiles() { + CC_SAFE_RELEASE(_outSceneProxy); } TransitionTurnOffTiles* TransitionTurnOffTiles::create(float t, Scene* scene) @@ -1373,6 +1376,12 @@ void TransitionTurnOffTiles::sceneOrder() void TransitionTurnOffTiles::onEnter() { TransitionScene::onEnter(); + + _outSceneProxy = GridNode::create(); + _outSceneProxy->retain(); + _outSceneProxy->setGridTarget(_outScene); + _outSceneProxy->onEnter(); + Size s = Director::getInstance()->getWinSize(); float aspect = s.width / s.height; int x = (int)(12 * aspect); @@ -1380,7 +1389,7 @@ void TransitionTurnOffTiles::onEnter() TurnOffTiles* toff = TurnOffTiles::create(_duration, Size(x,y)); ActionInterval* action = easeActionWithAction(toff); - _outScene->runAction + _outSceneProxy->runAction ( Sequence::create ( @@ -1392,6 +1401,28 @@ void TransitionTurnOffTiles::onEnter() ); } +void TransitionTurnOffTiles::onExit() +{ + _outSceneProxy->onExit(); + TransitionScene::onExit(); +} + +void TransitionTurnOffTiles::draw() +{ + Scene::draw(); + + if( _isInSceneOnTop ) + { + _outSceneProxy->visit(); + _inScene->visit(); + } + else + { + _inScene->visit(); + _outSceneProxy->visit(); + } +} + ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* action) { @@ -1403,9 +1434,11 @@ ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* ac // TransitionSplitCols::TransitionSplitCols() { + _gridProxy = nullptr; } TransitionSplitCols::~TransitionSplitCols() { + CC_SAFE_RELEASE(_gridProxy); } TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene) @@ -1423,18 +1456,22 @@ TransitionSplitCols* TransitionSplitCols::create(float t, Scene* scene) void TransitionSplitCols::onEnter() { TransitionScene::onEnter(); - _inScene->setVisible(false); + + _gridProxy = GridNode::create(); + _gridProxy->retain(); + _gridProxy->setGridTarget(_outScene); + _gridProxy->onEnter(); ActionInterval* split = action(); ActionInterval* seq = (ActionInterval*)Sequence::create ( split, - CallFunc::create(CC_CALLBACK_0(TransitionScene::hideOutShowIn,this)), + CallFunc::create(CC_CALLBACK_0(TransitionSplitCols::switchTargetToInscene,this)), split->reverse(), NULL ); - this->runAction + _gridProxy->runAction ( Sequence::create ( @@ -1446,6 +1483,23 @@ void TransitionSplitCols::onEnter() ); } +void TransitionSplitCols::switchTargetToInscene() +{ + _gridProxy->setGridTarget(_inScene); +} + +void TransitionSplitCols::draw() +{ + Scene::draw(); + _gridProxy->visit(); +} + +void TransitionSplitCols::onExit() +{ + _gridProxy->onExit(); + TransitionScene::onExit(); +} + ActionInterval* TransitionSplitCols:: action() { return SplitCols::create(_duration/2.0f, 3); @@ -1491,9 +1545,11 @@ TransitionSplitRows* TransitionSplitRows::create(float t, Scene* scene) // TransitionFadeTR::TransitionFadeTR() { + _outSceneProxy = nullptr; } TransitionFadeTR::~TransitionFadeTR() { + CC_SAFE_RELEASE(_outSceneProxy); } TransitionFadeTR* TransitionFadeTR::create(float t, Scene* scene) @@ -1516,6 +1572,10 @@ void TransitionFadeTR::sceneOrder() void TransitionFadeTR::onEnter() { TransitionScene::onEnter(); + _outSceneProxy = GridNode::create(); + _outSceneProxy->retain(); + _outSceneProxy->setGridTarget(_outScene); + _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); float aspect = s.width / s.height; @@ -1524,7 +1584,7 @@ void TransitionFadeTR::onEnter() ActionInterval* action = actionWithSize(Size(x,y)); - _outScene->runAction + _outSceneProxy->runAction ( Sequence::create ( @@ -1536,6 +1596,27 @@ void TransitionFadeTR::onEnter() ); } +void TransitionFadeTR::onExit() +{ + _outSceneProxy->onExit(); + TransitionScene::onExit(); +} + +void TransitionFadeTR::draw() +{ + Scene::draw(); + + if( _isInSceneOnTop ) + { + _outSceneProxy->visit(); + _inScene->visit(); + } + else + { + _inScene->visit(); + _outSceneProxy->visit(); + } +} ActionInterval* TransitionFadeTR::actionWithSize(const Size& size) { diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index f2485d016e..2c068b8460 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -43,6 +43,7 @@ NS_CC_BEGIN class ActionInterval; class Node; +class GridNode; /** @brief TransitionEaseScene can ease the actions of the scene protocol. @since v0.8.2 @@ -643,13 +644,16 @@ public : * @lua NA */ virtual void onEnter() override; + virtual void onExit() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; + virtual void draw() override; protected: TransitionTurnOffTiles(); virtual ~TransitionTurnOffTiles(); virtual void sceneOrder() override; + GridNode* _outSceneProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles); @@ -674,11 +678,13 @@ public: */ virtual void onEnter() override; virtual ActionInterval * easeActionWithAction(ActionInterval * action) override; - + virtual void onExit() override; + virtual void draw() override; protected: TransitionSplitCols(); virtual ~TransitionSplitCols(); - + void switchTargetToInscene(); + GridNode* _gridProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols); }; @@ -723,13 +729,16 @@ public: */ virtual void onEnter() override; virtual ActionInterval* easeActionWithAction(ActionInterval * action) override; - + virtual void onExit() override; + virtual void draw() override; protected: TransitionFadeTR(); virtual ~TransitionFadeTR(); virtual void sceneOrder(); + GridNode* _outSceneProxy; + private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR); }; From 08bfbbc582051217725bd5a9d5234882e28796bf Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 12 Dec 2013 16:20:52 +0800 Subject: [PATCH 10/26] Fix project can not compile after rebased pull --- cocos/2d/CCActionGrid.cpp | 48 +++++++++++++------ cocos/2d/CCActionGrid.h | 15 +++++- cocos/2d/CCActionTiledGrid.cpp | 7 +-- cocos/2d/CCGridNode.cpp | 6 +++ .../EffectsAdvancedTest.cpp | 1 + .../CocoStudioArmatureTest/ArmatureScene.cpp | 1 + 6 files changed, 60 insertions(+), 18 deletions(-) diff --git a/cocos/2d/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp index c2cddb2373..ddf727d1e8 100644 --- a/cocos/2d/CCActionGrid.cpp +++ b/cocos/2d/CCActionGrid.cpp @@ -25,6 +25,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCDirector.h" #include "CCGrid.h" +#include "CCGridNode.h" NS_CC_BEGIN // implementation of GridAction @@ -44,11 +45,11 @@ bool GridAction::initWithDuration(float duration, const Size& gridSize) void GridAction::startWithTarget(Node *target) { ActionInterval::startWithTarget(target); + cacheTargetAsGridNode(); GridBase *newgrid = this->getGrid(); - Node *t = _target; - GridBase *targetGrid = t->getGrid(); + GridBase *targetGrid = _gridNodeTarget->getNodeGrid(); if (targetGrid && targetGrid->getReuseGrid() > 0) { @@ -69,11 +70,17 @@ void GridAction::startWithTarget(Node *target) targetGrid->setActive(false); } - t->setGrid(newgrid); - t->getGrid()->setActive(true); + _gridNodeTarget->setNodeGrid(newgrid); + _gridNodeTarget->getNodeGrid()->setActive(true); } } +void GridAction::cacheTargetAsGridNode() +{ + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); +} + GridAction* GridAction::reverse() const { // FIXME: This conversion isn't safe. @@ -97,19 +104,19 @@ GridBase* Grid3DAction::getGrid() Vertex3F Grid3DAction::getVertex(const Point& position) const { - Grid3D *g = (Grid3D*)_target->getGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); return g->getVertex(position); } Vertex3F Grid3DAction::getOriginalVertex(const Point& position) const { - Grid3D *g = (Grid3D*)_target->getGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); return g->getOriginalVertex(position); } void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex) { - Grid3D *g = (Grid3D*)_target->getGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); g->setVertex(position, vertex); } @@ -122,19 +129,19 @@ GridBase* TiledGrid3DAction::getGrid(void) Quad3 TiledGrid3DAction::getTile(const Point& pos) const { - TiledGrid3D *g = (TiledGrid3D*)_target->getGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); return g->getTile(pos); } Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const { - TiledGrid3D *g = (TiledGrid3D*)_target->getGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); return g->getOriginalTile(pos); } void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords) { - TiledGrid3D *g = (TiledGrid3D*)_target->getGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); return g->setTile(pos, coords); } @@ -345,14 +352,20 @@ DeccelAmplitude* DeccelAmplitude::reverse() const void StopGrid::startWithTarget(Node *target) { ActionInstant::startWithTarget(target); - - GridBase *grid = _target->getGrid(); + cacheTargetAsGridNode(); + GridBase *grid = _gridNodeTarget->getNodeGrid(); if (grid && grid->isActive()) { grid->setActive(false); } } +void StopGrid::cacheTargetAsGridNode() +{ + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); +} + StopGrid* StopGrid::create() { StopGrid* pAction = new StopGrid(); @@ -402,13 +415,20 @@ bool ReuseGrid::initWithTimes(int times) void ReuseGrid::startWithTarget(Node *target) { ActionInstant::startWithTarget(target); + cacheTargetAsGridNode(); - if (_target->getGrid() && _target->getGrid()->isActive()) + if (_gridNodeTarget->getNodeGrid() && _gridNodeTarget->getNodeGrid()->isActive()) { - _target->getGrid()->setReuseGrid(_target->getGrid()->getReuseGrid() + _times); + _gridNodeTarget->getNodeGrid()->setReuseGrid(_gridNodeTarget->getNodeGrid()->getReuseGrid() + _times); } } +void ReuseGrid::cacheTargetAsGridNode() +{ + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); +} + ReuseGrid* ReuseGrid::clone() const { return ReuseGrid::create(_times); diff --git a/cocos/2d/CCActionGrid.h b/cocos/2d/CCActionGrid.h index eb9ddc23a5..af965f0008 100644 --- a/cocos/2d/CCActionGrid.h +++ b/cocos/2d/CCActionGrid.h @@ -31,6 +31,7 @@ THE SOFTWARE. NS_CC_BEGIN class GridBase; +class GridNode; /** * @addtogroup actions @@ -57,6 +58,10 @@ protected: bool initWithDuration(float duration, const Size& gridSize); Size _gridSize; + + GridNode* _gridNodeTarget; + + void cacheTargetAsGridNode(); private: CC_DISALLOW_COPY_AND_ASSIGN(GridAction); @@ -264,6 +269,10 @@ public: protected: StopGrid() {} virtual ~StopGrid() {} + + GridNode* _gridNodeTarget; + + void cacheTargetAsGridNode(); private: CC_DISALLOW_COPY_AND_ASSIGN(StopGrid); @@ -286,7 +295,11 @@ protected: virtual ~ReuseGrid() {} /** initializes an action with the number of times that the current grid will be reused */ bool initWithTimes(int times); - + + GridNode* _gridNodeTarget; + + void cacheTargetAsGridNode(); + int _times; private: diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp index 269a798b1d..4d7fcc0312 100644 --- a/cocos/2d/CCActionTiledGrid.cpp +++ b/cocos/2d/CCActionTiledGrid.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "CCDirector.h" #include "ccMacros.h" #include "CCGrid.h" +#include "CCGridNode.h" #include NS_CC_BEGIN @@ -279,7 +280,7 @@ void ShuffleTiles::placeTile(const Point& pos, Tile *t) { Quad3 coords = getOriginalTile(pos); - Point step = _target->getGrid()->getStep(); + Point step = _gridNodeTarget->getNodeGrid()->getStep(); coords.bl.x += (int)(t->position.x * step.x); coords.bl.y += (int)(t->position.y * step.y); @@ -408,7 +409,7 @@ void FadeOutTRTiles::turnOffTile(const Point& pos) void FadeOutTRTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Point step = _target->getGrid()->getStep(); + Point step = _gridNodeTarget->getNodeGrid()->getStep(); coords.bl.x += (step.x / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance); @@ -535,7 +536,7 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time) void FadeOutUpTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Point step = _target->getGrid()->getStep(); + Point step = _gridNodeTarget->getNodeGrid()->getStep(); coords.bl.y += (step.y / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance); diff --git a/cocos/2d/CCGridNode.cpp b/cocos/2d/CCGridNode.cpp index 90e9d06ac6..1810bc6866 100644 --- a/cocos/2d/CCGridNode.cpp +++ b/cocos/2d/CCGridNode.cpp @@ -107,5 +107,11 @@ void GridNode::visit() kmGLPopMatrix(); } +void GridNode::setNodeGrid(GridBase *grid) +{ + CC_SAFE_RELEASE(_nodeGrid); + CC_SAFE_RETAIN(grid); + _nodeGrid = grid; +} NS_CC_END diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index e5c182586e..bc1a1efd35 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -1,4 +1,5 @@ #include "EffectsAdvancedTest.h" +#include "CCGridNode.h" enum { diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 45ad60914e..e9301f6198 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1,6 +1,7 @@ #include "ArmatureScene.h" #include "../../testResource.h" #include "cocostudio/CocoStudio.h" +#include "CCGridNode.h" using namespace cocos2d; From 5509bd48ef4afdc051755127940e6d6aaf30f516 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 12 Dec 2013 16:21:21 +0800 Subject: [PATCH 11/26] remove _grid --- cocos/2d/CCNode.cpp | 25 ++------------- cocos/2d/CCNode.h | 31 +------------------ cocos/2d/CCParticleBatchNode.cpp | 11 ------- cocos/2d/CCRenderTexture.cpp | 11 ------- cocos/2d/CCSpriteBatchNode.cpp | 11 ------- .../editor-support/cocostudio/CCArmature.cpp | 10 ------ .../editor-support/cocostudio/CCBatchNode.cpp | 10 ------ extensions/GUI/CCScrollView/CCScrollView.cpp | 10 ------ 8 files changed, 3 insertions(+), 116 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index ad2a7730d7..56ab52d652 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -112,7 +112,6 @@ Node::Node(void) , _camera(NULL) // children (lazy allocs) // lazy alloc -, _grid(NULL) , _ZOrder(0) , _parent(NULL) // "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true @@ -164,7 +163,6 @@ Node::~Node() // attributes CC_SAFE_RELEASE(_camera); - CC_SAFE_RELEASE(_grid); CC_SAFE_RELEASE(_shaderProgram); CC_SAFE_RELEASE(_userObject); @@ -411,15 +409,6 @@ Camera* Node::getCamera() return _camera; } -/// grid setter -// void Node::setGrid(GridBase* pGrid) -// { -// CC_SAFE_RETAIN(pGrid); -// CC_SAFE_RELEASE(_grid); -// _grid = pGrid; -// } - - /// isVisible getter bool Node::isVisible() const { @@ -846,11 +835,6 @@ void Node::visit() kmGLPushMatrix(); - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - } - this->transform(); int i = 0; @@ -882,11 +866,6 @@ void Node::visit() // reset for next frame _orderOfArrival = 0; - - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } kmGLPopMatrix(); } @@ -916,9 +895,9 @@ void Node::transform() kmGLMultMatrix( &transfrom4x4 ); - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - if ( _camera != NULL && !(_grid != NULL && _grid->isActive()) ) + //_grid is always null + if ( _camera != NULL && false/*!(_grid != NULL && _grid->isActive())*/ ) { bool translate = (_anchorPointInPoints.x != 0.0f || _anchorPointInPoints.y != 0.0f); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index c82e7647c8..9551fb6d6f 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -702,34 +702,7 @@ public: virtual void sortAllChildren(); /// @} end of Children and Parent - - - - /// @{ - /// @name Grid object for effects - - /** - * Returns a grid object that is used when applying effects - * - * @return A Grid object that is used when applying effects - * @js NA - */ - //virtual GridBase* getGrid() { return _grid; } - /** - * @js NA - */ - //virtual const GridBase* getGrid() const { return _grid; } - - /** - * Changes a grid object that is used when applying effects - * - * @param grid A Grid object that is used when applying effects - */ - //virtual void setGrid(GridBase *grid); - - /// @} end of Grid - - + /// @{ /// @name Tag & User data @@ -1435,8 +1408,6 @@ protected: Camera *_camera; ///< a camera - GridBase *_grid; ///< a grid - int _ZOrder; ///< z-order value that affects the draw order Vector _children; ///< array of children nodes diff --git a/cocos/2d/CCParticleBatchNode.cpp b/cocos/2d/CCParticleBatchNode.cpp index 3f1b3779bd..8f421b3268 100644 --- a/cocos/2d/CCParticleBatchNode.cpp +++ b/cocos/2d/CCParticleBatchNode.cpp @@ -133,21 +133,10 @@ void ParticleBatchNode::visit() kmGLPushMatrix(); - if ( _grid && _grid->isActive()) - { - _grid->beforeDraw(); - transformAncestors(); - } - transform(); draw(); - if ( _grid && _grid->isActive()) - { - _grid->afterDraw(this); - } - kmGLPopMatrix(); } diff --git a/cocos/2d/CCRenderTexture.cpp b/cocos/2d/CCRenderTexture.cpp index a0f395c5bf..a57d4aaad9 100644 --- a/cocos/2d/CCRenderTexture.cpp +++ b/cocos/2d/CCRenderTexture.cpp @@ -455,22 +455,11 @@ void RenderTexture::visit() } kmGLPushMatrix(); - - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - transformAncestors(); - } transform(); _sprite->visit(); draw(); - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } - kmGLPopMatrix(); _orderOfArrival = 0; diff --git a/cocos/2d/CCSpriteBatchNode.cpp b/cocos/2d/CCSpriteBatchNode.cpp index 748a248f58..2804287f97 100644 --- a/cocos/2d/CCSpriteBatchNode.cpp +++ b/cocos/2d/CCSpriteBatchNode.cpp @@ -146,21 +146,10 @@ void SpriteBatchNode::visit(void) kmGLPushMatrix(); - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - transformAncestors(); - } - sortAllChildren(); transform(); draw(); - - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } kmGLPopMatrix(); setOrderOfArrival(0); diff --git a/cocos/editor-support/cocostudio/CCArmature.cpp b/cocos/editor-support/cocostudio/CCArmature.cpp index 8cecf76105..31fada45e8 100644 --- a/cocos/editor-support/cocostudio/CCArmature.cpp +++ b/cocos/editor-support/cocostudio/CCArmature.cpp @@ -612,11 +612,6 @@ void Armature::visit() } kmGLPushMatrix(); - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - } - transform(); sortAllChildren(); draw(); @@ -624,11 +619,6 @@ void Armature::visit() // reset for next frame _orderOfArrival = 0; - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } - kmGLPopMatrix(); } diff --git a/cocos/editor-support/cocostudio/CCBatchNode.cpp b/cocos/editor-support/cocostudio/CCBatchNode.cpp index 844e25f286..8c7ef3c5cf 100644 --- a/cocos/editor-support/cocostudio/CCBatchNode.cpp +++ b/cocos/editor-support/cocostudio/CCBatchNode.cpp @@ -141,11 +141,6 @@ void BatchNode::visit() } kmGLPushMatrix(); - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - } - transform(); sortAllChildren(); draw(); @@ -153,11 +148,6 @@ void BatchNode::visit() // reset for next frame _orderOfArrival = 0; - if (_grid && _grid->isActive()) - { - _grid->afterDraw(this); - } - kmGLPopMatrix(); } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 2a61d5223e..5abc586550 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -547,12 +547,6 @@ void ScrollView::visit() } kmGLPushMatrix(); - - if (_grid && _grid->isActive()) - { - _grid->beforeDraw(); - this->transformAncestors(); - } this->transform(); this->beforeDraw(); @@ -592,10 +586,6 @@ void ScrollView::visit() } this->afterDraw(); - if ( _grid && _grid->isActive()) - { - _grid->afterDraw(this); - } kmGLPopMatrix(); } From 00edb5f7febb3147527795487f88e8992853c4ea Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 13 Dec 2013 10:57:23 +0800 Subject: [PATCH 12/26] update android.mk in 2d folder --- cocos/2d/Android.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 789cae2d91..19a7f2cb9c 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -60,6 +60,7 @@ CCGLProgram.cpp \ ccGLStateCache.cpp \ CCGrabber.cpp \ CCGrid.cpp \ +CCGridNode.cpp \ CCIMEDispatcher.cpp \ CCLabel.cpp \ CCLabelAtlas.cpp \ From 2be1a640fa5f7cd6ffee5d0a39034c5a2fb0a4b2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 13 Dec 2013 10:58:31 +0800 Subject: [PATCH 13/26] update Xcode project file --- build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index b054635826..2fcc0d79c6 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -77ef9ee3921db604edd06a2cc0b9f9a89259a431 \ No newline at end of file +5872ab1b5a5ce60fdf570ba605ae3062d60421a3 \ No newline at end of file From 305e80030c914363d03e748ad31d5b3cea8866b0 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 13 Dec 2013 10:59:23 +0800 Subject: [PATCH 14/26] update Visual studio project file --- cocos/2d/cocos2d.vcxproj | 2 ++ cocos/2d/cocos2d.vcxproj.filters | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index a026926c95..c88e0b46b4 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -256,6 +256,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + @@ -427,6 +428,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 69900696e1..6efe31055d 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -566,6 +566,9 @@ base + + misc_nodes + @@ -1143,5 +1146,8 @@ base + + misc_nodes + \ No newline at end of file From a8a2ceb88719dd86977b8c4e50f319c4c843f000 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 13 Dec 2013 12:25:17 +0800 Subject: [PATCH 15/26] add linux make list --- cocos/2d/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index a5838f5dcb..a87cae3a40 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -63,6 +63,7 @@ set(COCOS2D_SRC CCDrawNode.cpp CCGrabber.cpp CCGrid.cpp + CCGridNode.cpp CCFont.cpp CCFontAtlas.cpp CCFontAtlasCache.cpp From 6aa2908c139a65ecf5abe61c7e88344662a7c14e Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 16 Dec 2013 14:21:05 +0800 Subject: [PATCH 16/26] =?UTF-8?q?rename=EF=BC=9A=201.=20class:=20GridNode-?= =?UTF-8?q?>NodeGrid=202.=20function:=20setNodeGrid->setGrid=20=20getNodeG?= =?UTF-8?q?rid->getGrid=20setGridTarget->setTarget=203.=20file:=20CCGridNo?= =?UTF-8?q?de.h&cpp->CCNodeGrid.h&cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos/2d/Android.mk | 2 +- cocos/2d/CCActionGrid.cpp | 38 +++++++++---------- cocos/2d/CCActionGrid.h | 8 ++-- cocos/2d/CCActionTiledGrid.cpp | 8 ++-- cocos/2d/{CCGridNode.cpp => CCNodeGrid.cpp} | 18 ++++----- cocos/2d/{CCGridNode.h => CCNodeGrid.h} | 16 ++++---- cocos/2d/CCTransition.cpp | 16 ++++---- cocos/2d/CCTransition.h | 8 ++-- cocos/2d/CCTransitionPageTurn.cpp | 10 ++--- cocos/2d/CCTransitionPageTurn.h | 6 +-- cocos/2d/CMakeLists.txt | 2 +- cocos/2d/cocos2d.vcxproj | 4 +- cocos/2d/cocos2d.vcxproj.filters | 4 +- .../platform/android/java/project.properties | 2 +- .../EffectsAdvancedTest.cpp | 12 +++--- .../Classes/EffectsTest/EffectsTest.cpp | 8 ++-- .../TestCpp/Classes/EffectsTest/EffectsTest.h | 2 +- .../CocoStudioArmatureTest/ArmatureScene.cpp | 8 ++-- .../CocoStudioArmatureTest/ArmatureScene.h | 2 +- .../TestCpp/proj.android/project.properties | 2 +- 21 files changed, 89 insertions(+), 89 deletions(-) rename cocos/2d/{CCGridNode.cpp => CCNodeGrid.cpp} (86%) rename cocos/2d/{CCGridNode.h => CCNodeGrid.h} (60%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id index 2fcc0d79c6..4b3ffa152c 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -5872ab1b5a5ce60fdf570ba605ae3062d60421a3 \ No newline at end of file +b395fa282d69784fdc483c1ad6a6acc9cc291599 \ No newline at end of file diff --git a/cocos/2d/Android.mk b/cocos/2d/Android.mk index 19a7f2cb9c..c472f58383 100644 --- a/cocos/2d/Android.mk +++ b/cocos/2d/Android.mk @@ -60,7 +60,7 @@ CCGLProgram.cpp \ ccGLStateCache.cpp \ CCGrabber.cpp \ CCGrid.cpp \ -CCGridNode.cpp \ +CCNodeGrid.cpp \ CCIMEDispatcher.cpp \ CCLabel.cpp \ CCLabelAtlas.cpp \ diff --git a/cocos/2d/CCActionGrid.cpp b/cocos/2d/CCActionGrid.cpp index ddf727d1e8..68a72de63b 100644 --- a/cocos/2d/CCActionGrid.cpp +++ b/cocos/2d/CCActionGrid.cpp @@ -25,7 +25,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCDirector.h" #include "CCGrid.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" NS_CC_BEGIN // implementation of GridAction @@ -49,7 +49,7 @@ void GridAction::startWithTarget(Node *target) GridBase *newgrid = this->getGrid(); - GridBase *targetGrid = _gridNodeTarget->getNodeGrid(); + GridBase *targetGrid = _gridNodeTarget->getGrid(); if (targetGrid && targetGrid->getReuseGrid() > 0) { @@ -70,15 +70,15 @@ void GridAction::startWithTarget(Node *target) targetGrid->setActive(false); } - _gridNodeTarget->setNodeGrid(newgrid); - _gridNodeTarget->getNodeGrid()->setActive(true); + _gridNodeTarget->setGrid(newgrid); + _gridNodeTarget->getGrid()->setActive(true); } } void GridAction::cacheTargetAsGridNode() { - _gridNodeTarget = dynamic_cast (_target); - CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } GridAction* GridAction::reverse() const @@ -104,19 +104,19 @@ GridBase* Grid3DAction::getGrid() Vertex3F Grid3DAction::getVertex(const Point& position) const { - Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getVertex(position); } Vertex3F Grid3DAction::getOriginalVertex(const Point& position) const { - Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); return g->getOriginalVertex(position); } void Grid3DAction::setVertex(const Point& position, const Vertex3F& vertex) { - Grid3D *g = (Grid3D*)_gridNodeTarget->getNodeGrid(); + Grid3D *g = (Grid3D*)_gridNodeTarget->getGrid(); g->setVertex(position, vertex); } @@ -129,19 +129,19 @@ GridBase* TiledGrid3DAction::getGrid(void) Quad3 TiledGrid3DAction::getTile(const Point& pos) const { - TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getTile(pos); } Quad3 TiledGrid3DAction::getOriginalTile(const Point& pos) const { - TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->getOriginalTile(pos); } void TiledGrid3DAction::setTile(const Point& pos, const Quad3& coords) { - TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getNodeGrid(); + TiledGrid3D *g = (TiledGrid3D*)_gridNodeTarget->getGrid(); return g->setTile(pos, coords); } @@ -353,7 +353,7 @@ void StopGrid::startWithTarget(Node *target) { ActionInstant::startWithTarget(target); cacheTargetAsGridNode(); - GridBase *grid = _gridNodeTarget->getNodeGrid(); + GridBase *grid = _gridNodeTarget->getGrid(); if (grid && grid->isActive()) { grid->setActive(false); @@ -362,8 +362,8 @@ void StopGrid::startWithTarget(Node *target) void StopGrid::cacheTargetAsGridNode() { - _gridNodeTarget = dynamic_cast (_target); - CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } StopGrid* StopGrid::create() @@ -417,16 +417,16 @@ void ReuseGrid::startWithTarget(Node *target) ActionInstant::startWithTarget(target); cacheTargetAsGridNode(); - if (_gridNodeTarget->getNodeGrid() && _gridNodeTarget->getNodeGrid()->isActive()) + if (_gridNodeTarget->getGrid() && _gridNodeTarget->getGrid()->isActive()) { - _gridNodeTarget->getNodeGrid()->setReuseGrid(_gridNodeTarget->getNodeGrid()->getReuseGrid() + _times); + _gridNodeTarget->getGrid()->setReuseGrid(_gridNodeTarget->getGrid()->getReuseGrid() + _times); } } void ReuseGrid::cacheTargetAsGridNode() { - _gridNodeTarget = dynamic_cast (_target); - CCASSERT(_gridNodeTarget, "GridActions can only used on GridNode"); + _gridNodeTarget = dynamic_cast (_target); + CCASSERT(_gridNodeTarget, "GridActions can only used on NodeGrid"); } ReuseGrid* ReuseGrid::clone() const diff --git a/cocos/2d/CCActionGrid.h b/cocos/2d/CCActionGrid.h index af965f0008..2983c0dbf4 100644 --- a/cocos/2d/CCActionGrid.h +++ b/cocos/2d/CCActionGrid.h @@ -31,7 +31,7 @@ THE SOFTWARE. NS_CC_BEGIN class GridBase; -class GridNode; +class NodeGrid; /** * @addtogroup actions @@ -59,7 +59,7 @@ protected: Size _gridSize; - GridNode* _gridNodeTarget; + NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); @@ -270,7 +270,7 @@ protected: StopGrid() {} virtual ~StopGrid() {} - GridNode* _gridNodeTarget; + NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); @@ -296,7 +296,7 @@ protected: /** initializes an action with the number of times that the current grid will be reused */ bool initWithTimes(int times); - GridNode* _gridNodeTarget; + NodeGrid* _gridNodeTarget; void cacheTargetAsGridNode(); diff --git a/cocos/2d/CCActionTiledGrid.cpp b/cocos/2d/CCActionTiledGrid.cpp index 4d7fcc0312..11bb045f0a 100644 --- a/cocos/2d/CCActionTiledGrid.cpp +++ b/cocos/2d/CCActionTiledGrid.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "CCDirector.h" #include "ccMacros.h" #include "CCGrid.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" #include NS_CC_BEGIN @@ -280,7 +280,7 @@ void ShuffleTiles::placeTile(const Point& pos, Tile *t) { Quad3 coords = getOriginalTile(pos); - Point step = _gridNodeTarget->getNodeGrid()->getStep(); + Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (int)(t->position.x * step.x); coords.bl.y += (int)(t->position.y * step.y); @@ -409,7 +409,7 @@ void FadeOutTRTiles::turnOffTile(const Point& pos) void FadeOutTRTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Point step = _gridNodeTarget->getNodeGrid()->getStep(); + Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.x += (step.x / 2) * (1.0f - distance); coords.bl.y += (step.y / 2) * (1.0f - distance); @@ -536,7 +536,7 @@ float FadeOutUpTiles::testFunc(const Size& pos, float time) void FadeOutUpTiles::transformTile(const Point& pos, float distance) { Quad3 coords = getOriginalTile(pos); - Point step = _gridNodeTarget->getNodeGrid()->getStep(); + Point step = _gridNodeTarget->getGrid()->getStep(); coords.bl.y += (step.y / 2) * (1.0f - distance); coords.br.y += (step.y / 2) * (1.0f - distance); diff --git a/cocos/2d/CCGridNode.cpp b/cocos/2d/CCNodeGrid.cpp similarity index 86% rename from cocos/2d/CCGridNode.cpp rename to cocos/2d/CCNodeGrid.cpp index 1810bc6866..acbf6e92fa 100644 --- a/cocos/2d/CCGridNode.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -1,14 +1,14 @@ -#include "CCGridNode.h" +#include "CCNodeGrid.h" #include "CCGrid.h" #include "kazmath/GL/matrix.h" NS_CC_BEGIN -GridNode* GridNode::create() +NodeGrid* NodeGrid::create() { - GridNode * pRet = new GridNode(); + NodeGrid * pRet = new NodeGrid(); if (pRet && pRet->init()) { pRet->autorelease(); @@ -20,7 +20,7 @@ GridNode* GridNode::create() return pRet; } -GridNode::GridNode() +NodeGrid::NodeGrid() :Node() ,_nodeGrid(nullptr) ,_gridTarget(nullptr) @@ -28,25 +28,25 @@ GridNode::GridNode() } -void GridNode::setGridTarget(Node* target) +void NodeGrid::setTarget(Node* target) { CC_SAFE_RELEASE(_gridTarget); CC_SAFE_RETAIN(target); _gridTarget = target; } -GridNode::~GridNode() +NodeGrid::~NodeGrid() { CC_SAFE_RELEASE(_nodeGrid); CC_SAFE_RELEASE(_gridTarget); } -bool GridNode::init() +bool NodeGrid::init() { return Node::init(); } -void GridNode::visit() +void NodeGrid::visit() { // quick return if not visible. children won't be drawn. if (!_visible) @@ -107,7 +107,7 @@ void GridNode::visit() kmGLPopMatrix(); } -void GridNode::setNodeGrid(GridBase *grid) +void NodeGrid::setGrid(GridBase *grid) { CC_SAFE_RELEASE(_nodeGrid); CC_SAFE_RETAIN(grid); diff --git a/cocos/2d/CCGridNode.h b/cocos/2d/CCNodeGrid.h similarity index 60% rename from cocos/2d/CCGridNode.h rename to cocos/2d/CCNodeGrid.h index dc85703dbe..4a7f4784fa 100644 --- a/cocos/2d/CCGridNode.h +++ b/cocos/2d/CCNodeGrid.h @@ -7,31 +7,31 @@ NS_CC_BEGIN class GridBase; -class GridNode : public Node +class NodeGrid : public Node { public: - static GridNode* create(); + static NodeGrid* create(); - GridBase* getNodeGrid() { return _nodeGrid; } + GridBase* getGrid() { return _nodeGrid; } /** * @js NA */ - const GridBase* getNodeGrid() const { return _nodeGrid; } + const GridBase* getGrid() const { return _nodeGrid; } /** * Changes a grid object that is used when applying effects * * @param grid A Grid object that is used when applying effects */ - void setNodeGrid(GridBase *grid); + void setGrid(GridBase *grid); virtual bool init(); virtual void visit(); - void setGridTarget(Node *target); + void setTarget(Node *target); protected: - GridNode(); - virtual ~GridNode(); + NodeGrid(); + virtual ~NodeGrid(); protected: Node* _gridTarget; diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index c1f3b7dd16..62cded2edc 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -35,7 +35,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCLayer.h" #include "CCRenderTexture.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" NS_CC_BEGIN @@ -1377,9 +1377,9 @@ void TransitionTurnOffTiles::onEnter() { TransitionScene::onEnter(); - _outSceneProxy = GridNode::create(); + _outSceneProxy = NodeGrid::create(); _outSceneProxy->retain(); - _outSceneProxy->setGridTarget(_outScene); + _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); @@ -1457,9 +1457,9 @@ void TransitionSplitCols::onEnter() { TransitionScene::onEnter(); - _gridProxy = GridNode::create(); + _gridProxy = NodeGrid::create(); _gridProxy->retain(); - _gridProxy->setGridTarget(_outScene); + _gridProxy->setTarget(_outScene); _gridProxy->onEnter(); ActionInterval* split = action(); @@ -1485,7 +1485,7 @@ void TransitionSplitCols::onEnter() void TransitionSplitCols::switchTargetToInscene() { - _gridProxy->setGridTarget(_inScene); + _gridProxy->setTarget(_inScene); } void TransitionSplitCols::draw() @@ -1572,9 +1572,9 @@ void TransitionFadeTR::sceneOrder() void TransitionFadeTR::onEnter() { TransitionScene::onEnter(); - _outSceneProxy = GridNode::create(); + _outSceneProxy = NodeGrid::create(); _outSceneProxy->retain(); - _outSceneProxy->setGridTarget(_outScene); + _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); Size s = Director::getInstance()->getWinSize(); diff --git a/cocos/2d/CCTransition.h b/cocos/2d/CCTransition.h index 2c068b8460..136dafe568 100644 --- a/cocos/2d/CCTransition.h +++ b/cocos/2d/CCTransition.h @@ -43,7 +43,7 @@ NS_CC_BEGIN class ActionInterval; class Node; -class GridNode; +class NodeGrid; /** @brief TransitionEaseScene can ease the actions of the scene protocol. @since v0.8.2 @@ -653,7 +653,7 @@ protected: virtual ~TransitionTurnOffTiles(); virtual void sceneOrder() override; - GridNode* _outSceneProxy; + NodeGrid* _outSceneProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionTurnOffTiles); @@ -684,7 +684,7 @@ protected: TransitionSplitCols(); virtual ~TransitionSplitCols(); void switchTargetToInscene(); - GridNode* _gridProxy; + NodeGrid* _gridProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionSplitCols); }; @@ -737,7 +737,7 @@ protected: virtual void sceneOrder(); - GridNode* _outSceneProxy; + NodeGrid* _outSceneProxy; private: CC_DISALLOW_COPY_AND_ASSIGN(TransitionFadeTR); diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index ec98ff60b9..8a3bc438bb 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. #include "CCActionInstant.h" #include "CCActionGrid.h" #include "CCActionPageTurn3D.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" NS_CC_BEGIN @@ -99,15 +99,15 @@ void TransitionPageTurn::draw() void TransitionPageTurn::onEnter() { TransitionScene::onEnter(); - _inSceneProxy = GridNode::create(); - _outSceneProxy = GridNode::create(); + _inSceneProxy = NodeGrid::create(); + _outSceneProxy = NodeGrid::create(); CCASSERT(_inSceneProxy && _outSceneProxy, "TransitionPageTurn proxy scene can not be nullptr"); _inSceneProxy->retain(); _outSceneProxy->retain(); - _inSceneProxy->setGridTarget(_inScene); - _outSceneProxy->setGridTarget(_outScene); + _inSceneProxy->setTarget(_inScene); + _outSceneProxy->setTarget(_outScene); _inSceneProxy->onEnter(); _outSceneProxy->onEnter(); diff --git a/cocos/2d/CCTransitionPageTurn.h b/cocos/2d/CCTransitionPageTurn.h index e5e316aec1..7230f2bd51 100644 --- a/cocos/2d/CCTransitionPageTurn.h +++ b/cocos/2d/CCTransitionPageTurn.h @@ -30,7 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN -class GridNode; +class NodeGrid; /** * @addtogroup transition @@ -91,8 +91,8 @@ protected: virtual void sceneOrder() override; protected: - GridNode* _inSceneProxy; - GridNode* _outSceneProxy; + NodeGrid* _inSceneProxy; + NodeGrid* _outSceneProxy; bool _back; static float POLYGON_OFFSET_FACTOR; static float POLYGON_OFFSET_UNITS; diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index a87cae3a40..17327e4259 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -63,7 +63,7 @@ set(COCOS2D_SRC CCDrawNode.cpp CCGrabber.cpp CCGrid.cpp - CCGridNode.cpp + CCNodeGrid.cpp CCFont.cpp CCFontAtlas.cpp CCFontAtlasCache.cpp diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index c88e0b46b4..67fa81a8cd 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -256,7 +256,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - + @@ -428,7 +428,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 6efe31055d..66b081a49b 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -566,7 +566,7 @@ base - + misc_nodes @@ -1146,7 +1146,7 @@ base - + misc_nodes diff --git a/cocos/2d/platform/android/java/project.properties b/cocos/2d/platform/android/java/project.properties index 88ca83f9d0..4a46b9d1c9 100644 --- a/cocos/2d/platform/android/java/project.properties +++ b/cocos/2d/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-10 +target=android-17 diff --git a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp index bc1a1efd35..bec6560c4e 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -1,5 +1,5 @@ #include "EffectsAdvancedTest.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" enum { @@ -155,7 +155,7 @@ private: void Effect4::onEnter() { EffectAdvanceTextLayer::onEnter(); - //Node* gridNode = GridNode::create(); + //Node* gridNode = NodeGrid::create(); auto lens = Lens3D::create(10, Size(32,24), Point(100,180), 150); auto move = JumpBy::create(5, Point(380,0), 100, 4); @@ -243,7 +243,7 @@ void Issue631::onEnter() layer->addChild(sprite, 10); // foreground - auto layer2BaseGrid = GridNode::create(); + auto layer2BaseGrid = NodeGrid::create(); auto layer2 = LayerColor::create(Color4B( 0, 255,0,255 ) ); auto fog = Sprite::create("Images/Fog.png"); @@ -339,7 +339,7 @@ void EffectAdvanceTextLayer::onEnter(void) { BaseTest::onEnter(); - _bgNode = GridNode::create(); + _bgNode = NodeGrid::create(); _bgNode->setAnchorPoint(Point(0.5,0.5)); addChild(_bgNode); //_bgNode->setPosition( VisibleRect::center() ); @@ -349,7 +349,7 @@ void EffectAdvanceTextLayer::onEnter(void) //bg->setPosition( VisibleRect::center() ); _bgNode->addChild(bg); - _target1 = GridNode::create(); + _target1 = NodeGrid::create(); _target1->setAnchorPoint(Point(0.5,0.5)); auto grossini = Sprite::create("Images/grossinis_sister2.png"); _target1->addChild(grossini); @@ -360,7 +360,7 @@ void EffectAdvanceTextLayer::onEnter(void) _target1->runAction( RepeatForever::create(Sequence::create(sc, sc_back, NULL) ) ); - _target2 = GridNode::create(); + _target2 = NodeGrid::create(); _target2->setAnchorPoint(Point(0.5,0.5)); auto tamara = Sprite::create("Images/grossinis_sister1.png"); _target2->addChild(tamara); diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp index 8d50659031..79b6efd4b7 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.cpp @@ -1,6 +1,6 @@ #include "EffectsTest.h" #include "../testResource.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" enum { kTagTextLayer = 1, @@ -342,7 +342,7 @@ TextLayer::TextLayer(void) LayerColor *background = LayerColor::create( Color4B(32,128,32,255) ); this->addChild(background,-20); - _gridNodeTarget = GridNode::create(); + _gridNodeTarget = NodeGrid::create(); auto effect = getAction(); _gridNodeTarget->runAction(effect); addChild(_gridNodeTarget, 0, kTagBackground); @@ -378,8 +378,8 @@ TextLayer::TextLayer(void) void TextLayer::checkAnim(float dt) { //auto s2 = getChildByTag(kTagBackground); - if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getNodeGrid() != NULL) - _gridNodeTarget->setNodeGrid(NULL);; + if ( _gridNodeTarget->getNumberOfRunningActions() == 0 && _gridNodeTarget->getGrid() != NULL) + _gridNodeTarget->setGrid(NULL);; } diff --git a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h index e7acd531a2..6772578b45 100644 --- a/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h +++ b/samples/Cpp/TestCpp/Classes/EffectsTest/EffectsTest.h @@ -14,7 +14,7 @@ class TextLayer : public BaseTest { protected: //UxString _title; - GridNode* _gridNodeTarget; + NodeGrid* _gridNodeTarget; public: TextLayer(void); ~TextLayer(void); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index e9301f6198..71a8278bce 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1,7 +1,7 @@ #include "ArmatureScene.h" #include "../../testResource.h" #include "cocostudio/CocoStudio.h" -#include "CCGridNode.h" +#include "CCNodeGrid.h" using namespace cocos2d; @@ -574,7 +574,7 @@ void TestAnimationEvent::callback2() void TestFrameEvent::onEnter() { ArmatureTestLayer::onEnter(); - _gridNode = GridNode::create(); + _gridNode = NodeGrid::create(); Armature *armature = Armature::create("HeroAnimation"); armature->getAnimation()->play("attack"); armature->getAnimation()->setSpeedScale(0.5); @@ -611,8 +611,8 @@ void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIn } void TestFrameEvent::checkAction(float dt) { - if ( _gridNode->getNumberOfRunningActions() == 0 && _gridNode->getNodeGrid() != nullptr) - _gridNode->setNodeGrid(nullptr); + if ( _gridNode->getNumberOfRunningActions() == 0 && _gridNode->getGrid() != nullptr) + _gridNode->setGrid(nullptr); } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index 09fba2c74e..5a7065f29a 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -166,7 +166,7 @@ public: void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex); void checkAction(float dt); protected: - GridNode* _gridNode; + NodeGrid* _gridNode; }; diff --git a/samples/Cpp/TestCpp/proj.android/project.properties b/samples/Cpp/TestCpp/proj.android/project.properties index 0a6dc6664d..02a4c7398a 100644 --- a/samples/Cpp/TestCpp/proj.android/project.properties +++ b/samples/Cpp/TestCpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-10 +target=android-17 android.library.reference.1=../../../../cocos/2d/platform/android/java From d63d3b3c24e5580ec1fb7973319cd533f1f1bd23 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 16 Dec 2013 14:45:21 +0800 Subject: [PATCH 17/26] remove manually JS binding functions --- .../javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id index 905d27d360..81cc046366 100644 --- a/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id +++ b/cocos/scripting/javascript/bindings/cocos2d_specifics.cpp.REMOVED.git-id @@ -1 +1 @@ -6ea6ffc183c8a15eae0641c73c9886b90172266f \ No newline at end of file +cb193c00a0514b8292266fba55b5f97cbebb73bd \ No newline at end of file From 6abb6639b53af23c3ee93b22d156fcf1ba864585 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Mon, 16 Dec 2013 19:22:40 +0800 Subject: [PATCH 18/26] remove android properties change by eclipse --- cocos/2d/platform/android/java/project.properties | 2 +- samples/Cpp/TestCpp/proj.android/project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/platform/android/java/project.properties b/cocos/2d/platform/android/java/project.properties index 4a46b9d1c9..88ca83f9d0 100644 --- a/cocos/2d/platform/android/java/project.properties +++ b/cocos/2d/platform/android/java/project.properties @@ -12,4 +12,4 @@ android.library=true # Project target. -target=android-17 +target=android-10 diff --git a/samples/Cpp/TestCpp/proj.android/project.properties b/samples/Cpp/TestCpp/proj.android/project.properties index 02a4c7398a..0a6dc6664d 100644 --- a/samples/Cpp/TestCpp/proj.android/project.properties +++ b/samples/Cpp/TestCpp/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-17 +target=android-10 android.library.reference.1=../../../../cocos/2d/platform/android/java From 46d1d5bb91711f2b46bd0c10ad688a97578712d2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Wed, 18 Dec 2013 17:19:50 +0800 Subject: [PATCH 19/26] add GridNode New renderer imp --- cocos/2d/CCNodeGrid.cpp | 57 ++++++++++++++++++++++++++++++++--------- cocos/2d/CCNodeGrid.h | 5 ++++ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index acbf6e92fa..728d99660c 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -2,7 +2,10 @@ #include "CCNodeGrid.h" #include "CCGrid.h" -#include "kazmath/GL/matrix.h" +#include "GroupCommand.h" +#include "Renderer.h" +#include "CustomCommand.h" + NS_CC_BEGIN @@ -46,6 +49,22 @@ bool NodeGrid::init() return Node::init(); } +void NodeGrid::onGridBeginDraw() +{ + if (_nodeGrid && _nodeGrid->isActive()) + { + _nodeGrid->beforeDraw(); + } +} + +void NodeGrid::onGridEndDraw() +{ + if(_nodeGrid && _nodeGrid->isActive()) + { + _nodeGrid->afterDraw(this); + } +} + void NodeGrid::visit() { // quick return if not visible. children won't be drawn. @@ -54,20 +73,32 @@ void NodeGrid::visit() return; } + Renderer* renderer = Renderer::getInstance(); + + GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); + groupCommand->init(0,_vertexZ); + renderer->addCommand(groupCommand); + + renderer->pushGroup(groupCommand->getRenderQueueID()); + kmGLPushMatrix(); - if (_nodeGrid && _nodeGrid->isActive()) - { - _nodeGrid->beforeDraw(); - } this->transform(); + + kmGLGetMatrix(KM_GL_MODELVIEW, &_cachedMVmat); + + CustomCommand* gridBeginCmd = CustomCommand::getCommandPool().generateCommand(); + gridBeginCmd->init(0,_vertexZ); + gridBeginCmd->func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); + renderer->addCommand(gridBeginCmd); + if(_gridTarget) { _gridTarget->visit(); } - + int i = 0; if(!_children.empty()) @@ -83,7 +114,7 @@ void NodeGrid::visit() else break; } - // self draw + // self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command this->draw(); // Uses std::for_each to improve performance. @@ -95,14 +126,16 @@ void NodeGrid::visit() { this->draw(); } - + // reset for next frame _orderOfArrival = 0; - if (_nodeGrid && _nodeGrid->isActive()) - { - _nodeGrid->afterDraw(this); - } + CustomCommand* gridEndCmd = CustomCommand::getCommandPool().generateCommand(); + gridEndCmd->init(0,_vertexZ); + gridEndCmd->func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this); + renderer->addCommand(gridEndCmd); + + renderer->popGroup(); kmGLPopMatrix(); } diff --git a/cocos/2d/CCNodeGrid.h b/cocos/2d/CCNodeGrid.h index 4a7f4784fa..c5444ede2b 100644 --- a/cocos/2d/CCNodeGrid.h +++ b/cocos/2d/CCNodeGrid.h @@ -2,6 +2,7 @@ #define __MISCNODE_CCGRID_NODE_H__ #include "CCNode.h" +#include "kazmath/GL/matrix.h" NS_CC_BEGIN @@ -33,7 +34,11 @@ protected: NodeGrid(); virtual ~NodeGrid(); + void onGridBeginDraw(); + void onGridEndDraw(); + protected: + kmMat4 _cachedMVmat; Node* _gridTarget; GridBase* _nodeGrid; }; From 1bc7250f7eb7e3a1e8c4d17068454f90a7e71004 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 16:54:39 +0800 Subject: [PATCH 20/26] node grid migrating to new renderer --- cocos/2d/CCNodeGrid.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 728d99660c..a6ca63fc72 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -82,9 +82,12 @@ void NodeGrid::visit() renderer->pushGroup(groupCommand->getRenderQueueID()); kmGLPushMatrix(); - - - this->transform(); + Director::Projection beforeProjectionType; + if(_nodeGrid && _nodeGrid->isActive()) + { + beforeProjectionType = Director::getInstance()->getProjection(); + _nodeGrid->set2DProjection(); + } kmGLGetMatrix(KM_GL_MODELVIEW, &_cachedMVmat); @@ -93,7 +96,8 @@ void NodeGrid::visit() gridBeginCmd->func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this); renderer->addCommand(gridBeginCmd); - + this->transform(); + if(_gridTarget) { _gridTarget->visit(); @@ -129,6 +133,13 @@ void NodeGrid::visit() // reset for next frame _orderOfArrival = 0; + + if(_nodeGrid && _nodeGrid->isActive()) + { + // restore projection + Director *director = Director::getInstance(); + director->setProjection(beforeProjectionType); + } CustomCommand* gridEndCmd = CustomCommand::getCommandPool().generateCommand(); gridEndCmd->init(0,_vertexZ); From 911e5b0bac16db17e41eb19c85bfb2a62ab9ad88 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 16:55:22 +0800 Subject: [PATCH 21/26] fix bug : group command nesting will cause infinite loop --- cocos/2d/renderer/GroupCommand.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/renderer/GroupCommand.cpp b/cocos/2d/renderer/GroupCommand.cpp index 46939b267e..4d9e0e56e5 100644 --- a/cocos/2d/renderer/GroupCommand.cpp +++ b/cocos/2d/renderer/GroupCommand.cpp @@ -47,6 +47,7 @@ int GroupCommandManager::getGroupID() { if(!it->second) { + _groupMapping[it->first] = true; return it->first; } } From 44366c653c1cca9dd580600da804d0ac79b71ecb Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 17:20:36 +0800 Subject: [PATCH 22/26] fix compile error --- cocos/2d/CCNodeGrid.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index a6ca63fc72..4361164add 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -2,9 +2,9 @@ #include "CCNodeGrid.h" #include "CCGrid.h" -#include "GroupCommand.h" -#include "Renderer.h" -#include "CustomCommand.h" +#include "CCGroupCommand.h" +#include "CCRenderer.h" +#include "CCCustomCommand.h" NS_CC_BEGIN @@ -73,7 +73,7 @@ void NodeGrid::visit() return; } - Renderer* renderer = Renderer::getInstance(); + Renderer* renderer = Director::getInstance()->getRenderer(); GroupCommand* groupCommand = GroupCommand::getCommandPool().generateCommand(); groupCommand->init(0,_vertexZ); From 9fec597ff304909b8cecc0440bea26e30cb272e1 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 21:36:44 +0800 Subject: [PATCH 23/26] remove unreachable code --- cocos/2d/CCNode.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 90fe208fc5..1ae9285a9a 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -854,20 +854,6 @@ void Node::transform() // saves the MV matrix kmGLGetMatrix(KM_GL_MODELVIEW, &_modelViewTransform); - // XXX: Expensive calls. Camera should be integrated into the cached affine matrix - //_grid is always null - if ( _camera != nullptr && false/*!(_grid != NULL && _grid->isActive())*/ ) - { - bool translate = (_anchorPointInPoints.x != 0.0f || _anchorPointInPoints.y != 0.0f); - - if( translate ) - kmGLTranslatef(RENDER_IN_SUBPIXEL(_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(_anchorPointInPoints.y), 0 ); - - _camera->locate(); - - if( translate ) - kmGLTranslatef(RENDER_IN_SUBPIXEL(-_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(-_anchorPointInPoints.y), 0 ); - } } From 034e1152e58d9f0170fcd1f1702044d221a5ffe8 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 21:41:07 +0800 Subject: [PATCH 24/26] minor change accord to cocos2d coding style --- cocos/2d/CCNodeGrid.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cocos/2d/CCNodeGrid.cpp b/cocos/2d/CCNodeGrid.cpp index 4361164add..a892e5bd59 100644 --- a/cocos/2d/CCNodeGrid.cpp +++ b/cocos/2d/CCNodeGrid.cpp @@ -11,22 +11,21 @@ NS_CC_BEGIN NodeGrid* NodeGrid::create() { - NodeGrid * pRet = new NodeGrid(); - if (pRet && pRet->init()) + NodeGrid * ret = new NodeGrid(); + if (ret && ret->init()) { - pRet->autorelease(); + ret->autorelease(); } else { - CC_SAFE_DELETE(pRet); + CC_SAFE_DELETE(ret); } - return pRet; + return ret; } NodeGrid::NodeGrid() -:Node() -,_nodeGrid(nullptr) -,_gridTarget(nullptr) +: _nodeGrid(nullptr) +, _gridTarget(nullptr) { } From 517fec4de733b8457c93119b5154b939f8f2910d Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 21:49:21 +0800 Subject: [PATCH 25/26] change TransitionTurnOffTiles::_outSceneProxy when class construction instead of onEnter --- cocos/2d/CCTransition.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index cede266d2e..e9ca73f3df 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -1346,8 +1346,10 @@ void TransitionCrossFade::onExit() // TurnOffTilesTransition // TransitionTurnOffTiles::TransitionTurnOffTiles() +: _outSceneProxy(nullptr) { - _outSceneProxy = nullptr; + _outSceneProxy = NodeGrid::create(); + _outSceneProxy->retain(); } TransitionTurnOffTiles::~TransitionTurnOffTiles() @@ -1376,9 +1378,6 @@ void TransitionTurnOffTiles::sceneOrder() void TransitionTurnOffTiles::onEnter() { TransitionScene::onEnter(); - - _outSceneProxy = NodeGrid::create(); - _outSceneProxy->retain(); _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); @@ -1403,6 +1402,7 @@ void TransitionTurnOffTiles::onEnter() void TransitionTurnOffTiles::onExit() { + _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); TransitionScene::onExit(); } From 61cf9e49ebd7d838abbc3a75cc1c89c459805a9f Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Thu, 19 Dec 2013 22:01:32 +0800 Subject: [PATCH 26/26] change TransitionPageTurn::_outSceneProxy when class construction instead of onEnter --- cocos/2d/CCTransition.cpp | 14 +++++++------- cocos/2d/CCTransitionPageTurn.cpp | 15 +++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index e9ca73f3df..13bd2a841e 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -1346,7 +1346,6 @@ void TransitionCrossFade::onExit() // TurnOffTilesTransition // TransitionTurnOffTiles::TransitionTurnOffTiles() -: _outSceneProxy(nullptr) { _outSceneProxy = NodeGrid::create(); _outSceneProxy->retain(); @@ -1434,7 +1433,8 @@ ActionInterval* TransitionTurnOffTiles:: easeActionWithAction(ActionInterval* ac // TransitionSplitCols::TransitionSplitCols() { - _gridProxy = nullptr; + _gridProxy = NodeGrid::create(); + _gridProxy->retain(); } TransitionSplitCols::~TransitionSplitCols() { @@ -1457,8 +1457,6 @@ void TransitionSplitCols::onEnter() { TransitionScene::onEnter(); - _gridProxy = NodeGrid::create(); - _gridProxy->retain(); _gridProxy->setTarget(_outScene); _gridProxy->onEnter(); @@ -1496,6 +1494,7 @@ void TransitionSplitCols::draw() void TransitionSplitCols::onExit() { + _gridProxy->setTarget(nullptr); _gridProxy->onExit(); TransitionScene::onExit(); } @@ -1545,7 +1544,8 @@ TransitionSplitRows* TransitionSplitRows::create(float t, Scene* scene) // TransitionFadeTR::TransitionFadeTR() { - _outSceneProxy = nullptr; + _outSceneProxy = NodeGrid::create(); + _outSceneProxy->retain(); } TransitionFadeTR::~TransitionFadeTR() { @@ -1572,8 +1572,7 @@ void TransitionFadeTR::sceneOrder() void TransitionFadeTR::onEnter() { TransitionScene::onEnter(); - _outSceneProxy = NodeGrid::create(); - _outSceneProxy->retain(); + _outSceneProxy->setTarget(_outScene); _outSceneProxy->onEnter(); @@ -1598,6 +1597,7 @@ void TransitionFadeTR::onEnter() void TransitionFadeTR::onExit() { + _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); TransitionScene::onExit(); } diff --git a/cocos/2d/CCTransitionPageTurn.cpp b/cocos/2d/CCTransitionPageTurn.cpp index 8169ca8075..f7b0188143 100644 --- a/cocos/2d/CCTransitionPageTurn.cpp +++ b/cocos/2d/CCTransitionPageTurn.cpp @@ -38,8 +38,11 @@ float TransitionPageTurn::POLYGON_OFFSET_UNITS = -20.f; TransitionPageTurn::TransitionPageTurn() { - _inSceneProxy = nullptr; - _outSceneProxy = nullptr; + _inSceneProxy = NodeGrid::create(); + _outSceneProxy = NodeGrid::create(); + + _inSceneProxy->retain(); + _outSceneProxy->retain(); } TransitionPageTurn::~TransitionPageTurn() @@ -99,12 +102,6 @@ void TransitionPageTurn::draw() void TransitionPageTurn::onEnter() { TransitionScene::onEnter(); - _inSceneProxy = NodeGrid::create(); - _outSceneProxy = NodeGrid::create(); - - CCASSERT(_inSceneProxy && _outSceneProxy, "TransitionPageTurn proxy scene can not be nullptr"); - _inSceneProxy->retain(); - _outSceneProxy->retain(); _inSceneProxy->setTarget(_inScene); _outSceneProxy->setTarget(_outScene); @@ -159,6 +156,8 @@ void TransitionPageTurn::onEnter() } void TransitionPageTurn::onExit() { + _outSceneProxy->setTarget(nullptr); + _outSceneProxy->setTarget(nullptr); _outSceneProxy->onExit(); _inSceneProxy->onExit();