Added a method that gets the actual object bounds rather than one confined

to the shape of the bottom of the object footprint; renamed the old method
and left it around in case we want to use it later.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1171 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-04-02 01:05:49 +00:00
parent 4110fb82c4
commit 405f105f0c
@@ -1,5 +1,5 @@
//
// $Id: IsoUtil.java,v 1.24 2002/03/26 23:35:02 ray Exp $
// $Id: IsoUtil.java,v 1.25 2002/04/02 01:05:49 mdb Exp $
package com.threerings.miso.scene.util;
@@ -95,16 +95,16 @@ public class IsoUtil
/**
* Returns a polygon bounding the given object tile display image,
* with the bottom of the polygon shaped to conform to the known
* object dimensions.
* object dimensions. This is currently not used.
*
* @param model the scene view model.
* @param root the polygon for the root tile at which the object
* is located.
* @param root the polygon for the root tile at which the object is
* located.
* @param tile the object tile.
*
* @return the bounding polygon.
*/
public static Polygon getObjectBounds (
public static Polygon getTightObjectBounds (
IsoSceneViewModel model, Polygon root, ObjectTile tile)
{
Rectangle bounds = root.getBounds();
@@ -150,6 +150,37 @@ public class IsoUtil
return boundsPoly;
}
/**
* Returns a rectangle that encloses the entire object image, with the
* upper left set to the appropriate values for rendering the object
* image.
*
* @param model the scene view model.
* @param root the polygon for the root tile at which the object is
* located.
* @param tile the object tile.
*
* @return the bounding rectangle.
*/
public static Rectangle getObjectBounds (
IsoSceneViewModel model, Polygon root, ObjectTile tile)
{
Rectangle bounds = root.getBounds();
// if the tile has an origin, use that, otherwise compute the
// origin based on the tile footprint
int tox = tile.getOriginX(), toy = tile.getOriginY();
if (tox == -1 || toy == -1) {
tox = tile.getBaseWidth() * model.tilehwid;
toy = tile.getHeight();
}
int oox = bounds.x + model.tilehwid, ooy = bounds.y + model.tilehei;
int sx = oox - tox, sy = ooy - toy;
return new Rectangle(sx, sy, tile.getWidth(), tile.getHeight());
}
/**
* Returns true if the footprints of the two object tiles overlap when
* the objects occupy the specified coordinates, false if not.