Skip to content

Commit 4d8753e

Browse files
committed
Tidying up for 2.4.7.
1 parent aad499b commit 4d8753e

1 file changed

Lines changed: 6 additions & 66 deletions

File tree

src/physics/arcade/World.js

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,49 +1124,21 @@ Phaser.Physics.Arcade.prototype = {
11241124
this._vel2.x = vxTotal + this._vel1.x;
11251125
}
11261126

1127-
// var absV = Math.abs(this._vel1.x) + Math.abs(this._vel2.x);
1128-
// var overlap = (body1.radius + body2.radius) - Math.abs(body1.center.x - body2.center.x);
11291127
var overlap = (body1.radius + body2.radius) - Phaser.Math.distance(body1.center.x, body1.center.y, body2.center.x, body2.center.y);
11301128

11311129
// Resets the overlapR to zero if there is no overlap, or to the actual pixel value if there is
1132-
// body1.overlapR = (this._vel1.x / absV * overlap);
1133-
// body2.overlapR = (this._vel2.x / absV * overlap);
1134-
11351130
body1.overlapR = overlap * 0.5;
11361131
body2.overlapR = overlap * 0.5;
11371132

1138-
// console.log('overlapR', overlap, 'r', body1.overlapR, body2.overlapR);
1139-
11401133
// Can't separate two immovable bodies, or a body with its own custom separation logic
11411134
if (overlapOnly || overlap === 0 || (body1.immovable && body2.immovable) || body1.customSeparateX || body2.customSeparateX)
11421135
{
11431136
// return true if there was some overlap, otherwise false
11441137
return (overlap !== 0);
11451138
}
11461139

1147-
// Adjust their positions and velocities accordingly (if there was any overlap)
1148-
if (!body1.immovable && !body2.immovable)
1149-
{
1150-
// Equal separation
1151-
this._pos1.x += (this._vel1.x + body1.overlapR) * this.game.time.physicsElapsed;
1152-
this._pos2.x += (this._vel2.x + body2.overlapR) * this.game.time.physicsElapsed;
1153-
1154-
this._vel1.x = this._velF.x1 * body1.bounce.x;
1155-
this._vel1.y = this._velF.y1 * body1.bounce.y;
1156-
1157-
this._vel2.x = this._velF.x2 * body2.bounce.x;
1158-
this._vel2.y = this._velF.y2 * body2.bounce.y;
1159-
}
1160-
else if (body1.immovable)
1161-
{
1162-
this._pos2.x += (this._vel2.x * this.game.time.physicsElapsed) + overlap;
1163-
this._pos2.y += (this._vel2.y * this.game.time.physicsElapsed) + overlap;
1164-
}
1165-
else
1166-
{
1167-
this._pos1.x += (this._vel1.x * this.game.time.physicsElapsed) + overlap;
1168-
this._pos1.y += (this._vel1.y * this.game.time.physicsElapsed) + overlap;
1169-
}
1140+
this._pos1.x += (this._vel1.x * this.game.time.physicsElapsed) + overlap;
1141+
this._pos2.x += (this._vel2.x * this.game.time.physicsElapsed) + overlap;
11701142

11711143
// Rotate positions back again
11721144
this.rotate(this._pos1, this._pos1.x, this._pos1.y, sin, cos, false);
@@ -1178,49 +1150,17 @@ Phaser.Physics.Arcade.prototype = {
11781150

11791151
// Apply to bodies
11801152

1181-
// console.log('current pos1', body1.y);
1182-
// console.log('current pos2', body2.y);
1183-
11841153
body2.x = body1.x + this._pos2.x;
11851154
body2.y = body1.y + this._pos2.y;
11861155

11871156
body1.x = body1.x + this._pos1.x;
11881157
body1.y = body1.y + this._pos1.y;
11891158

1190-
// console.log('after pos1', body1.y);
1191-
// console.log('after pos2', body2.y);
1192-
1193-
if (!body1.immovable && !body2.immovable)
1194-
{
1195-
body1.velocity.x = this._vel1.x;
1196-
body1.velocity.y = this._vel1.y;
1197-
1198-
body2.velocity.x = this._vel2.x;
1199-
body2.velocity.y = this._vel2.y;
1200-
}
1201-
else if (body1.immovable)
1202-
{
1203-
// Only move body2
1204-
1205-
// console.log('current vel1', body1.velocity.y);
1206-
// console.log('current vel2', body2.velocity.y);
1207-
1208-
body2.velocity.x = body1.velocity.x - body2.velocity.x * body2.bounce.x;
1209-
body2.velocity.y = body1.velocity.y - body2.velocity.y * body2.bounce.y;
1210-
1211-
// console.log('new vel1', body1.velocity.y - body2.velocity.y * body2.bounce.y);
1212-
// console.log('new vel2', body2.velocity.y);
1213-
}
1214-
else
1215-
{
1216-
// Only move body1
1217-
1218-
body1.velocity.x = body2.velocity.x - body1.velocity.x * body1.bounce.x;
1219-
body1.velocity.y = body2.velocity.y - body1.velocity.y * body1.bounce.y;
1220-
}
1159+
body1.velocity.x = this._vel1.x;
1160+
body1.velocity.y = this._vel1.y;
12211161

1222-
// console.log('still intersects?', this.intersects(body1, body2));
1223-
// debugger;
1162+
body2.velocity.x = this._vel2.x;
1163+
body2.velocity.y = this._vel2.y;
12241164

12251165
return true;
12261166

0 commit comments

Comments
 (0)