mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Remove _syncWorldDirty for recursive approach (#2582)
* Fix render data issue for bar filled sprite * Remove _syncWorldDirty for recursive approach
This commit is contained in:
+17
-26
@@ -316,16 +316,6 @@ function _checkListeners (node, events) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function _syncWorldDirty (children) {
|
||||
for (let i = 0, l = children.length; i < l; i++) {
|
||||
let child = children[i];
|
||||
child._worldMatDirty = true;
|
||||
if (child._children.length > 0) {
|
||||
_syncWorldDirty(child._children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Class of all entities in Cocos Creator scenes.<br/>
|
||||
@@ -2003,33 +1993,34 @@ var Node = cc.Class({
|
||||
},
|
||||
|
||||
_updateWorldMatrix () {
|
||||
let n = -1;
|
||||
// Find root of world matrix changing
|
||||
for (let node = this; node && node._worldMatDirty; node = node._parent) {
|
||||
n++;
|
||||
_parents[n] = node;
|
||||
let dirty = false;
|
||||
if (this.parent) {
|
||||
dirty = this.parent._updateWorldMatrix();
|
||||
}
|
||||
// Update world matrix of all changed parents
|
||||
for (let i = n; i >= 0; i--) {
|
||||
_parents[i]._calculWorldMatrix();
|
||||
_parents[i] = null;
|
||||
if (this._worldMatDirty) {
|
||||
dirty = true;
|
||||
}
|
||||
if (dirty) {
|
||||
this._calculWorldMatrix();
|
||||
// Sync dirty to children
|
||||
let children = this._children;
|
||||
for (let i = 0, l = children.length; i < l; i++) {
|
||||
children[i]._worldMatDirty = true;
|
||||
}
|
||||
}
|
||||
return dirty;
|
||||
},
|
||||
|
||||
setLocalDirty (flag) {
|
||||
if (!this._localMatDirty) {
|
||||
this.setWorldDirty();
|
||||
}
|
||||
this._localMatDirty = this._localMatDirty | flag;
|
||||
if (!this._worldMatDirty) {
|
||||
this._worldMatDirty = true;
|
||||
}
|
||||
},
|
||||
|
||||
setWorldDirty () {
|
||||
if (!this._worldMatDirty) {
|
||||
this._worldMatDirty = true;
|
||||
// Sync world mat dirty to sub tree
|
||||
if (this._children.length > 0) {
|
||||
_syncWorldDirty(this._children);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ module.exports = {
|
||||
let uvDirty = renderData.uvDirty,
|
||||
vertDirty = renderData.vertDirty;
|
||||
|
||||
if (!uvDirty && !vertDirty) return;
|
||||
if (!uvDirty && !vertDirty) {
|
||||
return sprite.__allocedDatas;
|
||||
}
|
||||
|
||||
let fillStart = sprite._fillStart;
|
||||
let fillRange = sprite._fillRange;
|
||||
|
||||
@@ -328,9 +328,12 @@ RenderComponentWalker.prototype = {
|
||||
let batchData = this._batchData;
|
||||
// Transform
|
||||
if (node._worldMatDirty) {
|
||||
node._updateWorldMatrix();
|
||||
batchData.worldMatUpdated = true;
|
||||
}
|
||||
// Parent world mat dirty will be registered in worldMatUpdated, so children will be updated too
|
||||
if (batchData.worldMatUpdated) {
|
||||
node._updateWorldMatrix();
|
||||
}
|
||||
|
||||
// Culling mask
|
||||
if (node.groupIndex !== 0) {
|
||||
@@ -346,8 +349,6 @@ RenderComponentWalker.prototype = {
|
||||
let assembler = comp._assembler || comp.constructor._assembler;
|
||||
this._commitComp(comp, assembler, cullingMask);
|
||||
}
|
||||
// Reset worldMatUpdated
|
||||
batchData.worldMatUpdated = false;
|
||||
|
||||
// Render children
|
||||
let children = node._children;
|
||||
@@ -360,6 +361,8 @@ RenderComponentWalker.prototype = {
|
||||
this._commitComp(comp, comp.constructor._postAssembler, cullingMask);
|
||||
}
|
||||
|
||||
// Reset worldMatUpdated
|
||||
batchData.worldMatUpdated = false;
|
||||
// Reset current camera node
|
||||
if (this._curCameraNode === node) {
|
||||
this._curCameraNode = null;
|
||||
|
||||
Reference in New Issue
Block a user