<commit_before>/**
 * @author       <NAME> <<EMAIL>>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
 */

// var CONST = require('./const');
var IntersectsRect = require('./IntersectsRect');

/**
 * Calculates and returns the vertical overlap between two arcade physics bodies.
 * 
 * We know the bodies are intersecting based on a previous check, so the point of this function
 * is to determine which face the overlap is occurring on and at what depth.
 *
 * @function Phaser.Physics.Arcade.CheckOverlapY
 * @since 3.17.0
 *
 * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate.
 * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate.
 * @param {number} [padding=0] - 
 *
 * @return {boolean} 
 */
var CheckOverlapY = function (body1, body2, padding)
{
    if (padding === undefined) { padding = 0; }

    // var body1Immovable = (body1.physicsType === CONST.STATIC_BODY || body1.immovable);
    // var body2Immovable = (body2.physicsType === CONST.STATIC_BODY || body2.immovable);

    var distance1 = body1.bottom - body2.y;
    var distance2 = body2.bottom - body1.y;

    var prevDistance1 = (body1.prev.y + body1.height) - body2.prev.y;
    var prevDistance2 = (body2.prev.y + body2.height) - body1.prev.y;

    // var worldBlocked1 = body1.worldBlocked;
    // var worldBlocked2 = body2.worldBlocked;

    var topFace = (distance1 > distance2 && prevDistance1 > prevDistance2);

    var intersects = IntersectsRect(body1, body2, padding);

    if (intersects && !topFace)
    {
        if (body1.checkCollision.up && body2.checkCollision.down)
        {
            body1.setTouchingDown();
            body2.setTouchingUp();

            body1.setBlockedDown(body2);
            body2.setBlockedUp(body1);

            //  World blocks cannot be penetrated
            // if (worldBlocked2.down || body2Immovable)
            // {
            //     body1.setWorldBlockedDown();
            // }

            // if (worldBlocked1.up || body1Immovable)
            // {
            //     body2.setWorldBlockedUp();
            // }
        }
    }
    else if (intersects && topFace)
    {
        if (body1.checkCollision.down && body2.checkCollision.up)
        {
            body1.setTouchingUp();
            body2.setTouchingDown();

            body1.setBlockedUp(body2);
            body2.setBlockedDown(body1);

            //  World blocks cannot be penetrated
            // if (worldBlocked2.up || body2Immovable)
            // {
            //     body1.setWorldBlockedUp();
            // }

            // if (worldBlocked1.down || body1Immovable)
            // {
            //     body2.setWorldBlockedDown();
            // }
        }
    }
<commit_msg>Don't force body position at this point<commit_after>/**
 * @author       <NAME> <<EMAIL>>
 * @copyright    2019 Photon Storm Ltd.
 * @license      {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
 */

var IntersectsRect = require('./IntersectsRect');

/**
 * Calculates and returns the vertical overlap between two arcade physics bodies.
 * 
 * We know the bodies are intersecting based on a previous check, so the point of this function
 * is to determine which face the overlap is occurring on and at what depth.
 *
 * @function Phaser.Physics.Arcade.CheckOverlapY
 * @since 3.17.0
 *
 * @param {Phaser.Physics.Arcade.Body} body1 - The first Body to separate.
 * @param {Phaser.Physics.Arcade.Body} body2 - The second Body to separate.
 * @param {number} [padding=0] - 
 *
 * @return {boolean} 
 */
var CheckOverlapY = function (body1, body2, padding)
{
    if (padding === undefined) { padding = 0; }

    var distance1 = body1.bottom - body2.y;
    var distance2 = body2.bottom - body1.y;

    var prevDistance1 = (body1.prev.y + body1.height) - body2.prev.y;
    var prevDistance2 = (body2.prev.y + body2.height) - body1.prev.y;

    var topFace = (distance1 > distance2 && prevDistance1 > prevDistance2);

    var intersects = IntersectsRect(body1, body2, padding);

    if (intersects && !topFace)
    {
        if (body1.checkCollision.up && body2.checkCollision.down)
        {
            body1.setTouchingDown();
            body2.setTouchingUp();

            body1.setBlockedDown(body2, false);
            body2.setBlockedUp(body1, false);
        }
    }
    else if (intersects && topFace)
    {
        if (body1.checkCollision.down && body2.checkCollision.up)
        {
            body1.setTouchingUp();
            body2.setTouchingDown();

            body1.setBlockedUp(body2, false);
            body2.setBlockedDown(body1, false);
        }
    }

{'fraction_non_alphanumeric': 0.12269548633184997, 'fraction_numerical': 0.025852934943844035, 'mean_word_length': 2.286908077994429, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540389', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1477, 'n_words': 345}