Fix _updateWorldMatrix issue

This commit is contained in:
pandamicro
2018-04-12 19:26:05 +08:00
parent 277707d892
commit ecd8015ec2
2 changed files with 10 additions and 5 deletions
+9 -5
View File
@@ -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 () {
@@ -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;