Skip to content

Commit

Permalink
Fixed a couple bugs in the constraint graph
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Jan 14, 2012
1 parent 86568f6 commit a0f65f9
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
21 changes: 12 additions & 9 deletions cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ var assertSoft = function(value, message)
{
if(!value && console && console.warn) {
console.warn("ASSERTION FAILED: " + message);
if(console.trace) {
console.trace();
}
}
};

Expand Down Expand Up @@ -3954,13 +3957,13 @@ Body.prototype.pushArbiter = function(arb)
assertSoft(next === null || (next.body_a === this ? next.thread_a_prev : next.thread_b_prev) === null,
"Internal Error: Dangling contact graph pointers detected. (C)");

if(arb.body_a === this){
arb.thread_a_next = next;
} else {
arb.thread_b_next = next;
}

if(next){
if(arb.body_a === this){
arb.thread_a_next = next;
} else {
arb.thread_b_next = next;
}

if (next.body_a === this){
next.thread_a_prev = arb;
} else {
Expand Down Expand Up @@ -3990,7 +3993,7 @@ var floodFillComponent = function(root, body)
for(var arb = body.arbiterList; arb; arb = arb.next(body)){
floodFillComponent(root, (body == arb.body_a ? arb.body_b : arb.body_a));
}
for(var constraint = body.constraintList; constraint; constraint = constraint.nodeNext){
for(var constraint = body.constraintList; constraint; constraint = constraint.next(body)){
floodFillComponent(root, (body == constraint.a ? constraint.b : constraint.a));
}
} else {
Expand All @@ -4013,7 +4016,7 @@ Space.prototype.processComponents = function(dt)
var sleep = (this.sleepTimeThreshold !== Infinity);
var bodies = this.bodies;

// This can be removed if we have debugging turned off.
// These checks can be removed at some stage (if DEBUG == undefined)
for(var i=0; i<bodies.length; i++){
var body = bodies[i];

Expand Down Expand Up @@ -4076,7 +4079,7 @@ Space.prototype.processComponents = function(dt)
this.deactivateBody(other);
}

// cpSpaceDeactivateBody() removed the current body from the list.
// deactivateBody() removed the current body from the list.
// Skip incrementing the index counter.
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions cp.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions lib/chipmunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var assertSoft = function(value, message)
{
if(!value && console && console.warn) {
console.warn("ASSERTION FAILED: " + message);
if(console.trace) {
console.trace();
}
}
};

Expand Down
18 changes: 9 additions & 9 deletions lib/cpSpaceComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,13 @@ Body.prototype.pushArbiter = function(arb)
assertSoft(next === null || (next.body_a === this ? next.thread_a_prev : next.thread_b_prev) === null,
"Internal Error: Dangling contact graph pointers detected. (C)");

if(arb.body_a === this){
arb.thread_a_next = next;
} else {
arb.thread_b_next = next;
}

if(next){
if(arb.body_a === this){
arb.thread_a_next = next;
} else {
arb.thread_b_next = next;
}

if (next.body_a === this){
next.thread_a_prev = arb;
} else {
Expand Down Expand Up @@ -190,7 +190,7 @@ var floodFillComponent = function(root, body)
for(var arb = body.arbiterList; arb; arb = arb.next(body)){
floodFillComponent(root, (body == arb.body_a ? arb.body_b : arb.body_a));
}
for(var constraint = body.constraintList; constraint; constraint = constraint.nodeNext){
for(var constraint = body.constraintList; constraint; constraint = constraint.next(body)){
floodFillComponent(root, (body == constraint.a ? constraint.b : constraint.a));
}
} else {
Expand All @@ -213,7 +213,7 @@ Space.prototype.processComponents = function(dt)
var sleep = (this.sleepTimeThreshold !== Infinity);
var bodies = this.bodies;

// This can be removed if we have debugging turned off.
// These checks can be removed at some stage (if DEBUG == undefined)
for(var i=0; i<bodies.length; i++){
var body = bodies[i];

Expand Down Expand Up @@ -276,7 +276,7 @@ Space.prototype.processComponents = function(dt)
this.deactivateBody(other);
}

// cpSpaceDeactivateBody() removed the current body from the list.
// deactivateBody() removed the current body from the list.
// Skip incrementing the index counter.
continue;
}
Expand Down

0 comments on commit a0f65f9

Please sign in to comment.