Use BaseTile objects to contain fringe tile info, mark them as impassible

if they are fringed on by any SPECIFIED tileId (ie, not the default tileId)
that is impassible.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2852 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2003-11-12 23:05:41 +00:00
parent 708008b65f
commit 7795edf604
3 changed files with 56 additions and 26 deletions
@@ -1,5 +1,5 @@
//
// $Id: MisoScenePanel.java,v 1.51 2003/10/15 23:20:40 mdb Exp $
// $Id: MisoScenePanel.java,v 1.52 2003/11/12 23:05:40 ray Exp $
package com.threerings.miso.client;
@@ -1403,14 +1403,14 @@ public class MisoScenePanel extends VirtualMediaPanel
}
/** Returns the fringe tile for the specified tile coordinate. */
protected Tile getFringeTile (int tx, int ty)
protected BaseTile getFringeTile (int tx, int ty)
{
SceneBlock block = getBlock(tx, ty);
return (block == null) ? null : block.getFringeTile(tx, ty);
}
/** Computes the fringe tile for the specified coordinate. */
protected Tile computeFringeTile (int tx, int ty)
protected BaseTile computeFringeTile (int tx, int ty)
{
return _ctx.getTileManager().getAutoFringer().getFringeTile(
_model, tx, ty, _masks);
@@ -1462,11 +1462,6 @@ public class MisoScenePanel extends VirtualMediaPanel
tile.paint(_gfx, tbounds.x, tbounds.y);
passable = ((BaseTile)tile).isPassable();
// highlight impassable tiles
if (_traverseDebug.getValue() && !passable) {
fillTile(_gfx, tx, ty, Color.yellow);
}
} else {
// draw black where there are no tiles
Polygon poly = MisoUtil.getTilePolygon(_metrics, tx, ty);
@@ -1476,12 +1471,19 @@ public class MisoScenePanel extends VirtualMediaPanel
if ((tile = getFringeTile(tx, ty)) != null) {
tile.paint(_gfx, tbounds.x, tbounds.y);
passable = passable && ((BaseTile)tile).isPassable();
}
// highlight passable non-traversable tiles
if (_traverseDebug.getValue() && passable &&
!canTraverse(null, tx, ty)) {
fillTile(_gfx, tx, ty, Color.green);
// highlight impassable tiles
if (_traverseDebug.getValue()) {
if (!passable) {
// highlight tiles blocked by base or fringe in yellow
fillTile(_gfx, tx, ty, Color.yellow);
} else if (!canTraverse(null, tx, ty)) {
// highlight passable non-traversable tiles in green
fillTile(_gfx, tx, ty, Color.green);
}
}
} catch (ArrayIndexOutOfBoundsException e) {
@@ -1,5 +1,5 @@
//
// $Id: SceneBlock.java,v 1.21 2003/10/29 01:42:37 mdb Exp $
// $Id: SceneBlock.java,v 1.22 2003/11/12 23:05:40 ray Exp $
package com.threerings.miso.client;
@@ -46,7 +46,7 @@ public class SceneBlock
_panel = panel;
_bounds = new Rectangle(tx, ty, width, height);
_base = new BaseTile[width*height];
_fringe = new Tile[width*height];
_fringe = new BaseTile[width*height];
_covered = new boolean[width*height];
// compute our screen-coordinate footprint polygon
@@ -252,7 +252,7 @@ public class SceneBlock
* Returns the fringe tile at the specified coordinates or null if
* there's no tile at said coordinates.
*/
public Tile getFringeTile (int tx, int ty)
public BaseTile getFringeTile (int tx, int ty)
{
return _fringe[index(tx, ty)];
}
@@ -367,8 +367,20 @@ public class SceneBlock
*/
public boolean canTraverse (Object traverser, int tx, int ty)
{
if (_covered[index(tx, ty)]) {
return false;
}
BaseTile base = getBaseTile(tx, ty);
return !_covered[index(tx, ty)] && (base != null && base.isPassable());
if ((base == null) || !base.isPassable()) {
return false;
}
BaseTile fringe = getFringeTile(tx, ty);
if (fringe != null) {
return fringe.isPassable();
}
return true;
}
/**
@@ -551,7 +563,7 @@ public class SceneBlock
protected BaseTile[] _base;
/** Our fringe tiles. */
protected Tile[] _fringe;
protected BaseTile[] _fringe;
/** Indicates whether our tiles are covered by an object. */
protected boolean[] _covered;
@@ -1,5 +1,5 @@
//
// $Id: AutoFringer.java,v 1.25 2003/05/31 00:56:38 mdb Exp $
// $Id: AutoFringer.java,v 1.26 2003/11/12 23:05:41 ray Exp $
package com.threerings.miso.tile;
@@ -57,14 +57,15 @@ public class AutoFringer
* Compute and return the fringe tile to be inserted at the specified
* location.
*/
public Tile getFringeTile (MisoSceneModel scene, int col, int row,
HashMap masks)
public BaseTile getFringeTile (MisoSceneModel scene, int col, int row,
HashMap masks)
{
// get the tileset id of the base tile we are considering
int underset = scene.getBaseTileId(col, row) >> 16;
// start with a clean temporary fringer map
_fringers.clear();
boolean passable = true;
// walk through our influence tiles
for (int y = row - 1, maxy = row + 2; y < maxy; y++) {
@@ -93,6 +94,20 @@ public class AutoFringer
// now turn on the appropriate fringebits
fringer.bits |= FLAGMATRIX[y - row + 1][x - col + 1];
// and see if this base tile kills passability
if (passable) {
if (btid > 0) {
try {
BaseTile bt = (BaseTile) _tmgr.getTile(btid);
passable = bt.isPassable();
} catch (NoSuchTileSetException nstse) {
Log.warning("Autofringer couldn't find a base " +
"set while attempting to figure passability " +
"[error=" + nstse + "].");
}
}
}
}
}
@@ -111,14 +126,17 @@ public class AutoFringer
}
}
return composeFringeTile(frecs, masks, MisoUtil.getTileHash(col, row));
BaseTile frTile = new BaseTile();
frTile.setPassable(passable);
composeFringeTile(frTile, frecs, masks, MisoUtil.getTileHash(col, row));
return frTile;
}
/**
* Compose a FringeTile out of the various fringe images needed.
*/
protected Tile composeFringeTile (
FringerRec[] fringers, HashMap masks, int hashValue)
protected void composeFringeTile (
Tile frTile, FringerRec[] fringers, HashMap masks, int hashValue)
{
// sort the array so that higher priority fringers get drawn first
QuickSort.sort(fringers);
@@ -140,9 +158,7 @@ public class AutoFringer
}
}
Tile tile = new Tile();
tile.setImage(new BufferedMirage(ftimg));
return tile;
frTile.setImage(new BufferedMirage(ftimg));
}
/**