From 991f7588e0012bdc256901fbf3b2ae6db5a35ed1 Mon Sep 17 00:00:00 2001 From: Bruce Pascoe Date: Tue, 1 Mar 2022 23:27:04 -0500 Subject: [PATCH] Remove `Transform.Zero` getter A fully-zeroed matrix is almost never what you want to use as a starting point (as multiplying it with anything produces another zero matrix), and even if it were, it's easy enough to manually zero the main diagonal of an identity matrix. --- web/oozaru.json | 2 +- web/scripts/galileo.js | 33 +++++++++++---------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/web/oozaru.json b/web/oozaru.json index f65105d..e7cccc2 100644 --- a/web/oozaru.json +++ b/web/oozaru.json @@ -1,5 +1,5 @@ { "name": "Oozaru", "publisher": "Fat Cerberus", - "version": "0.6.x" + "version": "0.5.1+" } \ No newline at end of file diff --git a/web/scripts/galileo.js b/web/scripts/galileo.js index 503fb2e..11e8893 100644 --- a/web/scripts/galileo.js +++ b/web/scripts/galileo.js @@ -1134,23 +1134,13 @@ class Transform ]); } - static get Zero() - { - return new Transform([ - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, - ]); - } - static project2D(left, top, right, bottom, near = -1.0, far = 1.0) { const deltaX = right - left; const deltaY = top - bottom; const deltaZ = far - near; - const transform = Transform.Zero; + const transform = Transform.Identity; const values = transform.#values; values[0] = 2.0 / deltaX; values[5] = 2.0 / deltaY; @@ -1171,7 +1161,7 @@ class Transform const deltaY = -fh - fh; const deltaZ = far - near; - const transform = Transform.Zero; + const transform = Transform.Identity; const values = transform.#values; values[0] = 2.0 * near / deltaX; values[5] = 2.0 * near / deltaY; @@ -1201,7 +1191,7 @@ class Transform const sin = Math.sin(theta); const siv = 1.0 - cos; - const transform = Transform.Zero; + const transform = Transform.Identity; const values = transform.#values; values[0] = (siv * vX * vX) + cos; values[1] = (siv * vX * vY) + (vZ * sin); @@ -1212,27 +1202,26 @@ class Transform values[8] = (siv * vX * vZ) + (vY * sin); values[9] = (siv * vY * vZ) - (vX * sin); values[10] = (siv * vZ * vZ) + cos; - values[15] = 1.0; return transform; } static scale(sX, sY, sZ = 1.0) { return new Transform([ - sX, 0, 0, 0, - 0, sY, 0, 0, - 0, 0, sZ, 0, - 0, 0, 0, 1, + sX, 0.0, 0.0, 0.0, + 0.0, sY, 0.0, 0.0, + 0.0, 0.0, sZ, 0.0, + 0.0, 0.0, 0.0, 1.0, ]); } static translate(tX, tY, tZ = 0.0) { return new Transform([ - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - tX, tY, tZ, 1, + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + tX, tY, tZ, 1.0, ]); }