Added support for rendering object footprints when rendering objects
(useful in the editor to see what's traversable and what's not). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@948 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Shape;
|
import java.awt.Shape;
|
||||||
@@ -32,7 +33,7 @@ public class DirtyItemList
|
|||||||
public void appendDirtySprite (
|
public void appendDirtySprite (
|
||||||
MisoCharacterSprite sprite, int x, int y, Rectangle dirtyRect)
|
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.
|
* dirty item list.
|
||||||
*/
|
*/
|
||||||
public void appendDirtyObject (
|
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. */
|
/** The bounds of the dirty item if it's an object tile. */
|
||||||
public Shape bounds;
|
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. */
|
/** The origin tile coordinates. */
|
||||||
public int ox, oy;
|
public int ox, oy;
|
||||||
|
|
||||||
@@ -175,11 +181,12 @@ public class DirtyItemList
|
|||||||
/**
|
/**
|
||||||
* Constructs a dirty item.
|
* Constructs a dirty item.
|
||||||
*/
|
*/
|
||||||
public DirtyItem (
|
public DirtyItem (Object obj, Shape bounds, Shape footprint,
|
||||||
Object obj, Shape bounds, int x, int y, Rectangle dirtyRect)
|
int x, int y, Rectangle dirtyRect)
|
||||||
{
|
{
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.bounds = bounds;
|
this.bounds = bounds;
|
||||||
|
this.footprint = footprint;
|
||||||
this.ox = x;
|
this.ox = x;
|
||||||
this.oy = y;
|
this.oy = y;
|
||||||
this.dirtyRect = dirtyRect;
|
this.dirtyRect = dirtyRect;
|
||||||
@@ -208,6 +215,12 @@ public class DirtyItemList
|
|||||||
// clip the draw region to the dirty portion of the item
|
// clip the draw region to the dirty portion of the item
|
||||||
gfx.clip(clip);
|
gfx.clip(clip);
|
||||||
|
|
||||||
|
// if there's a footprint, paint that
|
||||||
|
if (footprint != null) {
|
||||||
|
gfx.setColor(Color.black);
|
||||||
|
gfx.draw(footprint);
|
||||||
|
}
|
||||||
|
|
||||||
// paint the item
|
// paint the item
|
||||||
if (obj instanceof Sprite) {
|
if (obj instanceof Sprite) {
|
||||||
((Sprite)obj).paint(gfx);
|
((Sprite)obj).paint(gfx);
|
||||||
|
|||||||
@@ -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;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -648,16 +648,24 @@ public class IsoSceneView implements SceneView
|
|||||||
// get the object's coordinates and bounding polygon
|
// get the object's coordinates and bounding polygon
|
||||||
int coord = ((Integer)iter.next()).intValue();
|
int coord = ((Integer)iter.next()).intValue();
|
||||||
Polygon poly = (Polygon)_objpolys.get(coord);
|
Polygon poly = (Polygon)_objpolys.get(coord);
|
||||||
|
if (!poly.intersects(r)) {
|
||||||
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;
|
|
||||||
_dirtyItems.appendDirtyObject(
|
|
||||||
tiles.getTile(tx, ty), poly, tx, ty, drect);
|
|
||||||
// Log.info("Dirtied item: Object(" + tx + ", " +
|
|
||||||
// ty + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// 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. */
|
/** The object that the mouse is currently hovering over. */
|
||||||
protected Object _hobject;
|
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. */
|
/** The stroke object used to draw highlighted tiles and coordinates. */
|
||||||
protected BasicStroke _hstroke = new BasicStroke(2);
|
protected BasicStroke _hstroke = new BasicStroke(2);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user