Skip to content

Commit

Permalink
Remove Transform.Zero getter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fatcerberus committed Mar 2, 2022
1 parent dcf3de4 commit 991f758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion web/oozaru.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Oozaru",
"publisher": "Fat Cerberus",
"version": "0.6.x"
"version": "0.5.1+"
}
33 changes: 11 additions & 22 deletions web/scripts/galileo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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,
]);
}

Expand Down

0 comments on commit 991f758

Please sign in to comment.