@@ -65,6 +65,7 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
6565 var ny1 = v1 ;
6666 var ny2 = v2 ;
6767
68+ console . log ( '' ) ;
6869 console . log ( body1 . gameObject . name , 'overlaps' , body2 . gameObject . name , 'on the' , ( ( topFace ) ? 'top' : 'bottom' ) ) ;
6970
7071 // At this point, the velocity from gravity, world rebounds, etc has been factored in.
@@ -125,31 +126,22 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
125126 console . log ( 'sqrt' , bnv1 , bnv2 ) ;
126127 console . log ( 'delta' , body1 . deltaY ( ) , body2 . deltaY ( ) ) ;
127128 }
128-
129- // var total = v1 - v2;
130- // ny1 = (((mass1 - mass2) * v1 + 2 * mass1 * v1) / (mass1 + mass2)) * bounce1.y;
131- // ny2 = (total + ny1) * bounce2.y;
132- // console.log('*1', ny1, ny2, 'vs', v1, v2, 'delta', body1.deltaY(), body2.deltaY());
133-
134-
135- // console.log('*1', ny1, ny2, 'vs', v1, v2, 'avg', avg, 'nv', nv1, nv2, 'bounce', body1.bounce.y, body2.bounce.y, 'delta', body1.deltaY(), body2.deltaY());
136- // console.log('*1', ny1, ny2, 'vs', v1, v2, 'avg', avg, 'nv', nv1, nv2, 'bounce', body1.bounce.y, body2.bounce.y, 'delta', body1.deltaY(), body2.deltaY());
137129 }
138130 else if ( body1Immovable )
139131 {
140132 // Body1 is immovable, so adjust body2 speed
141133 ny2 = v1 - v2 * bounce2 . y ;
142- console . log ( 'uh oh1' ) ;
143134 }
144135 else if ( body2Immovable )
145136 {
146137 // Body2 is immovable, so adjust body1 speed
147138 ny1 = v2 - v1 * bounce1 . y ;
148- console . log ( 'uh oh2' ) ;
149139 }
150140 else
151141 {
152142 console . log ( 'uh oh' ) ;
143+ ny1 = 0 ;
144+ ny2 = 0 ;
153145 }
154146
155147 var totalA = 0 ;
@@ -197,15 +189,9 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
197189 return true ;
198190 }
199191
200- // console.log('d1', body1.deltaY(), 'd2', body2.deltaY());
201-
202192 // By this stage the bodies have their separation distance calculated (stored in totalA/B)
203193 // and they have their new post-impact velocity. So now we need to work out block state based on direction.
204194
205- // Then, adjust for rebounded direction, if any.
206-
207- // console.log('preb', worldBlocked1.up, worldBlocked1.down, worldBlocked2.up, worldBlocked2.down);
208-
209195 if ( ny1 < 0 )
210196 {
211197 // Body1 is moving UP
@@ -380,10 +366,7 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
380366 console . log ( 'body2 stationary' , body2 . y , ny1 , ny2 ) ;
381367 }
382368
383- // console.log('postb', worldBlocked1.up, worldBlocked1.down, worldBlocked2.up, worldBlocked2.down);
384-
385- // We disregard the new velocity when:
386- // Body is world blocked AND blocked on the opposite face
369+ // We disregard the new velocity when a Body is world blocked AND blocked by something on the opposite face
387370
388371 if ( body1 . isBlockedY ( ) )
389372 {
@@ -395,10 +378,13 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
395378 ny2 = 0 ;
396379 }
397380
381+ // Wakey, wakey?
382+
398383 if ( body1 . sleeping )
399384 {
400385 if ( Math . abs ( ny1 ) < body1 . minVelocity . y )
401386 {
387+ // Not enough new velocity to get out of bed for
402388 ny1 = 0 ;
403389 }
404390 else
@@ -412,6 +398,7 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
412398 {
413399 if ( Math . abs ( ny2 ) < body2 . minVelocity . y )
414400 {
401+ // Not enough new velocity to get out of bed for
415402 ny2 = 0 ;
416403 }
417404 else
@@ -420,8 +407,6 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
420407 }
421408 }
422409
423- // Rebound check
424-
425410 console . log ( 'SepY End' , ny1 , ny2 ) ;
426411
427412 velocity1 . y = ny1 ;
@@ -433,7 +418,9 @@ var SeparateY = function (body1, body2, overlapOnly, bias)
433418 // body1.x += body1.getMoveX((body2.deltaX()) * body2.friction.x, true);
434419 // }
435420
436- console . log ( '---' , Date . now ( ) ) ;
421+ console . log ( '' ) ;
422+
423+ window . dump = true ;
437424
438425 // If we got this far then there WAS overlap, and separation is complete, so return true
439426 return true ;
0 commit comments