Keep a rectangle around with our tile coordinate footprint and use that
for overlapping calculations. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2627 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SceneObject.java,v 1.8 2003/05/27 18:25:19 mdb Exp $
|
||||
// $Id: SceneObject.java,v 1.9 2003/05/31 00:52:15 mdb Exp $
|
||||
|
||||
package com.threerings.miso.client;
|
||||
|
||||
@@ -147,10 +147,16 @@ public class SceneObject
|
||||
*/
|
||||
public boolean objectFootprintOverlaps (SceneObject so)
|
||||
{
|
||||
return (so.info.x > info.x - tile.getBaseWidth() &&
|
||||
info.x > so.info.x - so.tile.getBaseWidth() &&
|
||||
so.info.y > info.y - tile.getBaseHeight() &&
|
||||
info.y > so.info.y - so.tile.getBaseHeight());
|
||||
return _frect.intersects(so._frect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this object's footprint overlaps the supplied tile
|
||||
* coordinate rectangle.
|
||||
*/
|
||||
public boolean objectFootprintOverlaps (Rectangle rect)
|
||||
{
|
||||
return _frect.intersects(rect);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,10 +263,11 @@ public class SceneObject
|
||||
tile.getWidth(), tile.getHeight());
|
||||
|
||||
// compute our object footprint as well
|
||||
int fx = info.x-tile.getBaseWidth()+1;
|
||||
int fy = info.y-tile.getBaseHeight()+1;
|
||||
_frect = new Rectangle(info.x - tile.getBaseWidth() + 1,
|
||||
info.y - tile.getBaseHeight() + 1,
|
||||
tile.getBaseWidth(), tile.getBaseHeight());
|
||||
_footprint = MisoUtil.getFootprintPolygon(
|
||||
metrics, fx, fy, tile.getBaseWidth(), tile.getBaseHeight());
|
||||
metrics, _frect.x, _frect.y, _frect.width, _frect.height);
|
||||
|
||||
// compute our object spot if we've got one
|
||||
if (tile.hasSpot()) {
|
||||
@@ -285,6 +292,9 @@ public class SceneObject
|
||||
return info + "[" + StringUtil.toString(bounds) + "]";
|
||||
}
|
||||
|
||||
/** Our object as a tile coordinate rectangle. */
|
||||
protected Rectangle _frect;
|
||||
|
||||
/** Our object footprint as a polygon. */
|
||||
protected Polygon _footprint;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user