diff --git a/src/java/com/threerings/miso/client/DirtyItemList.java b/src/java/com/threerings/miso/client/DirtyItemList.java index abc8bb6dd..26dfc3529 100644 --- a/src/java/com/threerings/miso/client/DirtyItemList.java +++ b/src/java/com/threerings/miso/client/DirtyItemList.java @@ -1,8 +1,9 @@ // -// $Id: DirtyItemList.java,v 1.9 2002/01/31 01:04:54 mdb Exp $ +// $Id: DirtyItemList.java,v 1.10 2002/02/06 23:14:56 mdb Exp $ package com.threerings.miso.scene; +import java.awt.Color; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; @@ -32,7 +33,7 @@ public class DirtyItemList public void appendDirtySprite ( MisoCharacterSprite sprite, int x, int y, Rectangle dirtyRect) { - _items.add(new DirtyItem(sprite, null, x, y, dirtyRect)); + _items.add(new DirtyItem(sprite, null, null, x, y, dirtyRect)); } /** @@ -40,9 +41,10 @@ public class DirtyItemList * dirty item list. */ public void appendDirtyObject ( - ObjectTile tile, Shape bounds, int x, int y, Rectangle dirtyRect) + ObjectTile tile, Shape bounds, Shape footprint, + int x, int y, Rectangle dirtyRect) { - _items.add(new DirtyItem(tile, bounds, x, y, dirtyRect)); + _items.add(new DirtyItem(tile, bounds, footprint, x, y, dirtyRect)); } /** @@ -160,6 +162,10 @@ public class DirtyItemList /** The bounds of the dirty item if it's an object tile. */ public Shape bounds; + /** The footprint of the dirty item if it's an object tile and + * we're drawing footprints. */ + public Shape footprint; + /** The origin tile coordinates. */ public int ox, oy; @@ -175,11 +181,12 @@ public class DirtyItemList /** * Constructs a dirty item. */ - public DirtyItem ( - Object obj, Shape bounds, int x, int y, Rectangle dirtyRect) + public DirtyItem (Object obj, Shape bounds, Shape footprint, + int x, int y, Rectangle dirtyRect) { this.obj = obj; this.bounds = bounds; + this.footprint = footprint; this.ox = x; this.oy = y; this.dirtyRect = dirtyRect; @@ -208,6 +215,12 @@ public class DirtyItemList // clip the draw region to the dirty portion of the item gfx.clip(clip); + // if there's a footprint, paint that + if (footprint != null) { + gfx.setColor(Color.black); + gfx.draw(footprint); + } + // paint the item if (obj instanceof Sprite) { ((Sprite)obj).paint(gfx); diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index b7d5e8530..367776c3b 100644 --- a/src/java/com/threerings/miso/client/IsoSceneView.java +++ b/src/java/com/threerings/miso/client/IsoSceneView.java @@ -1,5 +1,5 @@ // -// $Id: IsoSceneView.java,v 1.90 2002/02/06 17:13:06 mdb Exp $ +// $Id: IsoSceneView.java,v 1.91 2002/02/06 23:14:56 mdb Exp $ package com.threerings.miso.scene; @@ -648,16 +648,24 @@ public class IsoSceneView implements SceneView // get the object's coordinates and bounding polygon int coord = ((Integer)iter.next()).intValue(); Polygon poly = (Polygon)_objpolys.get(coord); - - if (poly.intersects(r)) { - // get the dirty portion of the object - Rectangle drect = poly.getBounds().intersection(r); - int tx = coord >> 16, ty = coord & 0x0000FFFF; - _dirtyItems.appendDirtyObject( - tiles.getTile(tx, ty), poly, tx, ty, drect); - // Log.info("Dirtied item: Object(" + tx + ", " + - // ty + ")"); + if (!poly.intersects(r)) { + continue; } + + // get the dirty portion of the object + Rectangle drect = poly.getBounds().intersection(r); + int tx = coord >> 16, ty = coord & 0x0000FFFF; + ObjectTile tile = tiles.getTile(tx, ty); + + // compute the footprint if we're rendering those + Polygon foot = null; + if (_renderObjectFootprints) { + foot = IsoUtil.getObjectFootprint( + _model, _polys[tx][ty], tile); + } + + _dirtyItems.appendDirtyObject(tile, poly, foot, tx, ty, drect); + // Log.info("Dirtied item: Object(" + tx + ", " + ty + ")"); } } } @@ -791,7 +799,7 @@ public class IsoSceneView implements SceneView } // we've passed the test, add the object to the list - list.appendDirtyObject(tile, poly, tx, ty, pbounds); + list.appendDirtyObject(tile, poly, null, tx, ty, pbounds); } } @@ -901,6 +909,9 @@ public class IsoSceneView implements SceneView /** The object that the mouse is currently hovering over. */ protected Object _hobject; + /** If true, object footprints are rendered when rendering objects. */ + protected boolean _renderObjectFootprints; + /** The stroke object used to draw highlighted tiles and coordinates. */ protected BasicStroke _hstroke = new BasicStroke(2); }