Fix heightfield scene BVH bounds missing upper z-range#1175
Merged
kevinzakka merged 1 commit intogoogle-deepmind:mainfrom Feb 23, 2026
Merged
Fix heightfield scene BVH bounds missing upper z-range#1175kevinzakka merged 1 commit intogoogle-deepmind:mainfrom
kevinzakka merged 1 commit intogoogle-deepmind:mainfrom
Conversation
f73308f to
b88316b
Compare
Collaborator
|
LGTM! |
thowell
reviewed
Feb 23, 2026
mujoco_warp/_src/bvh.py
Outdated
| elif type == GeomType.HFIELD: | ||
| size = hfield_bounds_size[geom_dataid[geom_id]] | ||
| lower_bound, upper_bound = _compute_box_bounds(pos, rot, size) | ||
| hfield_center = pos + rot @ wp.vec3(0.0, 0.0, size[2]) |
Collaborator
There was a problem hiding this comment.
maybe something like rot[:, 2] * size[2]?
Collaborator
Author
There was a problem hiding this comment.
Done, thanks Taylor.
thowell
approved these changes
Feb 23, 2026
Simplify hfield BVH center offset computation per review.
b88316b to
658e86b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The scene-level BVH bounds for heightfield geoms were computed with
_compute_box_bounds(pos, rot, size), which creates an AABB symmetric around the geom position. However, heightfield mesh vertices have z-values in[0, max_z], extending upward from the geom origin rather than being centered on it. This caused the upper half of the surface to fall outside the bounding volume, so rays aimed at the top of the heightfield skipped intersection entirely.Fix by offsetting the AABB center in-place using the existing half-extent. Since hfield z-values start at 0,
size[2](the z half-extent) equals the center offset:This is a minimal 2-line change in
_compute_bvh_boundswith no new arrays, fields, or plumbing required.In local coordinates:
[0, max_z][-max_z/2, +max_z/2](centered at geom origin, misses the top half)[0, max_z](centered atmax_z/2, tight fit)Note: This works because MuJoCo's compiler always normalizes hfield_data to [0, 1] by subtracting the minimum value (ref), so pmin_z = 0 and center_z = half_z = size[2].
Thanks to @slambert-bd for flagging this.