Migrate mjtByte to mjtBool for boolean-valued fields.

PiperOrigin-RevId: 921408093
Change-Id: Icb00457836359779f0f72fc02d6a7c0dc9f6bd23
This commit is contained in:
Yuval Tassa
2026-05-26 05:35:15 -07:00
committed by Copybara-Service
parent 3cabb2eb8e
commit 393c1e4217
33 changed files with 242 additions and 224 deletions
+6 -6
View File
@@ -146,10 +146,10 @@ struct mjData_ {
int nv_awake; // number of awake dofs
// flags marking lazily evaluated stages
mjtByte flg_energypos; // has mj_energyPos been called
mjtByte flg_energyvel; // has mj_energyVel been called
mjtByte flg_subtreevel; // has mj_subtreeVel been called
mjtByte flg_rnepost; // has mj_rnePostConstraint been called
mjtBool flg_energypos; // has mj_energyPos been called
mjtBool flg_energyvel; // has mj_energyVel been called
mjtBool flg_subtreevel; // has mj_subtreeVel been called
mjtBool flg_rnepost; // has mj_rnePostConstraint been called
// global properties
mjtNum time; // simulation time
@@ -175,7 +175,7 @@ struct mjData_ {
mjtNum* ctrl; // control (nu x 1)
mjtNum* qfrc_applied; // applied generalized force (nv x 1)
mjtNum* xfrc_applied; // applied Cartesian force/torque (nbody x 6)
mjtByte* eq_active; // enable/disable constraints (neq x 1)
mjtBool* eq_active; // enable/disable constraints (neq x 1)
// mocap data
mjtNum* mocap_pos; // positions of mocap bodies (nmocap x 3)
@@ -256,7 +256,7 @@ struct mjData_ {
mjtNum* qLDiagInv; // 1/diag(D) (nv x 1)
// computed by mj_collision/mj_collideTree
mjtByte* bvh_active; // was bounding volume checked for collision (nbvh x 1)
mjtBool* bvh_active; // was bounding volume checked for collision (nbvh x 1)
// computed by mj_updateSleep
int* tree_awake; // is tree awake; 0: asleep; 1: awake (ntree x 1)
+18 -18
View File
@@ -411,9 +411,9 @@ struct mjModel_ {
int* jnt_bodyid; // id of joint's body (njnt x 1)
int* jnt_actuatorid; // actuator contributing damping / armature (njnt x 1)
int* jnt_group; // group for visibility (njnt x 1)
mjtByte* jnt_limited; // does joint have limits (njnt x 1)
mjtByte* jnt_actfrclimited; // does joint have actuator force limits (njnt x 1)
mjtByte* jnt_actgravcomp; // is gravcomp force applied via actuators (njnt x 1)
mjtBool* jnt_limited; // does joint have limits (njnt x 1)
mjtBool* jnt_actfrclimited; // does joint have actuator force limits (njnt x 1)
mjtBool* jnt_actgravcomp; // is gravcomp force applied via actuators (njnt x 1)
mjtNum* jnt_solref; // constraint solver reference: limit (njnt x mjNREF)
mjtNum* jnt_solimp; // constraint solver impedance: limit (njnt x mjNIMP)
mjtNum* jnt_pos; // local anchor position (njnt x 3)
@@ -512,11 +512,11 @@ struct mjModel_ {
int* light_targetbodyid; // id of targeted body; -1: none (nlight x 1)
int* light_type; // spot, directional, etc. (mjtLightType) (nlight x 1)
int* light_texid; // texture id for image lights (nlight x 1)
mjtByte* light_castshadow; // does light cast shadows (nlight x 1)
mjtBool* light_castshadow; // does light cast shadows (nlight x 1)
float* light_bulbradius; // light radius for soft shadows (nlight x 1)
float* light_intensity; // intensity, in candela (nlight x 1)
float* light_range; // range of effectiveness (nlight x 1)
mjtByte* light_active; // is light on (nlight x 1)
mjtBool* light_active; // is light on (nlight x 1)
mjtNum* light_pos; // position rel. to body frame (nlight x 3)
mjtNum* light_dir; // direction rel. to body frame (nlight x 3)
mjtNum* light_poscom0; // global position rel. to sub-com in qpos0 (nlight x 3)
@@ -540,7 +540,7 @@ struct mjModel_ {
mjtNum* flex_friction; // friction for (slide, spin, roll) (nflex x 3)
mjtNum* flex_margin; // geometric inflation for contact (nflex x 1)
mjtNum* flex_gap; // additional contact detection buffer (nflex x 1)
mjtByte* flex_internal; // internal flex collision enabled (nflex x 1)
mjtBool* flex_internal; // internal flex collision enabled (nflex x 1)
int* flex_selfcollide; // self collision mode (mjtFlexSelf) (nflex x 1)
int* flex_activelayers; // number of active element layers, 3D only (nflex x 1)
int* flex_passive; // passive collisions enabled (nflex x 1)
@@ -596,10 +596,10 @@ struct mjModel_ {
mjtNum* flex_edgestiffness; // edge stiffness (nflex x 1)
mjtNum* flex_edgedamping; // edge damping (nflex x 1)
int* flex_edgeequality; // 0:none, 1:edges, 2:vertices, 3:strain (nflex x 1)
mjtByte* flex_rigid; // are all vertices in the same body (nflex x 1)
mjtByte* flexedge_rigid; // are both edge vertices in same body (nflexedge x 1)
mjtByte* flex_centered; // are all vertex coordinates (0,0,0) (nflex x 1)
mjtByte* flex_flatskin; // render flex skin with flat shading (nflex x 1)
mjtBool* flex_rigid; // are all vertices in the same body (nflex x 1)
mjtBool* flexedge_rigid; // are both edge vertices in same body (nflexedge x 1)
mjtBool* flex_centered; // are all vertex coordinates (0,0,0) (nflex x 1)
mjtBool* flex_flatskin; // render flex skin with flat shading (nflex x 1)
int* flex_bvhadr; // address of bvh root; -1: no bvh (nflex x 1)
int* flex_bvhnum; // number of bounding volumes (nflex x 1)
int* flexedge_J_rownnz; // number of non-zeros in Jacobian row (nflexedge x 1)
@@ -690,7 +690,7 @@ struct mjModel_ {
// materials
int* mat_texid; // indices of textures; -1: none (nmat x mjNTEXROLE)
mjtByte* mat_texuniform; // make texture cube uniform (nmat x 1)
mjtBool* mat_texuniform; // make texture cube uniform (nmat x 1)
float* mat_texrepeat; // texture repetition for 2d mapping (nmat x 2)
float* mat_emission; // emission (x rgb) (nmat x 1)
float* mat_specular; // specular (x white) (nmat x 1)
@@ -720,7 +720,7 @@ struct mjModel_ {
int* eq_obj1id; // id of object 1 (neq x 1)
int* eq_obj2id; // id of object 2 (neq x 1)
int* eq_objtype; // type of both objects (mjtObj) (neq x 1)
mjtByte* eq_active0; // initial enable/disable constraint state (neq x 1)
mjtBool* eq_active0; // initial enable/disable constraint state (neq x 1)
mjtNum* eq_solref; // constraint solver reference (neq x mjNREF)
mjtNum* eq_solimp; // constraint solver impedance (neq x mjNIMP)
mjtNum* eq_data; // numeric data for constraint (neq x mjNEQDATA)
@@ -736,8 +736,8 @@ struct mjModel_ {
int* ten_J_rownnz; // number of non-zeros in Jacobian row (ntendon x 1)
int* ten_J_rowadr; // row start address in colind array (ntendon x 1)
int* ten_J_colind; // column indices in sparse Jacobian (nJten x 1)
mjtByte* tendon_limited; // does tendon have length limits (ntendon x 1)
mjtByte* tendon_actfrclimited; // does tendon have actuator force limits (ntendon x 1)
mjtBool* tendon_limited; // does tendon have length limits (ntendon x 1)
mjtBool* tendon_actfrclimited; // does tendon have actuator force limits (ntendon x 1)
mjtNum* tendon_width; // width for rendering (ntendon x 1)
mjtNum* tendon_solref_lim; // constraint solver reference: limit (ntendon x mjNREF)
mjtNum* tendon_solimp_lim; // constraint solver impedance: limit (ntendon x mjNIMP)
@@ -778,13 +778,13 @@ struct mjModel_ {
int* actuator_history; // history buffer: [nsample, interp] (nu x 2)
int* actuator_historyadr; // address in history buffer; -1: none (nu x 1)
mjtNum* actuator_delay; // delay time in seconds; 0: no delay (nu x 1)
mjtByte* actuator_ctrllimited; // is control limited (nu x 1)
mjtByte* actuator_forcelimited;// is force limited (nu x 1)
mjtByte* actuator_actlimited; // is activation limited (nu x 1)
mjtBool* actuator_ctrllimited; // is control limited (nu x 1)
mjtBool* actuator_forcelimited;// is force limited (nu x 1)
mjtBool* actuator_actlimited; // is activation limited (nu x 1)
mjtNum* actuator_dynprm; // dynamics parameters (nu x mjNDYN)
mjtNum* actuator_gainprm; // gain parameters (nu x mjNGAIN)
mjtNum* actuator_biasprm; // bias parameters (nu x mjNBIAS)
mjtByte* actuator_actearly; // step activation before force (nu x 1)
mjtBool* actuator_actearly; // step activation before force (nu x 1)
mjtNum* actuator_ctrlrange; // range of controls (nu x 2)
mjtNum* actuator_forcerange; // range of forces (nu x 2)
mjtNum* actuator_actrange; // range of activations (nu x 2)
+24 -24
View File
@@ -318,9 +318,9 @@
X ( int, jnt_bodyid, njnt, 1 ) \
X ( int, jnt_actuatorid, njnt, 1 ) \
X ( int, jnt_group, njnt, 1 ) \
X ( mjtByte, jnt_limited, njnt, 1 ) \
X ( mjtByte, jnt_actfrclimited, njnt, 1 ) \
X ( mjtByte, jnt_actgravcomp, njnt, 1 ) \
X ( mjtBool, jnt_limited, njnt, 1 ) \
X ( mjtBool, jnt_actfrclimited, njnt, 1 ) \
X ( mjtBool, jnt_actgravcomp, njnt, 1 ) \
X ( mjtNum, jnt_solref, njnt, mjNREF ) \
X ( mjtNum, jnt_solimp, njnt, mjNIMP ) \
X ( mjtNum, jnt_pos, njnt, 3 ) \
@@ -419,11 +419,11 @@
X ( int, light_targetbodyid, nlight, 1 ) \
X ( int, light_type, nlight, 1 ) \
X ( int, light_texid, nlight, 1 ) \
X ( mjtByte, light_castshadow, nlight, 1 ) \
X ( mjtBool, light_castshadow, nlight, 1 ) \
X ( float, light_bulbradius, nlight, 1 ) \
X ( float, light_intensity, nlight, 1 ) \
X ( float, light_range, nlight, 1 ) \
X ( mjtByte, light_active, nlight, 1 ) \
X ( mjtBool, light_active, nlight, 1 ) \
X ( mjtNum, light_pos, nlight, 3 ) \
X ( mjtNum, light_dir, nlight, 3 ) \
X ( mjtNum, light_poscom0, nlight, 3 ) \
@@ -447,7 +447,7 @@
X ( mjtNum, flex_friction, nflex, 3 ) \
X ( mjtNum, flex_margin, nflex, 1 ) \
X ( mjtNum, flex_gap, nflex, 1 ) \
X ( mjtByte, flex_internal, nflex, 1 ) \
X ( mjtBool, flex_internal, nflex, 1 ) \
X ( int, flex_selfcollide, nflex, 1 ) \
X ( int, flex_activelayers, nflex, 1 ) \
X ( int, flex_passive, nflex, 1 ) \
@@ -501,10 +501,10 @@
X ( mjtNum, flex_edgestiffness, nflex, 1 ) \
X ( mjtNum, flex_edgedamping, nflex, 1 ) \
X ( int, flex_edgeequality, nflex, 1 ) \
X ( mjtByte, flex_rigid, nflex, 1 ) \
X ( mjtByte, flexedge_rigid, nflexedge, 1 ) \
X ( mjtByte, flex_centered, nflex, 1 ) \
X ( mjtByte, flex_flatskin, nflex, 1 ) \
X ( mjtBool, flex_rigid, nflex, 1 ) \
X ( mjtBool, flexedge_rigid, nflexedge, 1 ) \
X ( mjtBool, flex_centered, nflex, 1 ) \
X ( mjtBool, flex_flatskin, nflex, 1 ) \
X ( int, flex_bvhadr, nflex, 1 ) \
X ( int, flex_bvhnum, nflex, 1 ) \
X ( int, flexedge_J_rownnz, nflexedge, 1 ) \
@@ -595,7 +595,7 @@
#define MJMODEL_POINTERS_MATERIAL \
X ( int, mat_texid, nmat, mjNTEXROLE ) \
X ( mjtByte, mat_texuniform, nmat, 1 ) \
X ( mjtBool, mat_texuniform, nmat, 1 ) \
X ( float, mat_texrepeat, nmat, 2 ) \
X ( float, mat_emission, nmat, 1 ) \
X ( float, mat_specular, nmat, 1 ) \
@@ -625,7 +625,7 @@
X ( int, eq_obj1id, neq, 1 ) \
X ( int, eq_obj2id, neq, 1 ) \
X ( int, eq_objtype, neq, 1 ) \
X ( mjtByte, eq_active0, neq, 1 ) \
X ( mjtBool, eq_active0, neq, 1 ) \
X ( mjtNum, eq_solref, neq, mjNREF ) \
X ( mjtNum, eq_solimp, neq, mjNIMP ) \
X ( mjtNum, eq_data, neq, mjNEQDATA )
@@ -641,8 +641,8 @@
X ( int, ten_J_rownnz, ntendon, 1 ) \
X ( int, ten_J_rowadr, ntendon, 1 ) \
X ( int, ten_J_colind, nJten, 1 ) \
X ( mjtByte, tendon_limited, ntendon, 1 ) \
X ( mjtByte, tendon_actfrclimited, ntendon, 1 ) \
X ( mjtBool, tendon_limited, ntendon, 1 ) \
X ( mjtBool, tendon_actfrclimited, ntendon, 1 ) \
X ( mjtNum, tendon_width, ntendon, 1 ) \
X ( mjtNum, tendon_solref_lim, ntendon, mjNREF ) \
X ( mjtNum, tendon_solimp_lim, ntendon, mjNIMP ) \
@@ -678,13 +678,13 @@
X ( int, actuator_history, nu, 2 ) \
X ( int, actuator_historyadr, nu, 1 ) \
X ( mjtNum, actuator_delay, nu, 1 ) \
X ( mjtByte, actuator_ctrllimited, nu, 1 ) \
X ( mjtByte, actuator_forcelimited, nu, 1 ) \
X ( mjtByte, actuator_actlimited, nu, 1 ) \
X ( mjtBool, actuator_ctrllimited, nu, 1 ) \
X ( mjtBool, actuator_forcelimited, nu, 1 ) \
X ( mjtBool, actuator_actlimited, nu, 1 ) \
X ( mjtNum, actuator_dynprm, nu, mjNDYN ) \
X ( mjtNum, actuator_gainprm, nu, mjNGAIN ) \
X ( mjtNum, actuator_biasprm, nu, mjNBIAS ) \
X ( mjtByte, actuator_actearly, nu, 1 ) \
X ( mjtBool, actuator_actearly, nu, 1 ) \
X ( mjtNum, actuator_ctrlrange, nu, 2 ) \
X ( mjtNum, actuator_forcerange, nu, 2 ) \
X ( mjtNum, actuator_actrange, nu, 2 ) \
@@ -828,7 +828,7 @@
X ( mjtNum, ctrl, nu, 1 ) \
X ( mjtNum, qfrc_applied, nv, 1 ) \
X ( mjtNum, xfrc_applied, nbody, 6 ) \
X ( mjtByte, eq_active, neq, 1 ) \
X ( mjtBool, eq_active, neq, 1 ) \
X ( mjtNum, mocap_pos, nmocap, 3 ) \
X ( mjtNum, mocap_quat, nmocap, 4 ) \
X ( mjtNum, qacc, nv, 1 ) \
@@ -879,7 +879,7 @@
XNV ( mjtNum, M, nC, 1 ) \
XNV ( mjtNum, qLD, nC, 1 ) \
X ( mjtNum, qLDiagInv, nv, 1 ) \
X ( mjtByte, bvh_active, nbvh, 1 ) \
X ( mjtBool, bvh_active, nbvh, 1 ) \
X ( int, tree_awake, ntree, 1 ) \
X ( int, body_awake, nbody, 1 ) \
X ( int, body_awake_ind, nbody, 1 ) \
@@ -1032,10 +1032,10 @@
X( int, nbody_awake ) \
X( int, nparent_awake ) \
X( int, nv_awake ) \
X( mjtByte, flg_energypos ) \
X( mjtByte, flg_energyvel ) \
X( mjtByte, flg_subtreevel ) \
X( mjtByte, flg_rnepost ) \
X( mjtBool, flg_energypos ) \
X( mjtBool, flg_energyvel ) \
X( mjtBool, flg_subtreevel ) \
X( mjtBool, flg_rnepost ) \
X( mjtNum, time ) \
X( uintptr_t, threadpool )
+9 -9
View File
@@ -680,7 +680,7 @@ MJAPI const char* mj_versionString(void);
// geomgroup, flg_static are as in mjvOption; geomgroup==NULL skips group exclusion.
// Nullable: geomgroup, geomid, normal
MJAPI mjtNum mj_ray(const mjModel* m, const mjData* d, const mjtNum pnt[3], const mjtNum vec[3],
const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude,
const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude,
int geomid[1], mjtNum normal[3]);
// Intersect multiple rays emanating from a single point, compute normals if given.
@@ -688,7 +688,7 @@ MJAPI mjtNum mj_ray(const mjModel* m, const mjData* d, const mjtNum pnt[3], cons
// Geoms further than cutoff are ignored.
// Nullable: geomgroup, geomid, normal
MJAPI void mj_multiRay(const mjModel* m, mjData* d, const mjtNum pnt[3], const mjtNum* vec,
const mjtByte* geomgroup, mjtByte flg_static, int bodyexclude,
const mjtByte* geomgroup, mjtBool flg_static, int bodyexclude,
int* geomid, mjtNum* dist, mjtNum* normal, int nray, mjtNum cutoff);
// Intersect ray with hfield; return nearest distance or -1 if no intersection.
@@ -711,8 +711,8 @@ MJAPI mjtNum mju_rayGeom(const mjtNum pos[3], const mjtNum mat[9], const mjtNum
// and also output nearest vertex id and surface normal.
// Nullable: vertid, normal
MJAPI mjtNum mj_rayFlex(const mjModel* m, const mjData* d, int flex_layer,
mjtByte flg_vert, mjtByte flg_edge, mjtByte flg_face,
mjtByte flg_skin, int flexid, const mjtNum pnt[3],
mjtBool flg_vert, mjtBool flg_edge, mjtBool flg_face,
mjtBool flg_skin, int flexid, const mjtNum pnt[3],
const mjtNum vec[3], int vertid[1], mjtNum normal[3]);
// Intersect ray with skin; return nearest distance or -1 if no intersection,
@@ -1304,14 +1304,14 @@ MJAPI void mju_cholSolveBand(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
// Convert banded matrix to dense matrix, fill upper triangle if flg_sym>0.
MJAPI void mju_band2Dense(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense,
mjtByte flg_sym);
mjtBool flg_sym);
// Convert dense matrix to banded matrix.
MJAPI void mju_dense2Band(mjtNum* res, const mjtNum* mat, int ntotal, int nband, int ndense);
// Multiply band-diagonal matrix with nvec vectors, include upper triangle if flg_sym>0.
MJAPI void mju_bandMulMatVec(mjtNum* res, const mjtNum* mat, const mjtNum* vec,
int ntotal, int nband, int ndense, int nvec, mjtByte flg_sym);
int ntotal, int nband, int ndense, int nvec, mjtBool flg_sym);
// Address of diagonal element i in band-dense matrix representation.
MJAPI int mju_bandDiag(int i, int ntotal, int nband, int ndense);
@@ -1461,7 +1461,7 @@ MJAPI void mjc_gradient(const mjModel* m, const mjData* d, const mjSDF* s, mjtNu
// D: (nsensordata x 2*nv+na)
// C: (nsensordata x nu)
// Nullable: A, B, C, D
MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_centered,
MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtBool flg_centered,
mjtNum* A, mjtNum* B, mjtNum* C, mjtNum* D);
// Finite differenced Jacobians of (force, sensors) = mj_inverse(state, acceleration)
@@ -1480,7 +1480,7 @@ MJAPI void mjd_transitionFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg
// optionally computes mass matrix Jacobian DmDq
// flg_actuation specifies whether to subtract qfrc_actuator from qfrc_inverse
// Nullable: DfDq, DfDv, DfDa, DsDq, DsDv, DsDa, DmDq
MJAPI void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtByte flg_actuation,
MJAPI void mjd_inverseFD(const mjModel* m, mjData* d, mjtNum eps, mjtBool flg_actuation,
mjtNum *DfDq, mjtNum *DfDv, mjtNum *DfDa,
mjtNum *DsDq, mjtNum *DsDv, mjtNum *DsDa,
mjtNum *DmDq);
@@ -1860,7 +1860,7 @@ MJAPI void mjs_setString(mjString* dest, const char* text);
MJAPI void mjs_setStringVec(mjStringVec* dest, const char* text);
// Set entry in string vector.
MJAPI mjtByte mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
MJAPI mjtBool mjs_setInStringVec(mjStringVec* dest, int i, const char* text);
// Append text entry to string vector.
MJAPI void mjs_appendString(mjStringVec* dest, const char* text);