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
+15 -4
View File
@@ -97,10 +97,21 @@ def _generate_field_data(
):
builder = code_builder.CodeBuilder()
with builder.function(f"{f.type.name} {f.name}() const"):
builder.line(f"return ptr_->{f.name};")
with builder.function(f"void set_{f.name}({f.type.name} value)"):
builder.line(f"ptr_->{f.name} = value;")
# `mjtSize` is a 64-bit signed integer type and would be represented in
# JS/TS a `bigint` because it doesn't fit in the number primitive (a 64-bit
# float). By casting int, we avoid "TS2345: Argument of type 'bigint' is not
# assignable to parameter of type 'number'" errors.
if f.type.name == "mjtSize":
with builder.function(f"int {f.name}() const"):
builder.line(f"return static_cast<int>(ptr_->{f.name});")
with builder.function(f"void set_{f.name}(int value)"):
builder.line(f"ptr_->{f.name} = static_cast<mjtSize>(value);")
else:
with builder.function(f"{f.type.name} {f.name}() const"):
builder.line(f"return ptr_->{f.name};")
with builder.function(f"void set_{f.name}({f.type.name} value)"):
builder.line(f"ptr_->{f.name} = value;")
return WrappedFieldData(
declaration=builder.to_string(),