Add missing global fields to mjmModel.
PiperOrigin-RevId: 610415124 Change-Id: I07f284804bf73cb67703597973b50b8c00ea8deb
This commit is contained in:
committed by
Copybara-Service
parent
8679c9fc59
commit
1f2d673c7b
+5
-4
@@ -15,6 +15,7 @@
|
||||
#include "xml/xml.h"
|
||||
|
||||
#include <locale.h>
|
||||
#include "user/user_api.h"
|
||||
|
||||
#if defined(__APPLE__) || defined(__FreeBSD__)
|
||||
#include <xlocale.h>
|
||||
@@ -348,9 +349,9 @@ mjCModel* mjParseXML(const char* filename, const mjVFS* vfs,
|
||||
int ndir = 0;
|
||||
mju_getResourceDir(resource, &dir, &ndir);
|
||||
if (dir != nullptr) {
|
||||
model->modelfiledir = std::string(dir, ndir);
|
||||
mjm_setString(model->spec.modelfiledir, std::string(dir, ndir).c_str());
|
||||
} else {
|
||||
model->modelfiledir = "";
|
||||
mjm_setString(model->spec.modelfiledir, "");
|
||||
}
|
||||
|
||||
// close resource
|
||||
@@ -362,8 +363,8 @@ mjCModel* mjParseXML(const char* filename, const mjVFS* vfs,
|
||||
// find include elements, replace them with subtree from xml file
|
||||
std::unordered_set<std::string> included = {filename};
|
||||
mjXReader parser;
|
||||
parser.SetModelFileDir(model->modelfiledir);
|
||||
mjIncludeXML(parser, root, model->modelfiledir, vfs, included);
|
||||
parser.SetModelFileDir(mjm_getString(model->spec.modelfiledir));
|
||||
mjIncludeXML(parser, root, mjm_getString(model->spec.modelfiledir), vfs, included);
|
||||
|
||||
// parse MuJoCo model
|
||||
parser.SetModel(model);
|
||||
|
||||
@@ -811,9 +811,9 @@ void mjXReader::Parse(XMLElement* root) {
|
||||
|
||||
// get comment
|
||||
if (root->FirstChild() && root->FirstChild()->ToComment()) {
|
||||
model->comment = root->FirstChild()->Value();
|
||||
mjm_setString(model->spec.comment, root->FirstChild()->Value());
|
||||
} else {
|
||||
model->comment.clear();
|
||||
mjm_setString(model->spec.comment, "");
|
||||
}
|
||||
|
||||
//------------------- parse MuJoCo sections embedded in all XML formats
|
||||
|
||||
@@ -781,8 +781,9 @@ string mjXWriter::Write(char *error, size_t error_sz) {
|
||||
doc.InsertFirstChild(root);
|
||||
|
||||
// write comment if present
|
||||
if (!model->comment.empty()) {
|
||||
XMLComment* comment = doc.NewComment(model->comment.c_str());
|
||||
string text = mjm_getString(model->comment);
|
||||
if (!text.empty()) {
|
||||
XMLComment* comment = doc.NewComment(text.c_str());
|
||||
root->LinkEndChild(comment);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user