File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,9 +103,27 @@ var Common = require('../core/Common');
103103 * @param {number } timeScale
104104 */
105105 Constraint . solveAll = function ( constraints , timeScale ) {
106- for ( var i = 0 ; i < constraints . length ; i ++ ) {
106+ // Solve fixed constraints first.
107+ for ( var i = 0 ; i < constraints . length ; i += 1 ) {
108+ var constraint = constraints [ i ] ,
109+ fixedA = ! constraint . bodyA || ( constraint . bodyA && constraint . bodyA . isStatic ) ,
110+ fixedB = ! constraint . bodyB || ( constraint . bodyB && constraint . bodyB . isStatic ) ;
111+
112+ if ( fixedA || fixedB ) {
113+ Constraint . solve ( constraints [ i ] , timeScale ) ;
114+ }
115+ }
116+
117+ // Solve free constraints last.
118+ for ( i = 0 ; i < constraints . length ; i += 1 ) {
119+ constraint = constraints [ i ] ;
120+ fixedA = ! constraint . bodyA || ( constraint . bodyA && constraint . bodyA . isStatic ) ;
121+ fixedB = ! constraint . bodyB || ( constraint . bodyB && constraint . bodyB . isStatic ) ;
122+
123+ if ( ! fixedA && ! fixedB ) {
107124 Constraint . solve ( constraints [ i ] , timeScale ) ;
108125 }
126+ }
109127 } ;
110128
111129 /**
You can’t perform that action at this time.
0 commit comments