mirror of
https://github.com/photonstorm/phaser
synced 2024-09-21 06:51:55 +00:00
Camera.cullHitTest has been removed. It was never used internally and duplicates the code in Camera.cull
.
This commit is contained in:
parent
84a7b260b3
commit
ae603240e1
2 changed files with 1 additions and 78 deletions
|
@ -26,6 +26,7 @@
|
|||
* A Matter Mouse Spring will disable debug draw of its constraint by default (you can override it by passing in your own config)
|
||||
* Removed Camera.clearBeforeRender property as it was never used internally. This setting can be enabled on a Game-wide basis.
|
||||
* Camera now extends the Event Emitter, allowing it to emit events.
|
||||
* Camera.cullHitTest has been removed. It was never used internally and duplicates the code in `Camera.cull`.
|
||||
|
||||
### Examples, Documentation and TypeScript
|
||||
|
||||
|
|
|
@ -394,84 +394,6 @@ var Camera = new Class({
|
|||
return culledObjects;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Cameras.Scene2D.Camera#cullHitTest
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @generic {Phaser.GameObjects.GameObject[]} G - [interactiveObjects,$return]
|
||||
*
|
||||
* @param {Phaser.GameObjects.GameObject[]} interactiveObjects - [description]
|
||||
*
|
||||
* @return {Phaser.GameObjects.GameObject[]} [description]
|
||||
*/
|
||||
cullHitTest: function (interactiveObjects)
|
||||
{
|
||||
if (this.disableCull)
|
||||
{
|
||||
return interactiveObjects;
|
||||
}
|
||||
|
||||
var cameraMatrix = this.matrix.matrix;
|
||||
|
||||
var mva = cameraMatrix[0];
|
||||
var mvb = cameraMatrix[1];
|
||||
var mvc = cameraMatrix[2];
|
||||
var mvd = cameraMatrix[3];
|
||||
|
||||
/* First Invert Matrix */
|
||||
var determinant = (mva * mvd) - (mvb * mvc);
|
||||
|
||||
if (!determinant)
|
||||
{
|
||||
return interactiveObjects;
|
||||
}
|
||||
|
||||
var mve = cameraMatrix[4];
|
||||
var mvf = cameraMatrix[5];
|
||||
|
||||
var scrollX = this.scrollX;
|
||||
var scrollY = this.scrollY;
|
||||
var cameraW = this.width;
|
||||
var cameraH = this.height;
|
||||
var length = interactiveObjects.length;
|
||||
|
||||
determinant = 1 / determinant;
|
||||
|
||||
var culledObjects = [];
|
||||
|
||||
for (var index = 0; index < length; ++index)
|
||||
{
|
||||
var object = interactiveObjects[index].gameObject;
|
||||
|
||||
if (!object.hasOwnProperty('width') || object.parentContainer)
|
||||
{
|
||||
culledObjects.push(interactiveObjects[index]);
|
||||
continue;
|
||||
}
|
||||
|
||||
var objectW = object.width;
|
||||
var objectH = object.height;
|
||||
var objectX = (object.x - (scrollX * object.scrollFactorX)) - (objectW * object.originX);
|
||||
var objectY = (object.y - (scrollY * object.scrollFactorY)) - (objectH * object.originY);
|
||||
var tx = (objectX * mva + objectY * mvc + mve);
|
||||
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;
|
||||
|
||||
if (tx > -objectW || ty > -objectH || tx < cullW || ty < cullH ||
|
||||
tw > -objectW || th > -objectH || tw < cullW || th < cullH)
|
||||
{
|
||||
culledObjects.push(interactiveObjects[index]);
|
||||
}
|
||||
}
|
||||
|
||||
return culledObjects;
|
||||
},
|
||||
|
||||
/**
|
||||
* Fades the Camera in from the given color over the duration specified.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue