Commit Graph

4529 Commits

Author SHA1 Message Date
Kyle Bayes 6cb6e5a93f Enable multiccd by default.
PiperOrigin-RevId: 902752921
Change-Id: I8e2085ff17db0ac0db1641b8837415c458e5eca4
2026-04-20 12:00:10 -07:00
Haroon Qureshi 8e7787ad09 Use function for applying transforms to multimesh Renderables.
PiperOrigin-RevId: 902712241
Change-Id: I5bfdab8bce12ffb1a1f030ae0a32a61e9b8157e1
2026-04-20 10:39:44 -07:00
Alessio Quaglino 188196603d Fix flexcomp empty cell detection that was causing missing cells.
The previous implementation only checked whether grid cells contained mesh vertices to determine occupancy. For coarse meshes with large faces, most cells were incorrectly marked empty and pruned—even cells fully inside the object volume. This change improves the algorithm by:

- Marking cells that overlap with any mesh element's AABB as non-empty.
- For surface meshes, running a flood-fill from the grid boundary through non-overlapping cells to identify truly exterior cells. This preserves empty interior cells, preventing incorrect pruning of the object's core.
- For volumetric meshes, defaulting to element-AABB overlap detection directly.

Limitations for non-watertight meshes: If the mesh contains holes larger than the grid cell size, the flood-fill will leak into the interior. In this case, all non-element cells (including interior ones) will be marked as empty.

PiperOrigin-RevId: 902675331
Change-Id: I5a84303a33d5ca7436213e7ce9aca3806c9f5a0f
2026-04-20 09:27:40 -07:00
Haroon Qureshi 476e2e909e Allow Transforms to be set directly on Renderable.
Also allow multiple Meshes to be assigned at once rather than one at a
time.

This simplifies both the usage and implementation of Renderable.

PiperOrigin-RevId: 902665683
Change-Id: I23ff365a54fd6a3814ed3452b1e094ae9f698a1b
2026-04-20 09:06:14 -07:00
Yuval Tassa b2281883dd Improve slider precision and range clamping, fixes #3206
Add clamping to slider values in both ImGui widgets and mjUI to ensure they remain within the defined min/max ranges, preventing potential floating point inaccuracies from causing values to slightly exceed the bounds.

PiperOrigin-RevId: 902660458
Change-Id: Ia153ae7907f07b890f2b5ac2e3a4be93ecae7bd3
2026-04-20 08:54:11 -07:00
Yuval Tassa a8a5afc8dc Cache benchmark data in engine_util_sparse_benchmark_test
PiperOrigin-RevId: 902651349
Change-Id: I760e3f696b37699366c40c3c93a74e2b1b35678e
2026-04-20 08:29:56 -07:00
Alessio Quaglino 2d12dee025 Add dof="2d" option to flexcomp for in-plane deformations.
PiperOrigin-RevId: 902620719
Change-Id: Ib06d3f7b9439e1d90a8373a4289ade0c327e72e4
2026-04-20 07:14:40 -07:00
Haroon Qureshi cad734ae70 Introduce Trs type.
Combines a translation, rotation, and size into a single struct.

PiperOrigin-RevId: 902620586
Change-Id: I628bfdedebde8c83239215efe0bee4a338eabd06
2026-04-20 07:13:52 -07:00
Alessio Quaglino 35f7db8e91 Add StringToVector<std::string> overload for char*.
This overload allows `StringToVector` to accept a `char*` argument when parsing into a `std::vector<std::string>`, by converting the `char*` to `std::string` before processing.

PiperOrigin-RevId: 902611443
Change-Id: I2048918f915c1bac74522f368ea28f23ca9a6885
2026-04-20 06:48:59 -07:00
Haroon Qureshi 86ad41b9c2 Use RenderableParams for creating Renderables.
PiperOrigin-RevId: 902569516
Change-Id: Id233a5ef7fe86ce5902ce2552d8d0fec6ce860b7
2026-04-20 04:51:18 -07:00
Alessio Quaglino 508e581ba9 Optimize flex by pinning nodes in empty cells.
This change introduces an optimization for flexcomp objects defined by a mesh. It identifies grid cells that do not contain any mesh vertices and marks them as empty. Nodes that are exclusively part of empty cells are pinned, preventing them from moving. Stiffness computations are skipped for empty cells, reducing computational cost. The total mass is now distributed only among the non-pinned nodes.

