Skip to content

Conversation

@xavier2933
Copy link

@xavier2933 xavier2933 commented Oct 20, 2025

Importing height fields with the Unity plugin causes the program to crash. Fixes issue in discussion #2824

Fixed:

  • MjHeightFieldShape.BuildMesh() returns null, which crashed the program
  • Unity imports height fields with 0 minimum depth, which crashes mujoco
  • The condition which is supposed to check for this had the incorrect inequality, making this issue difficult to debug

Changes:

  • MjMeshFilter: Replace exception with graceful null handling when BuildMesh() returns null (e.g., for HeightFields)
  • MjHeightFieldShape: Dynamically set minimum height as a function of maximum height
  • MjHeightFieldShape: Change direction of inequality to trigger properly

Testing:

  • Ran all included tests, 11 were failing with current release
  • No new failures with my changes
  • I have these outputs saved, if required

Note: This is my first PR on an open-source project. Please feel free to share any feedback you may have, as it will help me make better contributions in the future. Thanks!

@google-cla
Copy link

google-cla bot commented Oct 20, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant