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
+14 -14
View File
@@ -7928,6 +7928,20 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='mjLROpt'),
doc='options for lengthrange computation',
),
StructFieldDecl(
name='meshdir',
type=PointerType(
inner_type=ValueType(name='mjString'),
),
doc='mesh and hfield directory',
),
StructFieldDecl(
name='texturedir',
type=PointerType(
inner_type=ValueType(name='mjString'),
),
doc='texture directory',
),
),
)),
('mjSpec',
@@ -7959,20 +7973,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([
type=ValueType(name='mjtByte'),
doc='automatically strip paths from mesh files',
),
StructFieldDecl(
name='meshdir',
type=PointerType(
inner_type=ValueType(name='mjString'),
),
doc='mesh and hfield directory',
),
StructFieldDecl(
name='texturedir',
type=PointerType(
inner_type=ValueType(name='mjString'),
),
doc='texture directory',
),
StructFieldDecl(
name='option',
type=ValueType(name='mjOption'),
+16
View File
@@ -593,6 +593,22 @@ PYBIND11_MODULE(_specs, m) {
},
py::arg("degree"), py::arg("sequence") = py::none(),
py::arg("orientation"), py::return_value_policy::copy);
mjSpec.def_property(
"meshdir",
[](MjSpec& self) -> std::string_view {
return *self.ptr->compiler.meshdir;
},
[](MjSpec& self, std::string_view meshdir) {
*(self.ptr->compiler.meshdir) = meshdir;
});
mjSpec.def_property(
"texturedir",
[](MjSpec& self) -> std::string_view {
return *self.ptr->compiler.texturedir;
},
[](MjSpec& self, std::string_view texturedir) {
*(self.ptr->compiler.texturedir) = texturedir;
});
// ============================= MJSBODY =====================================
mjsBody.def(