Commit Graph

1650 Commits

Author SHA1 Message Date
Haroon Qureshi a2fd5fdd4a Move profiler logic into a separate class.
PiperOrigin-RevId: 834200782
Change-Id: Ida050a5c055237c4e0a0c725a1277c9239a89538
2025-11-19 02:35:35 -08:00
Yuval Tassa e18e35f967 Fix normal only for libccd during hfield collisions.
PiperOrigin-RevId: 833933161
Change-Id: I3a4ff044276d9c7305154da09b440168f0f22305
2025-11-18 12:55:56 -08:00
Haroon Qureshi 7569ac960d Create material instances for each draw call rather than for each clip rect.
This fixes a bug where the wrong instance was being used in some cases.

PiperOrigin-RevId: 833818151
Change-Id: If8b0cb90017ee0b89cde98a5ae64c36704c7338c
2025-11-18 08:16:55 -08:00
Alessio Quaglino 971e73ab04 Remove unused argument from mj_vertBodyWeight.
PiperOrigin-RevId: 833744032
Change-Id: I26049003b1f45f8cac60c7ebc0b5abca5526177f
2025-11-18 03:28:25 -08:00
Haroon Qureshi 8077a6819c Add support for OpenSans and font-awesome fonts.
PiperOrigin-RevId: 833666932
Change-Id: I5f0207c3331705b9078a1297b3e7b2a8d363ad60
2025-11-17 23:14:47 -08:00
Haroon Qureshi e882399eb0 Use mjTHREADLOCAL macro instead of intrinsic.
Fixes #2927.

