Set mesh visual flag regardless of discardvisual.

PiperOrigin-RevId: 617428859
Change-Id: I427d888e6caa2fe1ae6597ca7165c600c9779cc7
This commit is contained in:
Alessio Quaglino
2024-03-20 01:14:57 -07:00
committed by Copybara-Service
parent 9b86329797
commit 07da7336e8
2 changed files with 6 additions and 14 deletions
+1
View File
@@ -432,6 +432,7 @@ void mjCMesh::LoadSDF() {
// compiler
void mjCMesh::Compile(const mjVFS* vfs) {
CopyFromSpec();
visual_ = true;
// load file
if (!file_.empty()) {
+5 -14
View File
@@ -983,21 +983,12 @@ void mjCModel::IndexAssets(bool discard) {
// find mesh by name
if (!pgeom->get_meshname().empty()) {
mjCBase* m = FindObject(mjOBJ_MESH, pgeom->get_meshname());
if (m) {
if (discard && geoms[i]->visual_) {
// do not associate with a mesh
pgeom->mesh = nullptr;
} else {
// associate mesh with geom
pgeom->mesh = (mjCMesh*)m;
// mark mesh as not visual
// this is irreversible so only performed when IndexAssets is called with discard
if (discard) {
pgeom->mesh->SetNotVisual();
}
mjCBase* pmesh = FindObject(mjOBJ_MESH, pgeom->get_meshname());
if (pmesh) {
if (!pgeom->visual_) {
((mjCMesh*)pmesh)->SetNotVisual(); // reset to true by mesh->Compile()
}
pgeom->mesh = (discard && pgeom->visual_) ? nullptr : (mjCMesh*)pmesh;
} else {
throw mjCError(pgeom, "mesh '%s' not found in geom %d", pgeom->get_meshname().c_str(), i);
}