#pragma once

#include "maths/transform.hpp"
#include "resources/primitive.hpp"

#include <glm/mat4x4.hpp>

#include <initializer_list>
#include <vector>

namespace kuiper::resource
{

class mesh {
  public:
    using primitive_storage = std::vector<primitive>;
    using submesh_storage   = std::vector<mesh>;

    mesh(const glm::mat4& t)
        : m_transform(t) {}

    mesh(const glm::mat4& t, std::initializer_list<primitive> primitives)
        : m_transform(t) {
        for (const auto& p : primitives) {
            m_primitives.push_back(p);
        }
    }

    void add_primitive(const primitive& prim) {
        return m_primitives.push_back(prim);
    }

    void add_submesh(const class mesh& mesh) {
        return m_submeshes.push_back(mesh);
    }

    const glm::mat4& transform() const noexcept {
        return m_transform;
    }

    const primitive_storage& primitives() const noexcept {
        return m_primitives;
    }

    const submesh_storage& submeshes() const noexcept {
        return m_submeshes;
    }

  private:
    primitive_storage m_primitives {};
    submesh_storage   m_submeshes {};
    glm::mat4         m_transform {};
};

} // namespace kuiper::resource
