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:
committed by
Copybara-Service
parent
681f5767b2
commit
77e025ea98
+18
-16
@@ -1210,6 +1210,13 @@ void mjCBase::NameSpace(const mjCModel* m) {
|
||||
|
||||
|
||||
|
||||
mjsCompiler* mjCBase::FindCompiler(const mjsCompiler* compiler) const {
|
||||
mjSpec* origin = model->FindSpec(compiler);
|
||||
return origin ? &origin->compiler : &model->spec.compiler;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// load resource if found (fallback to OS filesystem)
|
||||
mjResource* mjCBase::LoadResource(const std::string& modelfiledir,
|
||||
const std::string& filename,
|
||||
@@ -1313,8 +1320,7 @@ mjCBody::mjCBody(mjCModel* _model) {
|
||||
|
||||
mjCBody::mjCBody(const mjCBody& other, mjCModel* _model) {
|
||||
model = _model;
|
||||
mjSpec* origin = model->FindSpec(other.compiler);
|
||||
compiler = origin ? &origin->compiler : &model->spec.compiler;
|
||||
compiler = FindCompiler(other.compiler);
|
||||
*this = other;
|
||||
CopyPlugin();
|
||||
}
|
||||
@@ -1389,7 +1395,8 @@ mjCBody& mjCBody::operator+=(const mjCBody& other) {
|
||||
mjCBody& mjCBody::operator+=(const mjCFrame& other) {
|
||||
// append a copy of the attached spec
|
||||
if (other.model != model && !model->FindSpec(&other.model->spec.compiler)) {
|
||||
model->AppendSpec(mj_copySpec(&other.model->spec), &other.model->spec.compiler);
|
||||
model->AppendSpec(&other.model->spec, &other.model->spec.compiler);
|
||||
static_cast<mjCModel*>(other.model->spec.element)->AddRef();
|
||||
}
|
||||
|
||||
// create a copy of the subtree that contains the frame
|
||||
@@ -2644,7 +2651,8 @@ mjCFrame& mjCFrame::operator=(const mjCFrame& other) {
|
||||
mjCFrame& mjCFrame::operator+=(const mjCBody& other) {
|
||||
// append a copy of the attached spec
|
||||
if (other.model != model && !model->FindSpec(&other.model->spec.compiler)) {
|
||||
model->AppendSpec(mj_copySpec(&other.model->spec), &other.model->spec.compiler);
|
||||
model->AppendSpec(&other.model->spec, &other.model->spec.compiler);
|
||||
static_cast<mjCModel*>(other.model->spec.element)->AddRef();
|
||||
}
|
||||
|
||||
// apply namespace and store keyframes in the source model
|
||||
@@ -4363,9 +4371,6 @@ void mjCHField::NameSpace(const mjCModel* m) {
|
||||
if (modelfiledir_.empty()) {
|
||||
modelfiledir_ = FilePath(m->spec_modelfiledir_);
|
||||
}
|
||||
if (meshdir_.empty()) {
|
||||
meshdir_ = FilePath(m->spec_meshdir_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4489,9 +4494,8 @@ void mjCHField::Compile(const mjVFS* vfs) {
|
||||
if (modelfiledir_.empty()) {
|
||||
modelfiledir_ = FilePath(model->modelfiledir_);
|
||||
}
|
||||
if (meshdir_.empty()) {
|
||||
meshdir_ = FilePath(model->meshdir_);
|
||||
}
|
||||
mujoco::user::FilePath meshdir_;
|
||||
meshdir_ = FilePath(mjs_getString(compiler->meshdir));
|
||||
|
||||
FilePath filename = meshdir_ + FilePath(file_);
|
||||
mjResource* resource = LoadResource(modelfiledir_.Str(), filename.Str(), vfs);
|
||||
@@ -4626,9 +4630,6 @@ void mjCTexture::NameSpace(const mjCModel* m) {
|
||||
if (modelfiledir_.empty()) {
|
||||
modelfiledir_ = FilePath(m->spec_modelfiledir_);
|
||||
}
|
||||
if (texturedir_.empty()) {
|
||||
texturedir_ = FilePath(m->spec_texturedir_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5218,6 +5219,8 @@ void mjCTexture::LoadCubeSeparate(const mjVFS* vfs) {
|
||||
}
|
||||
|
||||
// make filename
|
||||
mujoco::user::FilePath texturedir_;
|
||||
texturedir_ = FilePath(mjs_getString(compiler->texturedir));
|
||||
FilePath filename = texturedir_ + FilePath(cubefiles_[i]);
|
||||
|
||||
// load PNG or custom
|
||||
@@ -5296,9 +5299,8 @@ void mjCTexture::Compile(const mjVFS* vfs) {
|
||||
if (modelfiledir_.empty()) {
|
||||
modelfiledir_ = FilePath(model->modelfiledir_);
|
||||
}
|
||||
if (texturedir_.empty()) {
|
||||
texturedir_ = FilePath(model->texturedir_);
|
||||
}
|
||||
mujoco::user::FilePath texturedir_;
|
||||
texturedir_ = FilePath(mjs_getString(compiler->texturedir));
|
||||
|
||||
// buffer from user
|
||||
if (!data_.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user