diff --git a/doc/includes/references.h b/doc/includes/references.h index 0f27ccf0..094931fb 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -2119,6 +2119,7 @@ typedef struct mjsMesh_ { // mesh specification double scale[3]; // rescale mesh mjtMeshInertia inertia; // inertia type (convex, legacy, exact, shell) mjtByte smoothnormal; // do not exclude large-angle faces from normals + mjtByte needsdf; // compute sdf from mesh int maxhullvert; // maximum vertex count for the convex hull mjFloatVec* uservert; // user vertex data mjFloatVec* usernormal; // user normal data diff --git a/include/mujoco/mjspec.h b/include/mujoco/mjspec.h index 138b1937..08f8a328 100644 --- a/include/mujoco/mjspec.h +++ b/include/mujoco/mjspec.h @@ -462,6 +462,7 @@ typedef struct mjsMesh_ { // mesh specification double scale[3]; // rescale mesh mjtMeshInertia inertia; // inertia type (convex, legacy, exact, shell) mjtByte smoothnormal; // do not exclude large-angle faces from normals + mjtByte needsdf; // compute sdf from mesh int maxhullvert; // maximum vertex count for the convex hull mjFloatVec* uservert; // user vertex data mjFloatVec* usernormal; // user normal data diff --git a/python/mujoco/introspect/structs.py b/python/mujoco/introspect/structs.py index 82137c3b..7dea2be0 100644 --- a/python/mujoco/introspect/structs.py +++ b/python/mujoco/introspect/structs.py @@ -9388,6 +9388,11 @@ STRUCTS: Mapping[str, StructDecl] = dict([ type=ValueType(name='mjtByte'), doc='do not exclude large-angle faces from normals', ), + StructFieldDecl( + name='needsdf', + type=ValueType(name='mjtByte'), + doc='compute sdf from mesh', + ), StructFieldDecl( name='maxhullvert', type=ValueType(name='int'), diff --git a/src/user/user_mesh.cc b/src/user/user_mesh.cc index 897b5164..a84a9220 100644 --- a/src/user/user_mesh.cc +++ b/src/user/user_mesh.cc @@ -140,7 +140,6 @@ mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) { maxhullvert_ = -1; processed_ = false; visual_ = true; - needoct_ = false; needreorient_ = true; // reset to default if given @@ -362,7 +361,7 @@ void mjCMesh::LoadSDF() { } needreorient_ = false; - needoct_ = false; + needsdf = false; normal_ = std::move(usernormal); face_ = std::move(userface); ProcessVertices(uservert); @@ -685,7 +684,7 @@ void mjCMesh::TryCompile(const mjVFS* vfs) { } // make octree - if (!needoct_) { + if (!needsdf) { octree_.Clear(); // this occurs when a non-SDF mesh is loaded from a cached SDF mesh } else if (octree_.Nodes().empty()) { octree_.SetFace(vert_, face_); diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 257b6524..03132736 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -1689,7 +1689,7 @@ void mjCModel::IndexAssets(bool discard) { ((mjCMesh*)mesh)->SetNotVisual(); // reset to true by mesh->Compile() } geom->mesh = (discard && geom->visual_) ? nullptr : (mjCMesh*)mesh; - static_cast(mesh)->needoct_ |= geom->spec.type == mjGEOM_SDF; + static_cast(mesh)->spec.needsdf |= geom->spec.type == mjGEOM_SDF; } else { throw mjCError(geom, "mesh '%s' not found in geom %d", geom->get_meshname().c_str(), i); } diff --git a/src/user/user_objects.h b/src/user/user_objects.h index 3060bf6c..aa3528fa 100644 --- a/src/user/user_objects.h +++ b/src/user/user_objects.h @@ -1004,7 +1004,6 @@ class mjCMesh_ : public mjCBase { // used by the compiler bool needreorient_; // needs reorientation - bool needoct_; // needs octree bool visual_; // true: the mesh is only visual std::vector< std::pair > halfedge_; // half-edge data