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.

This commit is contained in:
Richard Davey 2024-10-10 19:00:58 +01:00
parent e440887fb8
commit 10c342c5cb

View file

@ -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 = [];
},