When loading models use mj_parse instead of mj_parseXML, and allow non-xml file types.
PiperOrigin-RevId: 853730923 Change-Id: I1c107daafd558bedb99338779c8174ee3e4d07e2
This commit is contained in:
committed by
Copybara-Service
parent
1f4bb39b53
commit
2f2f9a30ba
@@ -165,15 +165,14 @@ void App::LoadModel(std::string data, ContentType type) {
|
|||||||
model_name_ = std::move(data);
|
model_name_ = std::move(data);
|
||||||
const std::string resolved_file =
|
const std::string resolved_file =
|
||||||
platform::ResolveFile(model_name_, search_paths_);
|
platform::ResolveFile(model_name_, search_paths_);
|
||||||
if (resolved_file.ends_with(".mjb")) {
|
if (resolved_file.ends_with(".mjb")) {
|
||||||
model_ = mj_loadModel(resolved_file.c_str(), 0);
|
model_ = mj_loadModel(resolved_file.c_str(), 0);
|
||||||
} else if (resolved_file.ends_with(".xml")) {
|
} else {
|
||||||
spec_ = mj_parseXML(resolved_file.c_str(), nullptr, err, sizeof(err));
|
spec_ =
|
||||||
|
mj_parse(resolved_file.c_str(), nullptr, nullptr, err, sizeof(err));
|
||||||
if (spec_ && err[0] == 0) {
|
if (spec_ && err[0] == 0) {
|
||||||
model_ = mj_compile(spec_, nullptr);
|
model_ = mj_compile(spec_, nullptr);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
error_ = "Unknown model file type; expected .mjb or .xml.";
|
|
||||||
}
|
}
|
||||||
} else if (type == ContentType::kModelXml) {
|
} else if (type == ContentType::kModelXml) {
|
||||||
model_name_ = "[xml]";
|
model_name_ = "[xml]";
|
||||||
|
|||||||
Reference in New Issue
Block a user