#pragma once

#include <glm/glm.hpp>

namespace geometry {
    /// Axis Aligned Floating Box
    struct Box {
        enum class ContainmentType {
            Disjoint = false, Intersects, Contains
        };

        Box(glm::vec3 min, glm::vec3 max): Min(min), Max(max) {
            assert((max.x >= min.x && max.y >= min.y && max.z >= min.z) && "Min > Max");
        }
        inline static Box fromCenter(glm::vec3 center, float radius) { return Box(center - radius, center + radius); }
        inline static Box fromMin(glm::vec3 min, glm::vec3 size) { return Box(min, min + size); }

        glm::vec3 Min;
        glm::vec3 Max;

        ContainmentType contains(const Box& box) const {
            //test if all corner is in the same side of a face by just checking min and max
            if (box.Max.x < Min.x
                || box.Min.x > Max.x
                || box.Max.y < Min.y
                || box.Min.y > Max.y
                || box.Max.z < Min.z
                || box.Min.z > Max.z)
                return ContainmentType::Disjoint;


            if (box.Min.x >= Min.x
                && box.Max.x <= Max.x
                && box.Min.y >= Min.y
                && box.Max.y <= Max.y
                && box.Min.z >= Min.z
                && box.Max.z <= Max.z)
                return ContainmentType::Contains;

            return ContainmentType::Intersects;
        }
    };
}