Commit Graph

1937 Commits

Author SHA1 Message Date
Kevin Zakka 43cde9716c Fix mj_sensorAcc returning zero after mj_step1 by clearing flg_rnepost in mj_step2.
Fixes #3133.
2026-02-25 14:04:33 -08:00
Haroon Qureshi 42d843a0fd Separate mjModel/mjData ImGui table helper from mjSpec ImGui table helper.
There are enough differences between how the two are structured that
having separate implementations makes things easier to implement
despite some minor code duplication.

PiperOrigin-RevId: 875287973
Change-Id: Id49e089e5e1944291ce79e79f8cb71d048a942cc
2026-02-25 12:37:31 -08:00
Taylor Howell 53fadd9d63 Improve nJmom by counting number of dofs for slidercrank and site transmissions
PiperOrigin-RevId: 875233737
Change-Id: I2cf3afad7e29e176a4f5a917dd35cfad99b2b0a3
2026-02-25 10:41:24 -08:00
Sam Haves b907ffedaa Move OBJ handling to a mjpDecoder.
PiperOrigin-RevId: 875194599
Change-Id: I2cccc683d69a217f1817e70d16bc1815e366d00c
2026-02-25 09:13:09 -08:00
Haroon Qureshi abdea379af Allow the shadow type and map size to be configured in data.
PiperOrigin-RevId: 875179785
Change-Id: I638c8c8c9e45dd58f393684a09f2ab4871911f7a
2026-02-25 08:35:01 -08:00
Yuval Tassa 0c66585e39 Fix typos and minor corrections in MuJoCo documentation and comments.
PiperOrigin-RevId: 875163889
Change-Id: Ic604d6235bf9cb999058f191e3ee41e47ec1a567
2026-02-25 07:56:31 -08:00
Haroon Qureshi 757758dd2e Rename all filament mjr_ functions to mjrf_.
Rename stubs.cc to mjr_compat.cc. This library acts like a
"compatibility layer" that allows the filament renderer to
be implemented behind the mjr API.

PiperOrigin-RevId: 875114054
Change-Id: I5c47581cacbcadff4c78d2ad15728cc1c3a394ad
2026-02-25 05:43:50 -08:00
Alessio Quaglino 22e3217fc0 Replace TriangleMeshDistance with custom BVH-based SDF computation.
The `mjCOctree::ComputeSdfCoeffs` function has been replaced by `mjCOctree::ComputeSdf`. The new implementation removes the dependency on the `triangle_mesh_distance` library. Instead, it uses a provided `mjCBoundingVolumeHierarchy` to perform closest point queries on the mesh. The signed distance is computed by finding the closest triangle face via the BVH and determining the sign based on the dot product of the vector from the closest point on the triangle to the octree vertex and the triangle's normal.

Optional Laplacian smoothing has been added to the SDF coefficients. This helps smooth out potential discontinuities at octree level boundaries.

PiperOrigin-RevId: 875093374
Change-Id: I6fa53243a2dda107ccf255bc6b876ca5a4554d4f
2026-02-25 04:47:46 -08:00
Taylor Howell 52ed96bc3a Move tendon sparsity fields from mjData to mjModel
PiperOrigin-RevId: 875087590
Change-Id: I1a5489d2d2011795ee38b09d547e68acd72e3cc7
2026-02-25 04:32:11 -08:00
Matija Kecman 253494739a Read the clear color from the model if available
PiperOrigin-RevId: 875079722
Change-Id: Id5a9c359d19f46d1c0bb5fbf5043db0ee4b1b9b6
2026-02-25 04:09:27 -08:00
Kyle Bayes 84205f7dd0 Isolate libccd logic in mjc_penetration.
PiperOrigin-RevId: 875073780
Change-Id: I71bd39695aa667110fffff47f34cd98faa562cc6
2026-02-25 03:53:34 -08:00
Kyle Bayes cd8bfb90c3 Improve polygon creation logic in compiler.
PiperOrigin-RevId: 875070301
Change-Id: I06e851f3450035fff68b99997406d6ea471ce3b8
2026-02-25 03:40:07 -08:00
Haroon Qureshi ae7efead09 Show MuJoCo version in the help menu.
PiperOrigin-RevId: 875061430
Change-Id: I4d4ce32eebd8ca4af4622e9b4d1cd50d180d0b96
2026-02-25 03:11:13 -08:00
Alessio Quaglino 09c7633a76 Add caching for flex stiffness computation.
This change introduces methods to cache and load the computed stiffness matrix and nodal masses for flex elements. The cache key is generated based on material properties (Young's modulus, Poisson's ratio), interpolation order, and the bounding box of the flex. This avoids redundant expensive computations when compiling models with identical flex definitions.

