Various fixes to support negative tile coordinates; created sparse miso
scene model and associated business to store scene data in an arbitrary set of blocks rather than fixed arrays; finally stuck a fork in scene width and height as well as view width and height along with origin offset and a few other now obsolete bits. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2434 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MisoSceneMetrics.java,v 1.1 2003/04/17 19:21:16 mdb Exp $
|
||||
// $Id: MisoSceneMetrics.java,v 1.2 2003/04/19 22:40:34 mdb Exp $
|
||||
|
||||
package com.threerings.miso.util;
|
||||
|
||||
@@ -23,22 +23,9 @@ public class MisoSceneMetrics
|
||||
/** Number of fine coordinates on each axis within a tile. */
|
||||
public int finegran;
|
||||
|
||||
/** Size of the view in tile count. */
|
||||
public int scenevwid, scenevhei;
|
||||
|
||||
/** Dimensions of our scene blocks in tile count. */
|
||||
public int blockwid = 10, blockhei = 10;
|
||||
|
||||
/** Whether or not this view can extend beyond the bounds defined by
|
||||
* the view width and height. True if it cannot, false if it can. */
|
||||
public boolean bounded = true;
|
||||
|
||||
/** The bounds of the view in screen pixel coordinates. */
|
||||
public Rectangle bounds;
|
||||
|
||||
/** The position in pixels at which tile (0, 0) is drawn. */
|
||||
public Point origin;
|
||||
|
||||
/** The length of a tile edge in pixels. */
|
||||
public float tilelen;
|
||||
|
||||
@@ -62,26 +49,13 @@ public class MisoSceneMetrics
|
||||
* @param tilehei the height in pixels of the tiles.
|
||||
* @param finegran the number of sub-tile divisions to use for fine
|
||||
* coordinates.
|
||||
* @param svwid the width in tiles of the viewport.
|
||||
* @param svhei the height in tiles of the viewport.
|
||||
* @param offy the offset of the origin (in tiles) from the top of the
|
||||
* viewport.
|
||||
*/
|
||||
public MisoSceneMetrics (int tilewid, int tilehei, int finegran,
|
||||
int svwid, int svhei, int offy)
|
||||
public MisoSceneMetrics (int tilewid, int tilehei, int finegran)
|
||||
{
|
||||
// keep track of this stuff
|
||||
this.tilewid = tilewid;
|
||||
this.tilehei = tilehei;
|
||||
this.finegran = finegran;
|
||||
this.scenevwid = svwid;
|
||||
this.scenevhei = svhei;
|
||||
|
||||
// set the desired scene view bounds
|
||||
bounds = new Rectangle(0, 0, scenevwid * tilewid, scenevhei * tilehei);
|
||||
|
||||
// set the scene display origin
|
||||
origin = new Point((bounds.width / 2), (offy * tilehei));
|
||||
|
||||
// halve the dimensions
|
||||
tilehwid = (tilewid / 2);
|
||||
@@ -107,28 +81,4 @@ public class MisoSceneMetrics
|
||||
finehwid = (int)((float)tilehwid / (float)finegran);
|
||||
finehhei = (int)((float)tilehhei / (float)finegran);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given tile coordinate is a valid coordinate in
|
||||
* our coordinate system (which allows tile coordinates from 0 to
|
||||
* 2^15-1).
|
||||
*/
|
||||
public boolean isCoordinateValid (int x, int y)
|
||||
{
|
||||
return (x >= 0 && x < Short.MAX_VALUE &&
|
||||
y >= 0 && y < Short.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given full coordinate is a valid coordinate
|
||||
* within the scene.
|
||||
*/
|
||||
public boolean isFullCoordinateValid (int x, int y)
|
||||
{
|
||||
int tx = MisoUtil.fullToTile(x), ty = MisoUtil.fullToTile(y);
|
||||
int fx = MisoUtil.fullToFine(x), fy = MisoUtil.fullToFine(y);
|
||||
return (isCoordinateValid(tx, ty) &&
|
||||
fx >= 0 && fx < finegran &&
|
||||
fy >= 0 && fy < finegran);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user