Skip to content

Comments

Fix heightfield scene BVH bounds missing upper z-range#1173

Closed
kevinzakka wants to merge 1 commit intomainfrom
fix-hfield-bvh-bounds
Closed

Fix heightfield scene BVH bounds missing upper z-range#1173
kevinzakka wants to merge 1 commit intomainfrom
fix-hfield-bvh-bounds

Conversation

@kevinzakka
Copy link
Collaborator

@kevinzakka kevinzakka commented Feb 22, 2026

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. Heightfield mesh z-values range from 0 to max_z (not centered at origin), so the upper half of the surface fell outside the bounding volume and rays missed it.

Fix by tracking the mesh center offset in local coordinates and offsetting the AABB center accordingly: _compute_box_bounds(pos + rot @ center, rot, size).

@kevinzakka kevinzakka requested a review from StafaH February 22, 2026 19:07
@kevinzakka kevinzakka marked this pull request as draft February 22, 2026 21:38
Heightfield mesh vertices have z-values in [0, max_z] (non-negative),
but the scene BVH assumed the mesh was centered at the geom origin.
This caused the AABB to miss the upper portion of the heightfield,
so rays aimed there would skip intersection entirely.

Fix by computing the mesh center offset in local coordinates and
applying it when building the AABB: `pos + rot @ center`.
@kevinzakka kevinzakka force-pushed the fix-hfield-bvh-bounds branch from 4170305 to f73308f Compare February 22, 2026 23:45
@kevinzakka kevinzakka closed this Feb 22, 2026
@kevinzakka kevinzakka deleted the fix-hfield-bvh-bounds branch February 22, 2026 23:47
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