Replace name attribute with setters and getters in the C API of mjSpec.
PiperOrigin-RevId: 778816015 Change-Id: Ieffb7a5bce37e887ff009f9a02d2434435e79ca1
This commit is contained in:
committed by
Copybara-Service
parent
1c5d47c94b
commit
594e17074a
@@ -108,7 +108,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
type == mjFCOMPTYPE_GMSH);
|
||||
|
||||
// check parent body name
|
||||
if (std::string(mjs_getString(body->name)).empty()) {
|
||||
if (mjs_getName(body->element)->empty()) {
|
||||
return comperr(error, "Parent body must have name", error_sz);
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
|
||||
flex->model = model;
|
||||
flex->id = id;
|
||||
mjs_setString(pf->name, name.c_str());
|
||||
mjs_setName(pf->element, name.c_str());
|
||||
mjs_setInt(pf->elem, element.data(), element.size());
|
||||
mjs_setFloat(pf->texcoord, texcoord.data(), texcoord.size());
|
||||
mjs_setInt(pf->elemtexcoord, elemtexcoord.data(), elemtexcoord.size());
|
||||
@@ -420,7 +420,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
|
||||
// rigid: set parent name, nothing else to do
|
||||
if (rigid) {
|
||||
mjs_appendString(pf->vertbody, mjs_getString(body->name));
|
||||
mjs_appendString(pf->vertbody, mjs_getName(body->element)->c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
|
||||
// pinned or trilinear: parent body
|
||||
if (pinned[i] || doftype == mjFCOMPDOF_TRILINEAR) {
|
||||
mjs_appendString(pf->vertbody, mjs_getString(body->name));
|
||||
mjs_appendString(pf->vertbody, mjs_getName(body->element)->c_str());
|
||||
|
||||
// add plugin
|
||||
if (plugin.active) {
|
||||
@@ -507,8 +507,8 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
// construct body name, add to vertbody
|
||||
char txt[100];
|
||||
mju::sprintf_arr(txt, "%s_%d", name.c_str(), i);
|
||||
mjs_setString(pb->name, txt);
|
||||
mjs_appendString(pf->vertbody, mjs_getString(pb->name));
|
||||
mjs_setName(pb->element, txt);
|
||||
mjs_appendString(pf->vertbody, mjs_getName(pb->element)->c_str());
|
||||
|
||||
// clear flex vertex coordinates if allocated
|
||||
if (!centered) {
|
||||
@@ -538,7 +538,7 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
node[3*(i*4+j*2+k)+0] = i == 0 ? minmax[0] : minmax[3];
|
||||
node[3*(i*4+j*2+k)+1] = j == 0 ? minmax[1] : minmax[4];
|
||||
node[3*(i*4+j*2+k)+2] = k == 0 ? minmax[2] : minmax[5];
|
||||
mjs_appendString(pf->nodebody, mjs_getString(body->name));
|
||||
mjs_appendString(pf->nodebody, mjs_getName(body->element)->c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -571,8 +571,8 @@ bool mjCFlexcomp::Make(mjsBody* body, char* error, int error_sz) {
|
||||
// construct node name, add to nodebody
|
||||
char txt[100];
|
||||
mju::sprintf_arr(txt, "%s_%d_%d_%d", name.c_str(), i, j, k);
|
||||
mjs_setString(pb->name, txt);
|
||||
mjs_appendString(pf->nodebody, mjs_getString(pb->name));
|
||||
mjs_setName(pb->element, txt);
|
||||
mjs_appendString(pf->nodebody, mjs_getName(pb->element)->c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user