PiperOrigin-RevId: 902565735
Change-Id: Id0a9a685536d5e18a3e42124a25ab08ff3a918f2
2026-04-20 04:41:17 -07:00
Alessio Quaglino fa7b36d111 Fix undefined reference errors for StringToVector with GCC and LTO.
This CL addresses link failures when building MuJoCo with GCC and Link Time Optimization (LTO) enabled:
- Declared the `StringToVector<std::string>(const std::string&)` specialization in `user_util.h` to prevent the compiler from incorrectly trying to instantiate the general template.
- Added an explicit instantiation for `StringToVector<unsigned char>(char*)` in `user_util.cc` to provide the definition needed by its `const std::string&` counterpart.

PiperOrigin-RevId: 902557141
Change-Id: I27b585cf1deb276d4150a5cbe6cf7e59c323a20a
2026-04-20 04:17:14 -07:00
Haroon Qureshi eb31027a7c Simplify RenderTarget creation.
Remove the RenderTargetTextureType enum and, instead, create
RenderTargets directly from pixel formats.

PiperOrigin-RevId: 902536708
Change-Id: I2683aa9db23c011212087d93df0260ad27621170
2026-04-20 03:27:52 -07:00
Yuval Tassa e6d77650f7 Refactor mju_combineSparse to eliminate temporary buffers.
Combine sparse vectors in-place by first counting total `nnz` and then working backwards from the end. This removes the need for temporary buffers in `mju_combineSparse` and its callers and speeds up the function by ~10%.

PiperOrigin-RevId: 902530210
Change-Id: I4f48c327103552ab968d3915399c6067367bec9f
2026-04-20 03:10:18 -07:00
Alessio Quaglino 3230cf99f9 Change flex constraints to eigenmodes of the stiffness matrix.
This provides a reduction from 26 to 18 constraints for trilinear and from 162 to 75 for quadratic. The assembly of the constraints becomes trivial. In total the speedup for a trilinear 3x3x3 grid is about 3x.

PiperOrigin-RevId: 902502398
Change-Id: I764772c7adef78da5a644f64701f842d36e4b543
2026-04-20 02:02:44 -07:00
Haroon Qureshi bf9be2c312 Remove MeshPtr type alias.
PiperOrigin-RevId: 902502036
Change-Id: I5bd0c185f204518f0cd0d9189741c17c24b51eb6
2026-04-20 02:01:34 -07:00
Yuval Tassa a04c2b1b4a Consolidate stack allocation calls in primal solvers down from 30 to 2 (dense) or 6 (sparse). Preparation for atomic allocation calls in threaded mode.
PiperOrigin-RevId: 902496039
Change-Id: I39df011951713505c4743c7475d74856ddbdf4f9
2026-04-20 01:47:30 -07:00
Matija Kecman cf3f6ccf1f Make file search deterministic in FindFileInPath.
Collect all entries from the recursive directory iterator, sort them, and then check for the filename. This ensures that if multiple files with the same name exist in different subdirectories, the one found is always the same, regardless of the filesystem's directory iteration order.

PiperOrigin-RevId: 902487291
Change-Id: Ia4c45cd2e3cab4a4e3825c267fc47c3134f99f76
2026-04-20 01:27:40 -07:00
Haroon Qureshi f3f12bfad6 Manage dynamic meshes (skins, flexes) in model_objects.
Simplifies Renderable as it no longer has the option of owning
any Meshes. Instead, the ModelObjects owns the Meshes for
flex and skin geom (just like it owns all the other mjModel
Meshes).