PiperOrigin-RevId: 874689771
Change-Id: I6d1e299baf294a984b507e2a2602b2c068610536
2026-02-24 10:45:23 -08:00
Haroon Qureshi 1d6ff2cece Display Bodies as a tree in Spec Explorer.
Display all other elements under "Elements" or "Assets" group.

Show properties for mjSpec, mjModel, and mjData for selected
elements.

PiperOrigin-RevId: 874614195
Change-Id: I128c2bec844983ac5d35a3a0b1e58b8a5b0109cb
2026-02-24 07:57:44 -08:00
Alessio Quaglino 5fc580a8ba Refactor SDF coefficient computation into mjCOctree.
The logic for computing Signed Distance Function (SDF) coefficients using TriangleMeshDistance is moved from `mjCPlugin::Make` in `user_mesh.cc` to a new method `mjCOctree::ComputeSdfCoeffs` in `user_objects.cc`. This encapsulates the SDF computation within the octree class.

PiperOrigin-RevId: 874572414
Change-Id: Ia2365c9c4527a252ff1d1bb43fe2c2593761e471
2026-02-24 06:03:59 -08:00
Taylor Howell 6ec808e2ce Fix attach for spatial tendon. Fixes #3119.
PiperOrigin-RevId: 874067521
Change-Id: If8d415278dde2bccf269cc90e8c176e3d7edefa6
2026-02-23 07:38:43 -08:00
Taylor Howell 37e993f67e Improve upper bound for nJmom by computing maximum number of dofs for tendon transmissions
PiperOrigin-RevId: 874057077
Change-Id: I83736719cc2d91a899cd5997ea4a91d21cf06c9e
2026-02-23 07:11:31 -08:00
Haroon Qureshi 7d4b615edb Use correct WIN32 define, not WINDOWS.
PiperOrigin-RevId: 872866601
Change-Id: I35bb5cc0fdef80cf816a63bb7fc1619ef424c0d0
2026-02-20 06:10:00 -08:00
Alessio Quaglino f9a39413cf Fix: Include ancestor DOFs in flex interpolation factorization.
The reduced dense factorization for flex interpolation now considers all DOFs in the kinematic chain of the body containing the flex, using mj_bodyChain, instead of only the DOFs directly associated with that body. This is necessary for correctly handling pinned flexes when their parent body is part of a larger kinematic structure.

PiperOrigin-RevId: 872854468
Change-Id: Idbe9fb459084dde9e8eb1076c70dbb685c1b0bdb
2026-02-20 05:30:54 -08:00
Haroon Qureshi 8c9ba9bcf5 Disable plugin on windows.
PiperOrigin-RevId: 872845569
Change-Id: I4d80c80a47358a2882b2c63c2d655fe374afe65d
2026-02-20 05:00:04 -08:00
Haroon Qureshi f71e215c9a Include missing header.
PiperOrigin-RevId: 872835150
Change-Id: I670bddb907b594788bda143c5175bbcb4b427903
2026-02-20 04:23:59 -08:00
Haroon Qureshi 0083cf7fa8 Refactor the projectile launcher into a plugin.
Add a simple GUI for it that allows users to enable/disable
the key binding as well as control some parameters.

