From 0aa83c607b4fd70be128c993950b26acdbdcfdbf Mon Sep 17 00:00:00 2001 From: Stefan Hedman Date: Sat, 21 Nov 2015 19:32:45 +0100 Subject: [PATCH] minor code cleanup --- src/material/ContactMaterial.js | 29 ++++++++++++++++------------- src/world/World.js | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/material/ContactMaterial.js b/src/material/ContactMaterial.js index 8826fa64..26bdb60f 100644 --- a/src/material/ContactMaterial.js +++ b/src/material/ContactMaterial.js @@ -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". diff --git a/src/world/World.js b/src/world/World.js index 327d7fe6..45096120 100644 --- a/src/world/World.js +++ b/src/world/World.js @@ -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;