From dc05c29740b6ea4661e77ae2fe4bed2ad20442bc Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Mon, 19 Jun 2017 21:58:23 +0100 Subject: [PATCH] Input matrix updates --- v3/src/checksum.js | 2 +- v3/src/components/TransformMatrix.js | 9 +++++-- .../input/components/GetTransformedPoint.js | 2 +- .../input/components/PointWithinGameObject.js | 26 +++++++++---------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 957259d14..226b48653 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '39f826c0-54fe-11e7-90c1-d1d02aa41ae8' +build: '2ac4ba60-552b-11e7-965c-39a419b0ea9b' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/components/TransformMatrix.js b/v3/src/components/TransformMatrix.js index 06514186a..5a132c582 100644 --- a/v3/src/components/TransformMatrix.js +++ b/v3/src/components/TransformMatrix.js @@ -126,8 +126,13 @@ TransformMatrix.prototype.transformPoint = function (x, y, point) var tx = matrix[4]; var ty = matrix[5]; - point.x = x * a + y * c + tx; - point.y = x * b + y * d + ty; + // point.x = x * a + y * c + tx; + // point.y = x * b + y * d + ty; + + var id = 1 / ((a * d) + (c * -b)); + + point.x = (d * id * x) + (-c * id * y) + (((ty * c) - (tx * d)) * id); + point.y = (a * id * y) + (-b * id * x) + (((-ty * a) + (tx * b)) * id); return point; }; diff --git a/v3/src/input/components/GetTransformedPoint.js b/v3/src/input/components/GetTransformedPoint.js index 28e8e50f6..2b8a346be 100644 --- a/v3/src/input/components/GetTransformedPoint.js +++ b/v3/src/input/components/GetTransformedPoint.js @@ -11,7 +11,7 @@ var GetTransformedPoint = function (matrix, gameObject, x, y, output) if (output === undefined) { output = { x: 0, y: 0 }; } matrix.applyITRS(gameObject.x, gameObject.y, gameObject.rotation, gameObject.scaleX, gameObject.scaleY); - matrix.invert(); + // matrix.invert(); matrix.transformPoint(x, y, output); // var a = matrix.matrix[0]; diff --git a/v3/src/input/components/PointWithinGameObject.js b/v3/src/input/components/PointWithinGameObject.js index eb634df3a..5fd05613c 100644 --- a/v3/src/input/components/PointWithinGameObject.js +++ b/v3/src/input/components/PointWithinGameObject.js @@ -3,24 +3,22 @@ var PointWithinGameObject = function (gameObject, x, y) { - // var width = gameObject.width; - // var height = gameObject.height; - // var x1 = -width * gameObject.originX; + var width = gameObject.displayWidth; + var height = gameObject.displayHeight; - // if (x >= x1 && x < x1 + width) - // { - // var y1 = -height * gameObject.originY; + var x1 = -width * gameObject.originX; - // if (y >= y1 && y < y1 + height) - // { - // return true; - // } - // } + if (x >= x1 && x < x1 + width) + { + var y1 = -height * gameObject.originY; - // return false; - - return (x >= gameObject.x && x <= gameObject.x+gameObject.width && y >= gameObject.y && y <= gameObject.y+gameObject.height); + if (y >= y1 && y < y1 + height) + { + return true; + } + } + return false; }; module.exports = PointWithinGameObject;