Skip to content

Commit 1a87cc1

Browse files
authored
Fix Camera culling bugs (Issue phaserjs#4092)
Make camera culling properly handle the camera's current zoom level and viewport position.
1 parent 3110942 commit 1a87cc1

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/cameras/2d/BaseCamera.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,12 @@ var BaseCamera = new Class({
727727
var ty = (objectX * mvb + objectY * mvd + mvf);
728728
var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve);
729729
var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf);
730-
var cullW = cameraW + objectW;
731-
var cullH = cameraH + objectH;
730+
var cullTop = this.y;
731+
var cullBottom = cullTop + cameraH;
732+
var cullLeft = this.x;
733+
var cullRight = cullLeft + cameraW;
732734

733-
if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH &&
734-
tw > -objectW && th > -objectH && tw < cullW && th < cullH)
735+
if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom))
735736
{
736737
culledObjects.push(object);
737738
}

0 commit comments

Comments
 (0)