Fix a bug in MuJoCo's user_mesh.cc that caused meshdir_ to be overwritten when a model was loaded with a nested model.

PiperOrigin-RevId: 675092713
Change-Id: Iad6336141749510bf5544cab9c06533ee1589c08
This commit is contained in:
Alessio Quaglino
2024-09-16 04:21:11 -07:00
committed by Copybara-Service
parent fd17b2144a
commit c77babe046
5 changed files with 116 additions and 9 deletions
+12 -4
View File
@@ -222,8 +222,12 @@ void mjCMesh::PointToLocal() {
void mjCMesh::NameSpace(const mjCModel* m) {
mjCBase::NameSpace(m);
modelfiledir_ = FilePath(m->spec_modelfiledir_);
meshdir_ = FilePath(m->spec_meshdir_);
if (modelfiledir_.empty()) {
modelfiledir_ = FilePath(m->spec_modelfiledir_);
}
if (meshdir_.empty()) {
meshdir_ = FilePath(m->spec_meshdir_);
}
}
@@ -2034,8 +2038,12 @@ void mjCSkin::NameSpace(const mjCModel* m) {
for (auto& name : spec_bodyname_) {
name = m->prefix + name + m->suffix;
}
modelfiledir_ = FilePath(m->spec_modelfiledir_);
meshdir_ = FilePath(m->spec_meshdir_);
if (modelfiledir_.empty()) {
modelfiledir_ = FilePath(m->spec_modelfiledir_);
}
if (meshdir_.empty()) {
meshdir_ = FilePath(m->spec_meshdir_);
}
}