diff --git a/CHANGELOG b/CHANGELOG index be1918594a..e2dd788f49 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ cocos2d-x-3.0rc0 Feb.?? 2014 [NEW] Action: RotateBy supports 3D rotations [NEW] Bindings: Using python to automatically generate script bindings [NEW] Bindings: Added JS bindings support for Linux + [NEW] ccConfig.h: removed support for CC_TEXTURE_ATLAS_USE_TRIANGLE_STRIP [NEW] Console: Added 'resolution', 'projection' commands. Improved API [NEW] Console: Added more commands: director resume|pause|stopanimation|startanimation. [NEW] Console: Added command: 'touch tap|swipe' to simulating touch events. @@ -48,6 +49,8 @@ cocos2d-x-3.0rc0 Feb.?? 2014 [FIX] EGLView improvements: renamed to GLView, no longer a singleton, easier to customize [FIX] Removes samples except testcpp|testjavascript|testlua. Moves sample games to `cocos2d/samples` repo. [FIX] cc.BuilderReader.load( path, null, parentSize ); was not allowed. + [FIX] Node: setAdditionalTransform receives a pointer and not a const reference + cocos2d-x-3.0beta2 Jan.24 2014 [All] diff --git a/cocos/2d/CCActionCamera.cpp b/cocos/2d/CCActionCamera.cpp index 45560f7ede..b11f6e40cd 100644 --- a/cocos/2d/CCActionCamera.cpp +++ b/cocos/2d/CCActionCamera.cpp @@ -122,7 +122,7 @@ void ActionCamera::updateTransform() // But that operation needs to be done after all the 'updates'. // So the Director should emit an 'director_after_update' event. // And this object should listen to it - _target->setAdditionalTransform(mv); + _target->setAdditionalTransform(&mv); } // diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index ff3c938ed9..57dbdd415a 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1361,16 +1361,20 @@ void Node::setNodeToParentTransform(const kmMat4& transform) void Node::setAdditionalTransform(const AffineTransform& additionalTransform) { - CGAffineToGL(additionalTransform, _additionalTransform.mat); - _transformUpdated = _transformDirty = _inverseDirty = true; - _useAdditionalTransform = true; + kmMat4 tmp; + CGAffineToGL(additionalTransform, tmp.mat); + setAdditionalTransform(&tmp); } -void Node::setAdditionalTransform(const kmMat4& additionalTransform) +void Node::setAdditionalTransform(kmMat4* additionalTransform) { - _additionalTransform = additionalTransform; + if(additionalTransform == nullptr) { + _useAdditionalTransform = false; + } else { + _additionalTransform = *additionalTransform; + _useAdditionalTransform = true; + } _transformUpdated = _transformDirty = _inverseDirty = true; - _useAdditionalTransform = true; } diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index 312615ef5c..7e13a8fb1d 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -1347,54 +1347,12 @@ public: /** * Sets an additional transform matrix to the node. * - * In order to remove it, set the Identity Matrix to the additional transform. + * In order to remove it, call it again with the argument `nullptr` * * @note The additional transform will be concatenated at the end of getNodeToParentTransform. * It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't). - @code - // create a batchNode - SpriteBatchNode* batch= SpriteBatchNode::create("Icon-114.png"); - this->addChild(batch); - - // create two sprites, spriteA will be added to batchNode, they are using different textures. - Sprite* spriteA = Sprite::createWithTexture(batch->getTexture()); - Sprite* spriteB = Sprite::create("Icon-72.png"); - - batch->addChild(spriteA); - - // We can't make spriteB as spriteA's child since they use different textures. So just add it to layer. - // But we want to simulate `parent-child` relationship for these two node. - this->addChild(spriteB); - - //position - spriteA->setPosition(Point(200, 200)); - - // Gets the spriteA's transform. - auto t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - - //scale - spriteA->setScale(2); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - - //rotation - spriteA->setRotation(20); - - // Gets the spriteA's transform. - t = spriteA->getNodeToParentTransform(); - - // Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA. - spriteB->setAdditionalTransform(t); - @endcode */ - void setAdditionalTransform(const kmMat4& additionalTransform); + void setAdditionalTransform(kmMat4* additionalTransform); void setAdditionalTransform(const AffineTransform& additionalTransform); /// @} end of Coordinate Converters diff --git a/cocos/2d/CCTransition.cpp b/cocos/2d/CCTransition.cpp index 7344a28306..0777474369 100644 --- a/cocos/2d/CCTransition.cpp +++ b/cocos/2d/CCTransition.cpp @@ -112,21 +112,18 @@ void TransitionScene::draw(Renderer *renderer, const kmMat4 &transform, bool tra void TransitionScene::finish() { - kmMat4 identity; - kmMat4Identity(&identity); - // clean up _inScene->setVisible(true); _inScene->setPosition(Point(0,0)); _inScene->setScale(1.0f); _inScene->setRotation(0.0f); - _inScene->setAdditionalTransform(identity); + _inScene->setAdditionalTransform(nullptr); _outScene->setVisible(false); _outScene->setPosition(Point(0,0)); _outScene->setScale(1.0f); _outScene->setRotation(0.0f); - _outScene->setAdditionalTransform(identity); + _outScene->setAdditionalTransform(nullptr); //[self schedule:@selector(setNewScene:) interval:0]; this->schedule(schedule_selector(TransitionScene::setNewScene), 0); diff --git a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp index 72428edfff..d3f894cf42 100644 --- a/cocos/editor-support/cocostudio/CCDisplayFactory.cpp +++ b/cocos/editor-support/cocostudio/CCDisplayFactory.cpp @@ -93,7 +93,8 @@ void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty) break; default: { - display->setAdditionalTransform(bone->getNodeToArmatureTransform()); + kmMat4 transform = bone->getNodeToArmatureTransform(); + display->setAdditionalTransform(&transform); } break; } diff --git a/tests/Classes/NodeTest/NodeTest.cpp b/tests/Classes/NodeTest/NodeTest.cpp index 900de637a2..27dcc0f6ce 100644 --- a/tests/Classes/NodeTest/NodeTest.cpp +++ b/tests/Classes/NodeTest/NodeTest.cpp @@ -1107,8 +1107,8 @@ CameraTest2::CameraTest2() kmMat4 lookupMatrix; kmMat4LookAt(&lookupMatrix, &eye, ¢er, &up); - _sprite1->setAdditionalTransform(lookupMatrix); - _sprite2->setAdditionalTransform(lookupMatrix); + _sprite1->setAdditionalTransform(&lookupMatrix); + _sprite2->setAdditionalTransform(&lookupMatrix); }