Skip to content

Support MJCF compiler discardvisual attribute #9

@TATP-233

Description

@TATP-233

Background

MuJoCo official XML reference documents <compiler discardvisual="true"/> here:
https://mujoco.readthedocs.io/en/stable/XMLreference.html#compiler

According to the MuJoCo docs, discardvisual should discard purely visual model elements with no effect on physics. This includes:

  • materials
  • textures
  • geoms with contype=0 and conaffinity=0 when they are not referenced elsewhere
  • meshes that are no longer referenced

Reproduction

Tested locally with:

  • MuJoCo: mujoco==3.6.0
  • MotrixSim: 0.7.0

Minimal MJCF:

<mujoco model="discardvisual_probe">
  <compiler angle="radian" discardvisual="true"/>
  <worldbody>
    <body name="base" pos="0 0 0">
      <freejoint/>
      <inertial pos="0 0 0" mass="1" diaginertia="0.1 0.1 0.1"/>
      <geom name="collision" type="box" size="0.1 0.1 0.1" contype="1" conaffinity="1" rgba="1 0 0 1"/>
      <geom name="visual" type="box" size="0.2 0.2 0.2" contype="0" conaffinity="0" rgba="0 1 0 1"/>
    </body>
  </worldbody>
</mujoco>

Observed result:

discardvisual=false
  MuJoCo:   num_geoms=2, geom_names=[collision, visual]
  MotrixSim:num_geoms=2, geom_names=[collision, visual]

discardvisual=true
  MuJoCo:   num_geoms=1, geom_names=[collision]
  MotrixSim:num_geoms=2, geom_names=[collision, visual]

This suggests that MotrixSim currently accepts the discardvisual attribute, but does not apply the MuJoCo compiler behavior and instead silently keeps the visual geom.

Expected behavior

When <compiler discardvisual="true"/> is set, MotrixSim should match MuJoCo behavior and remove purely-visual geoms/assets from the compiled model.

If full support is not planned yet, it would still help to emit a clear warning or error instead of silently ignoring the attribute, because the current behavior can create MJCF compatibility mismatches.

Impact

The current behavior can lead to:

  • different compiled models between MuJoCo and MotrixSim for the same MJCF
  • extra geoms / assets that the upstream model author expected to be removed
  • unnecessary memory/runtime overhead in large models that rely on discardvisual

If useful, I can also provide a mesh/material-based repro case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions