FIX: Correctly assign material name to model

This commit is contained in:
sebastian 2026-08-02 08:56:41 +02:00
parent 96d2e89d48
commit cfe51648bd

View File

@ -5,6 +5,8 @@
#include "ModelUploader.h"
#include <array>
#include <filesystem>
#include <iostream>
#include "Material.h"
#include "loader/textures/TextureUploader.h"
@ -58,11 +60,14 @@ engine::ModelUploader::MaterialMap engine::ModelUploader::buildMaterials(const s
for (const auto& raw : materials) {
std::array<std::shared_ptr<Texture2D>, static_cast<size_t>(TextureType::Count)> resolved;
for (const auto& [type, texName] : raw.texturePaths) {
for (const auto& [type, texFileName] : raw.texturePaths) {
auto texPath = std::filesystem::path(texFileName);
const auto& texName = texPath.replace_extension();
if (auto it = textures.find(texName); it != textures.end()) {
resolved[static_cast<size_t>(type)] = it->second;
} else {
spdlog::warn("Textur '{}' für Material '{}' nicht gefunden", texName, raw.name);
std::cerr << texName.string() << texName.string().size() << std::endl;
spdlog::warn("Textur '{}' für Material '{}' nicht gefunden", texFileName, raw.name);
}
}
result[raw.name] = std::make_shared<Material>(resolved, raw.shininess, raw.opacity);
@ -115,7 +120,6 @@ engine::Model engine::ModelUploader::buildCombinedByObject(const std::vector<Raw
std::vector<RawMeshSection> all;
for (const auto& object : objects) {
for (auto section : object.subModels) {
section.materialName = object.name;
all.push_back(std::move(section));
}
}