repack 'current tiles' array before reallocating it
This commit is contained in:
parent
f7b00b9692
commit
f3f1c4ae54
@ -74,14 +74,14 @@ public class TileManager {
|
|||||||
private float[] mTileCoords = new float[8];
|
private float[] mTileCoords = new float[8];
|
||||||
|
|
||||||
private static int mUpdateCnt;
|
private static int mUpdateCnt;
|
||||||
private static Object tilelock = new Object();
|
static Object tilelock = new Object();
|
||||||
private static TileSet mCurrentTiles;
|
private static TileSet mCurrentTiles;
|
||||||
/* package */static TileSet mNewTiles;
|
/* package */static TileSet mNewTiles;
|
||||||
|
|
||||||
private final ScanBox mScanBox = new ScanBox() {
|
private final ScanBox mScanBox = new ScanBox() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void setVisible(int y, int x1, int x2) {
|
public void setVisible(int y, int x1, int x2) {
|
||||||
MapTile[] tiles = mNewTiles.tiles;
|
MapTile[] tiles = mNewTiles.tiles;
|
||||||
int cnt = mNewTiles.cnt;
|
int cnt = mNewTiles.cnt;
|
||||||
int max = tiles.length;
|
int max = tiles.length;
|
||||||
@ -208,14 +208,14 @@ public class TileManager {
|
|||||||
changedPos = mMapViewPosition.getMapPosition(mapPosition, coords);
|
changedPos = mMapViewPosition.getMapPosition(mapPosition, coords);
|
||||||
|
|
||||||
if (changedPos) {
|
if (changedPos) {
|
||||||
//mMapView.render();
|
mMapView.render();
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// load some tiles more than currently visible
|
// load some tiles more than currently visible
|
||||||
// TODO limit how many more...
|
// TODO limit how many more...
|
||||||
float scale = mapPosition.scale * 0.8f;
|
float scale = mapPosition.scale * 0.5f;
|
||||||
float px = (float) mapPosition.x;
|
float px = (float) mapPosition.x;
|
||||||
float py = (float) mapPosition.y;
|
float py = (float) mapPosition.y;
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ public class TileManager {
|
|||||||
mUpdateCnt++;
|
mUpdateCnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Log.d(TAG, "tiles: " + mCurrentTiles.cnt + " added: " + mJobs.size());
|
||||||
if (mJobs.size() > 0) {
|
if (mJobs.size() > 0) {
|
||||||
|
|
||||||
JobTile[] jobs = new JobTile[mJobs.size()];
|
JobTile[] jobs = new JobTile[mJobs.size()];
|
||||||
@ -375,10 +375,17 @@ public class TileManager {
|
|||||||
QuadTree.add(tile);
|
QuadTree.add(tile);
|
||||||
|
|
||||||
if (mTilesSize == mTiles.length) {
|
if (mTilesSize == mTiles.length) {
|
||||||
MapTile[] tmp = new MapTile[mTiles.length + 20];
|
Log.d(TAG, "repack: " + mTiles.length + " / " + mTilesCount);
|
||||||
System.arraycopy(mTiles, 0, tmp, 0, mTilesSize);
|
|
||||||
mTiles = tmp;
|
TileDistanceSort.sort(mTiles, 0, mTilesSize);
|
||||||
Log.d(TAG, "increase tiles: " + mTiles.length);
|
|
||||||
|
if (mTilesCount == mTilesSize) {
|
||||||
|
Log.d(TAG, "realloc tiles");
|
||||||
|
MapTile[] tmp = new MapTile[mTiles.length + 20];
|
||||||
|
System.arraycopy(mTiles, 0, tmp, 0, mTilesCount);
|
||||||
|
mTiles = tmp;
|
||||||
|
}
|
||||||
|
mTilesSize = mTilesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
mTiles[mTilesSize++] = tile;
|
mTiles[mTilesSize++] = tile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user