From 508e3896782ee0268d62a407463d7eb805b2fb46 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 28 Apr 2003 20:27:35 +0000 Subject: [PATCH] Make the bounds of just our objects available as well. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2489 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/miso/client/SceneBlock.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/miso/client/SceneBlock.java b/src/java/com/threerings/miso/client/SceneBlock.java index 301288729..37780f000 100644 --- a/src/java/com/threerings/miso/client/SceneBlock.java +++ b/src/java/com/threerings/miso/client/SceneBlock.java @@ -1,5 +1,5 @@ // -// $Id: SceneBlock.java,v 1.12 2003/04/26 02:16:18 mdb Exp $ +// $Id: SceneBlock.java,v 1.13 2003/04/28 20:27:35 mdb Exp $ package com.threerings.miso.client; @@ -11,6 +11,7 @@ import com.samskivert.util.ArrayUtil; import com.samskivert.util.HashIntMap; import com.samskivert.util.StringUtil; +import com.threerings.geom.GeomUtil; import com.threerings.media.tile.NoSuchTileException; import com.threerings.media.tile.NoSuchTileSetException; import com.threerings.media.tile.Tile; @@ -66,6 +67,7 @@ public class SceneBlock // start with the bounds of the footprint polygon Rectangle sbounds = new Rectangle(_footprint.getBounds()); + Rectangle obounds = null; // resolve our base tiles MisoSceneModel model = _panel.getSceneModel(); @@ -98,6 +100,7 @@ public class SceneBlock for (int ii = 0; ii < _objects.length; ii++) { _objects[ii] = new SceneObject(_panel, set.get(ii)); sbounds.add(_objects[ii].bounds); + obounds = GeomUtil.grow(obounds, _objects[ii].bounds); } // resolve our default tileset @@ -114,6 +117,7 @@ public class SceneBlock // this both marks us as resolved and makes all our other updated // fields visible synchronized (this) { + _obounds = obounds; _sbounds = sbounds; } @@ -155,6 +159,16 @@ public class SceneBlock return _sbounds; } + /** + * Returns the bounds of the screen coordinate rectangle that contains + * all pixels that are drawn on by all objects (but not base tiles) in + * this block. + */ + public Rectangle getObjectBounds () + { + return _obounds; + } + /** * Returns the screen-coordinate polygon bounding the footprint of * this block. @@ -419,6 +433,9 @@ public class SceneBlock /** The bounds (in screen coords) of all images rendered by this block. */ protected Rectangle _sbounds; + /** The bounds (in screen coords) of all objects rendered by this block. */ + protected Rectangle _obounds; + /** A polygon bounding the footprint of this block. */ protected Polygon _footprint;