Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistent Bodies.fromVertices behavior #1178

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
19 changes: 11 additions & 8 deletions build/matter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4655,8 +4655,10 @@ var Common = __webpack_require__(0);
*/
Constraint.pointAWorld = function(constraint) {
return {
x: (constraint.bodyA ? constraint.bodyA.position.x : 0) + constraint.pointA.x,
y: (constraint.bodyA ? constraint.bodyA.position.y : 0) + constraint.pointA.y
x: (constraint.bodyA ? constraint.bodyA.position.x : 0)
+ (constraint.pointA ? constraint.pointA.x : 0),
y: (constraint.bodyA ? constraint.bodyA.position.y : 0)
+ (constraint.pointA ? constraint.pointA.y : 0)
};
};

Expand All @@ -4668,8 +4670,10 @@ var Common = __webpack_require__(0);
*/
Constraint.pointBWorld = function(constraint) {
return {
x: (constraint.bodyB ? constraint.bodyB.position.x : 0) + constraint.pointB.x,
y: (constraint.bodyB ? constraint.bodyB.position.y : 0) + constraint.pointB.y
x: (constraint.bodyB ? constraint.bodyB.position.x : 0)
+ (constraint.pointB ? constraint.pointB.x : 0),
y: (constraint.bodyB ? constraint.bodyB.position.y : 0)
+ (constraint.pointB ? constraint.pointB.y : 0)
};
};

Expand Down Expand Up @@ -5161,7 +5165,7 @@ var Vector = __webpack_require__(2);
}

parts.push({
position: { x: x, y: y },
position: Vertices.centre(vertices),
vertices: vertices
});
} else {
Expand Down Expand Up @@ -6070,7 +6074,6 @@ var Mouse = __webpack_require__(13);
*/
Render.create = function(options) {
var defaults = {
controller: Render,
engine: null,
element: null,
canvas: null,
Expand Down Expand Up @@ -6142,6 +6145,7 @@ var Mouse = __webpack_require__(13);
};

// for temporary back compatibility only
render.controller = Render;
render.options.showBroadphase = false;

if (render.options.pixelRatio !== 1) {
Expand All @@ -6150,8 +6154,6 @@ var Mouse = __webpack_require__(13);

if (Common.isElement(render.element)) {
render.element.appendChild(render.canvas);
} else if (!render.canvas.parentNode) {
Common.log('Render.create: options.element was undefined, render.canvas was created but not appended', 'warn');
}

return render;
Expand Down Expand Up @@ -7551,6 +7553,7 @@ var Mouse = __webpack_require__(13);
/**
* A back-reference to the `Matter.Render` module.
*
* @deprecated
* @property controller
* @type render
*/
Expand Down
2 changes: 1 addition & 1 deletion build/matter.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/factory/Bodies.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ var Vector = require('../geometry/Vector');
}

parts.push({
position: { x: x, y: y },
position: Vertices.centre(vertices),
vertices: vertices
});
} else {
Expand Down