Replace meshid and hfieldid with mjCMesh and mjCHField pointers in mjCGeom.

PiperOrigin-RevId: 597279837
Change-Id: I45ca00c70c13cd5bddb3385a0c60388fb166527c
This commit is contained in:
Alessio Quaglino
2024-01-10 09:55:58 -08:00
committed by Copybara-Service
parent 42515033a7
commit 889353dfa8
6 changed files with 57 additions and 58 deletions
+2 -2
View File
@@ -1525,8 +1525,8 @@ void mjXReader::OneGeom(XMLElement* elem, mjCGeom* pgeom) {
ReadAttr(elem, "solimp", mjNIMP, pgeom->solimp, text, false, false);
ReadAttr(elem, "margin", 1, &pgeom->margin, text);
ReadAttr(elem, "gap", 1, &pgeom->gap, text);
ReadAttrTxt(elem, "hfield", pgeom->hfield);
ReadAttrTxt(elem, "mesh", pgeom->mesh);
ReadAttrTxt(elem, "hfield", pgeom->hfieldname);
ReadAttrTxt(elem, "mesh", pgeom->meshname);
ReadAttr(elem, "fitscale", 1, &pgeom->fitscale, text);
ReadAttrTxt(elem, "material", pgeom->material);
ReadAttr(elem, "rgba", 4, pgeom->rgba, text);
+3 -3
View File
@@ -347,7 +347,7 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
// mesh geom
if (pgeom->type==mjGEOM_MESH || pgeom->type==mjGEOM_SDF) {
mjCMesh* pmesh = model->meshes[pgeom->meshid];
mjCMesh* pmesh = pgeom->mesh;
// write pos/quat if there is a difference
if (!SameVector(pgeom->pos, pmesh->GetPosPtr(pgeom->typeinertia), 3) ||
@@ -403,10 +403,10 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
// hfield and mesh attributes
if (pgeom->type==mjGEOM_HFIELD) {
WriteAttrTxt(elem, "hfield", pgeom->hfield);
WriteAttrTxt(elem, "hfield", pgeom->hfieldname);
}
if (pgeom->type==mjGEOM_MESH || pgeom->type==mjGEOM_SDF) {
WriteAttrTxt(elem, "mesh", pgeom->mesh);
WriteAttrTxt(elem, "mesh", pgeom->meshname);
}
// userdata
+1 -1
View File
@@ -573,7 +573,7 @@ mjCGeom* mjXURDF::Geom(XMLElement* geom_elem, mjCBody* pbody, bool collision) {
// set fields
pmesh->set_file(meshfile);
pmesh->name = meshname;
pgeom->mesh = meshname;
pgeom->meshname = meshname;
pmesh->set_scale(meshscale);
}