PiperOrigin-RevId: 833336768
Change-Id: I62bfdc7018853fc8459e03ba079fc6a15e97c7d0
2025-11-17 07:50:02 -08:00
Matija Kecman 85b6194f91 Add a README with instructions for how to build and run MuJoCo Studio externally
PiperOrigin-RevId: 833336577
Change-Id: Ib5f5ef33abe820796559a9da352360f57ea64bc8
2025-11-17 07:49:00 -08:00
Matija Kecman 8eca9926dc Fix various MuJoCo Studio build issues on Windows, MacOS and Linux
PiperOrigin-RevId: 833313973
Change-Id: I7ec181374e0bb49c32420d025044c31f6fc3c657
2025-11-17 06:35:43 -08:00
Yuval Tassa a66cf303f8 Clean up ray functions
PiperOrigin-RevId: 833299985
Change-Id: I30aabe889ccc5900ff0e50a578e98e176d3effa4
2025-11-17 05:47:44 -08:00
Haroon Qureshi 999344c998 Use the path of the loaded model as the base path for all further load/save operations.
PiperOrigin-RevId: 832358035
Change-Id: I44fdf8cd31d755087ebd5ec9f84f5faabe5d0702
2025-11-14 10:00:43 -08:00
Haroon Qureshi 3f69deb328 Correctly initialize mjrContext before creation.
PiperOrigin-RevId: 832233427
Change-Id: I5e7301637e73a739f141d4a3207b27ae1676f6b6
2025-11-14 02:41:56 -08:00
Haroon Qureshi 83363f41ee Fix arrow positioning.
PiperOrigin-RevId: 832233204
Change-Id: I10b780c261bf5c0b4891309559fa7aab4d47d32c
2025-11-14 02:40:31 -08:00
Haroon Qureshi 6c15c711ee Make mjv_cameraFrame and mjv_cameraFrustum public.
PiperOrigin-RevId: 832187804
Change-Id: I74d05d7fe03bc81bd05a823c7c9791bca12e3079
2025-11-14 00:03:18 -08:00
Kyle Bayes 8b9fa2674c Use std::vector instead of array in MJCF schema.
PiperOrigin-RevId: 831787681
Change-Id: I8093b8b10260daecb830e49319eda798e2dd2da5
2025-11-13 03:41:54 -08:00
Matija Kecman 26c1622ac8 Internal change
PiperOrigin-RevId: 831782555
Change-Id: I1dda7700e1c1def21c0b0879a5452ddf96d45aa8
2025-11-13 03:22:47 -08:00
Yuval Tassa 042c5223a6 Change mj_sizeModel return type to mjtSize.
PiperOrigin-RevId: 831768095
Change-Id: I079fbadc403b32a3ce8a73fe21b2cd66391401c3
2025-11-13 02:32:18 -08:00
Kyle Bayes a168b3ef7f Refactor hill climbing support function.
PiperOrigin-RevId: 831754211
Change-Id: I77c89c52fde86183b8e2e61a1fc71764119f208e
2025-11-13 01:47:27 -08:00
Yuval Tassa b8512b9d1f Fix bug related to sleeping static children of mocap bodies.
PiperOrigin-RevId: 831376685
Change-Id: I8891a1d7dc6efc037e9ade5c7e8dd5c35c7e455e
2025-11-12 07:20:03 -08:00
Haroon Qureshi 7b52d3034e Fix crash if Renderer is destroyed without having been Init'ed.
PiperOrigin-RevId: 831375559
Change-Id: Ia1d0334e32dbbd0582d4f75723867d6ea47bf9da
2025-11-12 07:15:39 -08:00
Haroon Qureshi 28c536bd93 Remove support for custom fonts for OSS project for now.
PiperOrigin-RevId: 831294808
Change-Id: I3f366ceafc1181e0624d1b26ef09fd64ed6275b4
2025-11-12 02:30:23 -08:00
Yuval Tassa 414d6d80ac Update model memory footprint reporting in mj_printModel.
PiperOrigin-RevId: 831015711
Change-Id: I7cb5aba019ed99e239b6fadbaf162cbd6fd9d9fb
2025-11-11 12:08:22 -08:00
Yuval Tassa bc83bfb076 Restructure AAMM storage for improved cache locality in broadphase, ~35% speedup (of broadphase).
PiperOrigin-RevId: 831007564
Change-Id: I1a72ca02f5a50194bb7770d5765c6140adde1852
2025-11-11 11:46:08 -08:00
Haroon Qureshi aa7cf15cc4 Set textures before assigning a material.
PiperOrigin-RevId: 830899288
Change-Id: I42029157e7be006d4dc18d0c84e27bf908af6f47
2025-11-11 07:10:18 -08:00
Yuval Tassa 22c0b68903 Improve logic and documentation for sleeping sensors
PiperOrigin-RevId: 830891115
Change-Id: Ife8309b165c085b54c9f668d825d69ed12a9a8f0
2025-11-11 06:45:56 -08:00
Haroon Qureshi 1b2206fc50 Do not generate mipmaps for textures loaded from KTX files.
PiperOrigin-RevId: 830874812
Change-Id: Ie9dccc52acd5ffd26e5d4f3597f3834f81ebebcb
2025-11-11 05:51:36 -08:00
Haroon Qureshi 2261733aa4 Toggle profiler window using F3.
PiperOrigin-RevId: 830869956
Change-Id: I396f89f95672096f59b909b9415be2168aac6473
2025-11-11 05:33:57 -08:00
Haroon Qureshi 1fbea85ef0 Remove redundant call to GenerateMipMaps.
The Create?Textures will generate the mipmaps themselves if needed.

PiperOrigin-RevId: 830868294
Change-Id: I295e0dac12bc7c31a98242256721f46467f883d6
2025-11-11 05:27:58 -08:00
Haroon Qureshi 4a5a36f3fc Display error when loading model.
PiperOrigin-RevId: 830862449
Change-Id: Iab1e8786d79d55db9a15a788ecb37e0b0418111c
2025-11-11 05:04:48 -08:00
Haroon Qureshi b3deb9dd12 Do not reset camera_id if no tracking object is set.
Otherwise, we can never incrementally move beyond a free camera.

