Move meshdir and texturedir to mjsCompiler.

For backwards compatibility in the Python bindings, both `spec.compiler.meshdir` and `spec.meshdir` are now allowed.

Fixes #2834.

PiperOrigin-RevId: 809060113
Change-Id: Ie23f1c5dd57de43568312a8e062906f4013bb474
This commit is contained in:
Alessio Quaglino
2025-09-19 09:04:42 -07:00
committed by Copybara-Service
parent 681f5767b2
commit 77e025ea98
16 changed files with 98 additions and 79 deletions
+8 -10
View File
@@ -140,8 +140,8 @@ mjCModel::mjCModel() {
elemtype = mjOBJ_MODEL;
spec_comment_.clear();
spec_modelfiledir_.clear();
spec_meshdir_.clear();
spec_texturedir_.clear();
meshdir_.clear();
texturedir_.clear();
spec_modelname_ = "MuJoCo Model";
//------------------------ auto-computed statistics
@@ -201,10 +201,12 @@ mjCModel& mjCModel::operator=(const mjCModel& other) {
this->spec = other.spec;
*static_cast<mjCModel_*>(this) = static_cast<const mjCModel_&>(other);
*static_cast<mjSpec*>(this) = static_cast<const mjSpec&>(other);
PointToLocal();
// copy attached specs first so that we can resolve references to them
for (const auto* s : other.specs_) {
specs_.push_back(mj_copySpec(s));
for (auto* s : other.specs_) {
specs_.push_back(s);
static_cast<mjCModel*>(s->element)->AddRef();
compiler2spec_[&s->compiler] = specs_.back();
}
@@ -869,13 +871,11 @@ void mjCModel::PointToLocal() {
spec.comment = &spec_comment_;
spec.modelfiledir = &spec_modelfiledir_;
spec.modelname = &spec_modelname_;
spec.meshdir = &spec_meshdir_;
spec.texturedir = &spec_texturedir_;
spec.compiler.meshdir = &meshdir_;
spec.compiler.texturedir = &texturedir_;
comment = nullptr;
modelfiledir = nullptr;
modelname = nullptr;
meshdir = nullptr;
texturedir = nullptr;
}
@@ -885,8 +885,6 @@ void mjCModel::CopyFromSpec() {
comment_ = spec_comment_;
modelfiledir_ = spec_modelfiledir_;
modelname_ = spec_modelname_;
meshdir_ = spec_meshdir_;
texturedir_ = spec_texturedir_;
}