Moved the bits -> index reverse lookup from FringeConfiguration to
AutoFringer because our fringe tileset is hardcoded now. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1220 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AutoFringer.java,v 1.7 2002/04/08 18:41:58 ray Exp $
|
// $Id: AutoFringer.java,v 1.8 2002/04/08 19:41:52 ray Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tile;
|
package com.threerings.miso.tile;
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ public class AutoFringer
|
|||||||
*/
|
*/
|
||||||
protected int[] getFringeIndexes (int bits)
|
protected int[] getFringeIndexes (int bits)
|
||||||
{
|
{
|
||||||
int index = _fringeconf.getTileIndexFromFringeBits(bits);
|
int index = BITS_TO_INDEX[bits];
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
int[] ret = new int[1];
|
int[] ret = new int[1];
|
||||||
ret[0] = index;
|
ret[0] = index;
|
||||||
@@ -240,7 +240,7 @@ public class AutoFringer
|
|||||||
if (((1 << ii) & bits) != 0) {
|
if (((1 << ii) & bits) != 0) {
|
||||||
weebits |= (1 << ii);
|
weebits |= (1 << ii);
|
||||||
} else if (weebits != 0) {
|
} else if (weebits != 0) {
|
||||||
index = _fringeconf.getTileIndexFromFringeBits(weebits);
|
index = BITS_TO_INDEX[weebits];
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
indexes.add(new Integer(index));
|
indexes.add(new Integer(index));
|
||||||
}
|
}
|
||||||
@@ -248,7 +248,7 @@ public class AutoFringer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (weebits != 0) {
|
if (weebits != 0) {
|
||||||
index = _fringeconf.getTileIndexFromFringeBits(weebits);
|
index = BITS_TO_INDEX[weebits];
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
indexes.add(new Integer(index));
|
indexes.add(new Integer(index));
|
||||||
}
|
}
|
||||||
@@ -308,6 +308,56 @@ public class AutoFringer
|
|||||||
{ NORTHWEST, (NORTHWEST | WEST | SOUTHWEST), SOUTHWEST }
|
{ NORTHWEST, (NORTHWEST | WEST | SOUTHWEST), SOUTHWEST }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fringe tiles we use. These are the 17 possible tiles made
|
||||||
|
* up of continuous fringebits sections.
|
||||||
|
* Huh? see docs/miso/fringebits.png
|
||||||
|
*/
|
||||||
|
protected static final int[] FRINGETILES = {
|
||||||
|
SOUTHEAST,
|
||||||
|
SOUTHWEST | SOUTH | SOUTHEAST,
|
||||||
|
SOUTHWEST,
|
||||||
|
NORTHEAST | EAST | SOUTHEAST,
|
||||||
|
NORTHWEST | WEST | SOUTHWEST,
|
||||||
|
NORTHEAST,
|
||||||
|
NORTHWEST | NORTH | NORTHEAST,
|
||||||
|
NORTHWEST,
|
||||||
|
|
||||||
|
SOUTHWEST | WEST | NORTHWEST | NORTH | NORTHEAST,
|
||||||
|
NORTHWEST | NORTH | NORTHEAST | EAST | SOUTHEAST,
|
||||||
|
NORTHWEST | WEST | SOUTHWEST | SOUTH | SOUTHEAST,
|
||||||
|
SOUTHWEST | SOUTH | SOUTHEAST | EAST | NORTHEAST,
|
||||||
|
|
||||||
|
NORTHEAST | NORTH | NORTHWEST | WEST | SOUTHWEST | SOUTH | SOUTHEAST,
|
||||||
|
SOUTHEAST | EAST | NORTHEAST | NORTH | NORTHWEST | WEST | SOUTHWEST,
|
||||||
|
SOUTHWEST | SOUTH | SOUTHEAST | EAST | NORTHEAST | NORTH | NORTHWEST,
|
||||||
|
NORTHWEST | WEST | SOUTHWEST | SOUTH | SOUTHEAST | EAST | NORTHEAST,
|
||||||
|
|
||||||
|
// all the directions!
|
||||||
|
NORTH | NORTHEAST | EAST | SOUTHEAST |
|
||||||
|
SOUTH | SOUTHWEST | WEST | NORTHWEST
|
||||||
|
};
|
||||||
|
|
||||||
|
// A reverse map of the above array, for quickly looking up which tile
|
||||||
|
// we want.
|
||||||
|
protected static final int[] BITS_TO_INDEX;
|
||||||
|
|
||||||
|
// Construct the BITS_TO_INDEX array.
|
||||||
|
static {
|
||||||
|
int num = (1 << NUM_FRINGEBITS);
|
||||||
|
BITS_TO_INDEX = new int[num];
|
||||||
|
|
||||||
|
// first clear everything to -1 (meaning there is no tile defined)
|
||||||
|
for (int ii=0; ii < num; ii++) {
|
||||||
|
BITS_TO_INDEX[ii] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// then fill in with the defined tiles.
|
||||||
|
for (int ii=0; ii < FRINGETILES.length; ii++) {
|
||||||
|
BITS_TO_INDEX[FRINGETILES[ii]] = ii;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Our tile manager. */
|
/** Our tile manager. */
|
||||||
protected TileManager _tmgr;
|
protected TileManager _tmgr;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: FringeConfiguration.java,v 1.8 2002/04/06 20:50:30 ray Exp $
|
// $Id: FringeConfiguration.java,v 1.9 2002/04/08 19:41:52 ray Exp $
|
||||||
|
|
||||||
package com.threerings.miso.tile;
|
package com.threerings.miso.tile;
|
||||||
|
|
||||||
@@ -72,25 +72,6 @@ public class FringeConfiguration implements Serializable
|
|||||||
_frecs.put(frec.base_tsid, frec);
|
_frecs.put(frec.base_tsid, frec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* During parsing we get an int[] representing the fringes we have
|
|
||||||
* defined.
|
|
||||||
*/
|
|
||||||
public void setTiles (int[] tiles)
|
|
||||||
{
|
|
||||||
// create an array of all possible tiles and set them all to invalid
|
|
||||||
_bits = new int[256];
|
|
||||||
for (int ii=0; ii < 256; ii++) {
|
|
||||||
_bits[ii] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fill in the fringebit configurations we have tiles for with the
|
|
||||||
// index of the tiles
|
|
||||||
for (int ii=0; ii < tiles.length; ii++) {
|
|
||||||
_bits[tiles[ii]] = ii;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the first base tileset fringes upon the second, return the
|
* If the first base tileset fringes upon the second, return the
|
||||||
* fringe priority of the first base tileset, otherwise return -1.
|
* fringe priority of the first base tileset, otherwise return -1.
|
||||||
@@ -118,16 +99,6 @@ public class FringeConfiguration implements Serializable
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the tile index of any fringing tileset that should be used
|
|
||||||
* if the following fringebits are turned on.
|
|
||||||
* @return -1 if not defined
|
|
||||||
*/
|
|
||||||
public int getTileIndexFromFringeBits (int bits)
|
|
||||||
{
|
|
||||||
return _bits[bits];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a random FringeTileSetRecord from amongst the ones
|
* Get a random FringeTileSetRecord from amongst the ones
|
||||||
* listed for the specified base tileset.
|
* listed for the specified base tileset.
|
||||||
@@ -142,7 +113,4 @@ public class FringeConfiguration implements Serializable
|
|||||||
|
|
||||||
/** The mapping from base tileset id to fringerecord. */
|
/** The mapping from base tileset id to fringerecord. */
|
||||||
protected HashIntMap _frecs = new HashIntMap();
|
protected HashIntMap _frecs = new HashIntMap();
|
||||||
|
|
||||||
/** An array that matches fringebits to fringe tile indexes. */
|
|
||||||
protected int[] _bits;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user