PiperOrigin-RevId: 902485912
Change-Id: I8b9f9d394de6c46f7e25aa4b3885a374aad05294
2026-04-20 01:23:47 -07:00
Yuval Tassa 6bf31cf68a Update Windows build notes.
PiperOrigin-RevId: 902480947
Change-Id: I69f099b3d7eabd6513a62e74e5ef697a5062e7b5
2026-04-20 01:13:17 -07:00
Alessio Quaglino 3d45a33190 Refactor flex strain constraints to be per-cell.
Each mjEQ_FLEXSTRAIN equality now represents a single cell within a flex. This allows for more efficient sparse Jacobian computation by only considering the degrees of freedom of the nodes within each specific cell. This change gives a speedup of about 10x on a 3x3x3 model.

PiperOrigin-RevId: 902164069
Change-Id: I78eedf1d5cf39b8989fe9863c22d164922fc0efb
2026-04-19 07:21:18 -07:00
Taylor Howell a9e61966b5 Import of Warp v1.12.1 from https://github.com/nvidia/warp.
PiperOrigin-RevId: 901388190
Change-Id: Id2c5f1bc2ba9050af2c3b7597d84b9525ffa5766
2026-04-17 11:22:44 -07:00
Alessio Quaglino b16383dfaf Use banded solver for implicit flex integration.
The flex interpolation stiffness matrix within the implicit/implicitfast solvers is now built and factorized in a banded format instead of a dense one. This involves:
-   Calculating the bandwidth based on the sparsity of the mass/damping matrix and the connectivity within flex cells.
-   Allocating and populating a banded matrix `H`.
-   Using `mju_cholFactorBand` and `mju_cholSolveBand` for factorization and solving.
This change improves performance for flexes with many DOFs but local coupling.

PiperOrigin-RevId: 901297952
Change-Id: I3efe06353d1903ea65ab30dc49685cede228bb68
2026-04-17 08:00:07 -07:00
Alessio Quaglino 6c7ed66781 Implement multi-cell finite element method for interpolated flexes.
This change introduces a `flex_cellcount` field to `mjModel` to specify the number of cells in each dimension for interpolated flexes. The stiffness computation, passive force calculation, and Jacobian derivatives are updated to operate on a per-cell basis, significantly improving performance by localizing computations to the nodes within each cell.

PiperOrigin-RevId: 901216393
Change-Id: Ic23132e609de11e71bb7fef8d1f139daad2ec264
2026-04-17 04:13:19 -07:00
Haroon Qureshi 8415dff307 Merge Material into Renderable.
Allows the Renderable to update its own MaterialInstances whenever
Material textures or parameters are modified.  Each Renderable now
also knows how it is intended to be used (i.e. scene objects or ux)
which allows it to correctly pick the underlying filament::Material
to use.

PiperOrigin-RevId: 901161990
Change-Id: Ic280731d39c272c50d6ad100cec7116e683cbc79
2026-04-17 01:59:02 -07:00
Matija Kecman c23b5e8420 Fix WASM build issues, improve test coverage and improve cmake files
* Ensure compiler.usethread=0 is set before compilation in single-threaded WASM builds
* Explicitly enable exceptions for the single-threaded WASM module
* Test the single-threaded module in addition to the multi-threaded module in internal and external CI
* Consolidate wasm/tests/CMakeLists.txt into wasm/CMakeLists.txt, fixing the single-threaded benchmark test build which was missing shared linker flags

PiperOrigin-RevId: 901149728
Change-Id: If4946e29e5116610782d218906cf3f5940c1cdd0
2026-04-17 01:29:40 -07:00
Matija Kecman f91ce9a627 Remove window dependency from PipGui
PiperOrigin-RevId: 901115560
Change-Id: I85183a91fd07682f17f43fcfad593dececdde28c
2026-04-17 00:11:59 -07:00
Yuval Tassa 506aa79ad8 Add Human-700 to model gallery
PiperOrigin-RevId: 900755246
Change-Id: I655c21c21f9b858c907e593d50c26698d90bcfbb
2026-04-16 09:02:08 -07:00
Haroon Qureshi 1117e7db39 Move DrawMode into its own header file.
PiperOrigin-RevId: 900656695
Change-Id: I4db6f0f74c2109752efe40bc37c7104505139049
2026-04-16 04:44:22 -07:00
Kyle Bayes 56e98cc16c Improve AABB bounds in makeAAMM.
MODEL           BEFORE(ns)   AFTER(ns)
boxmesh.xml     874645       744822
box.xml         808226       786226
ellipsoid.xml   1477609      1436058
mixed.xml       1492063      1404848

