Whoops, -1 is not a good value for "invalid offset" because object tiles

may well have a -1 origin offset. We use Integer.MIN_VALUE now which is
definitely not going to be a valid value.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1527 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-06-21 18:52:36 +00:00
parent 9ff74211d4
commit 53ca4a30ce
2 changed files with 27 additions and 21 deletions
@@ -1,5 +1,5 @@
// //
// $Id: ObjectTile.java,v 1.9 2002/05/16 01:53:36 ray Exp $ // $Id: ObjectTile.java,v 1.10 2002/06/21 18:52:36 mdb Exp $
package com.threerings.media.tile; package com.threerings.media.tile;
@@ -65,9 +65,10 @@ public class ObjectTile extends Tile
/** /**
* Returns the x offset into the tile image of the origin (which will * Returns the x offset into the tile image of the origin (which will
* be aligned with the bottom center of the origin tile) or -1 if the * be aligned with the bottom center of the origin tile) or
* origin is not explicitly specified and should be computed from the * <code>Integer.MIN_VALUE</code> if the origin is not explicitly
* image size and tile footprint. * specified and should be computed from the image size and tile
* footprint.
*/ */
public int getOriginX () public int getOriginX ()
{ {
@@ -76,9 +77,10 @@ public class ObjectTile extends Tile
/** /**
* Returns the y offset into the tile image of the origin (which will * Returns the y offset into the tile image of the origin (which will
* be aligned with the bottom center of the origin tile) or -1 if the * be aligned with the bottom center of the origin tile) or
* origin is not explicitly specified and should be computed from the * <code>Integer.MIN_VALUE</code> if the origin is not explicitly
* image size and tile footprint. * specified and should be computed from the image size and tile
* footprint.
*/ */
public int getOriginY () public int getOriginY ()
{ {
@@ -86,12 +88,12 @@ public class ObjectTile extends Tile
} }
/** /**
* Sets the offset in pixels to the origin in the tile image. The * Sets the offset in pixels from the origin of the tile image to the
* object will be rendered such that its origin is at the bottom * origin of the object. The object will be rendered such that its
* center of its origin tile. If no origin is specified, the bottom of * origin is at the bottom center of its origin tile. If no origin is
* the image is aligned with the bottom of the origin tile and the * specified, the bottom of the image is aligned with the bottom of
* left side of the image is aligned with the left edge of the * the origin tile and the left side of the image is aligned with the
* left-most base tile. * left edge of the left-most base tile.
*/ */
public void setOrigin (int x, int y) public void setOrigin (int x, int y)
{ {
@@ -128,11 +130,13 @@ public class ObjectTile extends Tile
/** The object footprint height in unit tile units. */ /** The object footprint height in unit tile units. */
protected int _baseHeight = 1; protected int _baseHeight = 1;
/** The x offset into the tile image of the origin or -1 if the origin /** The x offset from the origin of the tile image to the object's
* should be calculated based on the footprint. */ * origin or MIN_VALUE if the origin should be calculated based on the
protected int _originX = -1; * footprint. */
protected int _originX = Integer.MIN_VALUE;
/** The y offset into the tile image of the origin or -1 if the origin /** The y offset from the origin of the tile image to the object's
* should be calculated based on the footprint. */ * origin or MIN_VALUE if the origin should be calculated based on the
protected int _originY = -1; * footprint. */
protected int _originY = Integer.MIN_VALUE;
} }
@@ -1,5 +1,5 @@
// //
// $Id: IsoUtil.java,v 1.33 2002/06/18 22:38:12 mdb Exp $ // $Id: IsoUtil.java,v 1.34 2002/06/21 18:52:36 mdb Exp $
package com.threerings.miso.scene.util; package com.threerings.miso.scene.util;
@@ -169,8 +169,10 @@ public class IsoUtil
// if the tile has an origin, use that, otherwise compute the // if the tile has an origin, use that, otherwise compute the
// origin based on the tile footprint // origin based on the tile footprint
int tox = tile.getOriginX(), toy = tile.getOriginY(); int tox = tile.getOriginX(), toy = tile.getOriginY();
if (tox == -1 || toy == -1) { if (tox == Integer.MIN_VALUE) {
tox = tile.getBaseWidth() * model.tilehwid; tox = tile.getBaseWidth() * model.tilehwid;
}
if (toy == Integer.MIN_VALUE) {
toy = tile.getHeight(); toy = tile.getHeight();
} }