55 */
66
77var CONST = require ( './const' ) ;
8- var GetOverlapY = require ( './GetOverlapY' ) ;
98
109/**
1110 * Separates two overlapping bodies on the Y-axis (vertically).
@@ -48,18 +47,19 @@ var SeparateY = function (collisionInfo)
4847 var body1Immovable = ( body1 . physicsType === CONST . STATIC_BODY || body1 . immovable ) ;
4948 var body2Immovable = ( body2 . physicsType === CONST . STATIC_BODY || body2 . immovable ) ;
5049
51- console . log ( '' ) ;
52- console . log ( '%c Y frame ' + body1 . world . _frame + ' ' , 'background-color: pink' ) ;
53- console . log ( 'body1:' , body1 . gameObject . name , 'vs body2:' , body2 . gameObject . name ) ;
50+ // console.log('');
51+ // console.log('%c Y frame ' + body1.world._frame + ' ', 'background-color: pink');
52+ // console.log('body1:', body1.gameObject.name, 'vs body2:', body2.gameObject.name);
5453
55- // console.log('pre-GetOverlap by = body1', body1.y, 'body2', body2.y);
56- // console.log('pre-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
54+ console . log ( 'pre-GetOverlap by = body1' , body1 . y , 'body2' , body2 . y ) ;
55+ console . log ( 'pre-GetOverlap compare = body1' , body1 . bottom , 'body2' , body2 . y ) ;
56+ console . log ( 'pre-GetOverlap gy = body1' , body1 . gameObject . y , 'body2' , body2 . gameObject . y ) ;
5757
5858 // console.log(collisionInfo);
5959 // console.log('post-GetOverlap by = body1', body1.y, 'body2', body2.y);
6060 // console.log('post-GetOverlap gy = body1', body1.gameObject.y, 'body2', body2.gameObject.y);
6161
62- console . log ( 'body1 overlaps body2 across the' , ( ( topFace ) ? 'top' : 'bottom' ) , 'by' , overlap , 'px' ) ;
62+ // console.log('body1 overlaps body2 across the', ((topFace) ? 'top' : 'bottom'), 'by', overlap, 'px');
6363
6464 // Can't separate two immovable bodies, or a body with its own custom separation logic
6565 if ( ! intersects || overlapOnly || ( body1Immovable && body2Immovable ) || body1 . customSeparateY || body2 . customSeparateY )
@@ -180,7 +180,7 @@ var SeparateY = function (collisionInfo)
180180 var totalA = collisionInfo . shareY1 ;
181181 var totalB = collisionInfo . shareY2 ;
182182
183- // console.log('split at', totalA, totalB, 'of', overlap);
183+ console . log ( 'split at' , totalA , totalB , 'of' , overlap ) ;
184184
185185 if ( totalA === 0 && totalB === 0 && overlap !== 0 )
186186 {
@@ -207,12 +207,12 @@ var SeparateY = function (collisionInfo)
207207 }
208208
209209 // By this stage the bodies have their separation distance calculated (stored in totalA/B)
210- // and they have their new post-impact velocity. So now we need to work out block state based on direction.
210+ // and they have their new post-impact velocity. So now we need to work out block state based on direction.
211211
212212 if ( ny1 !== 0 )
213213 {
214- // ny1 < 0 = Body1 is moving UP
215- // ny1 > 0 = Body1 is moving DOWN
214+ // ny1 < 0 = Body1 is now moving UP
215+ // ny1 > 0 = Body1 is now moving DOWN
216216
217217 if ( topFace )
218218 {
@@ -272,7 +272,7 @@ var SeparateY = function (collisionInfo)
272272 else if ( bottomFace )
273273 {
274274 // The bottom of Body1 overlaps with the top of Body2
275- if ( totalA !== 0 && ! body1 . isBlockedDown ( ) )
275+ if ( totalA !== 0 && ! body1 . isBlockedUp ( ) )
276276 {
277277 // console.log('body1 stationary bottomface add', body1.y);
278278 body1 . y += body1 . getMoveY ( totalA ) ;
@@ -409,6 +409,9 @@ var SeparateY = function (collisionInfo)
409409 velocity1 . y = ny1 ;
410410 velocity2 . y = ny2 ;
411411
412+ console . log ( 'post-GetOverlap by = body1' , body1 . y , 'body2' , body2 . y ) ;
413+ console . log ( 'post-GetOverlap compare = body1' , body1 . bottom , 'body2' , body2 . y ) ;
414+
412415 // If we got this far then there WAS overlap, and separation is complete, so return true
413416 return true ;
414417} ;
0 commit comments