//
// Created by sebastian on 30.07.26.
//

#ifndef COLORRACE_MODELUPLOADER_H
#define COLORRACE_MODELUPLOADER_H
#include <vector>

#include "ModelImporter.h"
#include "loader/assets/LoadedAssets.h"


namespace engine {
    class Material;

    class ModelUploader {
    public:
        static std::vector<engine::LoadedAsset> upload(const engine::RawModelBundle& bundle, engine::ModelSplitPolicy policy);
    private:
        using MaterialMap = std::unordered_map<std::string, std::shared_ptr<Material>>;

        static std::unordered_map<std::string, std::shared_ptr<Texture2D>> uploadTextures(const std::vector<RawTextureData>& textures, std::vector<LoadedAsset>& results);
        static MaterialMap buildMaterials(const std::vector<RawMaterialData>& materials, const std::unordered_map<std::string, std::shared_ptr<Texture2D>>& textures);
        static Model uploadSections(const std::vector<RawMeshSection>& sections, const MaterialMap& materials);
        static Model buildCombinedByObject(const std::vector<RawObjectData> &objects, const MaterialMap& materials);
        static Model buildCombinedByMaterial(const std::vector<RawObjectData> &objects, const MaterialMap& materials);

        static std::vector<std::unique_ptr<Attribute>> makeAttributeList(std::unique_ptr<Attribute> attr);
    };
}


#endif //COLORRACE_MODELUPLOADER_H
