#pragma once #include #include #include #include "../Common/Sizes.hpp" #include "../Math/Common.hpp" namespace MC::GFX { class Mesh { public: struct Attribute { template Attribute( std::vector v ) : data_size(v.size()), attribute_size(1), type_size(sizeof(T)) { data = copy(v.data(), v.size() * type_size); } template Attribute( std::vector> v ) : data_size(v.size()), attribute_size(S), type_size(sizeof(T)) { data = copy(v.data(), v.size() * S * type_size); } Attribute( const Attribute& other ) : data(copy(other.data, other.data_size * other.attribute_size * other.type_size)), data_size(other.data_size), attribute_size(other.attribute_size), type_size(other.type_size) {} static void* copy(void* ptr, U32 size) { auto* buffer = new U8[size]; std::copy_n((U8*)ptr, size, buffer); return buffer; } void* data; USize data_size; USize attribute_size; USize type_size; }; Mesh( std::vector attributes, std::vector indices ) : m_attributes(std::move(attributes)), m_indices(std::move(indices)) {} explicit Mesh( std::vector attributes ) : m_attributes(std::move(attributes)) {} const std::vector& indices() const; const std::vector& attributes() const; private: std::vector m_attributes; std::vector m_indices; }; }