Implementation:Google deepmind Mujoco MJX Mesh
| Knowledge Sources | |
|---|---|
| Domains | Physics_Simulation, JAX, Mesh_Processing |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Mesh processing utilities that convert MuJoCo geom meshes into convex hull representations suitable for JAX-based collision detection.
Description
This module handles the conversion of mesh geometry data into the ConvexMesh and ConvexInfo data structures required by the convex collision routines. It computes face normals, edge normals, and convex hull representations using scipy and trimesh. The box() function converts box geom info into a convex representation, convex() processes arbitrary mesh data from a MuJoCo model, and hfield() / hfield_prism() handle height field decomposition into prism-shaped convex cells for collision. Coplanar face merging is performed to reduce face counts.
Usage
Called during model loading and collision setup. The convex() function is used to precompute ConvexMesh data stored in the model, while box() and hfield_prism() are invoked at collision time to construct convex representations on the fly.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: mjx/mujoco/mjx/_src/mesh.py
- Lines: 1-337
Key Functions
def _get_face_norm(vert: np.ndarray, face: np.ndarray) -> np.ndarray
def _get_edge_normals(face: np.ndarray, face_norm: np.ndarray) -> Tuple[np.ndarray, np.ndarray]
def _convex_hull_2d(points: np.ndarray, normal: np.ndarray) -> np.ndarray
def _merge_coplanar(vert, face, face_norm) -> Tuple
def box(info: GeomInfo) -> ConvexInfo
def convex(m: Union[mujoco.MjModel, Model], data_id: int) -> ConvexMesh
def hfield_prism(vert: jax.Array) -> ConvexInfo
def hfield(m: Union[mujoco.MjModel, Model], data_id: int) -> HFieldInfo
Import
from mujoco.mjx._src.mesh import box
from mujoco.mjx._src.mesh import convex
from mujoco.mjx._src.mesh import hfield
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | mjx.Model or mujoco.MjModel | Yes | Model containing mesh vertex and face data |
| info | GeomInfo | Yes | Geom properties (position, rotation, size) for box conversion |
| data_id | int | Yes | Mesh or height field data index within the model |
| vert | jax.Array | Yes | Vertex positions for height field prism construction |
Outputs
| Name | Type | Description |
|---|---|---|
| ConvexInfo | ConvexInfo | Convex geom info including vertices, faces, normals, and edges |
| ConvexMesh | ConvexMesh | Precomputed convex mesh data for storage in model |
| HFieldInfo | HFieldInfo | Height field info with grid data and dimensions |