PiperOrigin-RevId: 872816645
Change-Id: I8abb2803e17b4f6195d447220c436d4701b24db8
2026-02-20 03:19:53 -08:00
Haroon Qureshi 28ad603f6b Use templates and macros to reduce boilerplate.
PiperOrigin-RevId: 872805912
Change-Id: I6fc1abe283bc809a95d660abc072906b0810aaeb
2026-02-20 02:42:52 -08:00
Haroon Qureshi f0bf403254 Add a delete button to the highlighted element.
PiperOrigin-RevId: 872795277
Change-Id: I63afa9c87b425ebed5d20126e9909ad95532d559
2026-02-20 02:09:36 -08:00
Haroon Qureshi 82694b520b Re-apply changes that were accidentally deleted.
PiperOrigin-RevId: 872782055
Change-Id: If2f403835cd2d90c88abe9ed82380dfca5b3d9c8
2026-02-20 01:27:57 -08:00
Matija Kecman ca0552c83b Cleanup Studio toolbar
PiperOrigin-RevId: 872618794
Change-Id: I2e8f99dc47937416c8516ed1df7821369211b12f
2026-02-19 16:34:38 -08:00
Alessio Quaglino 8ba68cee3e Limit the number of flex contacts per collision pair.
This change introduces a filter for flex-related contacts, ensuring that no more than mjMAXCONPAIR contacts are kept for each geom-flex, flex-flex, flex internal, and flex self-collision pair. The contacts are sorted using farthest-point sampling:

- Starts with the deepest penetrating contact
- Iteratively selects the contact farthest from already-selected contacts
- Produces a spatially distributed set of contacts

PiperOrigin-RevId: 872593388
Change-Id: I50b233a0dc66da6a297852c258ba514f131c8f23
2026-02-19 15:32:17 -08:00
Taylor Howell 84431fbf7e Improved upper bound for nJten
PiperOrigin-RevId: 872479828
Change-Id: I750d56320d6ace6145475d378cb9d0c30919438d
2026-02-19 11:09:25 -08:00
Taylor Howell 9efe41c0c1 Remove dense code path for tendon Jacobian
PiperOrigin-RevId: 872444531
Change-Id: I6180101abc49469a72aee8bec5726e1e94f142ec
2026-02-19 09:53:49 -08:00
Haroon Qureshi 10524c28dd Track and restore viscous pause state every frame.
PiperOrigin-RevId: 872382150
Change-Id: I96bddcfb2a0a204c6505e9795dfff97f09834855
2026-02-19 07:06:38 -08:00
Haroon Qureshi ab80bd0916 Allow model holder to release ownership of mujoco structs.
PiperOrigin-RevId: 872242489
Change-Id: I055f54f4e111cc78c489c12d9ae5c02cfb57169d
2026-02-19 00:06:07 -08:00
Copybara-Service 57c2316b9e Merge pull request #3080 from kevinzakka:fix-fusestatic-camera-light-crash
PiperOrigin-RevId: 872054304
Change-Id: I9eab499002077afa46b236e8eae13100285f362c
2026-02-18 14:53:30 -08:00
Haroon Qureshi fdf6f1017c Remove enable_keyboard flag.
PiperOrigin-RevId: 871823567
Change-Id: I1e307f366106aa542a66b68b8e057b35c25134c9
2026-02-18 05:43:33 -08:00
Haroon Qureshi 6b197e198a Reset free camera when loading a new model.
PiperOrigin-RevId: 871622663
Change-Id: I1f1a4681752f7436c7bc7adbe64dcea286c5620c
2026-02-17 20:08:02 -08:00
Haroon Qureshi 767e52fb5b Fire projectiles when hitting "Ctrl+Shift+Enter".
PiperOrigin-RevId: 871215312
Change-Id: Ie22699d5446a49ea6997594b2800cf72840554c1
2026-02-17 02:53:31 -08:00
Haroon Qureshi 4ce9fb53ee Re-enable MJZ support.
Disabled on Windows until we can make plugins work correctly.

