diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index b5e1921efa..3034a23b30 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -1942,21 +1942,25 @@ var Node = cc.Class({ _updateWorldMatrix () { let node = this; + let n = -1; // Find root of world matrix changing while (node) { if (node._worldMatDirty) { - _parents.push(node); + n++; + _parents[n] = node; } else { break; } node = node._parent; } - // Update world matrix of all changed parents - for (let i = _parents.length - 1; i >= 0; i--) { - _parents[i]._calculWorldMatrix(); + if (n >= 0) { + _parents.length = n + 1; + // Update world matrix of all changed parents + for (let i = n; i >= 0; i--) { + _parents[i]._calculWorldMatrix(); + } } - _parents.length = 0; }, setLocalDirty () { diff --git a/cocos2d/core/renderer/render-component-walker.js b/cocos2d/core/renderer/render-component-walker.js index 8d42996a1e..cff1f6f453 100644 --- a/cocos2d/core/renderer/render-component-walker.js +++ b/cocos2d/core/renderer/render-component-walker.js @@ -125,6 +125,7 @@ RenderComponentWalker.prototype = { // reset caches for handle render components _batchData.node = null; + _batchData.worldMatUpdated = false; _batchData.vfmt = null; _batchData.material = null; _batchData.data = null;