From 4a60bbe64add83960e82abe52c9ef9bcc302b5ee Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Tue, 10 Aug 2010 22:48:27 +0000 Subject: [PATCH] Helps if our screen to iso-space transformation is accurate. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@971 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../miso/client/MisoMetricsTransformation.as | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/as/com/threerings/miso/client/MisoMetricsTransformation.as b/src/as/com/threerings/miso/client/MisoMetricsTransformation.as index 10130ea6..8ec4ec35 100644 --- a/src/as/com/threerings/miso/client/MisoMetricsTransformation.as +++ b/src/as/com/threerings/miso/client/MisoMetricsTransformation.as @@ -21,11 +21,30 @@ public class MisoMetricsTransformation implements IAxonometricTransformation var zx :int = int(Math.floor(screenPt.x / _metrics.tilewid)); var zy :int = int(Math.floor(screenPt.y / _metrics.tilehei)); + // these are the screen coordinates of the tile's top + var ox :int = (zx * _metrics.tilewid); + var oy :int = (zy * _metrics.tilehei); + // these are the tile coordinates tpos.x = zy + zx; tpos.y = zy - zx; tpos.z = 0; + // these are the tile coordinates + tpos.x = zy + zx; tpos.y = zy - zx; + + // now determine which of the four tiles our point occupies + var dx :int = screenPt.x - ox; + var dy :int = screenPt.y - oy; + + if (Math.round(_metrics.slopeY * dx + _metrics.tilehei) <= dy) { + tpos.x += 1; + } + + if (Math.round(_metrics.slopeX * dx) > dy) { + tpos.y -= 1; + } + return tpos; }