Add configurable octree max depth for meshes.
The maximum depth of the octree used for SDF generation can now be specified in the mesh definition via `mjsMesh::octree_maxdepth`. The default value is 6. PiperOrigin-RevId: 912494999 Change-Id: I6d828d1d3999b99d1210a6829a05b04fac591e1f
This commit is contained in:
committed by
Copybara-Service
parent
531a571dda
commit
8cef5bb978
@@ -243,6 +243,7 @@ void mjs_defaultMesh(mjsMesh* mesh) {
|
||||
mesh->scale[0] = mesh->scale[1] = mesh->scale[2] = 1;
|
||||
mesh->maxhullvert = -1;
|
||||
mesh->inertia = mjMESH_INERTIA_LEGACY;
|
||||
mesh->octree_maxdepth = 6;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -782,6 +782,7 @@ void mjCMesh::TryCompile(const mjVFS* vfs) {
|
||||
} else if (octree_.NumNodes() == 0) {
|
||||
std::vector<double> dvert(vert_.begin(), vert_.end());
|
||||
octree_.SetFace(dvert, face_);
|
||||
octree_.SetMaxDepth(spec.octree_maxdepth);
|
||||
octree_.CreateOctree(aamm_);
|
||||
if (!plugin.active) {
|
||||
octree_.ComputeSdfCoeffs(dvert.data(), nvert(), face_.data(), nface(), tree_);
|
||||
@@ -1532,6 +1533,7 @@ void mjCMesh::Process() {
|
||||
// make octree
|
||||
if (needsdf) {
|
||||
octree_.SetFace(dvert, face_);
|
||||
octree_.SetMaxDepth(spec.octree_maxdepth);
|
||||
octree_.CreateOctree(aamm_);
|
||||
|
||||
if (!plugin.active) {
|
||||
|
||||
@@ -1285,7 +1285,7 @@ void mjCOctree::MakeOctree(const std::vector<Triangle*>& elements, const double
|
||||
}
|
||||
|
||||
// skip if the box is empty
|
||||
if (colliding.empty() || task.lev >= 6) {
|
||||
if (colliding.empty() || task.lev >= max_depth_) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ struct OctreeTask {
|
||||
struct mjCOctree_ {
|
||||
int nnode_ = 0;
|
||||
int nvert_ = 0;
|
||||
int max_depth_ = 6; // max octree depth (default 6)
|
||||
std::vector<OctNode> node_;
|
||||
std::vector<Triangle> face_; // mesh faces (nmeshface x 3)
|
||||
std::vector<Point> vert_; // octree vertices (nvert x 3)
|
||||
@@ -308,6 +309,10 @@ class mjCOctree : public mjCOctree_ {
|
||||
void AddCoeff(int n, int v, double coeff) { node_[n].coeff[v] = coeff; }
|
||||
double Coeff(int n, int v) const { return node_[n].coeff[v]; }
|
||||
|
||||
// Set max octree depth (default 6)
|
||||
void SetMaxDepth(int depth) { max_depth_ = depth; }
|
||||
int MaxDepth() const { return max_depth_; }
|
||||
|
||||
// Set number of Laplacian smoothing iterations (0 = disabled, default)
|
||||
void SetSmoothingIterations(int iterations) { smoothing_iterations_ = iterations; }
|
||||
int SmoothingIterations() const { return smoothing_iterations_; }
|
||||
@@ -1208,6 +1213,7 @@ class mjCMesh: public mjCMesh_, private mjsMesh {
|
||||
|
||||
// octree
|
||||
const mjCOctree& octree() { return octree_; }
|
||||
mjCOctree& mutable_octree() { return octree_; }
|
||||
|
||||
void Compile(const mjVFS* vfs); // compiler
|
||||
double* GetPosPtr(); // get position
|
||||
|
||||
Reference in New Issue
Block a user