Add boolean flags for gravity compensation and surface velocity in mjModel.

These fields (`flg_gravcomp` and `flg_surfacevel`) replace the fast-path checks originally guarded by `ngravcomp` and (recently) `nsurfacevel`. Since the engine uses these integers only as flags (zero vs non-zero), migrating them to actual booleans makes them writeable from the Python bindings at runtime without violating size/dimension constraints.

The legacy integer field `ngravcomp` is marked as deprecated and will be removed in a future release.

PiperOrigin-RevId: 949779204
Change-Id: Ifab1f026063a4239302e6ad689663b611b59dda8
This commit is contained in:
Yuval Tassa
2026-07-17 15:04:37 -07:00
committed by Copybara-Service
parent ebd4abae03
commit a04b0c5b97
20 changed files with 111 additions and 34 deletions
+12 -6
View File
@@ -4242,12 +4242,6 @@ struct MjModel {
void set_ngravcomp(int value) {
ptr_->ngravcomp = static_cast<mjtSize>(value);
}
int nsurfacevel() const {
return static_cast<int>(ptr_->nsurfacevel);
}
void set_nsurfacevel(int value) {
ptr_->nsurfacevel = static_cast<mjtSize>(value);
}
int nemax() const {
return static_cast<int>(ptr_->nemax);
}
@@ -4314,6 +4308,18 @@ struct MjModel {
void set_nbuffer(int value) {
ptr_->nbuffer = static_cast<mjtSize>(value);
}
mjtBool flg_gravcomp() const {
return ptr_->flg_gravcomp;
}
void set_flg_gravcomp(mjtBool value) {
ptr_->flg_gravcomp = value;
}
mjtBool flg_surfacevel() const {
return ptr_->flg_surfacevel;
}
void set_flg_surfacevel(mjtBool value) {
ptr_->flg_surfacevel = value;
}
emscripten::val buffer() const {
return emscripten::val(emscripten::typed_memory_view(ptr_->nbuffer, static_cast<uint8_t*>(ptr_->buffer)));
}