import { BoxBoxSolver, BoxTerrainSolver } from "./collision/solver";
import { ObjectType } from "./object-type";
export class Narrowphase {
    constructor(world) {
        this.world = world;
    }
    perform(objs) {
        for (let x = 0; x < objs.length; x++) {
            for (let i = 0; i < objs[x].length; i++) {
                for (let j = 0; j < objs[x].length; j++) {
                    if (objs[x][i] === objs[x][j])
                        continue;
                    if (objs[x][i].collidesWith(objs[x][j])) {
                        this.world.collisionMatrix.add(objs[x][i], objs[x][j]);
                        if (objs[x][i].type === ObjectType.object) {
                            if (objs[x][j].type == ObjectType.object) {
                                BoxBoxSolver(objs[x][i].boundingBox, objs[x][j].boundingBox);
                            }
                            else {
                                BoxTerrainSolver(objs[x][i], objs[x][j]);
                            }
                        }
                    }
                }
            }
        }
    }
}