PiperOrigin-RevId: 900626282
Change-Id: I3df5a6cd8a4cb2e3b9ded1b40a5310a4c14ec624
2026-04-16 03:25:18 -07:00
Haroon Qureshi 5a0809efaf Remove dependency on Texture from ObjectManager.
ObjectManger now manages low-level filament Texture and
Material objects directly. Moves the IBL Texture to the
SceneBridge class.

PiperOrigin-RevId: 900626110
Change-Id: Idd39464bfb324188dd54975a500954d4ebb29006
2026-04-16 03:24:21 -07:00
Haroon Qureshi a6b98e5a78 Keep track of the vertex attributes in a Mesh.
PiperOrigin-RevId: 900583030
Change-Id: I5b1ff5ad7b698e3e68fd06f44f2c5d3399d08504
2026-04-16 01:41:56 -07:00
Haroon Qureshi eacbce95f4 Fix CMakeLists file.
gui_view was renamed imgui_bridge

PiperOrigin-RevId: 900208849
Change-Id: I305a8a90306038c236256c21d04d2bad7144d83a
2026-04-15 09:37:06 -07:00
Kyle Bayes d9b3faf8f4 Remove thread_local EPA data in favor of using mjData stack.
PiperOrigin-RevId: 900201369
Change-Id: I82fbe9bf0ef9ea117c2124353d876dd42a57fb3a
2026-04-15 09:19:57 -07:00
Matija Kecman 7ac30a39fe Fix mj_loadXML hang in single-threaded WASM builds
The top-level CMakeLists.txt unconditionally added -pthread for all Emscripten builds, but PTHREAD_POOL_SIZE was only set when MUJOCO_WASM_THREADS=ON. This gave the ST build a live pthread runtime with zero pre-spawned workers, causing CompileMeshesAndTextures to deadlock when it tried to spawn a ThreadPool on the main thread.

Fix by making -pthread conditional on MUJOCO_WASM_THREADS. Without -pthread, hardware_concurrency() returns 0 and the existing nthread < 2 guards naturally select the serial compilation path.

PiperOrigin-RevId: 900191420
Change-Id: I0481b81fc6f7cccb52c7d7592dcf9dd317b5bad1
2026-04-15 08:57:04 -07:00
Haroon Qureshi e047f1101a Rename GuiView to ImguiBridge.
PiperOrigin-RevId: 900186368
Change-Id: Ie8f08d081dbc9a2b5638b5e799788e81891c908a
2026-04-15 08:44:00 -07:00
Yuval Tassa a2d0e33c0f 2-3x speedup of sparse matrix squaring.
Split symbolic and numeric phases for sparse `M'*diag*M` computation. Microseconds per call for the monolithic vs the split approach for the 100_humanoids and 2humanoid100 models:

```
+-------+------+----------+------------+---------+
| Model | Arch | Col (µs) | Split (µs) | Speedup |
+-------+------+----------+------------+---------+
| 2H100 | x86  | 238.3    | 74.5       | 3.2x    |
+-------+------+----------+------------+---------+
|       | ARM  | 111.6    | 53.2       | 2.1x    |
+-------+------+----------+------------+---------+
| 100H  | x86  | 1325.3   | 656.2      | 2.0x    |
+-------+------+----------+------------+---------+
|       | ARM  | 594.8    | 306.6      | 1.9x    |
+-------+------+----------+------------+---------+
```

