Change coverage methods on TiledImage to be member methods.

This commit is contained in:
Jirka 2022-03-30 13:27:23 +02:00
parent 7f784835a7
commit 38e91f1fa5

View File

@ -1176,7 +1176,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// Stop the loop if lower-res tiles would all be covered by
// already drawn tiles
if ($.TiledImage._providesCoverage(this.coverage, level)) {
if (this._providesCoverage(this.coverage, level)) {
break;
}
}
@ -1287,8 +1287,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
});
}
$.TiledImage._resetCoverage(this.coverage, level);
$.TiledImage._resetCoverage(this.loadingCoverage, level);
this._resetCoverage(this.coverage, level);
this._resetCoverage(this.loadingCoverage, level);
//OK, a new drawing so do your calculations
var cornerTiles = this._getCornerTiles(level, topLeftBound, bottomRightBound);
@ -1392,18 +1392,18 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
});
}
$.TiledImage._setCoverage( this.coverage, level, x, y, false );
this._setCoverage( this.coverage, level, x, y, false );
var loadingCoverage = tile.loaded || tile.loading || $.TiledImage._isCovered(this.loadingCoverage, level, x, y);
$.TiledImage._setCoverage(this.loadingCoverage, level, x, y, loadingCoverage);
var loadingCoverage = tile.loaded || tile.loading || this._isCovered(this.loadingCoverage, level, x, y);
this._setCoverage(this.loadingCoverage, level, x, y, loadingCoverage);
if ( !tile.exists ) {
return best;
}
if ( haveDrawn && !drawTile ) {
if ( $.TiledImage._isCovered( this.coverage, level, x, y ) ) {
$.TiledImage._setCoverage( this.coverage, level, x, y, true );
if ( this._isCovered( this.coverage, level, x, y ) ) {
this._setCoverage( this.coverage, level, x, y, true );
} else {
drawTile = true;
}
@ -1789,7 +1789,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this.lastDrawn.push( tile );
if ( opacity === 1 ) {
$.TiledImage._setCoverage( this.coverage, level, x, y, true );
this._setCoverage( this.coverage, level, x, y, true );
this._hasOpaqueTile = true;
} else if ( deltaTime < blendTimeMillis ) {
return true;
@ -2080,8 +2080,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
}
}
}
}
});
},
/**
* @private
@ -2100,7 +2099,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* @param {Number} y - The Y position of the tile.
* @returns {Boolean}
*/
$.TiledImage._providesCoverage = function( coverage, level, x, y ) {
_providesCoverage: function( coverage, level, x, y ) {
var rows,
cols,
i, j;
@ -2130,7 +2129,7 @@ $.TiledImage._providesCoverage = function( coverage, level, x, y ) {
coverage[ level ][ x ][ y ] === undefined ||
coverage[ level ][ x ][ y ] === true
);
};
},
/**
* @private
@ -2145,7 +2144,7 @@ $.TiledImage._providesCoverage = function( coverage, level, x, y ) {
* @param {Number} y - The Y position of the tile.
* @returns {Boolean}
*/
$.TiledImage._isCovered = function( coverage, level, x, y ) {
_isCovered: function( coverage, level, x, y ) {
if ( x === undefined || y === undefined ) {
return this._providesCoverage( coverage, level + 1 );
} else {
@ -2156,7 +2155,7 @@ $.TiledImage._isCovered = function( coverage, level, x, y ) {
this._providesCoverage( coverage, level + 1, 2 * x + 1, 2 * y + 1 )
);
}
};
},
/**
* @private
@ -2169,7 +2168,7 @@ $.TiledImage._isCovered = function( coverage, level, x, y ) {
* @param {Number} y - The Y position of the tile.
* @param {Boolean} covers - Whether the tile provides coverage.
*/
$.TiledImage._setCoverage = function( coverage, level, x, y, covers ) {
_setCoverage: function( coverage, level, x, y, covers ) {
if ( !coverage[ level ] ) {
$.console.warn(
"Setting coverage for a tile before its level's coverage has been reset: %s",
@ -2183,7 +2182,7 @@ $.TiledImage._setCoverage = function( coverage, level, x, y, covers ) {
}
coverage[ level ][ x ][ y ] = covers;
};
},
/**
* @private
@ -2195,9 +2194,11 @@ $.TiledImage._setCoverage = function( coverage, level, x, y, covers ) {
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
* @param {Number} level - The resolution level of tiles to completely reset.
*/
$.TiledImage._resetCoverage = function( coverage, level ) {
_resetCoverage: function( coverage, level ) {
coverage[ level ] = {};
};
}
});
/**
* @private