Refactor octree in preparation for continuous interpolation.

PiperOrigin-RevId: 792092644
Change-Id: I096ca0989210a00ae0b4556498d96212755d23c7
This commit is contained in:
Alessio Quaglino
2025-08-07 04:04:59 -07:00
committed by Copybara-Service
parent 4e67fe79f3
commit 840108cf7c
5 changed files with 123 additions and 39 deletions
+3 -7
View File
@@ -772,7 +772,7 @@ void mjCMesh::TryCompile(const mjVFS* vfs) {
// make octree
if (!needsdf) {
octree_.Clear(); // this occurs when a non-SDF mesh is loaded from a cached SDF mesh
} else if (octree_.Nodes().empty()) {
} else if (octree_.NumNodes() == 0) {
octree_.SetFace(vert_, face_);
octree_.CreateOctree(aamm_);
@@ -782,14 +782,10 @@ void mjCMesh::TryCompile(const mjVFS* vfs) {
// TODO: do not evaluate the SDF multiple times at the same vertex
// TODO: the value at hanging vertices should be computed from the parent
const double* nodes = octree_.Nodes().data();
for (int i = 0; i < octree_.NumNodes(); ++i) {
for (int j = 0; j < 8; j++) {
mjtNum v[3];
v[0] = nodes[6*i+0] + (j&1 ? 1 : -1) * nodes[6*i+3];
v[1] = nodes[6*i+1] + (j&2 ? 1 : -1) * nodes[6*i+4];
v[2] = nodes[6*i+2] + (j&4 ? 1 : -1) * nodes[6*i+5];
octree_.AddCoeff(sdf.signed_distance(v).distance);
const double* v = octree_.Vert(i, j);
octree_.AddCoeff(i, j, sdf.signed_distance(v).distance);
}
}
}