From 2fc84145ad2b98640ea4a0731395950aca4103b2 Mon Sep 17 00:00:00 2001 From: wouterlucas Date: Mon, 4 Nov 2024 20:45:55 +0100 Subject: [PATCH] fix: prevent recursive RTT updates between parent & children --- src/core/CoreNode.ts | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/core/CoreNode.ts b/src/core/CoreNode.ts index 9ec3150d..d68923a9 100644 --- a/src/core/CoreNode.ts +++ b/src/core/CoreNode.ts @@ -862,22 +862,27 @@ export class CoreNode extends EventEmitter { setUpdateType(type: UpdateType): void { this.updateType |= type; - // If we're updating this node at all, we need to inform the parent - // (and all ancestors) that their children need updating as well const parent = this.props.parent; - if (parent !== null && !(parent.updateType & UpdateType.Children)) { + if (!parent) return; + + // Inform the parent if it doesn’t already have a child update + if ((parent.updateType & UpdateType.Children) === 0) { parent.setUpdateType(UpdateType.Children); } - // If node is part of RTT texture - // Flag that we need to update - if (this.parentHasRenderTexture) { - this.setRTTUpdates(type); + if (this.parentHasRenderTexture === false) return; - if (parent !== null) { + if (this.rtt === false) { + if ((parent.updateType & UpdateType.RenderTexture) === 0) { + this.setRTTUpdates(type); parent.setUpdateType(UpdateType.RenderTexture); } } + + // If this node has outstanding RTT updates, propagate them + if (this.hasRTTupdates) { + this.setRTTUpdates(type); + } } sortChildren() { @@ -2150,6 +2155,10 @@ export class CoreNode extends EventEmitter { } setRTTUpdates(type: number) { + if (this.hasRTTupdates === true) { + return; + } + this.hasRTTupdates = true; this.parent?.setRTTUpdates(type); }