PiperOrigin-RevId: 830845627
Change-Id: I07e8639f79efcdae451999ca07b91a41360752ca
2025-11-11 04:03:35 -08:00
Matija Kecman 88e75cd7e6 Remove implot from toolbox/window.cc
PiperOrigin-RevId: 830842619
Change-Id: I39d13508423ad0ba1e12349ceaccab2425d28243
2025-11-11 03:51:38 -08:00
Yuval Tassa 23023edc52 Fix bug in schema
PiperOrigin-RevId: 830819693
Change-Id: I9fd047975895f4a376d28b7eee2c0d38344ce864
2025-11-11 02:28:52 -08:00
Yuval Tassa 1c6a05de98 Snap Y-axis range to nice decimal bounds in gl2 figures.
PiperOrigin-RevId: 830355030
Change-Id: I2e9f145fb8c626dd671d286560c8334202586c6b
2025-11-10 03:01:30 -08:00
Taylor Howell 883836848a Fix box-box distance computation.
PiperOrigin-RevId: 829431553
Change-Id: I9e28bc8eb7687c3c83e5ff68c65e93d8a07378a9
2025-11-07 07:37:03 -08:00
Matija Kecman 80a91cfbea Internal change
PiperOrigin-RevId: 829417225
Change-Id: Ib2304c6a40fb7a2a9fed900a587b9f7ed4b3103a
2025-11-07 06:49:00 -08:00
Yuval Tassa 769f37b653 Implement sleeping in engine
PiperOrigin-RevId: 829361787
Change-Id: I6f64d8e25c4248cf32c18cd94d37ff5def78946e
2025-11-07 03:33:07 -08:00
Yuval Tassa 252a0d73df Add sleep related data structures
PiperOrigin-RevId: 829055431
Change-Id: I1ccbd77a57044a754ae7db611b4c2c0010fbda53
2025-11-06 12:10:55 -08:00
Sam Haves 8051f40817 During mj_parse, if mju_openResource fails pass a resource with only the filename to decoders.
This enables decoders to leverage their own file resolution systems. For example: USD can compose a stage (scene) from memory, via a file on disk, or via custom asset resolver.

Passing it through to the decoder reduces the need for custom resource providers that wrap these other resolution systems.

This will also enable a fun, but likely niche usecase where the decoder does procedural generation and does not have to be backed by a resource. See the tests for an example of this.

PiperOrigin-RevId: 828939899
Change-Id: Ic319a685332d91198a4ae926867c834bf7f7f724
2025-11-06 07:06:06 -08:00
Haroon Qureshi 01b0ea5b7d Use webgl backend in emscripten builds.
(Also only display the model name if its a file.)

PiperOrigin-RevId: 828498906
Change-Id: I7def85992f413b321c115ea63db2af057f5fd372
2025-11-05 09:17:34 -08:00
Haroon Qureshi 8b7eb097db Remove Sync and Scene functions from Renderer.
PiperOrigin-RevId: 828481721
Change-Id: Id0399139653b0ec27f0d365437e62cadefadfe6c
2025-11-05 08:33:28 -08:00
Haroon Qureshi 30a99de3b9 Remove dependencies on mjvScene for interactions.
Interactions (like moving the camera or mouse picking) no longer depend
on needing an mjvScene. Instead, everything is done relative to the
camera directly.

This duplicates some code in engine_vis_visualize which we will try to
resolve and recombine at a future time.

PiperOrigin-RevId: 828461259
Change-Id: If26329c1a7c37516f0213b18056c3e31760f60ae
2025-11-05 07:33:42 -08:00
Adrian Collister 740afe22b3 Append warnings to model compile errors.
PiperOrigin-RevId: 827903480
Change-Id: I2ad17bf4cea0dae0ab803fbb7baa9bd70eef303d
2025-11-04 04:15:07 -08:00
Sam Haves 7d7648f7ed Update UsdWriter to write any parts of MjSpec that are not from USD to the EditTarget.
This enables two workflows:
1) Users that parsed some other format into MjSpec, or built it programmatically can export animated USD easily with as minimal as possible interaction with USD.

