Skip to content

Commit

Permalink
minor code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed Nov 21, 2015
1 parent 187c786 commit 0aa83c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/material/ContactMaterial.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,52 +48,55 @@ function ContactMaterial(materialA, materialB, options){
this.materialB = materialB;

/**
* Friction to use in the contact of these two materials
* Friction coefficient to use in the contact of these two materials. Friction = 0 will make the involved objects super slippery, and friction = 1 will make it much less slippery. A friction coefficient larger than 1 will allow for very large friction forces, which can be convenient for preventing car tires not slip on the ground.
* @property friction
* @type {Number}
* @default 0.3
*/
this.friction = typeof(options.friction) !== "undefined" ? Number(options.friction) : 0.3;
this.friction = typeof(options.friction) !== "undefined" ? Number(options.friction) : 0.3;

/**
* Restitution to use in the contact of these two materials
* Restitution, or "bounciness" to use in the contact of these two materials. A restitution of 0 will make no bounce, while restitution=1 will approximately bounce back with the same velocity the object came with.
* @property restitution
* @type {Number}
* @default 0
*/
this.restitution = typeof(options.restitution) !== "undefined" ? Number(options.restitution) : 0.0;
this.restitution = typeof(options.restitution) !== "undefined" ? Number(options.restitution) : 0;

/**
* Stiffness of the resulting ContactEquation that this ContactMaterial generate
* Hardness of the contact. Less stiffness will make the objects penetrate more, and will make the contact act more like a spring than a contact force. Default value is {{#crossLink "Equation/DEFAULT_STIFFNESS:property"}}Equation.DEFAULT_STIFFNESS{{/crossLink}}.
* @property stiffness
* @type {Number}
*/
this.stiffness = typeof(options.stiffness) !== "undefined" ? Number(options.stiffness) : Equation.DEFAULT_STIFFNESS;
this.stiffness = typeof(options.stiffness) !== "undefined" ? Number(options.stiffness) : Equation.DEFAULT_STIFFNESS;

/**
* Relaxation of the resulting ContactEquation that this ContactMaterial generate
* Relaxation of the resulting ContactEquation that this ContactMaterial generate. Default value is {{#crossLink "Equation/DEFAULT_RELAXATION:property"}}Equation.DEFAULT_RELAXATION{{/crossLink}}.
* @property relaxation
* @type {Number}
*/
this.relaxation = typeof(options.relaxation) !== "undefined" ? Number(options.relaxation) : Equation.DEFAULT_RELAXATION;
this.relaxation = typeof(options.relaxation) !== "undefined" ? Number(options.relaxation) : Equation.DEFAULT_RELAXATION;

/**
* Stiffness of the resulting FrictionEquation that this ContactMaterial generate
* Stiffness of the resulting friction force. For most cases, the value of this property should be a large number. I cannot think of any case where you would want less frictionStiffness. Default value is {{#crossLink "Equation/DEFAULT_STIFFNESS:property"}}Equation.DEFAULT_STIFFNESS{{/crossLink}}.
* @property frictionStiffness
* @type {Number}
*/
this.frictionStiffness = typeof(options.frictionStiffness) !== "undefined" ? Number(options.frictionStiffness) : Equation.DEFAULT_STIFFNESS;
this.frictionStiffness = typeof(options.frictionStiffness) !== "undefined" ? Number(options.frictionStiffness) : Equation.DEFAULT_STIFFNESS;

/**
* Relaxation of the resulting FrictionEquation that this ContactMaterial generate
* Relaxation of the resulting friction force. The default value should be good for most simulations. Default value is {{#crossLink "Equation/DEFAULT_RELAXATION:property"}}Equation.DEFAULT_RELAXATION{{/crossLink}}.
* @property frictionRelaxation
* @type {Number}
*/
this.frictionRelaxation = typeof(options.frictionRelaxation) !== "undefined" ? Number(options.frictionRelaxation) : Equation.DEFAULT_RELAXATION;
this.frictionRelaxation = typeof(options.frictionRelaxation) !== "undefined" ? Number(options.frictionRelaxation) : Equation.DEFAULT_RELAXATION;

/**
* Will add surface velocity to this material. If bodyA rests on top if bodyB, and the surface velocity is positive, bodyA will slide to the right.
* @property {Number} surfaceVelocity
* @default 0
*/
this.surfaceVelocity = typeof(options.surfaceVelocity) !== "undefined" ? Number(options.surfaceVelocity) : 0;
this.surfaceVelocity = typeof(options.surfaceVelocity) !== "undefined" ? Number(options.surfaceVelocity) : 0;

/**
* Offset to be set on ContactEquations. A positive value will make the bodies penetrate more into each other. Can be useful in scenes where contacts need to be more persistent, for example when stacking. Aka "cure for nervous contacts".
Expand Down
1 change: 1 addition & 0 deletions src/world/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ var hitTest_tmp1 = vec2.create(),
* @return {Array} Array of bodies that overlap the point
* @todo Should use an api similar to the raycast function
* @todo Should probably implement a .containsPoint method for all shapes. Would be more efficient
* @todo Should use the broadphase
*/
World.prototype.hitTest = function(worldPoint,bodies,precision){
precision = precision || 0;
Expand Down

0 comments on commit 0aa83c6

Please sign in to comment.