Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions dist/PhaserBox2D-Debug.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
* Phaser Box2D v1.1.0
* Wednesday 1 January 2025 at 15:57
* Sunday, 6 April 2025 at 03:26
*
* This library includes code that is ported from the original C version. The original C code is Copyright 2023 Erin Catto
* and was released under the MIT license. The JavaScript port of the C code along with all additional code is
Expand Down Expand Up @@ -459,7 +459,7 @@ function b2SetAssertFcn(assertFcn) {
console.warn("b2SetAssertFcn not supported");
}
function b2GetVersion() {
return new b2Version(3, 0, 0);
return new b2Version(3, 1, 0);
}

// src/include/core_h.js
Expand Down Expand Up @@ -2622,10 +2622,10 @@ function b2MakeRoundedBox(hx, hy, radius) {
shape.radius = radius;
return shape;
}
function b2MakeOffsetBox(hx, hy, center, angle = 0) {
function b2MakeOffsetBox(hx, hy, center, rotation) {
const xf2 = new b2Transform();
xf2.p = center;
xf2.q = b2MakeRot(angle);
xf2.q = rotation;
const shape = new b2Polygon();
shape.count = 4;
shape.vertices[0] = b2TransformPoint(xf2, new b2Vec2(-hx, -hy));
Expand Down Expand Up @@ -3142,7 +3142,7 @@ function b2CreateShapeInternal(world, body, transform, def, geometry, shapeType)
shape.revision += 1;
if (body.setIndex != b2SetType.b2_disabledSet) {
const proxyType = body.type;
b2CreateShapeProxy(shape, world.broadPhase, proxyType, transform, def.forceContactCreation);
b2CreateShapeProxy(shape, world.broadPhase, proxyType, transform, def.forceContactCreation || def.isSensor);
}
if (body.headShapeId != B2_NULL_INDEX) {
const headShape = world.shapeArray[body.headShapeId];
Expand Down Expand Up @@ -7086,12 +7086,12 @@ function b2DistanceJoint_SetSpringDampingRatio(jointId, dampingRatio) {
const base = b2GetJointSimCheckType(jointId, b2JointType.b2_distanceJoint);
base.distanceJoint.dampingRatio = dampingRatio;
}
function b2DistanceJoint_GetHertz(jointId) {
function b2DistanceJoint_GetSpringHertz(jointId) {
const base = b2GetJointSimCheckType(jointId, b2JointType.b2_distanceJoint);
const joint = base.distanceJoint;
return joint.hertz;
}
function b2DistanceJoint_GetDampingRatio(jointId) {
function b2DistanceJoint_GetSpringDampingRatio(jointId) {
const base = b2GetJointSimCheckType(jointId, b2JointType.b2_distanceJoint);
const joint = base.distanceJoint;
return joint.dampingRatio;
Expand Down Expand Up @@ -8940,7 +8940,7 @@ function b2CreateJoint(world, bodyA, bodyB, userData, drawSize, type, collideCon
const bodyIdB = bodyB.id;
const maxSetIndex = Math.max(bodyA.setIndex, bodyB.setIndex);
const jointId = b2AllocId(world.jointIdPool);
console.assert(jointId != B2_NULL_INDEX);
console.assert(jointId !== B2_NULL_INDEX);
while (jointId >= world.jointArray.length) {
world.jointArray.push(new b2Joint());
}
Expand Down Expand Up @@ -9030,7 +9030,8 @@ function b2CreateJoint(world, bodyA, bodyB, userData, drawSize, type, collideCon
console.assert(jointSim.bodyIdA === bodyIdA);
console.assert(jointSim.bodyIdB === bodyIdB);
if (joint.setIndex > b2SetType.b2_disabledSet) {
b2LinkJoint(world, joint);
const mergeIslands = true;
b2LinkJoint(world, joint, mergeIslands);
}
b2ValidateSolverSets(world);
return new b2JointPair(joint, jointSim);
Expand Down Expand Up @@ -9318,7 +9319,9 @@ function b2DestroyJointInternal(world, joint, wakeBodies) {
bodyB.headJointKey = edgeB.nextKey;
}
bodyB.jointCount -= 1;
b2UnlinkJoint(world, joint);
if (joint.islandId !== B2_NULL_INDEX) {
b2UnlinkJoint(world, joint);
}
const setIndex = joint.setIndex;
const localIndex = joint.localIndex;
if (setIndex === b2SetType.b2_awakeSet) {
Expand Down Expand Up @@ -10251,7 +10254,7 @@ function b2AddJointToIsland(world, islandId, joint) {
joint.islandId = islandId;
b2ValidateIsland(world, islandId);
}
function b2LinkJoint(world, joint) {
function b2LinkJoint(world, joint, mergeIslands) {
const bodyA = b2GetBody(world, joint.edges[0].bodyId);
const bodyB = b2GetBody(world, joint.edges[1].bodyId);
if (bodyA.setIndex === b2SetType.b2_awakeSet && bodyB.setIndex >= b2SetType.b2_firstSleepingSet) {
Expand Down Expand Up @@ -10301,6 +10304,9 @@ function b2LinkJoint(world, joint) {
} else {
b2AddJointToIsland(world, islandIdB, joint);
}
if (mergeIslands) {
b2MergeAwakeIslands(world);
}
}
function b2UnlinkJoint(world, joint) {
console.assert(joint.islandId !== B2_NULL_INDEX);
Expand Down Expand Up @@ -11407,11 +11413,11 @@ function b2Body_SetType(bodyId, type) {
if (body.type === b2BodyType.b2_staticBody && otherBody.type === b2BodyType.b2_staticBody) {
continue;
}
b2LinkJoint(world, joint);
b2LinkJoint(world, joint, false);
}
b2MergeAwakeIslands(world);
}
b2UpdateBodyMassData(world, body);
b2ValidateConnectivity(world);
b2ValidateSolverSets(world);
}
function b2Body_SetUserData(bodyId, userData) {
Expand All @@ -11430,7 +11436,7 @@ function b2Body_GetMass(bodyId) {
const bodySim = b2GetBodySim(world, body);
return bodySim.mass;
}
function b2Body_GetInertiaTensor(bodyId) {
function b2Body_GetRotationalInertia(bodyId) {
const world = b2GetWorld(bodyId.world0);
const body = b2GetBodyFullId(world, bodyId);
const bodySim = b2GetBodySim(world, body);
Expand Down Expand Up @@ -11567,10 +11573,10 @@ function b2Body_IsSleepEnabled(bodyId) {
const body = b2GetBodyFullId(world, bodyId);
return body.enableSleep;
}
function b2Body_SetSleepThreshold(bodyId, sleepVelocity) {
function b2Body_SetSleepThreshold(bodyId, sleepThreshold) {
const world = b2GetWorld(bodyId.world0);
const body = b2GetBodyFullId(world, bodyId);
body.sleepThreshold = sleepVelocity;
body.sleepThreshold = sleepThreshold;
}
function b2Body_GetSleepThreshold(bodyId) {
const world = b2GetWorld(bodyId.world0);
Expand Down Expand Up @@ -11653,6 +11659,7 @@ function b2Body_Enable(bodyId) {
if (setId !== b2SetType.b2_staticSet) {
b2CreateIslandForBody(world, setId, body);
}
const mergeIslands = false;
let jointKey = body.headJointKey;
while (jointKey !== B2_NULL_INDEX) {
const jointId = jointKey >> 1;
Expand All @@ -11677,10 +11684,10 @@ function b2Body_Enable(bodyId) {
const jointSet = world.solverSetArray[jointSetId];
b2TransferJoint(world, jointSet, disabledSet, joint);
if (jointSetId !== b2SetType.b2_staticSet) {
b2LinkJoint(world, joint);
b2LinkJoint(world, joint, mergeIslands);
}
}
b2ValidateConnectivity(world);
b2MergeAwakeIslands(world);
b2ValidateSolverSets(world);
}
function b2Body_SetFixedRotation(bodyId, flag) {
Expand Down Expand Up @@ -12128,7 +12135,8 @@ var p2 = new b2Vec2();
var q1 = new b2Vec2();
var q2 = new b2Vec2();
function b2MakeCapsule(p14, p23, radius) {
const axis = b2NormalizeChecked(b2Sub(p23, p14));
const d = b2Sub(p23, p14);
const axis = b2Normalize(d);
const normal = b2RightPerp(axis);
const shape = new b2Polygon();
shape.vertices = [p14, p23];
Expand Down Expand Up @@ -16201,7 +16209,7 @@ function CreateBoxPolygon(data) {
let box;
if (data.size instanceof b2Vec2) {
if (data.bodyId) {
box = b2MakeOffsetBox(data.size.x, data.size.y, data.position, 0);
box = b2MakeOffsetBox(data.size.x, data.size.y, data.position, b2MakeRot(0));
} else {
box = b2MakeBox(data.size.x, data.size.y);
}
Expand Down Expand Up @@ -17465,7 +17473,6 @@ export {
b2Body_GetContactCapacity,
b2Body_GetContactData,
b2Body_GetGravityScale,
b2Body_GetInertiaTensor,
b2Body_GetJointCount,
b2Body_GetJoints,
b2Body_GetLinearDamping,
Expand All @@ -17477,6 +17484,7 @@ export {
b2Body_GetMassData,
b2Body_GetPosition,
b2Body_GetRotation,
b2Body_GetRotationalInertia,
b2Body_GetShapeCount,
b2Body_GetShapes,
b2Body_GetSleepThreshold,
Expand Down Expand Up @@ -17586,14 +17594,14 @@ export {
b2DistanceJoint_EnableMotor,
b2DistanceJoint_EnableSpring,
b2DistanceJoint_GetCurrentLength,
b2DistanceJoint_GetDampingRatio,
b2DistanceJoint_GetHertz,
b2DistanceJoint_GetLength,
b2DistanceJoint_GetMaxLength,
b2DistanceJoint_GetMaxMotorForce,
b2DistanceJoint_GetMinLength,
b2DistanceJoint_GetMotorForce,
b2DistanceJoint_GetMotorSpeed,
b2DistanceJoint_GetSpringDampingRatio,
b2DistanceJoint_GetSpringHertz,
b2DistanceJoint_IsLimitEnabled,
b2DistanceJoint_IsMotorEnabled,
b2DistanceJoint_IsSpringEnabled,
Expand Down
4 changes: 2 additions & 2 deletions dist/PhaserBox2D-Debug.js.map

Large diffs are not rendered by default.

Loading