mirror of
https://github.com/liabru/matter-js.git
synced 2024-12-26 13:49:01 -05:00
change constraint solve order
This commit is contained in:
parent
a8d1950148
commit
a5bd6b2d55
1 changed files with 19 additions and 1 deletions
|
@ -103,9 +103,27 @@ var Common = require('../core/Common');
|
|||
* @param {number} timeScale
|
||||
*/
|
||||
Constraint.solveAll = function(constraints, timeScale) {
|
||||
for (var i = 0; i < constraints.length; i++) {
|
||||
// Solve fixed constraints first.
|
||||
for (var i = 0; i < constraints.length; i += 1) {
|
||||
var constraint = constraints[i],
|
||||
fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic),
|
||||
fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic);
|
||||
|
||||
if (fixedA || fixedB) {
|
||||
Constraint.solve(constraints[i], timeScale);
|
||||
}
|
||||
}
|
||||
|
||||
// Solve free constraints last.
|
||||
for (i = 0; i < constraints.length; i += 1) {
|
||||
constraint = constraints[i];
|
||||
fixedA = !constraint.bodyA || (constraint.bodyA && constraint.bodyA.isStatic);
|
||||
fixedB = !constraint.bodyB || (constraint.bodyB && constraint.bodyB.isStatic);
|
||||
|
||||
if (!fixedA && !fixedB) {
|
||||
Constraint.solve(constraints[i], timeScale);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue