Remove usage of size_t types in mjModel, use mjtSize (uint64_t) instead to improve portabilty of MJB files to WASM.

PiperOrigin-RevId: 789321991
Change-Id: Ic25fab876c347fc75f5ca24cad09e8fd972f035f
This commit is contained in:
Matija Kecman
2025-07-31 07:06:58 -07:00
committed by Copybara-Service
parent 4c288c19ac
commit 23fa7c00d5
11 changed files with 224 additions and 185 deletions
+5 -5
View File
@@ -162,8 +162,8 @@ typedef struct mjSolverStat_ mjSolverStat;
struct mjData_ {
// constant sizes
size_t narena; // size of the arena in bytes (inclusive of the stack)
size_t nbuffer; // size of main buffer in bytes
mjtSize narena; // size of the arena in bytes (inclusive of the stack)
mjtSize nbuffer; // size of main buffer in bytes
int nplugin; // number of plugin instances
// stack pointer
@@ -174,9 +174,9 @@ struct mjData_ {
size_t parena; // first available byte in arena
// memory utilization statistics
size_t maxuse_stack; // maximum stack allocation in bytes
size_t maxuse_threadstack[mjMAXTHREAD]; // maximum stack allocation per thread in bytes
size_t maxuse_arena; // maximum arena allocation in bytes
mjtSize maxuse_stack; // maximum stack allocation in bytes
mjtSize maxuse_threadstack[mjMAXTHREAD]; // maximum stack allocation per thread in bytes
mjtSize maxuse_arena; // maximum arena allocation in bytes
int maxuse_con; // maximum number of contacts
int maxuse_efc; // maximum number of scalar constraints
+2 -2
View File
@@ -731,8 +731,8 @@ struct mjModel_ {
int nsensordata; // number of mjtNums in sensor data vector
int npluginstate; // number of mjtNums in plugin state vector
size_t narena; // number of bytes in the mjData arena (inclusive of stack)
size_t nbuffer; // number of bytes in buffer
mjtSize narena; // number of bytes in the mjData arena (inclusive of stack)
mjtSize nbuffer; // number of bytes in buffer
// ------------------------------- options and statistics
+2 -2
View File
@@ -170,7 +170,7 @@ typedef struct mjSpec_ { // model specification
mjStatistic stat; // statistics override (if defined)
// sizes
size_t memory; // number of bytes in arena+stack memory
mjtSize memory; // number of bytes in arena+stack memory
int nemax; // max number of equality constraints
int nuserdata; // number of mjtNums in userdata
int nuser_body; // number of mjtNums in body_user
@@ -184,7 +184,7 @@ typedef struct mjSpec_ { // model specification
int nkey; // number of keyframes
int njmax; // (deprecated) max number of constraints
int nconmax; // (deprecated) max number of detected contacts
size_t nstack; // (deprecated) number of mjtNums in mjData stack
mjtSize nstack; // (deprecated) number of mjtNums in mjData stack
// global data
mjString* comment; // comment at top of XML
+8
View File
@@ -15,6 +15,8 @@
#ifndef MUJOCO_INCLUDE_MJTNUM_H_
#define MUJOCO_INCLUDE_MJTNUM_H_
#include <stdint.h>
//---------------------------------- floating-point definition -------------------------------------
// floating point data type and minval
@@ -34,4 +36,10 @@ typedef unsigned char mjtByte; // used for true/false
//-------------------------------------- size definition -------------------------------------------
typedef uint64_t mjtSize; // used for buffer sizes
#endif // MUJOCO_INCLUDE_MJTNUM_H_