Skip to content

Commit

Permalink
Phaser.GameObjects.Container#tempTransformMatrix has been removed. …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
photonstorm committed Oct 10, 2024
1 parent e440887 commit 10c342c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/gameobjects/container/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
Expand All @@ -528,7 +520,7 @@ var Container = new Class({
*/
getBoundsTransformMatrix: function ()
{
return this.getWorldTransformMatrix(this.tempTransformMatrix, this.localTransform);
return this.getWorldTransformMatrix(tempTransformMatrix, this.localTransform);
},

/**
Expand Down Expand Up @@ -1451,7 +1443,6 @@ var Container = new Class({
this.removeAll(!!this.exclusive);

this.localTransform.destroy();
this.tempTransformMatrix.destroy();

this.list = [];
},
Expand Down

0 comments on commit 10c342c

Please sign in to comment.