From 05ff84f282e482e2d4773fb6501e81ca66cb14da Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 31 Jan 2017 18:27:43 +0000 Subject: [PATCH] dirtyLocal test. --- v3/src/checksum.js | 2 +- v3/src/components/experimental-Transform-2.js | 9 +++++++++ v3/src/gameobjects/GameObject.js | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 0155eb6c3..e4b557be5 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '186b6300-e7d5-11e6-9a5e-2ff3d2308a00' +build: 'aa3d0db0-e7df-11e6-b8bf-6f3109a66e78' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/components/experimental-Transform-2.js b/v3/src/components/experimental-Transform-2.js index 739d9b906..669a7bb56 100644 --- a/v3/src/components/experimental-Transform-2.js +++ b/v3/src/components/experimental-Transform-2.js @@ -68,6 +68,7 @@ function Transform(gameObject, root) this.childCount = 0; this.renderCount = 0; this.dirty = false; + this.dirtyLocal = true; this.root = root || this; this.gameObject = gameObject; } @@ -159,6 +160,11 @@ Transform.prototype.updateRoot = function () }; Transform.prototype.update = function (parentTransformMatrix) { + if (!this.dirtyLocal) + { + return; + } + var parent = parentTransformMatrix.matrix; var world = this.worldMatrix.matrix; var rotation = this.rotation; @@ -176,7 +182,10 @@ Transform.prototype.update = function (parentTransformMatrix) world[3] = parent[2] * local[1] + parent[3] * local[3]; world[4] = parent[4] * local[0] + parent[5] * local[2] + local[4]; world[5] = parent[4] * local[1] + parent[5] * local[3] + local[5]; + + this.dirtyLocal = false; }; + Transform.prototype.updateLocal = function () { var local = this.localMatrix.loadIdentity(); diff --git a/v3/src/gameobjects/GameObject.js b/v3/src/gameobjects/GameObject.js index 160140af7..f8443a1c5 100644 --- a/v3/src/gameobjects/GameObject.js +++ b/v3/src/gameobjects/GameObject.js @@ -118,6 +118,7 @@ Object.defineProperties(GameObject.prototype, { set: function (value) { this.transform.positionX = value; + this.transform.dirtyLocal = true; } }, @@ -134,6 +135,7 @@ Object.defineProperties(GameObject.prototype, { set: function (value) { this.transform.positionY = value; + this.transform.dirtyLocal = true; } }, @@ -151,6 +153,7 @@ Object.defineProperties(GameObject.prototype, { { this.transform.scaleX = value; this.transform.scaleY = value; + this.transform.dirtyLocal = true; } }, @@ -167,6 +170,7 @@ Object.defineProperties(GameObject.prototype, { set: function (value) { this.transform.scaleX = value; + this.transform.dirtyLocal = true; } }, @@ -183,6 +187,7 @@ Object.defineProperties(GameObject.prototype, { set: function (value) { this.transform.scaleY = value; + this.transform.dirtyLocal = true; } }, @@ -199,6 +204,7 @@ Object.defineProperties(GameObject.prototype, { set: function (value) { this.transform.rotation = value; + this.transform.dirtyLocal = true; } }, @@ -216,6 +222,7 @@ Object.defineProperties(GameObject.prototype, { { // value is in degrees this.transform.rotation = WrapAngle(value * MATH_CONST.DEG_TO_RAD); + this.transform.dirtyLocal = true; } },