Merge pull request #5154 from samme/feature/camera-cull-opt

Tiny optimization for BaseCamera#cull
This commit is contained in:
Richard Davey 2020-07-13 12:18:04 +01:00 committed by GitHub
commit 17e9a762a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -756,6 +756,10 @@ var BaseCamera = new Class({
var scrollY = this.scrollY; var scrollY = this.scrollY;
var cameraW = this.width; var cameraW = this.width;
var cameraH = this.height; var cameraH = this.height;
var cullTop = this.y;
var cullBottom = cullTop + cameraH;
var cullLeft = this.x;
var cullRight = cullLeft + cameraW;
var culledObjects = this.culledObjects; var culledObjects = this.culledObjects;
var length = renderableObjects.length; var length = renderableObjects.length;
@ -781,10 +785,6 @@ var BaseCamera = new Class({
var ty = (objectX * mvb + objectY * mvd + mvf); var ty = (objectX * mvb + objectY * mvd + mvf);
var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve); var tw = ((objectX + objectW) * mva + (objectY + objectH) * mvc + mve);
var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf); var th = ((objectX + objectW) * mvb + (objectY + objectH) * mvd + mvf);
var cullTop = this.y;
var cullBottom = cullTop + cameraH;
var cullLeft = this.x;
var cullRight = cullLeft + cameraW;
if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom)) if ((tw > cullLeft && tx < cullRight) && (th > cullTop && ty < cullBottom))
{ {