xml_native_writer saves geom mass or density, if specified.

Fixes a bug introduced in CL/432455486, which stopped saving explicit inertias if they were inferred from geoms. But if we don't save inertias then we need to save mass/density specifiers.

BEGIN_PUBLIC

xml_native_writer saves geom mass or density, if specified.

END_PUBLIC

PiperOrigin-RevId: 450667775
Change-Id: Ibb5b269b58f1143013091729642bb501243ed943
This commit is contained in:
Alessio Quaglino
2022-05-24 06:32:36 -07:00
committed by Copybara-Service
parent 18921c83ca
commit 20cc535ba6
2 changed files with 93 additions and 0 deletions
+5
View File
@@ -289,6 +289,11 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
WriteAttr(elem, "margin", 1, &pgeom->margin, &def->geom.margin);
WriteAttr(elem, "gap", 1, &pgeom->gap, &def->geom.gap);
WriteAttr(elem, "gap", 1, &pgeom->gap, &def->geom.gap);
if (mjuu_defined(pgeom->_mass)) {
WriteAttr(elem, "mass", 1, &pgeom->mass, &def->geom.mass);
} else {
WriteAttr(elem, "density", 1, &pgeom->density, &def->geom.density);
}
if (pgeom->material != def->geom.material) {
WriteAttrTxt(elem, "material", pgeom->material);
}