fix assets.parse_model with 'xml' format
This commit is contained in:
parent
da41de263d
commit
ec94abccbc
@ -110,7 +110,7 @@ function unlock_access()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function reload_model(filename, name)
|
local function reload_model(filename, name)
|
||||||
assets.parse_model("xml", document.editor.text, name)
|
assets.parse_model(file.ext(filename), document.editor.text, name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function run_current_file()
|
function run_current_file()
|
||||||
|
|||||||
@ -33,5 +33,4 @@
|
|||||||
onup="on_history_up()"
|
onup="on_history_up()"
|
||||||
ondown="on_history_down()">
|
ondown="on_history_down()">
|
||||||
</textbox>
|
</textbox>
|
||||||
<textbox size="200" margin="20" multiline="true" text-wrap="true" autoresize="false"/>
|
|
||||||
</container>
|
</container>
|
||||||
|
|||||||
@ -381,7 +381,8 @@ assetload::postfunc assetload::model(
|
|||||||
|
|
||||||
auto text = io::read_string(path);
|
auto text = io::read_string(path);
|
||||||
try {
|
try {
|
||||||
auto model = vcm::parse(path.string(), text).release();
|
auto model = vcm::parse(path.string(), text, path.extension() == ".xml")
|
||||||
|
.release();
|
||||||
return [=](Assets* assets) {
|
return [=](Assets* assets) {
|
||||||
request_textures(loader, *model);
|
request_textures(loader, *model);
|
||||||
assets->store(std::unique_ptr<model::Model>(model), name);
|
assets->store(std::unique_ptr<model::Model>(model), name);
|
||||||
|
|||||||
@ -163,11 +163,11 @@ static std::unique_ptr<model::Model> load_model(const xmlelement& root) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<model::Model> vcm::parse(
|
std::unique_ptr<model::Model> vcm::parse(
|
||||||
std::string_view file, std::string_view src
|
std::string_view file, std::string_view src, bool usexml
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
auto doc = io::path(std::string(file)).extension() == ".xml"
|
auto doc =
|
||||||
? xml::parse(file, src) : xml::parse_vcm(file, src, "model");
|
usexml ? xml::parse(file, src) : xml::parse_vcm(file, src, "model");
|
||||||
const auto& root = *doc->getRoot();
|
const auto& root = *doc->getRoot();
|
||||||
if (root.getTag() != "model") {
|
if (root.getTag() != "model") {
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
|
|||||||
@ -8,5 +8,7 @@ namespace model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace vcm {
|
namespace vcm {
|
||||||
std::unique_ptr<model::Model> parse(std::string_view file, std::string_view src);
|
std::unique_ptr<model::Model> parse(
|
||||||
|
std::string_view file, std::string_view src, bool usexml
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,9 @@ static int l_parse_model(lua::State* L) {
|
|||||||
auto name = lua::require_string(L, 3);
|
auto name = lua::require_string(L, 3);
|
||||||
|
|
||||||
if (format == "xml" || format == "vcm") {
|
if (format == "xml" || format == "vcm") {
|
||||||
engine->getAssets()->store(vcm::parse(name, string), name);
|
engine->getAssets()->store(
|
||||||
|
vcm::parse(name, string, format == "xml"), name
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
throw std::runtime_error("unknown format " + util::quote(std::string(format)));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user