Permalink
Browse files

Fixed namespace typo in VerletPhysics2D that was causing an error whe…

…never gravity was specified in the constructor.
  • Loading branch information...
1 parent 6c6c7c6 commit 1e80f63dae71c0b87b0c0b52ff6ada8ef9a630f1 @tkdave tkdave committed Aug 8, 2011
Showing with 2 additions and 2 deletions.
  1. +1 −1 build/toxiclibs.js
  2. +1 −1 src/physics/physics2d/VerletPhysics2D.js
View
@@ -264,7 +264,7 @@ toxi.physics2d.PullBackString2D=function(e,g,h){toxi.physics2d.VerletSpring2D.ca
toxi.physics2d.VerletConstrainedSpring2D=function(e,g,h,i,j){toxi.physics2d.VerletSpring2D.call(this,e,g,h,i);this.limit=j===undefined?Number.MAX_VALUE:j};toxi.extend(toxi.physics2d.VerletConstrainedSpring2D,toxi.physics2d.VerletSpring2D);
toxi.physics2d.VerletConstrainedSpring2D.update=function(e){var g=this.b.sub(this.a),h=g.magnitude()+toxi.physics2d.VerletSpring2D.EPS;h=(h-this.restLength)/(h*(this.a.invWeight+this.b.invWeight))*this.strength;if(!this.a.isLocked&&!this.isALocked){this.a.addSelf(g.scale(h*this.a.invWeight).limit(this.limit));e&&this.a.applyConstraints()}if(!this.b.isLocked&&!this.isBLocked){this.b.subSelf(g.scale(h*this.b.invWeight).limit(this.limit));e&&this.b.applyConstraints()}};
toxi.physics2d.VerletMinDistanceSpring2D=function(e,g,h,i){toxi.physics2d.VerletSpring2D.call(this,e,g,h,i);this.setRestLength(h)};toxi.extend(toxi.physics2d.VerletMinDistanceSpring2D,toxi.physics2d.VerletSpring2D);toxi.physics2d.VerletMinDistanceSpring2D.prototype.update=function(e){this.b.distanceToSquared(this.a)<this.restLengthSquared&&this.parent.update.call(this,e)};
-toxi.physics2d.VerletPhysics2D=function(e,g,h,i){this.behaviors=[];this.particles=[];this.springs=[];this.numIterations=g===undefined?50:g;this.timeStep=i===undefined?1:i;this.setDrag(h||0);e!==undefined&&this.addBehavior(new toxi.physics.GravityBehavior(e))};toxi.physics2d.VerletPhysics2D.addConstraintToAll=function(e,g){for(var h=0;h<g.length;h++)g[h].addConstraint(e)};toxi.physics2d.VerletPhysics2D.removeConstraintFromAll=function(e,g){for(var h=0;h<g.length;h++)g[h].removeConstraint(e)};
+toxi.physics2d.VerletPhysics2D=function(e,g,h,i){this.behaviors=[];this.particles=[];this.springs=[];this.numIterations=g===undefined?50:g;this.timeStep=i===undefined?1:i;this.setDrag(h||0);e!==undefined&&this.addBehavior(new toxi.physics2d.GravityBehavior(e))};toxi.physics2d.VerletPhysics2D.addConstraintToAll=function(e,g){for(var h=0;h<g.length;h++)g[h].addConstraint(e)};toxi.physics2d.VerletPhysics2D.removeConstraintFromAll=function(e,g){for(var h=0;h<g.length;h++)g[h].removeConstraint(e)};
toxi.physics2d.VerletPhysics2D.prototype={addBehavior:function(e){if(e===undefined)throw{name:"TypeError",message:"Incorrect Parameters for toxi.physics2d.VerletPhysics2D addBehavior"};e.configure(this.timeStep);this.behaviors.push(e)},addParticle:function(e){this.particles.push(e);return this},addSpring:function(e){this.getSpring(e.a,e.b)===undefined&&this.springs.push(e);return this},clear:function(){this.particles=[];this.springs=[];return this},constrainToBounds:function(){var e=undefined,g=0;
for(g=0;g<this.particles.length;g++){e=this.particles[g];e.bounds!==undefined&&e.constrain(e.bounds)}if(this.worldBounds!==undefined)for(g=0;g<this.particles.length;g++){e=this.particles[g];e.constrain(this.worldBounds)}},getCurrentBounds:function(){var e=new toxi.Vec2D(Number.MAX_VALUE,Number.MAX_VALUE),g=new toxi.Vec2D(Number.MIN_VALUE,Number.MIN_VALUE),h=0,i=undefined;for(h=0;h<this.particles.length;h++){i=this.particles[h];e.minSelf(i);g.maxSelf(i)}return new toxi.Rect(e,g)},getDrag:function(){return 1-
this.drag},getNumIterations:function(){return this.numIterations},getSpring:function(e,g){var h=0;for(h=0;h<this.springs.length;h++){var i=this.springs[h];if(i.a===e&&i.b===g||i.a===g&&i.b===g)return i}},getTimeStep:function(){return this.timeStep},getWorldBounds:function(){return this.worldBounds},removeBehavior:function(e){return toxi.physics2d.removeItemFrom(e,this.behaviors)},removeParticle:function(e){return toxi.physics2d.removeItemFrom(e,this.particles)},removeSpring:function(e){return toxi.physics2d.removeItemFrom(e,
@@ -7,7 +7,7 @@ toxi.physics2d.VerletPhysics2D = function(gravity, numIterations, drag, timeStep
this.setDrag(drag || 0);
if(gravity !== undefined){
- this.addBehavior(new toxi.physics.GravityBehavior(gravity));
+ this.addBehavior(new toxi.physics2d.GravityBehavior(gravity));
}
}

0 comments on commit 1e80f63

Please sign in to comment.