PiperOrigin-RevId: 871214280
Change-Id: I831238704c2807e70f4347989d642a189764e53c
2026-02-17 02:51:14 -08:00
Alessio Quaglino 8024124572 Use stack allocation for temporary flex rigidity storage in mj_setConst. Fixes #3081
PiperOrigin-RevId: 871200819
Change-Id: Ifbc1c0bd62261325a06a246cb2adb1106c02f829
2026-02-17 02:16:07 -08:00
Haroon Qureshi 989b6e63c7 Add ability to delete bodies.
PiperOrigin-RevId: 871200603
Change-Id: I08bc786ca8106ef13cfcbe89e8cc42e9ad2c99d5
2026-02-17 02:14:54 -08:00
Copybara-Service 160e601ba1 Merge pull request #3085 from Ashutosh0x:fix/windows-zero-alloc
PiperOrigin-RevId: 870765044
Change-Id: I91b6a6096fe58200f8b36fda62838046a9ee08fe
2026-02-16 01:47:04 -08:00
Matija Kecman 1808079c62 Implement viscous pause in Studio
Viscous pause is like pause but the simulation continues with zero gravity, high viscosity and passive springs disabled. It is useful to move things like cabinets with shelves---just move the shelf and the drawers come along as well.

* Updated the simulation control widgets
* Added Ctrl-space shortcut to toggle play/viscous pause

PiperOrigin-RevId: 869810053
Change-Id: Icf649e1f2631c2a64a5d2f25af9537b6a12bdf2c
2026-02-13 11:11:15 -08:00
Saran Tunyasuvunakool 5274e5f720 Clean up X macros and usages for mjOption, mjStatistic, and mjVisual.
* Replace various MJOPTION_ macros with a single MJOPTION_FIELDS.
* Use XVEC macro to denote vector members where there is a mixture of
  vector and scalar members in a given struct type.
* Split up MJVISUAL_FIELDS into separate macros for each substruct.
* Modify engine_print.c and Python bindings struct.h/cc to use the
  new X macros.

PiperOrigin-RevId: 869760513
Change-Id: Idac4fe9aa99f0258e7c79802ca9023a0d4486e2d
2026-02-13 09:10:36 -08:00
Haroon Qureshi 6d8b6028e2 Tweak default lighting and specularity for non-PBR scenes.
Most "classic" objects looked washed out. To "revert" to the old look, you can add the following to your XML files:

```
<custom>
    <numeric name="filament.phong.specular_multiplier" data="0.1"/>
    <numeric name="filament.fallback.scene_light_intensity" data="100000.0"/>
    <numeric name="filament.fallback.environment_light_intensity" data="10000.0"/>
</custom>
```

PiperOrigin-RevId: 869725829
Change-Id: Icab0cedaa27915400497745db886c393709c14b1
2026-02-13 07:37:36 -08:00
Taylor Howell 5903d4826f Sparse ten_J and ten_J_colind
PiperOrigin-RevId: 869712136
Change-Id: Id2979684aa0c39552cb8453852483cbac55f0ea3
2026-02-13 06:57:22 -08:00
ashutosh0x 04e5df08a9 Update mju_malloc to return NULL for zero-sized allocations 2026-02-13 19:22:05 +05:30
Michael Moss 42958aab81 Update MuJoCo version from 3.5.0 to 3.5.1 following the 3.5.0 release
PiperOrigin-RevId: 869654894
Change-Id: I9cacaf4cbb70ad17faa24c3c30ec38ffe91b5deb
2026-02-13 03:54:25 -08:00
Yuval Tassa c54f1fe380 Use semantic versioning.
PiperOrigin-RevId: 869102767
Change-Id: I8b01b9343289d4ad7d15bcc3634a28e661308a90
2026-02-12 02:11:20 -08:00
Haroon Qureshi 8e5436c335 Make phong-shading multipliers configurable.
PiperOrigin-RevId: 869080920
Change-Id: I4eb7311b54270d596c09a01d6725c1efb931de4b
2026-02-12 01:09:30 -08:00
Yuval Tassa 6af0d4c823 Replace margin/gap max with sum.
PiperOrigin-RevId: 868842521
Change-Id: Ia4a4ca5c6821c5a7b3ba7b0af7f71d981c2866c1
2026-02-11 14:22:27 -08:00
Google DeepMind 336e1026a4 Sparse ten_J and ten_J_colind memory
PiperOrigin-RevId: 868834376
Change-Id: Iec92d9e09e3134666895e54a78cb02439d74a4de
2026-02-11 14:05:43 -08:00