Skip to content

Commit

Permalink
fixed Body.setVertices
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jun 3, 2014
1 parent 8746185 commit 73ded98
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/body/Body.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ var Body = {};
Body.setVertices(body, body.vertices);
Body.setStatic(body, body.isStatic);
Sleeping.set(body, body.isSleeping);
Vertices.rotate(body.vertices, body.angle, body.position);
Axes.rotate(body.axes, body.angle);

// allow options to override the automatically calculated properties
body.axes = options.axes || body.axes;
Expand Down Expand Up @@ -151,7 +153,11 @@ var Body = {};
*/
Body.setVertices = function(body, vertices) {
// change vertices
body.vertices = Vertices.create(vertices, body);
if (vertices[0].body === body) {
body.vertices = vertices;
} else {
body.vertices = Vertices.create(vertices, body);
}

// update properties
body.axes = Axes.fromVertices(body.vertices);
Expand All @@ -169,8 +175,8 @@ var Body = {};

// update geometry
Vertices.translate(body.vertices, body.position);
Vertices.rotate(body.vertices, body.angle, body.position);
Axes.rotate(body.axes, body.angle);
Bounds.update(body.bounds, body.vertices, body.velocity);
};
Bounds.update(body.bounds, body.vertices, body.velocity);
};

Expand Down

0 comments on commit 73ded98

Please sign in to comment.