Add needsdf flag to mjsMesh.
PiperOrigin-RevId: 782949528 Change-Id: Iaa96326a91795c3469c991bd8def53560b38e4f0
This commit is contained in:
committed by
Copybara-Service
parent
92bcbeb5d3
commit
9a41d385c1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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_);
|
||||
|
||||
@@ -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<mjCMesh*>(mesh)->needoct_ |= geom->spec.type == mjGEOM_SDF;
|
||||
static_cast<mjCMesh*>(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);
|
||||
}
|
||||
|
||||
@@ -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<int, int> > halfedge_; // half-edge data
|
||||
|
||||
|
||||
Reference in New Issue
Block a user