* @param collision GeoCollision
* @param geoIndex int
*/
public static void applyGeoCollision(GeoCollision collision, int geoIndex)
{
Shape shape = collision.getShape();
if ((shape.getXmax() == shape.getYmax()) && (shape.getXmax() == 0))
{
throw new RuntimeException("Attempt to add incorrect collision: " + collision);
}
boolean isFirstTime = false;
int minX = (shape.getXmin() - World.MAP_MIN_X - 16) >> 4;
int maxX = ((shape.getXmax() - World.MAP_MIN_X) + 16) >> 4;
int minY = (shape.getYmin() - World.MAP_MIN_Y - 16) >> 4;
int maxY = ((shape.getYmax() - World.MAP_MIN_Y) + 16) >> 4;
int minZ = shape.getZmin();
int maxZ = shape.getZmax();
byte[][] around = collision.getGeoAround();
if (around == null)
{
isFirstTime = true;
byte[][] cells = new byte[(maxX - minX) + 1][(maxY - minY) + 1];
for (int gX = minX; gX <= maxX; gX++)
{
for (int gY = minY; gY <= maxY; gY++)
{
int x = (gX << 4) + World.MAP_MIN_X;
int y = (gY << 4) + World.MAP_MIN_Y;
loop:
for (int ax = x; ax < (x + 16); ax++)
{
for (int ay = y; ay < (y + 16); ay++)
{
if (shape.isInside(ax, ay))
{
cells[gX - minX][gY - minY] = 1;
break loop;
}
}