Migrate mjModel size fields from int to mjtSize.

This change updates all size-related members within the `mjModel` struct from `int` to `mjtSize`. This allows MuJoCo to handle models with a larger number of elements. Corresponding changes were made to macros, function signatures, and I/O routines to accommodate the new `mjtSize` type.

PiperOrigin-RevId: 860144595
Change-Id: I701c6d607715d240766b6210a9773cd9e4258c59
This commit is contained in:
Yuval Tassa
2026-01-23 09:40:42 -08:00
committed by Copybara-Service
parent 4a64017a5f
commit 30b903b6c0
24 changed files with 832 additions and 802 deletions
+11 -7
View File
@@ -56,9 +56,13 @@ namespace {
// (dim0, dim1).
#define X_ARRAY_SHAPE(dim0, dim1) XArrayShapeImpl(#dim1)((dim0), (dim1))
std::vector<int> XArrayShapeImpl1D(int dim0, int dim1) { return {dim0}; }
std::vector<mjtSize> XArrayShapeImpl1D(mjtSize dim0, mjtSize dim1) {
return {dim0};
}
std::vector<int> XArrayShapeImpl2D(int dim0, int dim1) { return {dim0, dim1}; }
std::vector<mjtSize> XArrayShapeImpl2D(mjtSize dim0, mjtSize dim1) {
return {dim0, dim1};
}
constexpr auto XArrayShapeImpl(const std::string_view dim1_str) {
if (dim1_str == "1") {
@@ -401,20 +405,20 @@ This is useful for example when the MJB is not available as a file on disk.)"));
#define X(var) \
mjModel.def_property_readonly( \
#var, [](const MjModelWrapper& m) { return m.get()->var; });
MJMODEL_INTS
MJMODEL_SIZES
#undef X
mjModel.def_property_readonly("_sizes", [](const MjModelWrapper& m) {
int nint = 0;
#define X(var) ++nint;
MJMODEL_INTS
MJMODEL_SIZES
#undef X
py::array_t<std::int64_t> sizes(nint);
{
int i = 0;
auto data = sizes.mutable_unchecked();
#define X(var) data[i++] = m.get()->var;
MJMODEL_INTS
MJMODEL_SIZES
#undef X
}
py::detail::array_proxy(sizes.ptr())->flags &=
@@ -425,7 +429,7 @@ This is useful for example when the MJB is not available as a file on disk.)"));
mjModel.def_property_readonly_static("_size_fields", [](py::object) {
std::vector<std::string> fields;
#define X(var) fields.push_back(#var);
MJMODEL_INTS
MJMODEL_SIZES
#undef X
return py::tuple(py::cast(fields));
});
@@ -433,7 +437,7 @@ This is useful for example when the MJB is not available as a file on disk.)"));
mjModel.def_property_readonly_static("_all_fields", [](py::object) {
std::vector<std::string> fields;
#define X(var) fields.push_back(#var);
MJMODEL_INTS
MJMODEL_SIZES
#undef X
#define X(type, name, nr, nc) fields.push_back(#name);
MJMODEL_POINTERS