From 10c342c5cb195bc43306a073846a0caae05f105c Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Thu, 10 Oct 2024 19:00:58 +0100 Subject: [PATCH] `Phaser.GameObjects.Container#tempTransformMatrix` has been removed. This was an internal private Transform Matrix. It has been replaced by a global single matrix that is used instead. This removes the need for every Container to have its own instance of this temporary matrix, reducing object allocation and memory overhead. --- src/gameobjects/container/Container.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/gameobjects/container/Container.js b/src/gameobjects/container/Container.js index dad0c1abb1..8816534c7b 100644 --- a/src/gameobjects/container/Container.js +++ b/src/gameobjects/container/Container.js @@ -16,6 +16,8 @@ var Render = require('./ContainerRender'); var Union = require('../../geom/rectangle/Union'); var Vector2 = require('../../math/Vector2'); +var tempTransformMatrix = new Components.TransformMatrix(); + /** * @classdesc * A Container Game Object. @@ -160,16 +162,6 @@ var Container = new Class({ */ this.localTransform = new Components.TransformMatrix(); - /** - * Internal temporary Transform Matrix used to avoid object creation. - * - * @name Phaser.GameObjects.Container#tempTransformMatrix - * @type {Phaser.GameObjects.Components.TransformMatrix} - * @private - * @since 3.4.0 - */ - this.tempTransformMatrix = new Components.TransformMatrix(); - /** * The property key to sort by. * @@ -504,7 +496,7 @@ var Container = new Class({ output.y = source.y; } - var tempMatrix = this.tempTransformMatrix; + var tempMatrix = tempTransformMatrix; // No need to loadIdentity because applyITRS overwrites every value anyway tempMatrix.applyITRS(this.x, this.y, this.rotation, this.scaleX, this.scaleY); @@ -528,7 +520,7 @@ var Container = new Class({ */ getBoundsTransformMatrix: function () { - return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform); + return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform); }, /** @@ -1451,7 +1443,6 @@ var Container = new Class({ this.removeAll(!!this.exclusive); this.localTransform.destroy(); - this.tempTransformMatrix.destroy(); this.list = []; },