2) Creating a spec from USD, then modifying the spec, should not cause a duplication of data when writing to USD.

PiperOrigin-RevId: 827627520
Change-Id: I02c8c14a18569547710e54f3704d52ac0bf70ce6
2025-11-03 13:29:46 -08:00
Yuval Tassa abc02b736e Minor fixes to viewer diagnostics
- When `mjData.nefc` was 0 (solver not run at all), we were plotting the stale diagnostics from the last run; now fixed.
- In the case where islands were used, the semantic of the plotted diagnostic `sqrt_nnz` (square root of Hessian nonzeros) is changed. It used to be the sum of square roots of solver nonzeros per island, it is now the square root of the sum of all nonzeros in all islands. The semantic `sqrt(sum(nnz_i))` was found to be more consistent than `sum(sqrt(nnz_i))`, in the sense that switching islanding on/off leads to smaller changes and is more in line with the interpretation of islanding as [block-diagonalization](https://mujoco.readthedocs.io/en/3.3.7/computation/#constraint-islands).

PiperOrigin-RevId: 827624908
Change-Id: I5fc86364ead585a4752a6d44823fb75cf6c7c318
2025-11-03 13:23:05 -08:00
Sam Haves 9319956a16 Modify mujoco_to_usd to operate on SdfLayer intead of SdfAbstractData.
Since we don't do any on demand data loading for USD and always convert everything it should be safe to use the SdfLayer API instead of the SdfAbstractData API. This enables other codepaths such as the USD writer class to reuse the same logic to generate USD specification from an mjSpec.

PiperOrigin-RevId: 827431722
Change-Id: I60a581e0c9577164a4a66229ea9dcb8912afcf74
2025-11-03 04:16:37 -08:00
Alessio Quaglino 3a7aa84e53 Add quadratic stiffness to flex.
PiperOrigin-RevId: 827409919
Change-Id: I3dff8ea49fb1726fec4acf5b91138d6d52c4bfba
2025-11-03 03:01:38 -08:00
Sam Haves 57f7145806 Create mjpDecoder, mj_parse, and mju_decodeResource
- plugin system similar to mjpResourceProvider, but instead of loading a resource it converts an existing mjResource into an mjSpec.
  - The returned spec is then composed into the referencing spec.
  - This enables different file types to generate arbitrary specs, and allows us to separate format parsing from compilation code.

Follow up CLs will move some of the logic in src/engine for PNG, USD, KTX, OBJ loading into decoders.

The mj_parse function MjSpec from a given file, it's a more generic version of mj_parseXML.

In it's implementation, mj_parse as opposed to mj_parseXML will look for any registered decoder and
not assume we are striclty dealing with MJCF.

PiperOrigin-RevId: 826149497
Change-Id: I0ece26904280cb94bd5ded6dd5a565c539d60254
2025-10-30 12:54:40 -07:00
Haroon Qureshi 80eb511620 Remove dependency on Window, Physics, and Renderer classes.
PiperOrigin-RevId: 825137441
Change-Id: I099a518ca9618698401d0330a6ef08278168f88e
2025-10-28 11:42:17 -07:00
Haroon Qureshi 4620b9f23a Merge HandleMouseEvents and HandleKeyboardEvents back into app.cc.
PiperOrigin-RevId: 825081195
Change-Id: I36445b8c452b15ca26056a52fd1844cf77083c0a
2025-10-28 09:44:42 -07:00
Alessio Quaglino 1bfa8b6fa6 Do not add bodies at mesh points for quadratic flex interpolation.
PiperOrigin-RevId: 825001743
Change-Id: Ica085b947fb1c3f56251bceaa6a228f364535d3e
2025-10-28 06:13:27 -07:00
Haroon Qureshi 3b79d3f14b Set flags directly on Renderer class.
This removes a dependency on mjvScene from the App class.

PiperOrigin-RevId: 824983816
Change-Id: I20dd411e6359ee411f9b0b86d4442c090ba4bd5c
2025-10-28 05:24:05 -07:00