Merge pull request #4093 from Cirras/patch-1

Fix Camera culling bugs (Issue #4092)
This commit is contained in:
Richard Davey 2018-10-19 13:45:36 +01:00 committed by GitHub
commit 8a974915d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -727,11 +727,12 @@ var BaseCamera = new Class({
var ty = (objectX * mvb + objectY * mvd + mvf);
var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve);
var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf);
var cullW = cameraW + objectW;
var cullH = cameraH + objectH;
var cullTop = this.y;
var cullBottom = cullTop + cameraH;
var cullLeft = this.x;
var cullRight = cullLeft + cameraW;
if (tx > -objectW && ty > -objectH && tx < cullW && ty < cullH &&
tw > -objectW && th > -objectH && tw < cullW && th < cullH)
if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom))
{
culledObjects.push(object);
}