mirror of
https://github.com/photonstorm/phaser
synced 2024-09-20 06:21:54 +00:00
Merge pull request #5134 from samme/feature/arcade-physics-collisions-perf
Arcade Physics collisions optimizations
This commit is contained in:
commit
2f48e5ee00
1 changed files with 12 additions and 4 deletions
|
@ -1341,12 +1341,14 @@ var World = new Class({
|
|||
* @param {ArcadePhysicsCallback} [processCallback] - The process callback.
|
||||
* @param {*} [callbackContext] - The context in which to invoke the callback.
|
||||
* @param {boolean} [overlapOnly] - If this a collide or overlap check?
|
||||
* @param {boolean} [intersects] - Assert that the bodies intersect and should not be tested before separation.
|
||||
*
|
||||
* @return {boolean} True if separation occurred, otherwise false.
|
||||
*/
|
||||
separate: function (body1, body2, processCallback, callbackContext, overlapOnly)
|
||||
separate: function (body1, body2, processCallback, callbackContext, overlapOnly, intersects)
|
||||
{
|
||||
if (
|
||||
!intersects &&
|
||||
!body1.enable ||
|
||||
!body2.enable ||
|
||||
body1.checkCollision.none ||
|
||||
|
@ -1398,8 +1400,14 @@ var World = new Class({
|
|||
var resultX = false;
|
||||
var resultY = false;
|
||||
|
||||
// Do we separate on x or y first?
|
||||
if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x))
|
||||
// Do we separate on x first or y first or both?
|
||||
if (overlapOnly)
|
||||
{
|
||||
// No separation but we need to calculate overlapX, overlapY, etc.
|
||||
resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS);
|
||||
resultY = SeparateY(body1, body2, overlapOnly, this.OVERLAP_BIAS);
|
||||
}
|
||||
else if (this.forceX || Math.abs(this.gravity.y + body1.gravity.y) < Math.abs(this.gravity.x + body1.gravity.x))
|
||||
{
|
||||
resultX = SeparateX(body1, body2, overlapOnly, this.OVERLAP_BIAS);
|
||||
|
||||
|
@ -1977,7 +1985,7 @@ var World = new Class({
|
|||
continue;
|
||||
}
|
||||
|
||||
if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly))
|
||||
if (this.separate(bodyA, bodyB, processCallback, callbackContext, overlapOnly, true))
|
||||
{
|
||||
if (collideCallback)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue