mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Swapped 4 ternaries for a single conditional #3834
This commit is contained in:
parent
f723d0e18a
commit
0cc52f6002
1 changed files with 14 additions and 7 deletions
|
@ -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++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue