optimises march with bounds wip
This commit is contained in:
parent
b3e504f672
commit
740f219157
@ -16,6 +16,7 @@ function IsoRenderer (canvas, options) {
|
||||
this.TILE_SIZE = 256;
|
||||
this.contourValues = [1,2,4,8,10,16,32];
|
||||
this.lines = [];
|
||||
this.bounds = {n: 10000, s: 0, e: 0, w: 100000};
|
||||
}
|
||||
|
||||
torque.extend(IsoRenderer.prototype, torque.Event, {
|
||||
@ -76,8 +77,9 @@ torque.extend(IsoRenderer.prototype, torque.Event, {
|
||||
|
||||
_renderTile: function(tile, key, frame_offset, sprites, shader, pos) {
|
||||
if (!this._canvas) return;
|
||||
var ctx = this._ctx;
|
||||
this._gridData(tile);
|
||||
if (tile.x.length > 0) {
|
||||
this._gridData(tile);
|
||||
}
|
||||
},
|
||||
|
||||
_gridData: function(tile){
|
||||
@ -95,6 +97,10 @@ torque.extend(IsoRenderer.prototype, torque.Event, {
|
||||
var x = tile.x[i], y = tile.y[i];
|
||||
this.globalGrid[baseIndex.y + (256 - y) / this.options.resolution -1][baseIndex.x + x/this.options.resolution] = tile.renderData[i];
|
||||
}
|
||||
if (tile.x < this.bounds.w) this.bounds.w = tile.x;
|
||||
else if (tile.x > this.bounds.e) this.bounds.e = tile.x;
|
||||
if (tile.y < this.bounds.n) this.bounds.n = tile.y;
|
||||
else if (tile.y > this.bounds.s) this.bounds.s = tile.y;
|
||||
},
|
||||
|
||||
_getPipe: function(cell, contour){
|
||||
@ -536,9 +542,14 @@ torque.extend(IsoRenderer.prototype, torque.Event, {
|
||||
for (var c = 0; c < contourValues.length; c++) {
|
||||
this.lines[c] = [];
|
||||
var pointsTraveled = new Set();
|
||||
var pointerX = 0, pointerY = 0, x = 0, y = 0;
|
||||
var pointerX = this.bounds.w,
|
||||
pointerY = this.bounds.n,
|
||||
x = 0,
|
||||
y = 0,
|
||||
limitX = this.bounds.e,
|
||||
limitY = this.bounds.s;
|
||||
var line = [];
|
||||
var xy = march(0,0);
|
||||
var xy = march(pointerX, pointerY);
|
||||
|
||||
while(xy){
|
||||
xy = march(xy.x, xy.y);
|
||||
|
Loading…
Reference in New Issue
Block a user