Compute the interpolation coefficients per vertex rather than per node.

PiperOrigin-RevId: 792124681
Change-Id: Ib0e18d0b59f09c7e3bdb2ef9940a9b7327b92cd3
This commit is contained in:
Alessio Quaglino
2025-08-07 06:01:58 -07:00
committed by Copybara-Service
parent 781242ae95
commit eb1da7c43d
2 changed files with 8 additions and 3 deletions
+6 -2
View File
@@ -780,11 +780,15 @@ void mjCMesh::TryCompile(const mjVFS* vfs) {
if (!plugin.active) {
tmd::TriangleMeshDistance sdf(vert_.data(), nvert(), face_.data(), nface());
std::vector<double> coeffs(octree_.NumVerts());
for (int i = 0; i < octree_.NumVerts(); ++i) {
coeffs[i] = sdf.signed_distance(octree_.Vert(i)).distance;
}
// TODO: the value at hanging vertices should be computed from the parent
for (int i = 0; i < octree_.NumNodes(); ++i) {
for (int j = 0; j < 8; j++) {
const double* v = octree_.Vert(i, j);
octree_.AddCoeff(i, j, sdf.signed_distance(v).distance);
octree_.AddCoeff(i, j, coeffs[octree_.VertId(i, j)]);
}
}
}
+2 -1
View File
@@ -275,7 +275,8 @@ class mjCOctree : public mjCOctree_ {
void CopyChild(int* child) const;
void CopyAabb(mjtNum* aabb) const;
void CopyCoeff(mjtNum* coeff) const;
const double* Vert(int n, int v) const { return vert_[node_[n].vertid[v]].p.data(); }
const double* Vert(int i) const { return vert_[i].p.data(); }
int VertId(int n, int v) const { return node_[n].vertid[v]; }
void SetFace(const std::vector<double>& vert, const std::vector<int>& face);
int Size() const {
return sizeof(OctNode) * node_.size() + sizeof(Triangle) * face_.size() +