Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ export enum CoreNodeRenderState {
InViewport = 8,
}

const NO_CLIPPING_RECT: RectWithValid = {
x: 0,
y: 0,
width: 0,
height: 0,
valid: false,
};

const CoreNodeRenderStateMap: Map<CoreNodeRenderState, string> = new Map();
CoreNodeRenderStateMap.set(CoreNodeRenderState.Init, 'init');
CoreNodeRenderStateMap.set(CoreNodeRenderState.OutOfBounds, 'outOfBounds');
Expand Down Expand Up @@ -1038,10 +1046,6 @@ export class CoreNode extends EventEmitter {
* @param delta
*/
update(delta: number, parentClippingRect: RectWithValid): void {
if (this.updateType === UpdateType.None) {
return;
}
Comment on lines -1041 to -1043
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed as the child for loop checks this.


const props = this.props;
const parent = props.parent;
const parentHasRenderTexture = this.parentHasRenderTexture;
Expand All @@ -1052,6 +1056,9 @@ export class CoreNode extends EventEmitter {
let updateType = this.updateType;
let childUpdateType = this.childUpdateType;
let updateParent = false;
// reset update type
this.updateType = 0;
this.childUpdateType = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset happens at beginning of loop rather than end


if (updateType & UpdateType.Local) {
this.updateLocalTransform();
Expand Down Expand Up @@ -1212,6 +1219,7 @@ export class CoreNode extends EventEmitter {

if (this.renderState === CoreNodeRenderState.OutOfBounds) {
updateType &= ~UpdateType.RenderBounds; // remove render bounds update
this.updateType = updateType;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just needed to be set back. Before this updateType &= ~UpdateType.RenderBounds; was doing nothing as it was changing a local variable and then returning

return;
}

Expand All @@ -1229,26 +1237,23 @@ export class CoreNode extends EventEmitter {
}

if (updateType & UpdateType.Children && this.children.length > 0) {
let childClippingRect = this.clippingRect;

if (this.rtt === true) {
childClippingRect = NO_CLIPPING_RECT;
}
Comment on lines +1240 to +1244
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this check outside the for loop as its for the parent and not each child


for (let i = 0, length = this.children.length; i < length; i++) {
const child = this.children[i] as CoreNode;

child.setUpdateType(childUpdateType);
if (childUpdateType !== 0) {
child.setUpdateType(childUpdateType);
}
Comment on lines +1249 to +1251
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip updating all children nodes and parent nodes if we're just resetting anyhow.


if (child.updateType === 0) {
continue;
}

let childClippingRect = this.clippingRect;
if (this.rtt === true) {
childClippingRect = {
x: 0,
y: 0,
width: 0,
height: 0,
valid: false,
};
}

child.update(delta, childClippingRect);
}
}
Expand Down Expand Up @@ -1283,10 +1288,6 @@ export class CoreNode extends EventEmitter {
this.notifyChildrenRTTOfUpdate(renderState);
}
}

// reset update type
this.updateType = 0;
this.childUpdateType = 0;
}

private findParentRTTNode(): CoreNode | null {
Expand Down
Loading