feat: support alternative vcm models syntax

This commit is contained in:
MihailRis
2025-06-01 23:08:59 +03:00
parent 8f342fe429
commit 4333d9ab06
10 changed files with 155 additions and 28 deletions
+27 -13
View File
@@ -352,21 +352,35 @@ assetload::postfunc assetload::model(
throw;
}
}
path = paths.find(file + ".xml");
if (io::exists(path)) {
auto text = io::read_string(path);
try {
auto model = vcm::parse(path.string(), text).release();
return [=](Assets* assets) {
request_textures(loader, *model);
assets->store(std::unique_ptr<model::Model>(model), name);
};
} catch (const parsing_error& err) {
std::cerr << err.errorLog() << std::endl;
throw;
std::array<std::string, 2> extensions {
".xml",
".vcm"
};
path = "";
for (const auto& ext : extensions) {
auto newPath = paths.find(file + ext);
if (io::exists(newPath)) {
path = std::move(newPath);
break;
}
}
throw std::runtime_error("could not to find model " + util::quote(file));
if (path.empty()) {
throw std::runtime_error("could not to find model " + util::quote(file));
}
auto text = io::read_string(path);
try {
auto model = vcm::parse(path.string(), text).release();
return [=](Assets* assets) {
request_textures(loader, *model);
assets->store(std::unique_ptr<model::Model>(model), name);
};
} catch (const parsing_error& err) {
std::cerr << err.errorLog() << std::endl;
throw;
}
}
static void read_anim_file(