import Vector2 from "../../../geom/Vector2.js";
import { resolveBoxOverlapUsingForce } from "./resolveBoxOverlapUsingForce.js";

/**
 *
 * @param {AABB2[]} boxes
 * @param {number} [maxSteps]
 */
export function resolveAABB2Overlap(boxes, maxSteps=3) {
    const forces = [];

    const n = boxes.length;

    for (let i = 0; i < n; i++) {
        forces.push(new Vector2(0, 0));
    }

    let overlapMoves = -1;

    let steps = maxSteps;

    while (steps > 0 && overlapMoves !== 0) {

        steps--;

        overlapMoves = resolveBoxOverlapUsingForce(forces, boxes);

    }

}
