Minimal Translation Distance too short?

I am having a little bit of trouble using an MTD formula for basic AABB collision detection.

The problem being is that the moving object collides with a static object, it should respond by “bouncing off” in the correct direction, so depending on the value of X or Y, I reverse the respected velocity of the moving object.

So I have a Ball and a Block, ball hits block > block gets deleted and ball bounces fine

However if ball hits a block and block say has, 3 health and requires 3 hits…the ball will collide with it constantly until it no longer exists. If that makes sense?

Basically this here:


Vector2 mtd;
if (ball.getBounds().overlaps(block.getBounds())) {
					mtd = ball.getBounds().getMinimumTranslation(
							block.getBounds());
					ball.getPos().add(mtd);
					if (mtd.x != 0) {
						ball.velocity.x = -(ball.velocity.x * ball
								.getFriction());
					} else if (mtd.y != 0) {
						ball.velocity.y = -(ball.velocity.y * ball
								.getRestitution());

					}
					notify(block, Event.BLOCK_COLLISION);
				}

The value of MTD is so small that it can not resolve the collision properly, so adding it to the current ball position does not move it out of the bounds of said block.

What can I do to stop this?

Here is the MTD method:


public Vector2 getMinimumTranslation(BoundingBox other) {

		/* The collision vector */
		Vector2 mtd = new Vector2();

		/* The left side of the AABB */
		float right = (other.getX() + other.getWidth()) - this.getX();
		/* The right side of the AABB */
		float left = other.getX() - (this.getX() + this.getWidth());
		/* The top side of the AABB */
		float top = (other.getY() + other.getHeight()) - this.getY();
		/* The bottom side of the AABB */
		float bottom = other.getY() - (this.getY() + this.getHeight());

		/* If right is less than left, we collided left */
		if (Math.abs(left) < Math.abs(right)) {
			mtd.x = left;
		} else {
			/* Else we collided right */
			mtd.x = right;
		}

		/* If top is less than bottom, we collided top */
		if (Math.abs(top) < Math.abs(bottom)) {
			mtd.y = top;
		} else {
			/* Else we collided bottom */
			mtd.y = bottom;
		}

		/*
		 * See which component of our collision vector is smallest
		 */
		if (Math.abs(mtd.x) < Math.abs(mtd.y)) {
			mtd.y = 0;
		} else {
			mtd.x = 0;
		}

		/* Return our collision vector */
		return mtd;

	}

So just scale up the minimum translation distance by 1.1. Or 1.01. or 1.001. Large enough that it works, small enough that it isn’t too noticeable.