Swapped 4 ternaries for a single conditional #3834

This commit is contained in:
Richard Davey 2018-07-16 14:55:51 +01:00
parent f723d0e18a
commit 0cc52f6002

View file

@ -40,18 +40,25 @@ var CullTiles = function (layer, camera, outputArray)
var tileW = Math.floor(layer.tileWidth * tilemapLayer.scaleX); var tileW = Math.floor(layer.tileWidth * tilemapLayer.scaleX);
var tileH = Math.floor(layer.tileHeight * tilemapLayer.scaleY); var tileH = Math.floor(layer.tileHeight * tilemapLayer.scaleY);
// Camera world view bounds, snapped for tile size // Camera world view bounds, snapped for scaled tile size
var boundsLeft = SnapFloor(camera.worldView.x, tileW) - (tilemapLayer.cullPaddingX * tileW); var boundsLeft = SnapFloor(camera.worldView.x, tileW) - (tilemapLayer.cullPaddingX * tileW);
var boundsRight = SnapCeil(camera.worldView.right, tileW) + (tilemapLayer.cullPaddingX * tileW); var boundsRight = SnapCeil(camera.worldView.right, tileW) + (tilemapLayer.cullPaddingX * tileW);
var boundsTop = SnapFloor(camera.worldView.y, tileH) - (tilemapLayer.cullPaddingY * tileH); var boundsTop = SnapFloor(camera.worldView.y, tileH) - (tilemapLayer.cullPaddingY * tileH);
var boundsBottom = SnapCeil(camera.worldView.bottom, tileH) + (tilemapLayer.cullPaddingY * tileH); var boundsBottom = SnapCeil(camera.worldView.bottom, tileH) + (tilemapLayer.cullPaddingY * tileH);
var skipCull = tilemapLayer.skipCull; var drawLeft = 0
var drawLeft = skipCull ? 0 : Math.max(0, boundsLeft / layer.tileWidth); var drawRight = mapWidth;
var drawRight = skipCull ? mapWidth : Math.min(mapWidth, boundsRight / layer.tileWidth); var drawTop = 0;
var drawTop = skipCull ? 0 : Math.max(0, boundsTop / layer.tileHeight); var drawBottom = mapHeight;
var drawBottom = skipCull ? mapHeight : Math.min(mapHeight, boundsBottom / layer.tileHeight);
if (!tilemapLayer.skipCull)
{
drawLeft = Math.max(0, boundsLeft / layer.tileWidth);
drawRight = Math.min(mapWidth, boundsRight / layer.tileWidth);
drawTop = Math.max(0, boundsTop / layer.tileHeight);
drawBottom = Math.min(mapHeight, boundsBottom / layer.tileHeight);
}
for (y = drawTop; y < drawBottom; y++) for (y = drawTop; y < drawBottom; y++)
{ {