mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
V3.1.2 zxx43 performance 2 (#8764)
* reduce clear frequency & check translate or rotate in updateWorldTransform function https://github.com/cocos-creator/3d-tasks/issues/7487 * make clear node as a static function
This commit is contained in:
@@ -907,6 +907,7 @@ export class Director extends EventTarget {
|
||||
|
||||
eventManager.frameUpdateListeners();
|
||||
Node.resetHasChangedFlags();
|
||||
Node.clearNodeArray();
|
||||
this._totalFrames++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,6 +167,13 @@ export class Node extends BaseNode {
|
||||
*/
|
||||
public static TransformBit = TransformBit;
|
||||
|
||||
/**
|
||||
* @en Counter to clear node array
|
||||
* @zh 清除节点数组计时器
|
||||
*/
|
||||
private static ClearFrame = 0;
|
||||
private static ClearRound = 1000;
|
||||
|
||||
// UI 部分的脏数据
|
||||
public _uiProps = new NodeUIProperties(this);
|
||||
|
||||
@@ -610,12 +617,6 @@ export class Node extends BaseNode {
|
||||
}
|
||||
dirtyBit = childDirtyBit;
|
||||
}
|
||||
if (this._invalidFrame < this._roundTime) {
|
||||
this._invalidFrame++;
|
||||
} else {
|
||||
array_a.length = 0;
|
||||
this._invalidFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -707,12 +708,6 @@ export class Node extends BaseNode {
|
||||
child._dirtyFlags = TransformBit.NONE;
|
||||
cur = child;
|
||||
}
|
||||
if (this._updateFrame < this._roundTime) {
|
||||
this._updateFrame++;
|
||||
} else {
|
||||
array_a.length = 0;
|
||||
this._updateFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ===============================
|
||||
@@ -1213,6 +1208,21 @@ export class Node extends BaseNode {
|
||||
bookOfChange.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @en
|
||||
* clear node array
|
||||
* @zh
|
||||
* 清除节点数组
|
||||
*/
|
||||
public static clearNodeArray () {
|
||||
if (Node.ClearFrame < Node.ClearRound) {
|
||||
Node.ClearFrame++;
|
||||
} else {
|
||||
Node.ClearFrame = 0;
|
||||
array_a.length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @en
|
||||
* Synchronize the js transform to the native layer.
|
||||
|
||||
Reference in New Issue
Block a user