PiperOrigin-RevId: 900154308
Change-Id: Ia6e9b8e196e2ed37b723a0faf60e9731303a9619
2026-04-15 07:19:41 -07:00
Haroon Qureshi 62cffb1536 Update GuiView to use SceneView and Renderables.
PiperOrigin-RevId: 900145167
Change-Id: I613c9fe171e97f8a4cd08c0c63e9706e09cbd202
2026-04-15 06:56:16 -07:00
Yuval Tassa 8f3ed662eb Hoist solver stack allocations out of iteration loop
PiperOrigin-RevId: 900085248
Change-Id: I2bde8fafc8a4801a92c39aa9a13af0ea7475843d
2026-04-15 04:23:08 -07:00
Haroon Qureshi f24f9ef44d Allow submeshes to be set when adding meshes to a Renderable.
Also add support for blend order.

PiperOrigin-RevId: 900061778
Change-Id: I601757a8672fed23e45defd4cdbe4e9526ea3b70
2026-04-15 03:25:55 -07:00
Matija Kecman 9289905c9a Make StepControlGui a reusable component and refactor/simplify the implementation
PiperOrigin-RevId: 900045404
Change-Id: I9976ece042710ddce0a7c5d99a6ac85a0ef06d2f
2026-04-15 02:48:11 -07:00
Haroon Qureshi d913e0b1e9 Add ReadPixels function to RenderTarget.
PiperOrigin-RevId: 900017779
Change-Id: I0632b66124632558ea19157e4ca319e4b0d10617
2026-04-15 01:39:54 -07:00
Michael Moss 4a98cc8bff Update MuJoCo version to 3.7.1 following the 3.7.0 release
PiperOrigin-RevId: 899835826
Change-Id: Ibe247b921e7dad7184acef69ee3199fec79c6e24
2026-04-14 16:49:03 -07:00
Taylor Howell 8bf11166b1 Import google-deepmind/mujoco_warp from GitHub.
PiperOrigin-RevId: 899731493
Change-Id: Ib563023047e85db1aff56e78724dc28d769ef91e
2026-04-14 12:55:31 -07:00
Alessio Quaglino 5724158593 Refactor flex stiffness storage to support variable sizes.
This change introduces `nflexstiffness` and `flex_stiffnessadr` to allow flex stiffness matrices to have sizes other than the fixed 21 per element. Higher-order flexes can now store larger stiffness matrices based on their number of nodes. The `flex_stiffnessadr` array provides the starting index for each flex's stiffness data within the `flex_stiffness` array.

PiperOrigin-RevId: 899632263
Change-Id: Ie49182c46c3777acf0c6b492345edfcf62fb5e44
2026-04-14 09:39:00 -07:00
Haroon Qureshi 08bb6e66f1 Small fixes to decor rendering.
Use an unlit material for decorative elements and do not render them
in the reflection pass.

PiperOrigin-RevId: 899560291
Change-Id: I3b035d556432c850ce8240e0c4c4c2d6645d7bf2
2026-04-14 06:50:51 -07:00
Michael Moss 72cb2b210d Update changelog for the 3.7.0 release.
PiperOrigin-RevId: 899497703
Change-Id: Ib9ec75550615dc245bc66af60c877e8adae17e67
2026-04-14 04:10:38 -07:00
Haroon Qureshi aef0589442 Allow Light objects to be image based lights.
PiperOrigin-RevId: 899488765
Change-Id: I3b56fc6499404bb011f9361c03dba23b736ad4bc
2026-04-14 03:49:26 -07:00
Haroon Qureshi fd5a7004f8 Remove Drawable abstraction.
Instead, use a set of functions to create/update a Renderable
from an mjvGeom.

This completely isolates mjvScene/mjvGeom from SceneView,
making SceneView a more general purpose class.

PiperOrigin-RevId: 899475268
Change-Id: I48a3a45bc8fff3e1f514847c7a1ca8ab3a1ff16e
2026-04-14 03:13:55 -07:00
Michael Moss 171e6dc177 Automated rollback of PiperOrigin-RevId: 899009633.
*** Original change description ***

Add protocols for authoring simulation environments. This is for preview only, we discourage users from using this in production code.

PiperOrigin-RevId: 899425542
Change-Id: Ifb6c5d3b762789d821bfa9826f5d6d983e8af7d3
2026-04-14 01:16:35 -07:00