@@ -149,7 +149,7 @@ var Body = require('../body/Body');
149149 // update all body position and rotation by integration
150150 _bodiesUpdate ( allBodies , delta , timing . timeScale , correction , world . bounds ) ;
151151
152- // update all constraints
152+ // update all constraints (first pass)
153153 Constraint . preSolveAll ( allBodies ) ;
154154 for ( i = 0 ; i < engine . constraintIterations ; i ++ ) {
155155 Constraint . solveAll ( allConstraints , timing . timeScale ) ;
@@ -158,7 +158,6 @@ var Body = require('../body/Body');
158158
159159 // broadphase pass: find potential collision pairs
160160 if ( broadphase . controller ) {
161-
162161 // if world is dirty, we must flush the whole grid
163162 if ( world . isModified )
164163 broadphase . controller . clear ( broadphase ) ;
@@ -167,7 +166,6 @@ var Body = require('../body/Body');
167166 broadphase . controller . update ( broadphase , allBodies , engine , world . isModified ) ;
168167 broadphasePairs = broadphase . pairsList ;
169168 } else {
170-
171169 // if no broadphase set, we just pass all bodies
172170 broadphasePairs = allBodies ;
173171 }
@@ -201,6 +199,13 @@ var Body = require('../body/Body');
201199 }
202200 Resolver . postSolvePosition ( allBodies ) ;
203201
202+ // update all constraints (second pass)
203+ Constraint . preSolveAll ( allBodies ) ;
204+ for ( i = 0 ; i < engine . constraintIterations ; i ++ ) {
205+ Constraint . solveAll ( allConstraints , timing . timeScale ) ;
206+ }
207+ Constraint . postSolveAll ( allBodies ) ;
208+
204209 // iteratively resolve velocity between collisions
205210 Resolver . preSolveVelocity ( pairs . list ) ;
206211 for ( i = 0 ; i < engine . velocityIterations ; i ++ ) {
0 commit comments