Commit Graph

1570 Commits

Author SHA1 Message Date
Yuval Tassa bbeb0b95a7 Reset contact efc_address in mj_clearEfc, fixes #2869
The truth is that all these solver-related values should be moved out of `mjContact` altogether, but that can be done in a future followup.

PiperOrigin-RevId: 818624976
Change-Id: I5b9e63927098cdf26b9f8acfdd9d86e75d6ce331
2025-10-13 06:18:41 -07:00
Haroon Qureshi 9b7e7e471d Add line and linebox geom primitives.
PiperOrigin-RevId: 818570050
Change-Id: If02873dd878a23b442368ce69bc024e0310e9d02
2025-10-13 02:59:13 -07:00
Haroon Qureshi 66a1c22cae Label all bodies, not just selected bodies, when mjLABEL_BODY is set.
An earlier refactor incorrectly assumed that only selected bodies needed
labels.

PiperOrigin-RevId: 818568645
Change-Id: I7aea07c5342673dd589e1891d0db1f2b0c489fe4
2025-10-13 02:54:34 -07:00
Yuval Tassa a7fe06c717 Further simplification to mj_crb
PiperOrigin-RevId: 818241421
Change-Id: I67dd2a60f415eb17b41f5ee553939118ab124123
2025-10-12 01:43:30 -07:00
Yuval Tassa 12f0e3df9a Quick return for static bodies in mj_object{Velocity,Acceleration}
PiperOrigin-RevId: 818238459
Change-Id: I340a2f61439db2a149cc64a5fee543680fdcad0f
2025-10-12 01:25:05 -07:00
Kyle Bayes 9e0885a4fa Handle exceptions in VFS C API.
PiperOrigin-RevId: 817688877
Change-Id: Ia2e306fe4cd1848eb5731212aa4e959080a9d377
2025-10-10 10:03:36 -07:00
Haroon Qureshi b63252e4bb Render labels for any geom with a label, not just label geoms.
PiperOrigin-RevId: 817686605
Change-Id: I030626dd942e50eef33e0de7e9d0f314fd2f457d
2025-10-10 09:58:21 -07:00
Haroon Qureshi ff7c613c79 Initial implementation of the filament rendering backend for mujoco.
This is intended as a drop-in replacement for mjr_render to enable high
quality, physically-based rendering (PBR) using the filament render engine.

This is a work-in-progress and, as such, some features may be missing. This
is also a code-only drop; build files (including instructions on how to
generate the filament materials) will be provided at a later date.

This library is intended to be run with the experimental studio app.

PiperOrigin-RevId: 817593684
Change-Id: Ib9cd14c1881e4897c1111275bd749aa38ebb5317
2025-10-10 05:01:39 -07:00
Matija Kecman 59a5a7bf5f Improve error messages in LoadMujocoModel
PiperOrigin-RevId: 817565307
Change-Id: I367298cdf77d26b6f8deb5c6a0d5c3cab1e4d065
2025-10-10 03:24:50 -07:00
Haroon Qureshi abe88202d0 Remove redundant flags argument.
PiperOrigin-RevId: 817115667
Change-Id: I4e5096206d7c24f5861e1bb9e8049149803dceeb
2025-10-09 04:07:43 -07:00
Alessio Quaglino 98682ae284 Do not modify mesh position when fitting a geom to the mesh AABB.
Also, unify the meaning of fitting a geom to an AABB: it now means to find the smallest geom such that its AABB contains the mesh AABB.

Fixes #2881.

PiperOrigin-RevId: 817097544
Change-Id: I883c686feffa803bd16ba461db24a474dfec7712
2025-10-09 03:05:00 -07:00
Sam Haves 3a299c49ca Remove use of usdaFileFormat from mjcf_file_format.
Previously this was just used for the USDA file format token, which we can confidently just construct ourselves.

