diff --git a/doc/changelog.rst b/doc/changelog.rst index 0a1fd882..9648c15d 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -29,6 +29,7 @@ General - ``sidesite -> MjsSite|None`` - ``coef -> real`` - ``divisor -> real`` +- Non-breaking API change: :ref:`mj_sizeModel` now returns an :ref:`mjtSize` rather than an ``int``. MJX ^^^ diff --git a/doc/includes/references.h b/doc/includes/references.h index ce24d87e..f8eae940 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -3097,7 +3097,7 @@ mjModel* mj_copyModel(mjModel* dest, const mjModel* src); void mj_saveModel(const mjModel* m, const char* filename, void* buffer, int buffer_sz); mjModel* mj_loadModel(const char* filename, const mjVFS* vfs); void mj_deleteModel(mjModel* m); -int mj_sizeModel(const mjModel* m); +mjtSize mj_sizeModel(const mjModel* m); mjData* mj_makeData(const mjModel* m); mjData* mj_copyData(mjData* dest, const mjModel* m, const mjData* src); mjData* mjv_copyData(mjData* dest, const mjModel* m, const mjData* src); diff --git a/include/mujoco/mujoco.h b/include/mujoco/mujoco.h index 7100fcaa..5badc217 100644 --- a/include/mujoco/mujoco.h +++ b/include/mujoco/mujoco.h @@ -216,7 +216,7 @@ MJAPI mjModel* mj_loadModel(const char* filename, const mjVFS* vfs); MJAPI void mj_deleteModel(mjModel* m); // Return size of buffer needed to hold model. -MJAPI int mj_sizeModel(const mjModel* m); +MJAPI mjtSize mj_sizeModel(const mjModel* m); // Allocate mjData corresponding to given model. // If the model buffer is unallocated the initial configuration will not be set. diff --git a/python/mujoco/introspect/functions.py b/python/mujoco/introspect/functions.py index 5a8ab934..75aeca47 100644 --- a/python/mujoco/introspect/functions.py +++ b/python/mujoco/introspect/functions.py @@ -856,7 +856,7 @@ FUNCTIONS: Mapping[str, FunctionDecl] = dict([ ('mj_sizeModel', FunctionDecl( name='mj_sizeModel', - return_type=ValueType(name='int'), + return_type=ValueType(name='mjtSize'), parameters=( FunctionParameterDecl( name='m', diff --git a/src/engine/engine_io.c b/src/engine/engine_io.c index a2ae5544..32ea64f0 100644 --- a/src/engine/engine_io.c +++ b/src/engine/engine_io.c @@ -671,8 +671,8 @@ void mj_deleteModel(mjModel* m) { // size of buffer needed to hold model -int mj_sizeModel(const mjModel* m) { - int size = ( +mjtSize mj_sizeModel(const mjModel* m) { + mjtSize size = ( sizeof(int)*(NHEADER+getnint()) + sizeof(mjtSize)*getnbuffer() + sizeof(mjOption) diff --git a/src/engine/engine_io.h b/src/engine/engine_io.h index 7a3df5ac..a2d7bc34 100644 --- a/src/engine/engine_io.h +++ b/src/engine/engine_io.h @@ -76,7 +76,7 @@ mjModel* mj_loadModelBuffer(const void* buffer, int buffer_sz); MJAPI void mj_deleteModel(mjModel* m); // size of buffer needed to hold model -MJAPI int mj_sizeModel(const mjModel* m); +MJAPI mjtSize mj_sizeModel(const mjModel* m); // validate reference fields in a model; return null if valid, error message otherwise MJAPI const char* mj_validateReferences(const mjModel* m); diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index 3239c5f0..b7c3823b 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -6448,7 +6448,7 @@ public static unsafe extern mjModel_* mj_loadModel([MarshalAs(UnmanagedType.LPSt public static unsafe extern void mj_deleteModel(mjModel_* m); [DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)] -public static unsafe extern int mj_sizeModel(mjModel_* m); +public static unsafe extern UInt64 mj_sizeModel(mjModel_* m); [DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)] public static unsafe extern mjData_* mj_makeData(mjModel_* m); diff --git a/wasm/codegen/generated/bindings.cc b/wasm/codegen/generated/bindings.cc index 31b5744b..2651bcaf 100644 --- a/wasm/codegen/generated/bindings.cc +++ b/wasm/codegen/generated/bindings.cc @@ -10114,7 +10114,7 @@ void mj_defaultVisual_wrapper(MjVisual& vis) { mj_defaultVisual(vis.get()); } -int mj_sizeModel_wrapper(const MjModel& m) { +mjtSize mj_sizeModel_wrapper(const MjModel& m) { return mj_sizeModel(m.get()); }