Skip to content

Commit 4935a4e

Browse files
committed
RevoluteConstraint fixed for new version of p2.
1 parent b25bdf3 commit 4935a4e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Version 2.1.0 - "Cairhien" - -in development-
7676
### p2.js changes
7777

7878
* DistanceConstraint signature changed to take the new localAnchors.
79-
*
79+
* RevoluteConstraint signature changed to include worldPivot
8080

8181
### New Features
8282

src/physics/p2/RevoluteConstraint.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616
* @param {Float32Array} pivotA - The point relative to the center of mass of bodyA which bodyA is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32].
1717
* @param {p2.Body} bodyB - Second connected body.
1818
* @param {Float32Array} pivotB - The point relative to the center of mass of bodyB which bodyB is constrained to. The value is an array with 2 elements matching x and y, i.e: [32, 32].
19+
* @param {Float32Array} [worldPivot] - A pivot point given in world coordinates. If specified, localPivotA and localPivotB are automatically computed from this value.
1920
* @param {number} [maxForce=0] - The maximum force that should be applied to constrain the bodies.
2021
*/
21-
Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pivotB, maxForce) {
22+
Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pivotB, worldPivot, maxForce) {
2223

24+
if (typeof worldPivot === 'undefined') { worldPivot = null; }
2325
if (typeof maxForce === 'undefined') { maxForce = Number.MAX_VALUE; }
2426

2527
/**
@@ -35,7 +37,9 @@ Phaser.Physics.P2.RevoluteConstraint = function (world, bodyA, pivotA, bodyB, pi
3537
pivotA = [ world.pxmi(pivotA[0]), world.pxmi(pivotA[1]) ];
3638
pivotB = [ world.pxmi(pivotB[0]), world.pxmi(pivotB[1]) ];
3739

38-
p2.RevoluteConstraint.call(this, bodyA, pivotA, bodyB, pivotB, {maxForce: maxForce});
40+
var options = { worldPivot: worldPivot, localPivotA: pivotA, localPivotB: pivotB, maxForce: maxForce };
41+
42+
p2.RevoluteConstraint.call(this, bodyA, bodyB, options);
3943

4044
};
4145

0 commit comments

Comments
 (0)