Remove classname from mjs* structs.
PiperOrigin-RevId: 647277317 Change-Id: Ic3cb0d3bf890d6be2712c0538e21910a8f12ab44
This commit is contained in:
committed by
Copybara-Service
parent
62e2842116
commit
f6cc3f4091
@@ -1289,16 +1289,13 @@ void mjXReader::Statistic(XMLElement* section) {
|
||||
|
||||
// flex element parser
|
||||
void mjXReader::OneFlex(XMLElement* elem, mjsFlex* pflex) {
|
||||
string text, name, classname, material;
|
||||
string text, name, material;
|
||||
int n;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pflex->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "classname", classname)) {
|
||||
mjs_setString(pflex->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "material", material)) {
|
||||
mjs_setString(pflex->material, material.c_str());
|
||||
}
|
||||
@@ -1364,15 +1361,12 @@ void mjXReader::OneFlex(XMLElement* elem, mjsFlex* pflex) {
|
||||
// mesh element parser
|
||||
void mjXReader::OneMesh(XMLElement* elem, mjsMesh* pmesh) {
|
||||
int n;
|
||||
string text, name, classname, content_type;
|
||||
string text, name, content_type;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pmesh->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pmesh->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "content_type", content_type)) {
|
||||
mjs_setString(pmesh->content_type, content_type.c_str());
|
||||
}
|
||||
@@ -1526,16 +1520,13 @@ void mjXReader::OneSkin(XMLElement* elem, mjsSkin* pskin) {
|
||||
|
||||
// material element parser
|
||||
void mjXReader::OneMaterial(XMLElement* elem, mjsMaterial* pmat) {
|
||||
string text, name, classname, texture;
|
||||
string text, name, texture;
|
||||
int n;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pmat->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pmat->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "texture", texture)) {
|
||||
mjs_setString(pmat->texture, texture.c_str());
|
||||
}
|
||||
@@ -1559,7 +1550,7 @@ void mjXReader::OneMaterial(XMLElement* elem, mjsMaterial* pmat) {
|
||||
|
||||
// joint element parser
|
||||
void mjXReader::OneJoint(XMLElement* elem, mjsJoint* pjoint) {
|
||||
string text, name, classname;
|
||||
string text, name;
|
||||
std::vector<double> userdata;
|
||||
int n;
|
||||
|
||||
@@ -1567,9 +1558,6 @@ void mjXReader::OneJoint(XMLElement* elem, mjsJoint* pjoint) {
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pjoint->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pjoint->classname, classname.c_str());
|
||||
}
|
||||
if (MapValue(elem, "type", &n, joint_map, joint_sz)) {
|
||||
pjoint->type = (mjtJoint)n;
|
||||
}
|
||||
@@ -1609,7 +1597,7 @@ void mjXReader::OneJoint(XMLElement* elem, mjsJoint* pjoint) {
|
||||
|
||||
// geom element parser
|
||||
void mjXReader::OneGeom(XMLElement* elem, mjsGeom* pgeom) {
|
||||
string text, name, classname;
|
||||
string text, name;
|
||||
std::vector<double> userdata;
|
||||
std::string hfieldname, meshname, material;
|
||||
int n;
|
||||
@@ -1618,9 +1606,6 @@ void mjXReader::OneGeom(XMLElement* elem, mjsGeom* pgeom) {
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pgeom->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pgeom->classname, classname.c_str());
|
||||
}
|
||||
if (MapValue(elem, "type", &n, geom_map, mjNGEOMTYPES)) {
|
||||
pgeom->type = (mjtGeom)n;
|
||||
}
|
||||
@@ -1685,7 +1670,7 @@ void mjXReader::OneGeom(XMLElement* elem, mjsGeom* pgeom) {
|
||||
// site element parser
|
||||
void mjXReader::OneSite(XMLElement* elem, mjsSite* site) {
|
||||
int n;
|
||||
string text, name, classname;
|
||||
string text, name;
|
||||
std::vector<double> userdata;
|
||||
std::string material;
|
||||
|
||||
@@ -1693,9 +1678,6 @@ void mjXReader::OneSite(XMLElement* elem, mjsSite* site) {
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(site->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(site->classname, classname.c_str());
|
||||
}
|
||||
if (MapValue(elem, "type", &n, geom_map, mjNGEOMTYPES)) {
|
||||
site->type = (mjtGeom)n;
|
||||
}
|
||||
@@ -1722,16 +1704,13 @@ void mjXReader::OneSite(XMLElement* elem, mjsSite* site) {
|
||||
// camera element parser
|
||||
void mjXReader::OneCamera(XMLElement* elem, mjsCamera* pcam) {
|
||||
int n;
|
||||
string text, name, classname, targetbody;
|
||||
string text, name, targetbody;
|
||||
std::vector<double> userdata;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pcam->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pcam->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "target", targetbody)) {
|
||||
mjs_setString(pcam->targetbody, targetbody.c_str());
|
||||
}
|
||||
@@ -1780,15 +1759,12 @@ void mjXReader::OneCamera(XMLElement* elem, mjsCamera* pcam) {
|
||||
// light element parser
|
||||
void mjXReader::OneLight(XMLElement* elem, mjsLight* plight) {
|
||||
int n;
|
||||
string text, name, classname, targetbody;
|
||||
string text, name, targetbody;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(plight->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(plight->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "target", targetbody)) {
|
||||
mjs_setString(plight->targetbody, targetbody.c_str());
|
||||
}
|
||||
@@ -1822,13 +1798,10 @@ void mjXReader::OneLight(XMLElement* elem, mjsLight* plight) {
|
||||
|
||||
// pair element parser
|
||||
void mjXReader::OnePair(XMLElement* elem, mjsPair* ppair) {
|
||||
string text, name, classname, geomname1, geomname2;
|
||||
string text, name, geomname1, geomname2;
|
||||
|
||||
// regular only
|
||||
if (!readingdefaults) {
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(ppair->classname, classname.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "geom1", geomname1)) {
|
||||
mjs_setString(ppair->geomname1, geomname1.c_str());
|
||||
}
|
||||
@@ -1858,7 +1831,7 @@ void mjXReader::OnePair(XMLElement* elem, mjsPair* ppair) {
|
||||
// equality element parser
|
||||
void mjXReader::OneEquality(XMLElement* elem, mjsEquality* pequality) {
|
||||
int n;
|
||||
string text, name1, name2, name, classname;
|
||||
string text, name1, name2, name;
|
||||
|
||||
// read type (bad keywords already detected by schema)
|
||||
text = elem->Value();
|
||||
@@ -1869,9 +1842,6 @@ void mjXReader::OneEquality(XMLElement* elem, mjsEquality* pequality) {
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pequality->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pequality->classname, classname.c_str());
|
||||
};
|
||||
|
||||
switch (pequality->type) {
|
||||
case mjEQ_CONNECT:
|
||||
@@ -1935,16 +1905,13 @@ void mjXReader::OneEquality(XMLElement* elem, mjsEquality* pequality) {
|
||||
|
||||
// tendon element parser
|
||||
void mjXReader::OneTendon(XMLElement* elem, mjsTendon* pten) {
|
||||
string text, name, classname, material;
|
||||
string text, name, material;
|
||||
std::vector<double> userdata;
|
||||
|
||||
// read attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pten->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pten->classname, classname.c_str());
|
||||
}
|
||||
ReadAttrInt(elem, "group", &pten->group);
|
||||
if (ReadAttrTxt(elem, "material", material)) {
|
||||
mjs_setString(pten->material, material.c_str());
|
||||
@@ -1979,15 +1946,12 @@ void mjXReader::OneTendon(XMLElement* elem, mjsTendon* pten) {
|
||||
|
||||
// actuator element parser
|
||||
void mjXReader::OneActuator(XMLElement* elem, mjsActuator* pact) {
|
||||
string text, type, name, classname, target, slidersite, refsite;
|
||||
string text, type, name, target, slidersite, refsite;
|
||||
|
||||
// common attributes
|
||||
if (ReadAttrTxt(elem, "name", name)) {
|
||||
mjs_setString(pact->name, name.c_str());
|
||||
}
|
||||
if (ReadAttrTxt(elem, "class", classname)) {
|
||||
mjs_setString(pact->classname, classname.c_str());
|
||||
}
|
||||
ReadAttrInt(elem, "group", &pact->group);
|
||||
MapValue(elem, "ctrllimited", &pact->ctrllimited, TFAuto_map, 3);
|
||||
MapValue(elem, "forcelimited", &pact->forcelimited, TFAuto_map, 3);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
@@ -198,7 +199,9 @@ void mjXWriter::OneMesh(XMLElement* elem, const mjCMesh* pmesh, mjCDef* def) {
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pmesh->name);
|
||||
WriteAttrTxt(elem, "class", pmesh->classname);
|
||||
if (pmesh->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pmesh->classname);
|
||||
}
|
||||
WriteAttrTxt(elem, "content_type", pmesh->get_content_type());
|
||||
WriteAttrTxt(elem, "file", pmesh->get_file());
|
||||
|
||||
@@ -295,7 +298,9 @@ void mjXWriter::OneMaterial(XMLElement* elem, const mjCMaterial* pmat, mjCDef* d
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pmat->name);
|
||||
WriteAttrTxt(elem, "class", pmat->classname);
|
||||
if (pmat->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pmat->classname);
|
||||
}
|
||||
}
|
||||
|
||||
// defaults and regular
|
||||
@@ -316,13 +321,16 @@ void mjXWriter::OneMaterial(XMLElement* elem, const mjCMaterial* pmat, mjCDef* d
|
||||
|
||||
|
||||
// write joint
|
||||
void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* pjoint, mjCDef* def) {
|
||||
void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* pjoint, mjCDef* def,
|
||||
std::string_view classname) {
|
||||
double zero = 0;
|
||||
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pjoint->name);
|
||||
WriteAttrTxt(elem, "class", pjoint->classname);
|
||||
if (classname != pjoint->classname && pjoint->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pjoint->classname);
|
||||
}
|
||||
if (pjoint->type != mjJNT_FREE) {
|
||||
WriteAttr(elem, "pos", 3, pjoint->pos);
|
||||
}
|
||||
@@ -364,17 +372,18 @@ void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* pjoint, mjCDef* def)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write geom
|
||||
void mjXWriter::OneGeom(XMLElement* elem, const mjCGeom* pgeom, mjCDef* def) {
|
||||
void mjXWriter::OneGeom(XMLElement* elem, const mjCGeom* pgeom, mjCDef* def,
|
||||
std::string_view classname) {
|
||||
double unitq[4] = {1, 0, 0, 0};
|
||||
double mass = 0;
|
||||
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pgeom->name);
|
||||
WriteAttrTxt(elem, "class", pgeom->classname);
|
||||
if (classname != pgeom->classname && pgeom->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pgeom->classname);
|
||||
}
|
||||
if (mjGEOMINFO[pgeom->type]) {
|
||||
WriteAttr(elem, "size", mjGEOMINFO[pgeom->type], pgeom->size, def->Geom().size);
|
||||
}
|
||||
@@ -459,16 +468,17 @@ void mjXWriter::OneGeom(XMLElement* elem, const mjCGeom* pgeom, mjCDef* def) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write site
|
||||
void mjXWriter::OneSite(XMLElement* elem, const mjCSite* psite, mjCDef* def) {
|
||||
void mjXWriter::OneSite(XMLElement* elem, const mjCSite* psite, mjCDef* def,
|
||||
std::string_view classname) {
|
||||
double unitq[4] = {1, 0, 0, 0};
|
||||
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", psite->name);
|
||||
WriteAttrTxt(elem, "class", psite->classname);
|
||||
if (classname != psite->classname && psite->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", psite->classname);
|
||||
}
|
||||
WriteAttr(elem, "pos", 3, psite->pos);
|
||||
WriteAttr(elem, "quat", 4, psite->quat, unitq);
|
||||
if (mjGEOMINFO[psite->type]) {
|
||||
@@ -494,16 +504,17 @@ void mjXWriter::OneSite(XMLElement* elem, const mjCSite* psite, mjCDef* def) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write camera
|
||||
void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* pcam, mjCDef* def) {
|
||||
void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* pcam, mjCDef* def,
|
||||
std::string_view classname) {
|
||||
double unitq[4] = {1, 0, 0, 0};
|
||||
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pcam->name);
|
||||
WriteAttrTxt(elem, "class", pcam->classname);
|
||||
if (classname != pcam->classname && pcam->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pcam->classname);
|
||||
}
|
||||
WriteAttrTxt(elem, "target", pcam->get_targetbody());
|
||||
WriteAttr(elem, "pos", 3, pcam->pos);
|
||||
WriteAttr(elem, "quat", 4, pcam->quat, unitq);
|
||||
@@ -534,14 +545,15 @@ void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* pcam, mjCDef* def)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write light
|
||||
void mjXWriter::OneLight(XMLElement* elem, const mjCLight* plight, mjCDef* def) {
|
||||
void mjXWriter::OneLight(XMLElement* elem, const mjCLight* plight, mjCDef* def,
|
||||
std::string_view classname) {
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", plight->name);
|
||||
WriteAttrTxt(elem, "class", plight->classname);
|
||||
if (classname != plight->classname && plight->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", plight->classname);
|
||||
}
|
||||
WriteAttrTxt(elem, "target", plight->get_targetbody());
|
||||
WriteAttr(elem, "pos", 3, plight->pos);
|
||||
WriteAttr(elem, "dir", 3, plight->dir);
|
||||
@@ -561,13 +573,13 @@ void mjXWriter::OneLight(XMLElement* elem, const mjCLight* plight, mjCDef* def)
|
||||
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, plight->mode, def->Light().mode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// write pair
|
||||
void mjXWriter::OnePair(XMLElement* elem, const mjCPair* ppair, mjCDef* def) {
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "class", ppair->classname);
|
||||
if (ppair->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", ppair->classname);
|
||||
}
|
||||
WriteAttrTxt(elem, "geom1", ppair->get_geomname1());
|
||||
WriteAttrTxt(elem, "geom2", ppair->get_geomname2());
|
||||
}
|
||||
@@ -591,7 +603,9 @@ void mjXWriter::OneEquality(XMLElement* elem, const mjCEquality* peq, mjCDef* de
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", peq->name);
|
||||
WriteAttrTxt(elem, "class", peq->classname);
|
||||
if (peq->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", peq->classname);
|
||||
}
|
||||
|
||||
switch (peq->type) {
|
||||
case mjEQ_CONNECT:
|
||||
@@ -644,7 +658,9 @@ void mjXWriter::OneTendon(XMLElement* elem, const mjCTendon* pten, mjCDef* def)
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pten->name);
|
||||
WriteAttrTxt(elem, "class", pten->classname);
|
||||
if (pten->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pten->classname);
|
||||
}
|
||||
}
|
||||
|
||||
// defaults and regular
|
||||
@@ -691,7 +707,9 @@ void mjXWriter::OneActuator(XMLElement* elem, const mjCActuator* pact, mjCDef* d
|
||||
// regular
|
||||
if (!writingdefaults) {
|
||||
WriteAttrTxt(elem, "name", pact->name);
|
||||
WriteAttrTxt(elem, "class", pact->classname);
|
||||
if (pact->classname != "main") {
|
||||
WriteAttrTxt(elem, "class", pact->classname);
|
||||
}
|
||||
|
||||
// transmission target
|
||||
switch (pact->trntype) {
|
||||
@@ -1515,7 +1533,7 @@ XMLElement* mjXWriter::OneFrame(XMLElement* elem, mjCFrame* frame) {
|
||||
|
||||
|
||||
// recursive body and frame writer
|
||||
void mjXWriter::Body(XMLElement* elem, mjCBody* body) {
|
||||
void mjXWriter::Body(XMLElement* elem, mjCBody* body, std::string_view childclass) {
|
||||
double unitq[4] = {1, 0, 0, 0};
|
||||
|
||||
if (!body) {
|
||||
@@ -1557,31 +1575,51 @@ void mjXWriter::Body(XMLElement* elem, mjCBody* body) {
|
||||
// write joints
|
||||
for (int i=0; i<body->joints.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->joints[i]->frame);
|
||||
OneJoint(InsertEnd(celem, "joint"), body->joints[i], body->joints[i]->def);
|
||||
std::string classname = body->joints[i]->frame && !body->joints[i]->frame->classname.empty()
|
||||
? body->joints[i]->frame->classname
|
||||
: body->classname;
|
||||
OneJoint(InsertEnd(celem, "joint"), body->joints[i], body->joints[i]->def,
|
||||
classname.empty() ? childclass : classname);
|
||||
}
|
||||
|
||||
// write geoms
|
||||
for (int i=0; i<body->geoms.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->geoms[i]->frame);
|
||||
OneGeom(InsertEnd(celem, "geom"), body->geoms[i], body->geoms[i]->def);
|
||||
std::string classname = body->geoms[i]->frame && !body->geoms[i]->frame->classname.empty()
|
||||
? body->geoms[i]->frame->classname
|
||||
: body->classname;
|
||||
OneGeom(InsertEnd(celem, "geom"), body->geoms[i], body->geoms[i]->def,
|
||||
classname.empty() ? childclass : classname);
|
||||
}
|
||||
|
||||
// write sites
|
||||
for (int i=0; i<body->sites.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->sites[i]->frame);
|
||||
OneSite(InsertEnd(celem, "site"), body->sites[i], body->sites[i]->def);
|
||||
std::string classname = body->sites[i]->frame && !body->sites[i]->frame->classname.empty()
|
||||
? body->sites[i]->frame->classname
|
||||
: body->classname;
|
||||
OneSite(InsertEnd(celem, "site"), body->sites[i], body->sites[i]->def,
|
||||
classname.empty() ? childclass : classname);
|
||||
}
|
||||
|
||||
// write cameras
|
||||
for (int i=0; i<body->cameras.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->cameras[i]->frame);
|
||||
OneCamera(InsertEnd(celem, "camera"), body->cameras[i], body->cameras[i]->def);
|
||||
std::string classname = body->cameras[i]->frame && !body->cameras[i]->frame->classname.empty()
|
||||
? body->cameras[i]->frame->classname
|
||||
: body->classname;
|
||||
OneCamera(InsertEnd(celem, "camera"), body->cameras[i], body->cameras[i]->def,
|
||||
classname.empty() ? childclass : classname);
|
||||
}
|
||||
|
||||
// write lights
|
||||
for (int i=0; i<body->lights.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->lights[i]->frame);
|
||||
OneLight(InsertEnd(celem, "light"), body->lights[i], body->lights[i]->def);
|
||||
std::string classname = body->lights[i]->frame && !body->lights[i]->frame->classname.empty()
|
||||
? body->lights[i]->frame->classname
|
||||
: body->classname;
|
||||
OneLight(InsertEnd(celem, "light"), body->lights[i], body->lights[i]->def,
|
||||
classname.empty() ? childclass : classname);
|
||||
}
|
||||
|
||||
// write plugin
|
||||
@@ -1592,7 +1630,10 @@ void mjXWriter::Body(XMLElement* elem, mjCBody* body) {
|
||||
// write child bodies recursively
|
||||
for (int i=0; i<body->bodies.size(); i++) {
|
||||
XMLElement* celem = OneFrame(elem, body->bodies[i]->frame);
|
||||
Body(InsertEnd(celem, "body"), body->bodies[i]);
|
||||
std::string classname = body->bodies[i]->frame && !body->bodies[i]->frame->classname.empty()
|
||||
? body->bodies[i]->frame->classname
|
||||
: body->classname;
|
||||
Body(InsertEnd(celem, "body"), body->bodies[i], classname.empty() ? childclass : classname);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#include <mujoco/mjspec.h>
|
||||
#include "user/user_objects.h"
|
||||
@@ -49,7 +50,6 @@ class mjXWriter : public mjXBase {
|
||||
void Extension(tinyxml2::XMLElement* root); // extension section
|
||||
void Custom(tinyxml2::XMLElement* root); // custom section
|
||||
void Asset(tinyxml2::XMLElement* root); // asset section
|
||||
void Body(tinyxml2::XMLElement* elem, mjCBody* body); // body/world section
|
||||
void Contact(tinyxml2::XMLElement* root); // contact section
|
||||
void Deformable(tinyxml2::XMLElement* root); // deformable section
|
||||
void Equality(tinyxml2::XMLElement* root); // equality section
|
||||
@@ -58,16 +58,24 @@ class mjXWriter : public mjXBase {
|
||||
void Sensor(tinyxml2::XMLElement* root); // sensor section
|
||||
void Keyframe(tinyxml2::XMLElement* root); // keyframe section
|
||||
|
||||
// body/world section
|
||||
void Body(tinyxml2::XMLElement* elem, mjCBody* body, std::string_view childclass = "");
|
||||
|
||||
// single element writers, used in defaults and main body
|
||||
void OneFlex(tinyxml2::XMLElement* elem, const mjCFlex* pflex);
|
||||
void OneMesh(tinyxml2::XMLElement* elem, const mjCMesh* pmesh, mjCDef* def);
|
||||
void OneSkin(tinyxml2::XMLElement* elem, const mjCSkin* pskin);
|
||||
void OneMaterial(tinyxml2::XMLElement* elem, const mjCMaterial* pmaterial, mjCDef* def);
|
||||
void OneJoint(tinyxml2::XMLElement* elem, const mjCJoint* pjoint, mjCDef* def);
|
||||
void OneGeom(tinyxml2::XMLElement* elem, const mjCGeom* pgeom, mjCDef* def);
|
||||
void OneSite(tinyxml2::XMLElement* elem, const mjCSite* psite, mjCDef* def);
|
||||
void OneCamera(tinyxml2::XMLElement* elem, const mjCCamera* pcamera, mjCDef* def);
|
||||
void OneLight(tinyxml2::XMLElement* elem, const mjCLight* plight, mjCDef* def);
|
||||
void OneJoint(tinyxml2::XMLElement* elem, const mjCJoint* pjoint, mjCDef* def,
|
||||
std::string_view classname = "");
|
||||
void OneGeom(tinyxml2::XMLElement* elem, const mjCGeom* pgeom, mjCDef* def,
|
||||
std::string_view classname = "");
|
||||
void OneSite(tinyxml2::XMLElement* elem, const mjCSite* psite, mjCDef* def,
|
||||
std::string_view classname = "");
|
||||
void OneCamera(tinyxml2::XMLElement* elem, const mjCCamera* pcamera,
|
||||
mjCDef* def, std::string_view classname = "");
|
||||
void OneLight(tinyxml2::XMLElement* elem, const mjCLight* plight, mjCDef* def,
|
||||
std::string_view classname = "");
|
||||
void OnePair(tinyxml2::XMLElement* elem, const mjCPair* ppair, mjCDef* def);
|
||||
void OneEquality(tinyxml2::XMLElement* elem, const mjCEquality* pequality, mjCDef* def);
|
||||
void OneTendon(tinyxml2::XMLElement* elem, const mjCTendon* ptendon, mjCDef* def);
|
||||
|
||||
Reference in New Issue
Block a user