Skip to content

Commit

Permalink
convert MassData to interface
Browse files Browse the repository at this point in the history
  • Loading branch information
shakiba committed Aug 23, 2023
1 parent 5b96d95 commit 9d86ecc
Show file tree
Hide file tree
Showing 120 changed files with 1,506 additions and 1,521 deletions.
22 changes: 14 additions & 8 deletions dist/planck-with-testbed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,11 +1390,11 @@ interface BodyDef {
/**
* MassData This holds the mass data computed for a shape.
*/
declare class MassData {
interface MassData {
/** The mass of the shape, usually in kilograms. */
mass: number;
/** The position of the shape's centroid relative to the shape's origin. */
center: Vec2;
center: Vec2Value;
/** The rotational inertia of the shape about the local origin. */
I: number;
}
Expand Down Expand Up @@ -1651,8 +1651,11 @@ declare class Body {
*/
applyAngularImpulse(impulse: number, wake?: boolean): void;
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
shouldCollide(that: Body): boolean;
/**
Expand Down Expand Up @@ -5599,11 +5602,11 @@ declare namespace planck {
/**
* MassData This holds the mass data computed for a shape.
*/
class MassData {
interface MassData {
/** The mass of the shape, usually in kilograms. */
mass: number;
/** The position of the shape's centroid relative to the shape's origin. */
center: Vec2;
center: Vec2Value;
/** The rotational inertia of the shape about the local origin. */
I: number;
}
Expand Down Expand Up @@ -5860,8 +5863,11 @@ declare namespace planck {
*/
applyAngularImpulse(impulse: number, wake?: boolean): void;
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
shouldCollide(that: Body): boolean;
/**
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.d.ts.map

Large diffs are not rendered by default.

33 changes: 12 additions & 21 deletions dist/planck-with-testbed.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.0.0-beta.10
* Planck.js v1.0.0-beta.11
* @license The MIT license
* @copyright Copyright (c) 2021 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -3436,20 +3436,6 @@
active: true,
userData: null
};
/**
* MassData This holds the mass data computed for a shape.
*/
var MassData = /** @class */ (function () {
function MassData() {
/** The mass of the shape, usually in kilograms. */
this.mass = 0;
/** The position of the shape's centroid relative to the shape's origin. */
this.center = Vec2.zero();
/** The rotational inertia of the shape about the local origin. */
this.I = 0;
}
return MassData;
}());
/**
* A rigid body composed of one or more fixtures.
*
Expand Down Expand Up @@ -3910,7 +3896,7 @@
Body.prototype.getMassData = function (data) {
data.mass = this.m_mass;
data.I = this.getInertia();
data.center.setVec2(this.m_sweep.localCenter);
copyVec2(data.center, this.m_sweep.localCenter);
};
/**
* This resets the mass properties to the sum of the mass properties of the
Expand All @@ -3937,7 +3923,11 @@
if (f.m_density == 0.0) {
continue;
}
var massData = new MassData();
var massData = {
mass: 0,
center: vec2(0, 0),
I: 0
};
f.getMassData(massData);
this.m_mass += massData.mass;
addMulVec2(localCenter, massData.mass, massData.center);
Expand Down Expand Up @@ -4108,8 +4098,11 @@
}
};
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
Body.prototype.shouldCollide = function (that) {
// At least one body should be dynamic.
Expand Down Expand Up @@ -19360,7 +19353,6 @@
Shape: Shape,
FixtureProxy: FixtureProxy,
Fixture: Fixture,
MassData: MassData,
Body: Body,
ContactEdge: ContactEdge,
mixFriction: mixFriction,
Expand Down Expand Up @@ -19461,7 +19453,6 @@
exports.JointEdge = JointEdge;
exports.Manifold = Manifold;
exports.ManifoldPoint = ManifoldPoint;
exports.MassData = MassData;
exports.Mat22 = Mat22;
exports.Mat33 = Mat33;
exports.Math = math$1;
Expand Down
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/planck-with-testbed.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/planck-with-testbed.min.js.map

Large diffs are not rendered by default.

34 changes: 13 additions & 21 deletions dist/planck-with-testbed.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Planck.js v1.0.0-beta.10
* Planck.js v1.0.0-beta.11
* @license The MIT license
* @copyright Copyright (c) 2021 Erin Catto, Ali Shakiba
*
Expand Down Expand Up @@ -3430,20 +3430,6 @@ var Fixture = /** @class */ (function () {
active: true,
userData: null
};
/**
* MassData This holds the mass data computed for a shape.
*/
var MassData = /** @class */ (function () {
function MassData() {
/** The mass of the shape, usually in kilograms. */
this.mass = 0;
/** The position of the shape's centroid relative to the shape's origin. */
this.center = Vec2.zero();
/** The rotational inertia of the shape about the local origin. */
this.I = 0;
}
return MassData;
}());
/**
* A rigid body composed of one or more fixtures.
*
Expand Down Expand Up @@ -3904,7 +3890,7 @@ var Body = /** @class */ (function () {
Body.prototype.getMassData = function (data) {
data.mass = this.m_mass;
data.I = this.getInertia();
data.center.setVec2(this.m_sweep.localCenter);
copyVec2(data.center, this.m_sweep.localCenter);
};
/**
* This resets the mass properties to the sum of the mass properties of the
Expand All @@ -3931,7 +3917,11 @@ var Body = /** @class */ (function () {
if (f.m_density == 0.0) {
continue;
}
var massData = new MassData();
var massData = {
mass: 0,
center: vec2(0, 0),
I: 0
};
f.getMassData(massData);
this.m_mass += massData.mass;
addMulVec2(localCenter, massData.mass, massData.center);
Expand Down Expand Up @@ -4102,8 +4092,11 @@ var Body = /** @class */ (function () {
}
};
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
Body.prototype.shouldCollide = function (that) {
// At least one body should be dynamic.
Expand Down Expand Up @@ -19354,7 +19347,6 @@ var planck = /*#__PURE__*/Object.freeze({
Shape: Shape,
FixtureProxy: FixtureProxy,
Fixture: Fixture,
MassData: MassData,
Body: Body,
ContactEdge: ContactEdge,
mixFriction: mixFriction,
Expand Down Expand Up @@ -19422,5 +19414,5 @@ var planck = /*#__PURE__*/Object.freeze({
internal: internal
});

export { AABB, Body, Box, BoxShape, Chain, ChainShape, Circle, CircleShape, ClipVertex, CollideCircles, CollideEdgeCircle, CollideEdgePolygon, CollidePolygonCircle, CollidePolygons, Contact, ContactEdge, ContactFeatureType, ContactID, Distance, DistanceInput, DistanceJoint, DistanceOutput, DistanceProxy, DynamicTree, Edge, EdgeShape, Fixture, FixtureProxy, FrictionJoint, GearJoint, Joint, JointEdge, Manifold, ManifoldPoint, ManifoldType, MassData, Mat22, Mat33, math$1 as Math, MotorJoint, MouseJoint, PointState, Polygon, PolygonShape, PrismaticJoint, PulleyJoint, RevoluteJoint, RopeJoint, Rot, Serializer, Settings, SettingsInternal, Shape, ShapeCast, ShapeCastInput, ShapeCastOutput, SimplexCache, Sweep, TOIInput, TOIOutput, TOIOutputState, Testbed, TimeOfImpact, Transform, TreeNode, Vec2, Vec3, VelocityConstraintPoint, WeldJoint, WheelJoint, World, WorldManifold, clipSegmentToLine, planck as default, getPointStates, internal, mixFriction, mixRestitution, stats$1 as stats, testOverlap, testbed };
export { AABB, Body, Box, BoxShape, Chain, ChainShape, Circle, CircleShape, ClipVertex, CollideCircles, CollideEdgeCircle, CollideEdgePolygon, CollidePolygonCircle, CollidePolygons, Contact, ContactEdge, ContactFeatureType, ContactID, Distance, DistanceInput, DistanceJoint, DistanceOutput, DistanceProxy, DynamicTree, Edge, EdgeShape, Fixture, FixtureProxy, FrictionJoint, GearJoint, Joint, JointEdge, Manifold, ManifoldPoint, ManifoldType, Mat22, Mat33, math$1 as Math, MotorJoint, MouseJoint, PointState, Polygon, PolygonShape, PrismaticJoint, PulleyJoint, RevoluteJoint, RopeJoint, Rot, Serializer, Settings, SettingsInternal, Shape, ShapeCast, ShapeCastInput, ShapeCastOutput, SimplexCache, Sweep, TOIInput, TOIOutput, TOIOutputState, Testbed, TimeOfImpact, Transform, TreeNode, Vec2, Vec3, VelocityConstraintPoint, WeldJoint, WheelJoint, World, WorldManifold, clipSegmentToLine, planck as default, getPointStates, internal, mixFriction, mixRestitution, stats$1 as stats, testOverlap, testbed };
//# sourceMappingURL=planck-with-testbed.mjs.map
2 changes: 1 addition & 1 deletion dist/planck-with-testbed.mjs.map

Large diffs are not rendered by default.

22 changes: 14 additions & 8 deletions dist/planck.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1390,11 +1390,11 @@ interface BodyDef {
/**
* MassData This holds the mass data computed for a shape.
*/
declare class MassData {
interface MassData {
/** The mass of the shape, usually in kilograms. */
mass: number;
/** The position of the shape's centroid relative to the shape's origin. */
center: Vec2;
center: Vec2Value;
/** The rotational inertia of the shape about the local origin. */
I: number;
}
Expand Down Expand Up @@ -1651,8 +1651,11 @@ declare class Body {
*/
applyAngularImpulse(impulse: number, wake?: boolean): void;
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
shouldCollide(that: Body): boolean;
/**
Expand Down Expand Up @@ -7533,11 +7536,11 @@ declare namespace planck {
/**
* MassData This holds the mass data computed for a shape.
*/
class MassData {
interface MassData {
/** The mass of the shape, usually in kilograms. */
mass: number;
/** The position of the shape's centroid relative to the shape's origin. */
center: Vec2;
center: Vec2Value;
/** The rotational inertia of the shape about the local origin. */
I: number;
}
Expand Down Expand Up @@ -7794,8 +7797,11 @@ declare namespace planck {
*/
applyAngularImpulse(impulse: number, wake?: boolean): void;
/**
* This is used to prevent connected bodies (by joints) from colliding,
* depending on the joint's collideConnected flag.
* This is used to test if two bodies should collide.
*
* Bodies do not collide when:
* - Neither of them is dynamic
* - They are connected by a joint with collideConnected == false
*/
shouldCollide(that: Body): boolean;
/**
Expand Down
Loading

0 comments on commit 9d86ecc

Please sign in to comment.