Cull empty tiles
This commit is contained in:
parent
6bc8c0ed80
commit
b5b2b76ff0
|
@ -156,8 +156,12 @@ export class Tiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cut up tile strips.
|
// Cut up tile strips.
|
||||||
//console.log("strips count:", this.strips.length);
|
this.tileStrips = [];
|
||||||
this.tileStrips = this.strips.map(strip => this.divideStrip(strip));
|
for (const strip of this.strips) {
|
||||||
|
const tileStrip = this.divideStrip(strip);
|
||||||
|
if (!tileStrip.isEmpty())
|
||||||
|
this.tileStrips.push(tileStrip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private divideStrip(strip: Strip): TileStrip {
|
private divideStrip(strip: Strip): TileStrip {
|
||||||
|
@ -192,7 +196,9 @@ export class Tiler {
|
||||||
nextEdgeIndex++;
|
nextEdgeIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tile.isEmpty())
|
||||||
tileStrip.pushTile(tile);
|
tileStrip.pushTile(tile);
|
||||||
|
|
||||||
tileLeft = tileRight;
|
tileLeft = tileRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +409,10 @@ class TileStrip {
|
||||||
tileBottom(): number {
|
tileBottom(): number {
|
||||||
return this.tileTop + TILE_SIZE.height;
|
return this.tileTop + TILE_SIZE.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEmpty(): boolean {
|
||||||
|
return this.tiles.length === 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Tile {
|
class Tile {
|
||||||
|
@ -418,6 +428,10 @@ class Tile {
|
||||||
this.edges.push(new Edge(new Point2D(edge.from.x - this.tileLeft, edge.from.y),
|
this.edges.push(new Edge(new Point2D(edge.from.x - this.tileLeft, edge.from.y),
|
||||||
new Point2D(edge.to.x - this.tileLeft, edge.to.y)));
|
new Point2D(edge.to.x - this.tileLeft, edge.to.y)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isEmpty(): boolean {
|
||||||
|
return this.edges.length === 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ClippedEdgesX {
|
interface ClippedEdgesX {
|
||||||
|
@ -538,7 +552,6 @@ export class TileDebugger {
|
||||||
const tileStrips = tiler.getTileStrips();
|
const tileStrips = tiler.getTileStrips();
|
||||||
for (let tileStripIndex = 0; tileStripIndex < tileStrips.length; tileStripIndex++) {
|
for (let tileStripIndex = 0; tileStripIndex < tileStrips.length; tileStripIndex++) {
|
||||||
const tileStrip = tileStrips[tileStripIndex];
|
const tileStrip = tileStrips[tileStripIndex];
|
||||||
const tileBottom = tileStrip.tileBottom();
|
|
||||||
|
|
||||||
for (let tileIndex = 0; tileIndex < tileStrip.tiles.length; tileIndex++) {
|
for (let tileIndex = 0; tileIndex < tileStrip.tiles.length; tileIndex++) {
|
||||||
const tile = tileStrip.tiles[tileIndex];
|
const tile = tileStrip.tiles[tileIndex];
|
||||||
|
|
Loading…
Reference in New Issue