From e0b9878e585f43cf950c091a3e430c552b68f9cd Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Mon, 29 Sep 2014 15:07:05 +0800 Subject: [PATCH 1/8] added ClippingRegionNode --- cocos/2d/CCClippingRegionNode.cpp | 84 +++++++++++++++++++++++++++++++ cocos/2d/CCClippingRegionNode.h | 77 ++++++++++++++++++++++++++++ cocos/cocos2d.h | 1 + tools/tolua/cocos2dx.ini | 2 +- 4 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 cocos/2d/CCClippingRegionNode.cpp create mode 100644 cocos/2d/CCClippingRegionNode.h diff --git a/cocos/2d/CCClippingRegionNode.cpp b/cocos/2d/CCClippingRegionNode.cpp new file mode 100644 index 0000000000..5b9eb81781 --- /dev/null +++ b/cocos/2d/CCClippingRegionNode.cpp @@ -0,0 +1,84 @@ + +#include "CCClippingRegionNode.h" +#include "base/CCDirector.h" +#include "renderer/CCRenderer.h" +#include "math/Vec2.h" +#include "CCGLView.h" + +NS_CC_BEGIN + +ClippingRegionNode* ClippingRegionNode::create(const Rect& clippingRegion) +{ + ClippingRegionNode* node = new ClippingRegionNode(); + if (node && node->init()) { + node->setClippingRegion(clippingRegion); + node->autorelease(); + } else { + CC_SAFE_DELETE(node); + } + + return node; +} + +ClippingRegionNode* ClippingRegionNode::create(void) +{ + ClippingRegionNode* node = new ClippingRegionNode(); + if (node && node->init()) { + node->autorelease(); + } else { + CC_SAFE_DELETE(node); + } + + return node; +} + +void ClippingRegionNode::setClippingRegion(const Rect &clippingRegion) +{ + _clippingRegion = clippingRegion; +} + +void ClippingRegionNode::onBeforeVisitScissor() +{ + if (_clippingEnabled) { + glEnable(GL_SCISSOR_TEST); + + float scaleX = _scaleX; + float scaleY = _scaleY; + Node *parent = this->getParent(); + while (parent) { + scaleX *= parent->getScaleX(); + scaleY *= parent->getScaleY(); + parent = parent->getParent(); + } + + const Point pos = convertToWorldSpace(Point(_clippingRegion.origin.x, _clippingRegion.origin.y)); + GLView* glView = Director::getInstance()->getOpenGLView(); + glView->setScissorInPoints(pos.x * scaleX, + pos.y * scaleY, + _clippingRegion.size.width * scaleX, + _clippingRegion.size.height * scaleY); + } +} + +void ClippingRegionNode::onAfterVisitScissor() +{ + if (_clippingEnabled) + { + glDisable(GL_SCISSOR_TEST); + } +} + +void ClippingRegionNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) +{ + _beforeVisitCmdScissor.init(_globalZOrder); + _beforeVisitCmdScissor.func = CC_CALLBACK_0(ClippingRegionNode::onBeforeVisitScissor, this); + renderer->addCommand(&_beforeVisitCmdScissor); + + Node::visit(renderer, parentTransform, parentFlags); + + _afterVisitCmdScissor.init(_globalZOrder); + _afterVisitCmdScissor.func = CC_CALLBACK_0(ClippingRegionNode::onAfterVisitScissor, this); + renderer->addCommand(&_afterVisitCmdScissor); +} + +NS_CC_END diff --git a/cocos/2d/CCClippingRegionNode.h b/cocos/2d/CCClippingRegionNode.h new file mode 100644 index 0000000000..065ed013a9 --- /dev/null +++ b/cocos/2d/CCClippingRegionNode.h @@ -0,0 +1,77 @@ +/* + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * cocos2d-x: http://www.cocos2d-x.org + * + * Copyright (c) 2012 Pierre-David BĂ©langer + * Copyright (c) 2012 cocos2d-x.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +#ifndef __MISCNODE_CCCLIPPING_REGION_NODE_H__ +#define __MISCNODE_CCCLIPPING_REGION_NODE_H__ + +#include "2d/CCNode.h" +#include "renderer/CCCustomCommand.h" +#include "platform/CCGL.h" + +NS_CC_BEGIN + +class CC_DLL ClippingRegionNode : public Node +{ +public: + static ClippingRegionNode* create(const Rect& clippingRegion); + static ClippingRegionNode* create(void); + + const Rect getClippingRegion(void) { + return _clippingRegion; + } + void setClippingRegion(const Rect& clippingRegion); + + bool isClippingEnabled(void) { + return _clippingEnabled; + } + void setClippingEnabled(bool enabled) { + _clippingEnabled = enabled; + } + + //virtual void draw(Renderer* renderer, const Mat4 &transform, uint32_t flags) override; + virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; + +protected: + ClippingRegionNode(void) + : _clippingEnabled(true) + { + } + + void onBeforeVisitScissor(); + void onAfterVisitScissor(); + + Rect _clippingRegion; + bool _clippingEnabled; + + CustomCommand _beforeVisitCmdScissor; + CustomCommand _afterVisitCmdScissor; +}; + +NS_CC_END + +#endif + diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index e322b14a0d..c743044558 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -125,6 +125,7 @@ THE SOFTWARE. #include "2d/CCMenu.h" #include "2d/CCMenuItem.h" #include "2d/CCClippingNode.h" +#include "2d/CCClippingRegionNode.h" #include "2d/CCMotionStreak.h" #include "2d/CCProgressTimer.h" #include "2d/CCRenderTexture.h" diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 8583530c0e..75994ba2d6 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Camera Device +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode ClippingRegionNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Camera Device # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also From fbbc90431e546b99840822f1f0f38e1954a9606e Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Mon, 29 Sep 2014 15:42:56 +0800 Subject: [PATCH 2/8] standardized codes --- cocos/2d/CCClippingRegionNode.cpp | 2 +- cocos/2d/CCClippingRegionNode.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos/2d/CCClippingRegionNode.cpp b/cocos/2d/CCClippingRegionNode.cpp index 5b9eb81781..4bc65e2e54 100644 --- a/cocos/2d/CCClippingRegionNode.cpp +++ b/cocos/2d/CCClippingRegionNode.cpp @@ -20,7 +20,7 @@ ClippingRegionNode* ClippingRegionNode::create(const Rect& clippingRegion) return node; } -ClippingRegionNode* ClippingRegionNode::create(void) +ClippingRegionNode* ClippingRegionNode::create() { ClippingRegionNode* node = new ClippingRegionNode(); if (node && node->init()) { diff --git a/cocos/2d/CCClippingRegionNode.h b/cocos/2d/CCClippingRegionNode.h index 065ed013a9..0946ac4702 100644 --- a/cocos/2d/CCClippingRegionNode.h +++ b/cocos/2d/CCClippingRegionNode.h @@ -38,14 +38,14 @@ class CC_DLL ClippingRegionNode : public Node { public: static ClippingRegionNode* create(const Rect& clippingRegion); - static ClippingRegionNode* create(void); + static ClippingRegionNode* create(); - const Rect getClippingRegion(void) { + const Rect& getClippingRegion() const { return _clippingRegion; } void setClippingRegion(const Rect& clippingRegion); - bool isClippingEnabled(void) { + const bool isClippingEnabled() const { return _clippingEnabled; } void setClippingEnabled(bool enabled) { @@ -56,7 +56,7 @@ public: virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; protected: - ClippingRegionNode(void) + ClippingRegionNode() : _clippingEnabled(true) { } From ba064167a81d6717bcd4de1285843745b3b1ba51 Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Fri, 10 Oct 2014 18:43:40 +0800 Subject: [PATCH 3/8] modified project files and make files --- build/cocos2d_libs.xcodeproj/project.pbxproj | 12 ++++++++++++ cocos/2d/cocos2d_winrt.vcxproj | 2 ++ cocos/2d/cocos2d_winrt.vcxproj.filters | 6 ++++++ cocos/2d/cocos2d_wp8.vcxproj | 2 ++ cocos/2d/cocos2d_wp8.vcxproj.filters | 6 ++++++ cocos/2d/libcocos2d.vcxproj | 2 ++ cocos/2d/libcocos2d.vcxproj.filters | 6 ++++++ cocos/Android.mk | 1 + cocos/CMakeLists.txt | 1 + templates/cocos2dx_files.json | 2 ++ tools/tolua/cocos2dx.ini | 2 +- 11 files changed, 41 insertions(+), 1 deletion(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 54f8649053..85e1083b8f 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1811,6 +1811,10 @@ B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; + DABC9FA919E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */; }; + DABC9FAA19E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */; }; + DABC9FAB19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */; }; + DABC9FAC19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; @@ -2796,6 +2800,8 @@ B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = ""; }; B60C5BD319AC68B10056FBDE /* CCBillBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBillBoard.h; sourceTree = ""; }; + DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRegionNode.cpp; sourceTree = ""; }; + DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingRegionNode.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -3198,6 +3204,8 @@ 1A5701FF180BCBBD0088DEC7 /* misc-nodes */ = { isa = PBXGroup; children = ( + DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */, + DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */, ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */, ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */, 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */, @@ -4840,6 +4848,7 @@ 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, + DABC9FAB19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */, 50ABBEC11925AB6F00A911A9 /* CCValue.h in Headers */, 15AE19EB19AAD3A700C27E9E /* SlotData.h in Headers */, B276EF631988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */, @@ -5344,6 +5353,7 @@ 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 15AE195C19AAD35100C27E9E /* CCSGUIReader.h in Headers */, 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, + DABC9FAC19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, @@ -6172,6 +6182,7 @@ 15AE190B19AAD35000C27E9E /* CCDisplayFactory.cpp in Sources */, 1A9DCA27180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 50ABBD541925AB0000A911A9 /* TransformUtils.cpp in Sources */, + DABC9FA919E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */, 3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */, 15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, 50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */, @@ -6306,6 +6317,7 @@ 1A570072180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 15AE1ABC19AAD40300C27E9E /* b2PolygonAndCircleContact.cpp in Sources */, 15AE1ADA19AAD41000C27E9E /* b2Rope.cpp in Sources */, + DABC9FAA19E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */, 15AE1BF119AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */, 15AE1B8419AADA9A00C27E9E /* UITextField.cpp in Sources */, 15AE198E19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index e8cc8dfe68..e4b145ab6b 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -455,6 +455,7 @@ + @@ -672,6 +673,7 @@ + diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index a395535147..90c3971a6a 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -155,6 +155,9 @@ 2d + + 2d + 2d @@ -723,6 +726,9 @@ 2d + + 2d + 2d diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 94ebe8a919..bb374c9ba8 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -389,6 +389,7 @@ + @@ -625,6 +626,7 @@ + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index efbec2797f..363dfab42c 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -166,6 +166,9 @@ 2d + + 2d + 2d @@ -784,6 +787,9 @@ 2d + + 2d + 2d diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index b22ca3a084..330176ba22 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -448,6 +448,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -828,6 +829,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 537fe8b5bb..e44072ea81 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -322,6 +322,9 @@ 2d + + 2d + 2d @@ -1294,6 +1297,9 @@ 2d + + 2d + 2d diff --git a/cocos/Android.mk b/cocos/Android.mk index 7c4c2475ba..9b9b90cc48 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -25,6 +25,7 @@ cocos2d.cpp \ 2d/CCAnimationCache.cpp \ 2d/CCAtlasNode.cpp \ 2d/CCClippingNode.cpp \ +2d/CCClippingRegionNode.cpp \ 2d/CCComponent.cpp \ 2d/CCComponentContainer.cpp \ 2d/CCDrawNode.cpp \ diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 6c837de435..9a82045a66 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -127,6 +127,7 @@ set(COCOS2D_BASE_SRC 2d/CCAnimationCache.cpp 2d/CCAtlasNode.cpp 2d/CCClippingNode.cpp + 2d/CCClippingRegionNode.cpp 2d/CCComponent.cpp 2d/CCComponentContainer.cpp 2d/CCDrawNode.cpp diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index fc7d272e38..98ba5600d9 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -81,6 +81,8 @@ "cocos/2d/CCAtlasNode.h", "cocos/2d/CCClippingNode.cpp", "cocos/2d/CCClippingNode.h", + "cocos/2d/CCClippingRegionNode.cpp", + "cocos/2d/CCClippingRegionNode.h", "cocos/2d/CCComponent.cpp", "cocos/2d/CCComponent.h", "cocos/2d/CCComponentContainer.cpp", diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index 75994ba2d6..8583530c0e 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode ClippingRegionNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Camera Device +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Camera Device # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also From 88acc56e565dc4709b09d0bf0d95820c0f76dea6 Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Sat, 11 Oct 2014 02:15:29 +0800 Subject: [PATCH 4/8] restored cocos/CMakeList.txt --- cocos/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 9a82045a66..6c837de435 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -127,7 +127,6 @@ set(COCOS2D_BASE_SRC 2d/CCAnimationCache.cpp 2d/CCAtlasNode.cpp 2d/CCClippingNode.cpp - 2d/CCClippingRegionNode.cpp 2d/CCComponent.cpp 2d/CCComponentContainer.cpp 2d/CCDrawNode.cpp From a36dbf5362674c78f0cc7fef18acfa032b3976e2 Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Sat, 11 Oct 2014 11:49:01 +0800 Subject: [PATCH 5/8] ClippingRegionNode --> ClippingRectangleNode --- build/cocos2d_libs.xcodeproj/project.pbxproj | 24 +++++++++---------- ...onNode.cpp => CCClippingRectangleNode.cpp} | 22 ++++++++--------- ...RegionNode.h => CCClippingRectangleNode.h} | 12 +++++----- cocos/2d/cocos2d_winrt.vcxproj | 4 ++-- cocos/2d/cocos2d_winrt.vcxproj.filters | 4 ++-- cocos/2d/cocos2d_wp8.vcxproj | 4 ++-- cocos/2d/cocos2d_wp8.vcxproj.filters | 4 ++-- cocos/2d/libcocos2d.vcxproj | 4 ++-- cocos/2d/libcocos2d.vcxproj.filters | 4 ++-- cocos/Android.mk | 2 +- cocos/cocos2d.h | 2 +- templates/cocos2dx_files.json | 4 ++-- 12 files changed, 45 insertions(+), 45 deletions(-) rename cocos/2d/{CCClippingRegionNode.cpp => CCClippingRectangleNode.cpp} (67%) rename cocos/2d/{CCClippingRegionNode.h => CCClippingRectangleNode.h} (88%) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 85e1083b8f..314c0a213c 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -1811,10 +1811,10 @@ B60C5BD519AC68B10056FBDE /* CCBillBoard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */; }; B60C5BD619AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; B60C5BD719AC68B10056FBDE /* CCBillBoard.h in Headers */ = {isa = PBXBuildFile; fileRef = B60C5BD319AC68B10056FBDE /* CCBillBoard.h */; }; - DABC9FA919E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */; }; - DABC9FAA19E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */; }; - DABC9FAB19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */; }; - DABC9FAC19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */; }; + DABC9FA919E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */; }; + DABC9FAA19E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */; }; + DABC9FAB19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; }; + DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */ = {isa = PBXBuildFile; fileRef = DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */; }; ED9C6A9418599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9518599AD8000A5232 /* CCNodeGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */; }; ED9C6A9618599AD8000A5232 /* CCNodeGrid.h in Headers */ = {isa = PBXBuildFile; fileRef = ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */; }; @@ -2800,8 +2800,8 @@ B3AF019F1842FBA400A98B85 /* b2MotorJoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = b2MotorJoint.h; sourceTree = ""; }; B60C5BD219AC68B10056FBDE /* CCBillBoard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCBillBoard.cpp; sourceTree = ""; }; B60C5BD319AC68B10056FBDE /* CCBillBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCBillBoard.h; sourceTree = ""; }; - DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRegionNode.cpp; sourceTree = ""; }; - DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingRegionNode.h; sourceTree = ""; }; + DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCClippingRectangleNode.cpp; sourceTree = ""; }; + DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCClippingRectangleNode.h; sourceTree = ""; }; ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = CCNodeGrid.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCNodeGrid.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -3204,8 +3204,8 @@ 1A5701FF180BCBBD0088DEC7 /* misc-nodes */ = { isa = PBXGroup; children = ( - DABC9FA719E7DFA900FA252C /* CCClippingRegionNode.cpp */, - DABC9FA819E7DFA900FA252C /* CCClippingRegionNode.h */, + DABC9FA719E7DFA900FA252C /* CCClippingRectangleNode.cpp */, + DABC9FA819E7DFA900FA252C /* CCClippingRectangleNode.h */, ED9C6A9218599AD8000A5232 /* CCNodeGrid.cpp */, ED9C6A9318599AD8000A5232 /* CCNodeGrid.h */, 1A57020C180BCBF40088DEC7 /* CCProgressTimer.cpp */, @@ -4848,7 +4848,7 @@ 15AE18A319AAD33D00C27E9E /* CCParticleSystemQuadLoader.h in Headers */, 46A170F01807CECA005B8026 /* CCPhysicsWorld.h in Headers */, 15AE199D19AAD39600C27E9E /* ScrollViewReader.h in Headers */, - DABC9FAB19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */, + DABC9FAB19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */, 50ABBEC11925AB6F00A911A9 /* CCValue.h in Headers */, 15AE19EB19AAD3A700C27E9E /* SlotData.h in Headers */, B276EF631988D1D500CD400F /* CCVertexIndexBuffer.h in Headers */, @@ -5353,7 +5353,7 @@ 1A57006C180BC5A10088DEC7 /* CCActionCatmullRom.h in Headers */, 15AE195C19AAD35100C27E9E /* CCSGUIReader.h in Headers */, 5034CA3A191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */, - DABC9FAC19E7DFA900FA252C /* CCClippingRegionNode.h in Headers */, + DABC9FAC19E7DFA900FA252C /* CCClippingRectangleNode.h in Headers */, 50ABBEC41925AB6F00A911A9 /* CCVector.h in Headers */, 50ABBE501925AB6F00A911A9 /* CCEventCustom.h in Headers */, 15AE1AD719AAD40300C27E9E /* b2WheelJoint.h in Headers */, @@ -6182,7 +6182,7 @@ 15AE190B19AAD35000C27E9E /* CCDisplayFactory.cpp in Sources */, 1A9DCA27180E6955007A3AD4 /* CCGLBufferedNode.cpp in Sources */, 50ABBD541925AB0000A911A9 /* TransformUtils.cpp in Sources */, - DABC9FA919E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */, + DABC9FA919E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */, 3E2F27A619CFBFE100E7C490 /* AudioEngine.cpp in Sources */, 15AE1A3619AAD3D500C27E9E /* b2PolygonShape.cpp in Sources */, 50ABBD9B1925AB4100A911A9 /* ccGLStateCache.cpp in Sources */, @@ -6317,7 +6317,7 @@ 1A570072180BC5A10088DEC7 /* CCActionGrid.cpp in Sources */, 15AE1ABC19AAD40300C27E9E /* b2PolygonAndCircleContact.cpp in Sources */, 15AE1ADA19AAD41000C27E9E /* b2Rope.cpp in Sources */, - DABC9FAA19E7DFA900FA252C /* CCClippingRegionNode.cpp in Sources */, + DABC9FAA19E7DFA900FA252C /* CCClippingRectangleNode.cpp in Sources */, 15AE1BF119AAE01E00C27E9E /* CCControlPotentiometer.cpp in Sources */, 15AE1B8419AADA9A00C27E9E /* UITextField.cpp in Sources */, 15AE198E19AAD36E00C27E9E /* CheckBoxReader.cpp in Sources */, diff --git a/cocos/2d/CCClippingRegionNode.cpp b/cocos/2d/CCClippingRectangleNode.cpp similarity index 67% rename from cocos/2d/CCClippingRegionNode.cpp rename to cocos/2d/CCClippingRectangleNode.cpp index 4bc65e2e54..fa0cb5549d 100644 --- a/cocos/2d/CCClippingRegionNode.cpp +++ b/cocos/2d/CCClippingRectangleNode.cpp @@ -1,5 +1,5 @@ -#include "CCClippingRegionNode.h" +#include "CCClippingRectangleNode.h" #include "base/CCDirector.h" #include "renderer/CCRenderer.h" #include "math/Vec2.h" @@ -7,9 +7,9 @@ NS_CC_BEGIN -ClippingRegionNode* ClippingRegionNode::create(const Rect& clippingRegion) +ClippingRectangleNode* ClippingRectangleNode::create(const Rect& clippingRegion) { - ClippingRegionNode* node = new ClippingRegionNode(); + ClippingRectangleNode* node = new ClippingRectangleNode(); if (node && node->init()) { node->setClippingRegion(clippingRegion); node->autorelease(); @@ -20,9 +20,9 @@ ClippingRegionNode* ClippingRegionNode::create(const Rect& clippingRegion) return node; } -ClippingRegionNode* ClippingRegionNode::create() +ClippingRectangleNode* ClippingRectangleNode::create() { - ClippingRegionNode* node = new ClippingRegionNode(); + ClippingRectangleNode* node = new ClippingRectangleNode(); if (node && node->init()) { node->autorelease(); } else { @@ -32,12 +32,12 @@ ClippingRegionNode* ClippingRegionNode::create() return node; } -void ClippingRegionNode::setClippingRegion(const Rect &clippingRegion) +void ClippingRectangleNode::setClippingRegion(const Rect &clippingRegion) { _clippingRegion = clippingRegion; } -void ClippingRegionNode::onBeforeVisitScissor() +void ClippingRectangleNode::onBeforeVisitScissor() { if (_clippingEnabled) { glEnable(GL_SCISSOR_TEST); @@ -60,7 +60,7 @@ void ClippingRegionNode::onBeforeVisitScissor() } } -void ClippingRegionNode::onAfterVisitScissor() +void ClippingRectangleNode::onAfterVisitScissor() { if (_clippingEnabled) { @@ -68,16 +68,16 @@ void ClippingRegionNode::onAfterVisitScissor() } } -void ClippingRegionNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) +void ClippingRectangleNode::visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) { _beforeVisitCmdScissor.init(_globalZOrder); - _beforeVisitCmdScissor.func = CC_CALLBACK_0(ClippingRegionNode::onBeforeVisitScissor, this); + _beforeVisitCmdScissor.func = CC_CALLBACK_0(ClippingRectangleNode::onBeforeVisitScissor, this); renderer->addCommand(&_beforeVisitCmdScissor); Node::visit(renderer, parentTransform, parentFlags); _afterVisitCmdScissor.init(_globalZOrder); - _afterVisitCmdScissor.func = CC_CALLBACK_0(ClippingRegionNode::onAfterVisitScissor, this); + _afterVisitCmdScissor.func = CC_CALLBACK_0(ClippingRectangleNode::onAfterVisitScissor, this); renderer->addCommand(&_afterVisitCmdScissor); } diff --git a/cocos/2d/CCClippingRegionNode.h b/cocos/2d/CCClippingRectangleNode.h similarity index 88% rename from cocos/2d/CCClippingRegionNode.h rename to cocos/2d/CCClippingRectangleNode.h index 0946ac4702..08e2673730 100644 --- a/cocos/2d/CCClippingRegionNode.h +++ b/cocos/2d/CCClippingRectangleNode.h @@ -25,8 +25,8 @@ * */ -#ifndef __MISCNODE_CCCLIPPING_REGION_NODE_H__ -#define __MISCNODE_CCCLIPPING_REGION_NODE_H__ +#ifndef __MISCNODE_CCCLIPPING_RECTANGLE_NODE_H__ +#define __MISCNODE_CCCLIPPING_RECTANGLE_NODE_H__ #include "2d/CCNode.h" #include "renderer/CCCustomCommand.h" @@ -34,11 +34,11 @@ NS_CC_BEGIN -class CC_DLL ClippingRegionNode : public Node +class CC_DLL ClippingRectangleNode : public Node { public: - static ClippingRegionNode* create(const Rect& clippingRegion); - static ClippingRegionNode* create(); + static ClippingRectangleNode* create(const Rect& clippingRegion); + static ClippingRectangleNode* create(); const Rect& getClippingRegion() const { return _clippingRegion; @@ -56,7 +56,7 @@ public: virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override; protected: - ClippingRegionNode() + ClippingRectangleNode() : _clippingEnabled(true) { } diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index e4b145ab6b..d46ccf5597 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -455,7 +455,7 @@ - + @@ -673,7 +673,7 @@ - + diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index 90c3971a6a..83967794fb 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -155,7 +155,7 @@ 2d - + 2d @@ -726,7 +726,7 @@ 2d - + 2d diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index bb374c9ba8..19c7ada4ac 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -389,7 +389,7 @@ - + @@ -626,7 +626,7 @@ - + diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 363dfab42c..504edf457c 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -166,7 +166,7 @@ 2d - + 2d @@ -787,7 +787,7 @@ 2d - + 2d diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 330176ba22..d51a7a4824 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -448,7 +448,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + @@ -829,7 +829,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index e44072ea81..c666671bfa 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -322,7 +322,7 @@ 2d - + 2d @@ -1297,7 +1297,7 @@ 2d - + 2d diff --git a/cocos/Android.mk b/cocos/Android.mk index 9b9b90cc48..057e9186d5 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -25,7 +25,7 @@ cocos2d.cpp \ 2d/CCAnimationCache.cpp \ 2d/CCAtlasNode.cpp \ 2d/CCClippingNode.cpp \ -2d/CCClippingRegionNode.cpp \ +2d/CCClippingRectangleNode.cpp \ 2d/CCComponent.cpp \ 2d/CCComponentContainer.cpp \ 2d/CCDrawNode.cpp \ diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index c743044558..07a4ea2d52 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -125,7 +125,7 @@ THE SOFTWARE. #include "2d/CCMenu.h" #include "2d/CCMenuItem.h" #include "2d/CCClippingNode.h" -#include "2d/CCClippingRegionNode.h" +#include "2d/CCClippingRectangleNode.h" #include "2d/CCMotionStreak.h" #include "2d/CCProgressTimer.h" #include "2d/CCRenderTexture.h" diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index 98ba5600d9..0cbd32885e 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -81,8 +81,8 @@ "cocos/2d/CCAtlasNode.h", "cocos/2d/CCClippingNode.cpp", "cocos/2d/CCClippingNode.h", - "cocos/2d/CCClippingRegionNode.cpp", - "cocos/2d/CCClippingRegionNode.h", + "cocos/2d/CCClippingRectangleNode.cpp", + "cocos/2d/CCClippingRectangleNode.h", "cocos/2d/CCComponent.cpp", "cocos/2d/CCComponent.h", "cocos/2d/CCComponentContainer.cpp", From f1ce16b463a7b152c3f2209d9ba2407b0bd186d3 Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Wed, 15 Oct 2014 13:41:47 +0800 Subject: [PATCH 6/8] added ClippingRectangleNode Test --- .../ClippingNodeTest/ClippingNodeTest.cpp | 27 +++++++++++++++++++ .../ClippingNodeTest/ClippingNodeTest.h | 10 +++++++ 2 files changed, 37 insertions(+) diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp index 2ae93ee353..0f7054be65 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.cpp @@ -33,6 +33,7 @@ static std::function createFunctions[] = { CL(RawStencilBufferTest5), CL(RawStencilBufferTest6), CL(ClippingToRenderTextureTest), + CL(ClippingRectangleNodeTest), }; static int sceneIdx=-1; @@ -1097,6 +1098,32 @@ void ClippingToRenderTextureTest::reproduceBug() rt->end(); } +// ClippingRectangleNodeDemo + +std::string ClippingRectangleNodeTest::title() const +{ + return "ClippingRectangleNode Test"; +} + +std::string ClippingRectangleNodeTest::subtitle() const +{ + return "more effectively"; +} + +void ClippingRectangleNodeTest::setup() +{ + auto clipper = ClippingRectangleNode::create(); + clipper->setClippingRegion(Rect(this->getContentSize().width / 2 - 100, this->getContentSize().height / 2 - 100, 200, 200)); + clipper->setTag( kTagClipperNode ); + this->addChild(clipper); + + auto content = Sprite::create(s_back2); + content->setTag( kTagContentNode ); + content->setAnchorPoint( Vec2(0.5, 0.5) ); + content->setPosition(this->getContentSize().width / 2, this->getContentSize().height / 2); + clipper->addChild(content); +} + // main entry point diff --git a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h index 4b9faa13cb..535259b13a 100644 --- a/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h +++ b/tests/cpp-tests/Classes/ClippingNodeTest/ClippingNodeTest.h @@ -244,6 +244,16 @@ public: virtual std::string subtitle() const override; }; +class ClippingRectangleNodeTest : public BaseClippingNodeTest +{ +public: + CREATE_FUNC(ClippingRectangleNodeTest); + + virtual std::string title() const override; + virtual std::string subtitle() const override; + virtual void setup(); +}; + class ClippingNodeTestScene : public TestScene { From 3352fb7bf35ce98c00922a65515bf34638192d08 Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Wed, 15 Oct 2014 14:14:02 +0800 Subject: [PATCH 7/8] reset wp8 project files --- cocos/2d/cocos2d_winrt.vcxproj | 2 -- cocos/2d/cocos2d_winrt.vcxproj.filters | 6 ------ cocos/2d/cocos2d_wp8.vcxproj | 2 -- cocos/2d/cocos2d_wp8.vcxproj.filters | 6 ------ 4 files changed, 16 deletions(-) diff --git a/cocos/2d/cocos2d_winrt.vcxproj b/cocos/2d/cocos2d_winrt.vcxproj index a3105de4bc..00d7f67216 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj +++ b/cocos/2d/cocos2d_winrt.vcxproj @@ -456,7 +456,6 @@ - @@ -675,7 +674,6 @@ - diff --git a/cocos/2d/cocos2d_winrt.vcxproj.filters b/cocos/2d/cocos2d_winrt.vcxproj.filters index 7483ecb7e9..f486f2c14a 100644 --- a/cocos/2d/cocos2d_winrt.vcxproj.filters +++ b/cocos/2d/cocos2d_winrt.vcxproj.filters @@ -155,9 +155,6 @@ 2d - - 2d - 2d @@ -729,9 +726,6 @@ 2d - - 2d - 2d diff --git a/cocos/2d/cocos2d_wp8.vcxproj b/cocos/2d/cocos2d_wp8.vcxproj index 2515039fbc..2e40199da9 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj +++ b/cocos/2d/cocos2d_wp8.vcxproj @@ -404,7 +404,6 @@ - @@ -665,7 +664,6 @@ - diff --git a/cocos/2d/cocos2d_wp8.vcxproj.filters b/cocos/2d/cocos2d_wp8.vcxproj.filters index 2b7c9a91fc..b670c0eeb1 100644 --- a/cocos/2d/cocos2d_wp8.vcxproj.filters +++ b/cocos/2d/cocos2d_wp8.vcxproj.filters @@ -175,9 +175,6 @@ 2d - - 2d - 2d @@ -841,9 +838,6 @@ 2d - - 2d - 2d From 74952d72581be0a0c0faa5492bd53549fbccb62b Mon Sep 17 00:00:00 2001 From: SunLightJuly Date: Wed, 15 Oct 2014 14:17:04 +0800 Subject: [PATCH 8/8] added CCClippingRectangleNode.cpp to CMakeList --- cocos/2d/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 356c94dbad..bfbd6a8447 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -21,6 +21,7 @@ set(COCOS_2D_SRC 2d/CCAnimation.cpp 2d/CCAtlasNode.cpp 2d/CCClippingNode.cpp + 2d/CCClippingRectangleNode.cpp 2d/CCComponentContainer.cpp 2d/CCComponent.cpp 2d/CCDrawingPrimitives.cpp