Skip to content

Commit 0cc52f6

Browse files
committed
Swapped 4 ternaries for a single conditional phaserjs#3834
1 parent f723d0e commit 0cc52f6

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/tilemaps/components/CullTiles.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,26 @@ var CullTiles = function (layer, camera, outputArray)
4040
var tileW = Math.floor(layer.tileWidth * tilemapLayer.scaleX);
4141
var tileH = Math.floor(layer.tileHeight * tilemapLayer.scaleY);
4242

43-
// Camera world view bounds, snapped for tile size
43+
// Camera world view bounds, snapped for scaled tile size
4444

4545
var boundsLeft = SnapFloor(camera.worldView.x, tileW) - (tilemapLayer.cullPaddingX * tileW);
4646
var boundsRight = SnapCeil(camera.worldView.right, tileW) + (tilemapLayer.cullPaddingX * tileW);
4747
var boundsTop = SnapFloor(camera.worldView.y, tileH) - (tilemapLayer.cullPaddingY * tileH);
4848
var boundsBottom = SnapCeil(camera.worldView.bottom, tileH) + (tilemapLayer.cullPaddingY * tileH);
4949

50-
var skipCull = tilemapLayer.skipCull;
51-
var drawLeft = skipCull ? 0 : Math.max(0, boundsLeft / layer.tileWidth);
52-
var drawRight = skipCull ? mapWidth : Math.min(mapWidth, boundsRight / layer.tileWidth);
53-
var drawTop = skipCull ? 0 : Math.max(0, boundsTop / layer.tileHeight);
54-
var drawBottom = skipCull ? mapHeight : Math.min(mapHeight, boundsBottom / layer.tileHeight);
55-
50+
var drawLeft = 0
51+
var drawRight = mapWidth;
52+
var drawTop = 0;
53+
var drawBottom = mapHeight;
54+
55+
if (!tilemapLayer.skipCull)
56+
{
57+
drawLeft = Math.max(0, boundsLeft / layer.tileWidth);
58+
drawRight = Math.min(mapWidth, boundsRight / layer.tileWidth);
59+
drawTop = Math.max(0, boundsTop / layer.tileHeight);
60+
drawBottom = Math.min(mapHeight, boundsBottom / layer.tileHeight);
61+
}
62+
5663
for (y = drawTop; y < drawBottom; y++)
5764
{
5865
for (x = drawLeft; x < drawRight; x++)

0 commit comments

Comments
 (0)