diff --git a/doc/changelog.rst b/doc/changelog.rst index 441c036d..a3b025ce 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -14,50 +14,52 @@ General 1. Added the :ref:`replicate` to MJCF, a :ref:`meta-element` which permits to repeat a subtree with incremental translational and rotational offsets. -2. Added ``mjModel.mesh_scale``: the scaling applied to asset vertices, as specified in the +2. Enabled an internal cache in the MuJoCo compiler resulting in recompilation speedup. Currently, processed + textures, hfields, and OBJ meshes are cached. Support for Unity environments is not yet available. +3. Added ``mjModel.mesh_scale``: the scaling applied to asset vertices, as specified in the :ref:`scale` attribute. -3. Added visual properties which are ignored by the native renderer, but can be used by external renderers: +4. Added visual properties which are ignored by the native renderer, but can be used by external renderers: - :ref:`light/bulbradius` attribute and corresponding ``mjModel.light_bulbradius`` field. - :ref:`material/metallic` attribute and corresponding ``mjModel.material_metallic`` field. - :ref:`material/roughness` attribute and corresponding ``mjModel.material_roughness`` field. -4. The type of the ``size`` argument of :ref:`mj_stackAllocNum` and :ref:`mj_stackAllocInt` was changed from ``int`` +5. The type of the ``size`` argument of :ref:`mj_stackAllocNum` and :ref:`mj_stackAllocInt` was changed from ``int`` to ``size_t``. -5. Added support for gmsh format version 2.2 surface meshes in :ref:`flexcomp`. +6. Added support for gmsh format version 2.2 surface meshes in :ref:`flexcomp`. MJX ^^^ .. admonition:: Breaking API changes :class: attention - 6. Removed deprecated ``mjx.device_get_into`` and ``mjx.device_put`` functions as they lack critical new + 7. Removed deprecated ``mjx.device_get_into`` and ``mjx.device_put`` functions as they lack critical new functionality. **Migration:** Use ``mjx.get_data_into`` instead of ``mjx.device_get_into``, and ``mjx.put_data`` instead of ``mjx.device_put``. -7. Added cylinder plane collisions. -8. Added ``efc_type`` to ``mjx.Data`` and ``dim``, ``efc_address`` to ``mjx.Contact``. -9. Added ``geom`` to ``mjx.Contact`` and marked ``geom1``, ``geom2`` deprecated. -10. Added ``ne``, ``nf``, ``nl``, ``nefc``, and ``ncon`` to ``mjx.Data`` to match ``mujoco.MjData``. -11. Given the above added fields, removed ``mjx.get_params``, ``mjx.ncon``, and ``mjx.count_constraints``. -12. Changed the way meshes are organized on device to speed up collision detection when a mesh is replicated for many +8. Added cylinder plane collisions. +9. Added ``efc_type`` to ``mjx.Data`` and ``dim``, ``efc_address`` to ``mjx.Contact``. +10. Added ``geom`` to ``mjx.Contact`` and marked ``geom1``, ``geom2`` deprecated. +11. Added ``ne``, ``nf``, ``nl``, ``nefc``, and ``ncon`` to ``mjx.Data`` to match ``mujoco.MjData``. +12. Given the above added fields, removed ``mjx.get_params``, ``mjx.ncon``, and ``mjx.count_constraints``. +13. Changed the way meshes are organized on device to speed up collision detection when a mesh is replicated for many geoms. -13. Fixed a bug where capsules might be ignored in broadphase colliision checking. -14. Added cylinder collisions using SDFs. -15. Added support for all :ref:`condim `: 1, 3, 4, 6. -16. Add support functions for ``id2name`` and ``name2id``, MJX versions of :ref:`mj_id2name` and :ref:`mj_name2id`. -17. Added support for :ref:`gravcomp` and :ref:`actuatorgravcomp`. -18. Fixed a bug in ``mjx.ray`` for sometimes allowed negative distances for ray-mesh tests. +14. Fixed a bug where capsules might be ignored in broadphase colliision checking. +15. Added cylinder collisions using SDFs. +16. Added support for all :ref:`condim `: 1, 3, 4, 6. +17. Add support functions for ``id2name`` and ``name2id``, MJX versions of :ref:`mj_id2name` and :ref:`mj_name2id`. +18. Added support for :ref:`gravcomp` and :ref:`actuatorgravcomp`. +19. Fixed a bug in ``mjx.ray`` for sometimes allowed negative distances for ray-mesh tests. Bug fixes ^^^^^^^^^ -19. Defaults of lights were not being saved, now fixed. -20. Prevent overwriting of frame names by body names when saving an XML. Bug introduced in 3.1.4. -21. Fixed bug in Python binding of :ref:`mj_saveModel`: ``buffer`` argument was documented as optional but was actually +20. Defaults of lights were not being saved, now fixed. +21. Prevent overwriting of frame names by body names when saving an XML. Bug introduced in 3.1.4. +22. Fixed bug in Python binding of :ref:`mj_saveModel`: ``buffer`` argument was documented as optional but was actually not optional. -22. Fixed bug that prevented memory allocations larger than 2.15 GB. +23. Fixed bug that prevented memory allocations larger than 2.15 GB. Version 3.1.4 (April 10th, 2024) diff --git a/src/user/user_api.cc b/src/user/user_api.cc index 2c448edd..abc6e23c 100644 --- a/src/user/user_api.cc +++ b/src/user/user_api.cc @@ -29,6 +29,9 @@ #include "user/user_cache.h" #include "xml/xml_util.h" +// global cache size in bytes (default 500MB) +static constexpr std::size_t kGlobalCacheSize = 500 * (1 << 20); + // prepend prefix template @@ -698,5 +701,12 @@ void mj_setCacheSize(mjCache cache, std::size_t size) { mjCache mj_globalCache() { - return NULL; // currently disabled + // mjCCache is not trivially destructible and so the global cache needs to + // allocated on the heap + if constexpr (kGlobalCacheSize) { + static mjCCache* cache = new(std::nothrow) mjCCache(kGlobalCacheSize); + return (mjCache) cache; + } else { + return NULL; + } }