Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fix Body.getVelAtPoint etc and (hopefully) Body.eachConstraint #9

Merged
merged 1 commit into from

2 participants

@tnovelli

BTW, I don't have any code to test .eachConstraint... in the C version I see func(body, constraint, data); but in your port it's func(constraint); -- should that be this.call(constraint) ? Gahhh, OO strikes again...

@nornagon
Collaborator

Nope, just func(constraint). The rest of the information will be available in the closure of func, because JavaScript is awesome and has closures.

@nornagon nornagon merged commit d0a855b into josephg:master
@nornagon
Collaborator

PS thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/cpBody.js
View
8 lib/cpBody.js
@@ -292,19 +292,19 @@ Body.prototype.applyImpulse = function(j, r)
Body.prototype.getVelAtPoint = function(r)
{
- return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), body.w));
+ return vadd(new Vect(this.vx, this.vy), vmult(vperp(r), this.w));
};
/// Get the velocity on a body (in world units) at a point on the body in world coordinates.
Body.prototype.getVelAtWorldPoint = function(point)
{
- return this.getVelAtPoint(vsub(point, body.p));
+ return this.getVelAtPoint(vsub(point, this.p));
};
/// Get the velocity on a body (in world units) at a point on the body in local coordinates.
Body.prototype.getVelAtLocalPoint = function(point)
{
- return this.getVelAtPoint(vrotate(point, body.rot));
+ return this.getVelAtPoint(vrotate(point, this.rot));
};
Body.prototype.eachShape = function(func)
@@ -318,7 +318,7 @@ Body.prototype.eachConstraint = function(func)
{
var constraint = this.constraintList;
while(constraint) {
- var next = constraint.next(body);
+ var next = constraint.next(this);
func(constraint);
constraint = next;
}
Something went wrong with that request. Please try again.