0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-03-10 00:06:42 -04:00

remove constraint torque clamp

This commit is contained in:
liabru 2015-12-28 18:50:07 +00:00
parent 2e6afd477a
commit 6f892502c2

View file

@ -206,12 +206,6 @@ var Common = require('../core/Common');
if (bodyA && !bodyA.isStatic) { if (bodyA && !bodyA.isStatic) {
torque = Vector.cross(offsetA, normalVelocity) * bodyA.inverseInertia * (1 - constraint.angularStiffness); torque = Vector.cross(offsetA, normalVelocity) * bodyA.inverseInertia * (1 - constraint.angularStiffness);
Sleeping.set(bodyA, false);
// clamp to prevent instability
// TODO: solve this properly
torque = Common.clamp(torque, -0.01, 0.01);
// keep track of applied impulses for post solving // keep track of applied impulses for post solving
bodyA.constraintImpulse.x -= force.x; bodyA.constraintImpulse.x -= force.x;
bodyA.constraintImpulse.y -= force.y; bodyA.constraintImpulse.y -= force.y;
@ -226,12 +220,6 @@ var Common = require('../core/Common');
if (bodyB && !bodyB.isStatic) { if (bodyB && !bodyB.isStatic) {
torque = Vector.cross(offsetB, normalVelocity) * bodyB.inverseInertia * (1 - constraint.angularStiffness); torque = Vector.cross(offsetB, normalVelocity) * bodyB.inverseInertia * (1 - constraint.angularStiffness);
Sleeping.set(bodyB, false);
// clamp to prevent instability
// TODO: solve this properly
torque = Common.clamp(torque, -0.01, 0.01);
// keep track of applied impulses for post solving // keep track of applied impulses for post solving
bodyB.constraintImpulse.x += force.x; bodyB.constraintImpulse.x += force.x;
bodyB.constraintImpulse.y += force.y; bodyB.constraintImpulse.y += force.y;
@ -260,6 +248,8 @@ var Common = require('../core/Common');
continue; continue;
} }
Sleeping.set(body, false);
// update geometry and reset // update geometry and reset
for (var j = 0; j < body.parts.length; j++) { for (var j = 0; j < body.parts.length; j++) {
var part = body.parts[j]; var part = body.parts[j];