Replace TriangleMeshDistance with custom BVH-based SDF computation.

The `mjCOctree::ComputeSdfCoeffs` function has been replaced by `mjCOctree::ComputeSdf`. The new implementation removes the dependency on the `triangle_mesh_distance` library. Instead, it uses a provided `mjCBoundingVolumeHierarchy` to perform closest point queries on the mesh. The signed distance is computed by finding the closest triangle face via the BVH and determining the sign based on the dot product of the vector from the closest point on the triangle to the octree vertex and the triangle's normal.

Optional Laplacian smoothing has been added to the SDF coefficients. This helps smooth out potential discontinuities at octree level boundaries.

PiperOrigin-RevId: 875093374
Change-Id: I6fa53243a2dda107ccf255bc6b876ca5a4554d4f
This commit is contained in:
Alessio Quaglino
2026-02-25 04:46:49 -08:00
committed by Copybara-Service
parent 52ed96bc3a
commit 22e3217fc0
5 changed files with 411 additions and 43 deletions
+1 -1
View File
@@ -779,7 +779,7 @@ void mjCMesh::TryCompile(const mjVFS* vfs) {
// compute sdf coefficients
if (!plugin.active) {
octree_.ComputeSdfCoeffs(vert_.data(), nvert(), face_.data(), nface());
octree_.ComputeSdfCoeffs(vert_.data(), nvert(), face_.data(), nface(), tree_);
}
}