From d89378b446123210d1c875049898e378efdfa776 Mon Sep 17 00:00:00 2001 From: Cubester Date: Tue, 28 Jan 2025 14:50:02 -0500 Subject: [PATCH 1/5] Small Interpolation Improvement --- src/engine/tw-interpolate.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/engine/tw-interpolate.js b/src/engine/tw-interpolate.js index 3556dffd224..d040326e0ae 100644 --- a/src/engine/tw-interpolate.js +++ b/src/engine/tw-interpolate.js @@ -51,7 +51,11 @@ const interpolate = (runtime, time) => { } // Don't waste time interpolating sprites that are hidden. - if (!target.visible) { + if ( + !target.visible || + target.effects.ghost === 100 && + interpolationData.ghost === 100 + ) { continue; } From b895b048008b70032a95933f3abe5837ef844a17 Mon Sep 17 00:00:00 2001 From: Cubester Date: Tue, 28 Jan 2025 14:53:09 -0500 Subject: [PATCH 2/5] Lint fixes --- src/engine/tw-interpolate.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/engine/tw-interpolate.js b/src/engine/tw-interpolate.js index d040326e0ae..20d274de637 100644 --- a/src/engine/tw-interpolate.js +++ b/src/engine/tw-interpolate.js @@ -53,8 +53,10 @@ const interpolate = (runtime, time) => { // Don't waste time interpolating sprites that are hidden. if ( !target.visible || - target.effects.ghost === 100 && - interpolationData.ghost === 100 + ( + target.effects.ghost === 100 && + interpolationData.ghost === 100 + ) ) { continue; } From b25579a366579fc284f68e0b1c51d7a4ee9c3083 Mon Sep 17 00:00:00 2001 From: Cubester Date: Tue, 28 Jan 2025 15:40:31 -0500 Subject: [PATCH 3/5] Interpolation Events --- src/engine/runtime.js | 14 ++++++++++++++ src/engine/tw-interpolate.js | 4 ++++ src/virtual-machine.js | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 0f0c74a86f3..f0deb6d5736 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -643,6 +643,20 @@ class Runtime extends EventEmitter { return 'INTERPOLATION_CHANGED'; } + /** + * Event called before interpolation data is set. + */ + static get BEFORE_INTERPOLATION () { + return 'BEFORE_INTERPOLATION'; + } + + /** + * Event called after interpolation data is set. + */ + static get AFTER_INTERPOLATION () { + return 'AFTER_INTERPOLATION'; + } + /** * Event name for stage size changing. * @const {string} diff --git a/src/engine/tw-interpolate.js b/src/engine/tw-interpolate.js index 20d274de637..8e2ccdaf741 100644 --- a/src/engine/tw-interpolate.js +++ b/src/engine/tw-interpolate.js @@ -61,6 +61,8 @@ const interpolate = (runtime, time) => { continue; } + runtime.emit(runtime.constructor.BEFORE_INTERPOLATION, target); + const drawableID = target.drawableID; // Position interpolation. @@ -137,6 +139,8 @@ const interpolate = (runtime, time) => { renderer.updateDrawableDirectionScale(drawableID, direction, scale); } } + + runtime.emit(runtime.constructor.AFTER_INTERPOLATION, target); } }; diff --git a/src/virtual-machine.js b/src/virtual-machine.js index e02d87222a2..a33fbab80d9 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -184,6 +184,12 @@ class VirtualMachine extends EventEmitter { this.runtime.on(Runtime.INTERPOLATION_CHANGED, framerate => { this.emit(Runtime.INTERPOLATION_CHANGED, framerate); }); + this.runtime.on(Runtime.BEFORE_INTERPOLATION, target => { + this.emit(Runtime.BEFORE_INTERPOLATION, target); + }); + this.runtime.on(Runtime.AFTER_INTERPOLATION, target => { + this.emit(Runtime.AFTER_INTERPOLATION, target); + }); this.runtime.on(Runtime.STAGE_SIZE_CHANGED, (width, height) => { this.emit(Runtime.STAGE_SIZE_CHANGED, width, height); }); From 088c704bde4b6aa5c51a78fa6ce98cdf372fc30c Mon Sep 17 00:00:00 2001 From: Cubester Date: Tue, 28 Jan 2025 15:47:58 -0500 Subject: [PATCH 4/5] Open interpolate to runtime (could this be done better?) --- src/engine/runtime.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index f0deb6d5736..0b0660671c1 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -471,6 +471,7 @@ class Runtime extends EventEmitter { this._lastStepTime = Date.now(); this.interpolationEnabled = false; + this.interpolate = interpolate; this._defaultStoredSettings = this._generateAllProjectOptions(); From ea476e1631abcb5b363d2eb2ff1df2ba5f4cfb38 Mon Sep 17 00:00:00 2001 From: Cubester Date: Tue, 28 Jan 2025 15:52:08 -0500 Subject: [PATCH 5/5] Potato, Potata --- src/engine/runtime.js | 8 ++++---- src/engine/tw-interpolate.js | 4 ++-- src/virtual-machine.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 0b0660671c1..024bfe57f37 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -647,15 +647,15 @@ class Runtime extends EventEmitter { /** * Event called before interpolation data is set. */ - static get BEFORE_INTERPOLATION () { - return 'BEFORE_INTERPOLATION'; + static get BEFORE_INTERPOLATE () { + return 'BEFORE_INTERPOLATE'; } /** * Event called after interpolation data is set. */ - static get AFTER_INTERPOLATION () { - return 'AFTER_INTERPOLATION'; + static get AFTER_INTERPOLATE () { + return 'AFTER_INTERPOLATE'; } /** diff --git a/src/engine/tw-interpolate.js b/src/engine/tw-interpolate.js index 8e2ccdaf741..e33318a9cc2 100644 --- a/src/engine/tw-interpolate.js +++ b/src/engine/tw-interpolate.js @@ -61,7 +61,7 @@ const interpolate = (runtime, time) => { continue; } - runtime.emit(runtime.constructor.BEFORE_INTERPOLATION, target); + runtime.emit(runtime.constructor.BEFORE_INTERPOLATE, target); const drawableID = target.drawableID; @@ -140,7 +140,7 @@ const interpolate = (runtime, time) => { } } - runtime.emit(runtime.constructor.AFTER_INTERPOLATION, target); + runtime.emit(runtime.constructor.AFTER_INTERPOLATE, target); } }; diff --git a/src/virtual-machine.js b/src/virtual-machine.js index a33fbab80d9..2d31cbda96c 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -184,11 +184,11 @@ class VirtualMachine extends EventEmitter { this.runtime.on(Runtime.INTERPOLATION_CHANGED, framerate => { this.emit(Runtime.INTERPOLATION_CHANGED, framerate); }); - this.runtime.on(Runtime.BEFORE_INTERPOLATION, target => { - this.emit(Runtime.BEFORE_INTERPOLATION, target); + this.runtime.on(Runtime.BEFORE_INTERPOLATE, target => { + this.emit(Runtime.BEFORE_INTERPOLATE, target); }); - this.runtime.on(Runtime.AFTER_INTERPOLATION, target => { - this.emit(Runtime.AFTER_INTERPOLATION, target); + this.runtime.on(Runtime.AFTER_INTERPOLATE, target => { + this.emit(Runtime.AFTER_INTERPOLATE, target); }); this.runtime.on(Runtime.STAGE_SIZE_CHANGED, (width, height) => { this.emit(Runtime.STAGE_SIZE_CHANGED, width, height);