Since [this PR in OpenUSD](https://github.com/PixarAnimationStudios/OpenUSD/commit/5bb9ad1fb2a034e1f9b48c7db936f296b5b78e25) the file lives in a different place now and public usage will be deprecated anyways.

PiperOrigin-RevId: 816801204
Change-Id: I42e92d2af52b0f9ff0a679ecb96f3d2dbf623531
2025-10-08 11:54:44 -07:00
Haroon Qureshi 1335ec87e4 Move font assets data targets into toolbox library.
PiperOrigin-RevId: 816654994
Change-Id: Ic56fab2b0af0c8d85682f8b233342a0d088d5cca
2025-10-08 05:09:42 -07:00
Haroon Qureshi 8e4932170a Remove unused params.
PiperOrigin-RevId: 816654011
Change-Id: Ib26bc90dcda167e8acf1feaa3b015acb5aa7aceb
2025-10-08 05:05:59 -07:00
Haroon Qureshi e7e331b11e Update sensor decor elements to be of type mjOBJ_SENSOR.
PiperOrigin-RevId: 816640568
Change-Id: I838608c0482ec1ee499fe9598ddb33aa6c5331e9
2025-10-08 04:17:40 -07:00
Haroon Qureshi 7b9f6a5cc1 Invert early-out checks to reduce nesting.
PiperOrigin-RevId: 816606107
Change-Id: I325d3f4695cdeb189694088d8a81b198d65f96ea
2025-10-08 02:21:14 -07:00
Haroon Qureshi fbab761627 Cleanup how different rendering backends are selected.
PiperOrigin-RevId: 816169098
Change-Id: I915aa45fa3a6d45a5178d3ff7bfdd0f1b1e01789
2025-10-07 17:48:23 +01:00
Yuval Tassa 52eff3da0f Fix mismatched argument format in mju_mulInertVec declaration.
PiperOrigin-RevId: 815818142
Change-Id: Id9caa581962705095f227a113505fc3e3ddd1054
2025-10-06 11:40:32 -07:00
Yuval Tassa ab9575d8a6 Refactor and speed up mj_crb and add a benchmark.
This is a no-op "prefactor" of `mj_crb` to reduce the number of lines changed in the upcoming sleeping CL. The main change here is that `mj_crb` now avoids accessing the model and data pointer repeatedly, but instead has the input and output pointers explicitly declared as local variables. A benchmark test found a healthy **14% perf bump** due to two changes:
- Adding `restrict` to `mju_mulInertVec`
- The function-local pointers.

Adding `restrict` to the local pointers had no effect. Note that `mj_crb` is not a particularly expensive function so these speed bumps are not significant per se, but rather indicative of possible future gains with these techniques.

```
Benchmark                Time(ns)        CPU(ns)     Iterations
---------------------------------------------------------------

ORGINAL BASELINE
BM_CRB_BASELINE_mean         4325           4348         993200  230.052k items/s

BASELINE + RESTRICT
BM_CRB_BASELINE_mean         4057           4090        1186150  244.573k items/s

LOCAL POINTERS + RESTRICT
BM_CRB_mean                  3772           3800        1001750  263.209k items/s
```

PiperOrigin-RevId: 815798225
Change-Id: Iffdf57b544e8e10562807c617f73ca4ccd1c614f
2025-10-06 10:54:01 -07:00
Yuval Tassa 431f96572e Remove unused mjOption.apirate.
PiperOrigin-RevId: 815633571
Change-Id: Ib98f3eb2df47f96fa1fe6e987a3a0cd23a9479f6
2025-10-06 02:51:17 -07:00
Haroon Qureshi a849fedcd2 Separate mjv_addGeoms into separate functions for each category.
PiperOrigin-RevId: 815607891
Change-Id: I16b29061c7e2229146bd0e0152721bca40fa4fd1
2025-10-06 01:30:26 -07:00
Yuval Tassa 18779ab54a Clean up engine_core_util
PiperOrigin-RevId: 814709359
Change-Id: If4ec66808e7de51e16b772afdb8485fa4ff30030
2025-10-03 08:48:11 -07:00
Sam Haves b5c35f87fc Add material parsing path for colliders instead of strictly visual gprims.
PiperOrigin-RevId: 814692421
Change-Id: If92a36d0382f60e0d92c7d90320dec51c20ea739
2025-10-03 07:52:55 -07:00
Haroon Qureshi 24679b47e4 Separate out site and geom frame construction.
PiperOrigin-RevId: 814677737
Change-Id: I623f9d1e23ac6b3076a577e97911f7ec73492f52
2025-10-03 06:56:53 -07:00
Haroon Qureshi 493d73062c Misc cleanup to addFrameGeoms.
PiperOrigin-RevId: 814582959
Change-Id: I2546bf1c13334628d379ad24737de095085e1b1f
2025-10-03 01:14:32 -07:00
Sam Haves 32e08f9507 Expose userfacenormal to mjsMesh
PiperOrigin-RevId: 814253177
Change-Id: I644974feea0722f03e7c3b01be7b702dba233f0a
2025-10-02 08:53:42 -07:00
Sam Haves 6320b95957 Add mju_getXMLDependencies that given an MJCF file returns filepaths to all of it's dependencies.
PiperOrigin-RevId: 814203235
Change-Id: Ib5c2e2f4dd42224a768c88d76473544190c72bc0
2025-10-02 06:14:48 -07:00
Haroon Qureshi 6ed2ceaa83 Add non-decorative elements before decorative elements.
PiperOrigin-RevId: 814165875
Change-Id: Iab09e2fe1fa129b0c19760c969b5639e690a95d9
2025-10-02 03:59:06 -07:00
Kyle Bayes 91257896c0 Implement faster mju_isZeroByte.
PiperOrigin-RevId: 814148714
Change-Id: Iaf5ed9d3502eaaaee8d46a986f2db00811ae0707
2025-10-02 02:53:53 -07:00
Yuval Tassa edbdb5195c Change MuJoCo engine source code function-spacing convention from 3 blank lines to 2
PiperOrigin-RevId: 813754244
Change-Id: I6836e41c3b021cb727e922c25c60f629b9814c93
2025-10-01 07:58:17 -07:00
Sam Haves c439628f82 When parsing USD, infer gravity from stage metadata if UsdPhysicsScene missing or undefined.
PiperOrigin-RevId: 813705210
Change-Id: I13741af6dc87ecd9efb83219e978f5f06c72d021
2025-10-01 05:19:31 -07:00
Haroon Qureshi b1ae44d10f Refactor duplicated frame drawing logic into a utility function.
PiperOrigin-RevId: 813675737
Change-Id: I7f9094852f26b2ddc08534bf87cf2f71476d99ec
2025-10-01 03:36:14 -07:00
Haroon Qureshi f9d0bedb44 Minor cleanup: Move geom-related functions together.
PiperOrigin-RevId: 813661319
Change-Id: I6cdf74ff57f39f932ddd39268f15f1128ddf1df4
2025-10-01 02:46:45 -07:00
Haroon Qureshi 328a4ab293 Merge geomsExhausted into acquireGeom.
PiperOrigin-RevId: 813347956
Change-Id: I07bd566388383cc5c49e675f5b85fffb379ef6d1
2025-09-30 11:19:53 -07:00
Sam Haves 4d590afdad Instead of caching PNGImage results, cache mjCTexture and mjCHField assets.
PiperOrigin-RevId: 813307632
Change-Id: I9de8b46423f57240d22811571d0533b010ee1e2b
2025-09-30 09:44:45 -07:00
Haroon Qureshi 59d0676dcc Remove redundant checks for exhausted geoms.
PiperOrigin-RevId: 813284297
Change-Id: I565c517bef782ba07ff323e206b75f6f905e5809
2025-09-30 08:44:17 -07:00
Sam Haves 2dc533b63b Allow flipping textures with any number of channels and user provided pixel data.
PiperOrigin-RevId: 813256285
Change-Id: I0d49885dc483ab8f093b2566ec4bef355575505e
2025-09-30 07:28:13 -07:00
Haroon Qureshi 70d03adc71 Store the status of the scene in the scene itself.
PiperOrigin-RevId: 813119377
Change-Id: Iebff9e7796ca9809ea22902522982bfd96eeba06
2025-09-30 00:06:00 -07:00
Haroon Qureshi 6a7566872a Functions for printing the contents of mjvScene.
PiperOrigin-RevId: 812699642
Change-Id: Iafff53c952c952624129ff01a8c1b0aa5d38eec5
2025-09-29 02:47:17 -07:00
Haroon Qureshi e1c7e19780 Add rendering flags to the studio UI.
PiperOrigin-RevId: 812649785
Change-Id: I47c6f974b7336bdd63c088ccfd06b5835e77ebff
2025-09-28 23:58:33 -07:00
Kyle Bayes 8de86c9944 Remove margin name from geomdist sensors.
PiperOrigin-RevId: 811775910
Change-Id: I4d265d4ad0206ea2d92c6c4b659f509a17f12baa
2025-09-26 05:24:12 -07:00
Yuval Tassa e51459f949 Break out struct initialization functions into engine_init.c.
PiperOrigin-RevId: 811598048
Change-Id: Ia832a8268e2209a5a264bbf79aa00dda487206bc
2025-09-25 19:22:27 -07:00
Yuval Tassa fe8384b6c5 Visualize joint and tendon limits by re-coloring.
PiperOrigin-RevId: 811590674
Change-Id: I5b65f2294a4bcda3c321fb51ebf29501bd0d416d
2025-09-25 19:02:26 -07:00
Sam Haves 922aebbeed Provide explicit argument for asset cache ID.
This will allow assets to cache compiled results with different parameters. For example, we could cache both an RGB version of a texture and a Mono version.

PiperOrigin-RevId: 811341377
Change-Id: Ifd6a4ff88661a2b38be47c02d6a666de2c202885
2025-09-25 07:24:12 -07:00
Haroon Qureshi 0baac58999 Remove redundant ngeoms check.
PiperOrigin-RevId: 810787607
Change-Id: I5d04b1d7f5f8ad758960a46ff08cc47d2887e851
2025-09-24 02:21:35 -07:00
Yuval Tassa d9650b68b0 Remove unused private functions
PiperOrigin-RevId: 810776310
Change-Id: I1c67c5efe07c4ca23b04122548b674719be927f7
2025-09-24 01:48:54 -07:00
Yuval Tassa d71d42a374 Add private function mju_isZeroByte to check for byte-wise zero.
PiperOrigin-RevId: 810456282
Change-Id: I877d0f9225e7a783ed7ff12ce54f4ed0a7889793
2025-09-23 08:49:43 -07:00
Haroon Qureshi bb0878417e Automated g4 rollback of changelist 810355812.
*** Reason for rollback ***

mjv_makeScene does not call mjv_defaultScene directly.  Instead, it calls mjv_freeScene which calls mjv_defaultScene.  However, mjv_freeScene attempts to free pointers if they are not NULL and if you don't call mjv_defaultScene then you'll have garbage data in those pointers.

*** Original change description ***

Remove redundant mjv_defaultScene call since its called by mjv_makeScene

***

PiperOrigin-RevId: 810442645
Change-Id: Ica50493d6769a0afb086f9ead99d731cdf0d75d9
2025-09-23 08:05:40 -07:00
Yuval Tassa 33b09e0822 Stop using stack allocation for catenary drawing
PiperOrigin-RevId: 810434095
Change-Id: Iee8c01ff721c2af216c5725fc9eaf6267b2e5284
2025-09-23 07:37:34 -07:00
Haroon Qureshi 09e6723dab Remove unnecessary stack mark/free in engine_vis_visualize.c
PiperOrigin-RevId: 810391913
Change-Id: Id02f4dadba7ef08f60bb7726470082f45c5761c5
2025-09-23 04:53:50 -07:00