Make default class members private.
PiperOrigin-RevId: 634288934 Change-Id: I1b7a5ec8dd51c65377b09bcb85c56a849573cac7
This commit is contained in:
committed by
Copybara-Service
parent
6e58cedb47
commit
e885a3dc3d
@@ -429,7 +429,7 @@ mjsPlugin* mjs_addPlugin(mjSpec* s) {
|
|||||||
// add default to model
|
// add default to model
|
||||||
mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, int parentid, int* id) {
|
mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, int parentid, int* id) {
|
||||||
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
*id = (int)modelC->Defaults().size();
|
*id = (int)modelC->NumDefaults();
|
||||||
mjCDef* def = modelC->AddDefault(classname, parentid);
|
mjCDef* def = modelC->AddDefault(classname, parentid);
|
||||||
if (def) {
|
if (def) {
|
||||||
return &def->spec;
|
return &def->spec;
|
||||||
@@ -469,7 +469,7 @@ mjsDefault* mjs_findDefault(mjSpec* s, const char* classname) {
|
|||||||
// get default[0] from model
|
// get default[0] from model
|
||||||
mjsDefault* mjs_getSpecDefault(mjSpec* s) {
|
mjsDefault* mjs_getSpecDefault(mjSpec* s) {
|
||||||
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = modelC->Defaults()[0];
|
mjCDef* def = modelC->Defaults(0);
|
||||||
if (!def) {
|
if (!def) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -561,7 +561,7 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjsBody* body, char* error, int
|
|||||||
|
|
||||||
// create tendon
|
// create tendon
|
||||||
mjsTendon* ten = mjs_addTendon(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
mjsTendon* ten = mjs_addTendon(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
||||||
mjs_setDefault(ten->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(ten->element, &model->Defaults(0)->spec);
|
||||||
mjs_setString(ten->name, txt0);
|
mjs_setString(ten->name, txt0);
|
||||||
ten->group = 4;
|
ten->group = 4;
|
||||||
mjs_wrapSite(ten, txt1);
|
mjs_wrapSite(ten, txt1);
|
||||||
@@ -569,7 +569,7 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjsBody* body, char* error, int
|
|||||||
|
|
||||||
// add equality constraint
|
// add equality constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_TENDON;
|
eq->type = mjEQ_TENDON;
|
||||||
mjs_setString(eq->name1, mjs_getString(ten->name));
|
mjs_setString(eq->name1, mjs_getString(ten->name));
|
||||||
}
|
}
|
||||||
@@ -675,7 +675,7 @@ bool mjCComposite::MakeGrid(mjCModel* model, mjsBody* body, char* error, int err
|
|||||||
|
|
||||||
// create tendon
|
// create tendon
|
||||||
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_TENDON);
|
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_TENDON);
|
||||||
ten->def = model->Defaults()[0];
|
ten->def = model->Defaults(0);
|
||||||
mju::sprintf_arr(txt, "%sT%d_%d_%d", prefix.c_str(), i, ix, iy);
|
mju::sprintf_arr(txt, "%sT%d_%d_%d", prefix.c_str(), i, ix, iy);
|
||||||
ten->name = txt;
|
ten->name = txt;
|
||||||
ten->WrapSite(txt1);
|
ten->WrapSite(txt1);
|
||||||
@@ -683,7 +683,7 @@ bool mjCComposite::MakeGrid(mjCModel* model, mjsBody* body, char* error, int err
|
|||||||
|
|
||||||
// add equality constraint
|
// add equality constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_TENDON;
|
eq->type = mjEQ_TENDON;
|
||||||
mjs_setString(eq->name1, ten->name.c_str());
|
mjs_setString(eq->name1, ten->name.c_str());
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1045,7 @@ mjsBody* mjCComposite::AddRopeBody(mjCModel* model, mjsBody* body, int ix, int i
|
|||||||
|
|
||||||
// add constraint
|
// add constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TWIST].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TWIST].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_JOINT;
|
eq->type = mjEQ_JOINT;
|
||||||
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
||||||
}
|
}
|
||||||
@@ -1063,7 +1063,7 @@ mjsBody* mjCComposite::AddRopeBody(mjCModel* model, mjsBody* body, int ix, int i
|
|||||||
|
|
||||||
// add constraint
|
// add constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_STRETCH].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_STRETCH].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_JOINT;
|
eq->type = mjEQ_JOINT;
|
||||||
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
||||||
}
|
}
|
||||||
@@ -1131,7 +1131,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjsBody* body, char* error, int erro
|
|||||||
|
|
||||||
// fixed tendon for all joints
|
// fixed tendon for all joints
|
||||||
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_TENDON);
|
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_TENDON);
|
||||||
ten->def = model->Defaults()[0];
|
ten->def = model->Defaults(0);
|
||||||
mju::sprintf_arr(txt, "%sT", prefix.c_str());
|
mju::sprintf_arr(txt, "%sT", prefix.c_str());
|
||||||
ten->name = txt;
|
ten->name = txt;
|
||||||
|
|
||||||
@@ -1184,7 +1184,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjsBody* body, char* error, int erro
|
|||||||
|
|
||||||
// add fix constraint
|
// add fix constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_JOINT].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_JOINT].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_JOINT;
|
eq->type = mjEQ_JOINT;
|
||||||
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
mjs_setString(eq->name1, mjs_getString(jnt->name));
|
||||||
|
|
||||||
@@ -1218,7 +1218,7 @@ bool mjCComposite::MakeBox(mjCModel* model, mjsBody* body, char* error, int erro
|
|||||||
|
|
||||||
// finalize fixed tendon
|
// finalize fixed tendon
|
||||||
mjsEquality* eqt = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
mjsEquality* eqt = mjs_addEquality(&model->spec, &def[mjCOMPKIND_TENDON].spec);
|
||||||
mjs_setDefault(eqt->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eqt->element, &model->Defaults(0)->spec);
|
||||||
eqt->type = mjEQ_TENDON;
|
eqt->type = mjEQ_TENDON;
|
||||||
mjs_setString(eqt->name1, ten->name.c_str());
|
mjs_setString(eqt->name1, ten->name.c_str());
|
||||||
|
|
||||||
@@ -1244,7 +1244,7 @@ void mjCComposite::MakeShear(mjCModel* model) {
|
|||||||
|
|
||||||
// create tendon
|
// create tendon
|
||||||
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_SHEAR);
|
mjCTendon* ten = model->AddTendon(def + mjCOMPKIND_SHEAR);
|
||||||
ten->def = model->Defaults()[0];
|
ten->def = model->Defaults(0);
|
||||||
ten->WrapSite(txt1);
|
ten->WrapSite(txt1);
|
||||||
ten->WrapSite(txt2);
|
ten->WrapSite(txt2);
|
||||||
|
|
||||||
@@ -1254,7 +1254,7 @@ void mjCComposite::MakeShear(mjCModel* model) {
|
|||||||
|
|
||||||
// equality constraint
|
// equality constraint
|
||||||
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_SHEAR].spec);
|
mjsEquality* eq = mjs_addEquality(&model->spec, &def[mjCOMPKIND_SHEAR].spec);
|
||||||
mjs_setDefault(eq->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(eq->element, &model->Defaults(0)->spec);
|
||||||
eq->type = mjEQ_TENDON;
|
eq->type = mjEQ_TENDON;
|
||||||
mjs_setString(eq->name1, txt);
|
mjs_setString(eq->name1, txt);
|
||||||
}
|
}
|
||||||
@@ -1552,11 +1552,11 @@ void mjCComposite::MakeCableBonesSubgrid(mjCModel* model, mjsSkin* skin) {
|
|||||||
// bind pose
|
// bind pose
|
||||||
if (iy==0) {
|
if (iy==0) {
|
||||||
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
||||||
bindpos.push_back(-def[0].geom.spec.size[1]);
|
bindpos.push_back(-def[0].Geom().spec.size[1]);
|
||||||
bindpos.push_back(0);
|
bindpos.push_back(0);
|
||||||
} else if (iy==2) {
|
} else if (iy==2) {
|
||||||
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
||||||
bindpos.push_back(def[0].geom.spec.size[1]);
|
bindpos.push_back(def[0].Geom().spec.size[1]);
|
||||||
bindpos.push_back(0);
|
bindpos.push_back(0);
|
||||||
} else {
|
} else {
|
||||||
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
bindpos.push_back((ix==count[0]-1) ? -2*def[0].spec.geom->size[0] : 0);
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
mjsFlex* pf = &flex->spec;
|
mjsFlex* pf = &flex->spec;
|
||||||
int id = flex->id;
|
int id = flex->id;
|
||||||
|
|
||||||
*flex = def.flex;
|
*flex = def.Flex();
|
||||||
flex->PointToLocal();
|
flex->PointToLocal();
|
||||||
|
|
||||||
flex->model = model;
|
flex->model = model;
|
||||||
@@ -521,7 +521,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
// create edge equality constraint
|
// create edge equality constraint
|
||||||
if (equality) {
|
if (equality) {
|
||||||
mjsEquality* pe = mjs_addEquality(&model->spec, &def.spec);
|
mjsEquality* pe = mjs_addEquality(&model->spec, &def.spec);
|
||||||
mjs_setDefault(pe->element, &model->Defaults()[0]->spec);
|
mjs_setDefault(pe->element, &model->Defaults(0)->spec);
|
||||||
pe->type = mjEQ_FLEX;
|
pe->type = mjEQ_FLEX;
|
||||||
pe->active = true;
|
pe->active = true;
|
||||||
mjs_setString(pe->name1, name.c_str());
|
mjs_setString(pe->name1, name.c_str());
|
||||||
@@ -544,7 +544,7 @@ int mjCFlexcomp::GridID(int ix, int iy, int iz) {
|
|||||||
|
|
||||||
// make grid
|
// make grid
|
||||||
bool mjCFlexcomp::MakeGrid(char* error, int error_sz) {
|
bool mjCFlexcomp::MakeGrid(char* error, int error_sz) {
|
||||||
int dim = def.flex.spec.dim;
|
int dim = def.Flex().spec.dim;
|
||||||
bool hastex = texcoord.empty();
|
bool hastex = texcoord.empty();
|
||||||
|
|
||||||
// 1D
|
// 1D
|
||||||
|
|||||||
@@ -146,12 +146,12 @@ mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->mesh;
|
*this = _def->Mesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// in case this body is not compiled
|
// in case this body is not compiled
|
||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
@@ -1426,7 +1426,7 @@ void mjCMesh::Process() {
|
|||||||
// apply formula, accumulate
|
// apply formula, accumulate
|
||||||
GetVolumeRef(type) += vol;
|
GetVolumeRef(type) += vol;
|
||||||
for (int j=0; j<6; j++) {
|
for (int j=0; j<6; j++) {
|
||||||
P[j] += def->geom.density*vol /
|
P[j] += def->Geom().density*vol /
|
||||||
(type==mjINERTIA_SHELL ? 12 : 20) * (
|
(type==mjINERTIA_SHELL ? 12 : 20) * (
|
||||||
2*(D[k[j][0]] * D[k[j][1]] +
|
2*(D[k[j][0]] * D[k[j][1]] +
|
||||||
E[k[j][0]] * E[k[j][1]] +
|
E[k[j][0]] * E[k[j][1]] +
|
||||||
@@ -1467,7 +1467,7 @@ void mjCMesh::Process() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// compute sizes of equivalent inertia box
|
// compute sizes of equivalent inertia box
|
||||||
double mass = GetVolumeRef(type) * def->geom.density;
|
double mass = GetVolumeRef(type) * def->Geom().density;
|
||||||
double* boxsz = GetInertiaBoxPtr(type);
|
double* boxsz = GetInertiaBoxPtr(type);
|
||||||
boxsz[0] = sqrt(6*(eigval[1]+eigval[2]-eigval[0])/mass)/2;
|
boxsz[0] = sqrt(6*(eigval[1]+eigval[2]-eigval[0])/mass)/2;
|
||||||
boxsz[1] = sqrt(6*(eigval[0]+eigval[2]-eigval[1])/mass)/2;
|
boxsz[1] = sqrt(6*(eigval[0]+eigval[2]-eigval[1])/mass)/2;
|
||||||
|
|||||||
@@ -222,7 +222,8 @@ class mjCModel : public mjCModel_, private mjSpec {
|
|||||||
std::string get_meshdir() const { return meshdir_; }
|
std::string get_meshdir() const { return meshdir_; }
|
||||||
std::string get_texturedir() const { return texturedir_; }
|
std::string get_texturedir() const { return texturedir_; }
|
||||||
|
|
||||||
const std::vector<mjCDef*>& Defaults() const { return defaults_; }
|
mjCDef* Defaults(int i) const { return defaults_[i]; }
|
||||||
|
int NumDefaults() const { return defaults_.size(); }
|
||||||
|
|
||||||
const std::vector<std::pair<const mjpPlugin*, int>>& ActivePlugins() const {
|
const std::vector<std::pair<const mjpPlugin*, int>>& ActivePlugins() const {
|
||||||
return active_plugins_;
|
return active_plugins_;
|
||||||
|
|||||||
+93
-94
@@ -557,22 +557,22 @@ int mjCBoundingVolumeHierarchy::MakeBVH(
|
|||||||
//------------------------- class mjCDef implementation --------------------------------------------
|
//------------------------- class mjCDef implementation --------------------------------------------
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
mjCDef::mjCDef(void) {
|
mjCDef::mjCDef() {
|
||||||
name.clear();
|
name.clear();
|
||||||
parentid = -1;
|
parentid = -1;
|
||||||
childid.clear();
|
childid.clear();
|
||||||
mjs_defaultJoint(&joint.spec);
|
mjs_defaultJoint(&joint_.spec);
|
||||||
mjs_defaultGeom(&geom.spec);
|
mjs_defaultGeom(&geom_.spec);
|
||||||
mjs_defaultSite(&site.spec);
|
mjs_defaultSite(&site_.spec);
|
||||||
mjs_defaultCamera(&camera.spec);
|
mjs_defaultCamera(&camera_.spec);
|
||||||
mjs_defaultLight(&light.spec);
|
mjs_defaultLight(&light_.spec);
|
||||||
mjs_defaultFlex(&flex.spec);
|
mjs_defaultFlex(&flex_.spec);
|
||||||
mjs_defaultMesh(&mesh.spec);
|
mjs_defaultMesh(&mesh_.spec);
|
||||||
mjs_defaultMaterial(&material.spec);
|
mjs_defaultMaterial(&material_.spec);
|
||||||
mjs_defaultPair(&pair.spec);
|
mjs_defaultPair(&pair_.spec);
|
||||||
mjs_defaultEquality(&equality.spec);
|
mjs_defaultEquality(&equality_.spec);
|
||||||
mjs_defaultTendon(&tendon.spec);
|
mjs_defaultTendon(&tendon_.spec);
|
||||||
mjs_defaultActuator(&actuator.spec);
|
mjs_defaultActuator(&actuator_.spec);
|
||||||
|
|
||||||
// make sure all the pointers are local
|
// make sure all the pointers are local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -592,12 +592,12 @@ void mjCDef::Compile(const mjCModel* model) {
|
|||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
|
|
||||||
// enforce length of all default userdata arrays
|
// enforce length of all default userdata arrays
|
||||||
joint.userdata_.resize(model->nuser_jnt);
|
joint_.userdata_.resize(model->nuser_jnt);
|
||||||
geom.userdata_.resize(model->nuser_geom);
|
geom_.userdata_.resize(model->nuser_geom);
|
||||||
site.userdata_.resize(model->nuser_site);
|
site_.userdata_.resize(model->nuser_site);
|
||||||
camera.userdata_.resize(model->nuser_cam);
|
camera_.userdata_.resize(model->nuser_cam);
|
||||||
tendon.userdata_.resize(model->nuser_tendon);
|
tendon_.userdata_.resize(model->nuser_tendon);
|
||||||
actuator.userdata_.resize(model->nuser_actuator);
|
actuator_.userdata_.resize(model->nuser_actuator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -608,18 +608,18 @@ mjCDef& mjCDef::operator=(const mjCDef& other) {
|
|||||||
name = other.name;
|
name = other.name;
|
||||||
parentid = other.parentid;
|
parentid = other.parentid;
|
||||||
childid = other.childid;
|
childid = other.childid;
|
||||||
joint = other.joint;
|
joint_ = other.joint_;
|
||||||
geom = other.geom;
|
geom_ = other.geom_;
|
||||||
site = other.site;
|
site_ = other.site_;
|
||||||
camera = other.camera;
|
camera_ = other.camera_;
|
||||||
light = other.light;
|
light_ = other.light_;
|
||||||
flex = other.flex;
|
flex_ = other.flex_;
|
||||||
mesh = other.mesh;
|
mesh_ = other.mesh_;
|
||||||
material = other.material;
|
material_ = other.material_;
|
||||||
pair = other.pair;
|
pair_ = other.pair_;
|
||||||
equality = other.equality;
|
equality_ = other.equality_;
|
||||||
tendon = other.tendon;
|
tendon_ = other.tendon_;
|
||||||
actuator = other.actuator;
|
actuator_ = other.actuator_;
|
||||||
}
|
}
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
return *this;
|
return *this;
|
||||||
@@ -628,49 +628,49 @@ mjCDef& mjCDef::operator=(const mjCDef& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCDef::PointToLocal() {
|
void mjCDef::PointToLocal() {
|
||||||
joint.PointToLocal();
|
joint_.PointToLocal();
|
||||||
geom.PointToLocal();
|
geom_.PointToLocal();
|
||||||
site.PointToLocal();
|
site_.PointToLocal();
|
||||||
camera.PointToLocal();
|
camera_.PointToLocal();
|
||||||
light.PointToLocal();
|
light_.PointToLocal();
|
||||||
flex.PointToLocal();
|
flex_.PointToLocal();
|
||||||
mesh.PointToLocal();
|
mesh_.PointToLocal();
|
||||||
material.PointToLocal();
|
material_.PointToLocal();
|
||||||
pair.PointToLocal();
|
pair_.PointToLocal();
|
||||||
equality.PointToLocal();
|
equality_.PointToLocal();
|
||||||
tendon.PointToLocal();
|
tendon_.PointToLocal();
|
||||||
actuator.PointToLocal();
|
actuator_.PointToLocal();
|
||||||
spec.element = static_cast<mjElement*>(this);
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.joint = &joint.spec;
|
spec.joint = &joint_.spec;
|
||||||
spec.geom = &geom.spec;
|
spec.geom = &geom_.spec;
|
||||||
spec.site = &site.spec;
|
spec.site = &site_.spec;
|
||||||
spec.camera = &camera.spec;
|
spec.camera = &camera_.spec;
|
||||||
spec.light = &light.spec;
|
spec.light = &light_.spec;
|
||||||
spec.flex = &flex.spec;
|
spec.flex = &flex_.spec;
|
||||||
spec.mesh = &mesh.spec;
|
spec.mesh = &mesh_.spec;
|
||||||
spec.material = &material.spec;
|
spec.material = &material_.spec;
|
||||||
spec.pair = &pair.spec;
|
spec.pair = &pair_.spec;
|
||||||
spec.equality = &equality.spec;
|
spec.equality = &equality_.spec;
|
||||||
spec.tendon = &tendon.spec;
|
spec.tendon = &tendon_.spec;
|
||||||
spec.actuator = &actuator.spec;
|
spec.actuator = &actuator_.spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void mjCDef::CopyFromSpec() {
|
void mjCDef::CopyFromSpec() {
|
||||||
joint.CopyFromSpec();
|
joint_.CopyFromSpec();
|
||||||
geom.CopyFromSpec();
|
geom_.CopyFromSpec();
|
||||||
site.CopyFromSpec();
|
site_.CopyFromSpec();
|
||||||
camera.CopyFromSpec();
|
camera_.CopyFromSpec();
|
||||||
light.CopyFromSpec();
|
light_.CopyFromSpec();
|
||||||
flex.CopyFromSpec();
|
flex_.CopyFromSpec();
|
||||||
mesh.CopyFromSpec();
|
mesh_.CopyFromSpec();
|
||||||
material.CopyFromSpec();
|
material_.CopyFromSpec();
|
||||||
pair.CopyFromSpec();
|
pair_.CopyFromSpec();
|
||||||
equality.CopyFromSpec();
|
equality_.CopyFromSpec();
|
||||||
tendon.CopyFromSpec();
|
tendon_.CopyFromSpec();
|
||||||
actuator.CopyFromSpec();
|
actuator_.CopyFromSpec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1674,12 +1674,12 @@ mjCJoint::mjCJoint(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->joint;
|
*this = _def->Joint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -1878,12 +1878,12 @@ mjCGeom::mjCGeom(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->geom;
|
*this = _def->Geom();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -1964,7 +1964,7 @@ void mjCGeom::NameSpace(const mjCModel* m) {
|
|||||||
|
|
||||||
|
|
||||||
// compute geom volume
|
// compute geom volume
|
||||||
double mjCGeom::GetVolume(void) {
|
double mjCGeom::GetVolume() const {
|
||||||
double height;
|
double height;
|
||||||
|
|
||||||
// get from mesh
|
// get from mesh
|
||||||
@@ -2512,7 +2512,7 @@ mjCSite::mjCSite(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->site;
|
*this = _def->Site();
|
||||||
}
|
}
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
@@ -2523,7 +2523,7 @@ mjCSite::mjCSite(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2664,12 +2664,12 @@ mjCCamera::mjCCamera(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->camera;
|
*this = _def->Camera();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -2818,12 +2818,12 @@ mjCLight::mjCLight(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->light;
|
*this = _def->Light();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
@@ -3855,12 +3855,12 @@ mjCMaterial::mjCMaterial(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->material;
|
*this = _def->Material();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -3943,12 +3943,12 @@ mjCPair::mjCPair(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->pair;
|
*this = _def->Pair();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -4304,12 +4304,12 @@ mjCEquality::mjCEquality(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->equality;
|
*this = _def->Equality();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -4466,12 +4466,12 @@ mjCTendon::mjCTendon(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->tendon;
|
*this = _def->Tendon();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// point to local
|
// point to local
|
||||||
PointToLocal();
|
PointToLocal();
|
||||||
@@ -4629,19 +4629,18 @@ void mjCTendon::WrapPulley(double divisor, std::string_view info) {
|
|||||||
|
|
||||||
|
|
||||||
// get number of wraps
|
// get number of wraps
|
||||||
int mjCTendon::NumWraps(void) {
|
int mjCTendon::NumWraps() const {
|
||||||
return (int)path.size();
|
return (int)path.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// get pointer to specified wrap
|
// get pointer to specified wrap
|
||||||
mjCWrap* mjCTendon::GetWrap(int id) {
|
const mjCWrap* mjCTendon::GetWrap(int i) const {
|
||||||
if (id>=0 && id<(int)path.size()) {
|
if (i >= 0 && i < (int)path.size()) {
|
||||||
return path[id];
|
return path[i];
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4945,12 +4944,12 @@ mjCActuator::mjCActuator(mjCModel* _model, mjCDef* _def) {
|
|||||||
|
|
||||||
// reset to default if given
|
// reset to default if given
|
||||||
if (_def) {
|
if (_def) {
|
||||||
*this = _def->actuator;
|
*this = _def->Actuator();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set model, def
|
// set model, def
|
||||||
model = _model;
|
model = _model;
|
||||||
def = (_def ? _def : (_model ? _model->Defaults()[0] : 0));
|
def = (_def ? _def : (_model ? _model->Defaults(0) : 0));
|
||||||
|
|
||||||
// in case this actuator is not compiled
|
// in case this actuator is not compiled
|
||||||
CopyFromSpec();
|
CopyFromSpec();
|
||||||
|
|||||||
+72
-56
@@ -413,8 +413,8 @@ class mjCJoint : public mjCJoint_, private mjsJoint {
|
|||||||
void CopyFromSpec(void);
|
void CopyFromSpec(void);
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
const double* get_range() { return range; }
|
const double* get_range() const { return range; }
|
||||||
|
|
||||||
bool is_limited() const;
|
bool is_limited() const;
|
||||||
bool is_actfrclimited() const;
|
bool is_actfrclimited() const;
|
||||||
@@ -475,7 +475,7 @@ class mjCGeom : public mjCGeom_, private mjsGeom {
|
|||||||
|
|
||||||
using mjCBase::name;
|
using mjCBase::name;
|
||||||
mjsGeom spec; // variables set by user
|
mjsGeom spec; // variables set by user
|
||||||
double GetVolume(void); // compute geom volume
|
double GetVolume() const; // compute geom volume
|
||||||
void SetInertia(void); // compute and set geom inertia
|
void SetInertia(void); // compute and set geom inertia
|
||||||
bool IsVisual(void) const { return visual_; }
|
bool IsVisual(void) const { return visual_; }
|
||||||
void SetNotVisual(void) { visual_ = false; }
|
void SetNotVisual(void) { visual_ = false; }
|
||||||
@@ -489,10 +489,10 @@ class mjCGeom : public mjCGeom_, private mjsGeom {
|
|||||||
void SetBoundingVolume(mjCBoundingVolume* bv) const;
|
void SetBoundingVolume(mjCBoundingVolume* bv) const;
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
const std::string& get_hfieldname() { return spec_hfieldname_; }
|
const std::string& get_hfieldname() const { return spec_hfieldname_; }
|
||||||
const std::string& get_meshname() { return spec_meshname_; }
|
const std::string& get_meshname() const { return spec_meshname_; }
|
||||||
const std::string& get_material() { return spec_material_; }
|
const std::string& get_material() const { return spec_material_; }
|
||||||
void del_material() { spec_material_.clear(); }
|
void del_material() { spec_material_.clear(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -546,8 +546,8 @@ class mjCSite : public mjCSite_, private mjsSite {
|
|||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
const std::string& get_material() { return material_; }
|
const std::string& get_material() const { return material_; }
|
||||||
void del_material() { material_.clear(); }
|
void del_material() { material_.clear(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -589,8 +589,8 @@ class mjCCamera : public mjCCamera_, private mjsCamera {
|
|||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::string& get_targetbody() { return targetbody_; }
|
const std::string& get_targetbody() const { return targetbody_; }
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Compile(void); // compiler
|
void Compile(void); // compiler
|
||||||
@@ -629,7 +629,7 @@ class mjCLight : public mjCLight_, private mjsLight {
|
|||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::string& get_targetbody() { return targetbody_; }
|
const std::string& get_targetbody() const { return targetbody_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Compile(void); // compiler
|
void Compile(void); // compiler
|
||||||
@@ -697,12 +697,12 @@ class mjCFlex: public mjCFlex_, private mjsFlex {
|
|||||||
void NameSpace(const mjCModel* m);
|
void NameSpace(const mjCModel* m);
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::string& get_material() { return material_; }
|
const std::string& get_material() const { return material_; }
|
||||||
const std::vector<std::string>& get_vertbody() { return vertbody_; }
|
const std::vector<std::string>& get_vertbody() const { return vertbody_; }
|
||||||
const std::vector<double>& get_vert() { return vert_; }
|
const std::vector<double>& get_vert() const { return vert_; }
|
||||||
const std::vector<double>& get_elemaabb() { return elemaabb_; }
|
const std::vector<double>& get_elemaabb() const { return elemaabb_; }
|
||||||
const std::vector<int>& get_elem() { return elem_; }
|
const std::vector<int>& get_elem() const { return elem_; }
|
||||||
const std::vector<float>& get_texcoord() { return texcoord_; }
|
const std::vector<float>& get_texcoord() const { return texcoord_; }
|
||||||
|
|
||||||
bool HasTexcoord() const; // texcoord not null
|
bool HasTexcoord() const; // texcoord not null
|
||||||
void DelTexcoord(); // delete texcoord
|
void DelTexcoord(); // delete texcoord
|
||||||
@@ -921,16 +921,16 @@ class mjCSkin: public mjCSkin_, private mjsSkin {
|
|||||||
using mjCBase::classname;
|
using mjCBase::classname;
|
||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
std::string get_file() const { return file_; }
|
const std::string& get_file() const { return file_; }
|
||||||
std::string& get_material() { return material_; }
|
const std::string& get_material() const { return material_; }
|
||||||
std::vector<float>& get_vert() { return vert_; }
|
const std::vector<float>& get_vert() const { return vert_; }
|
||||||
std::vector<float>& get_texcoord() { return texcoord_; }
|
const std::vector<float>& get_texcoord() const { return texcoord_; }
|
||||||
std::vector<int>& get_face() { return face_; }
|
const std::vector<int>& get_face() const { return face_; }
|
||||||
std::vector<std::string>& get_bodyname() { return bodyname_; }
|
const std::vector<std::string>& get_bodyname() const { return bodyname_; }
|
||||||
std::vector<float>& get_bindpos() { return bindpos_; }
|
const std::vector<float>& get_bindpos() const { return bindpos_; }
|
||||||
std::vector<float>& get_bindquat() { return bindquat_; }
|
const std::vector<float>& get_bindquat() const { return bindquat_; }
|
||||||
std::vector<std::vector<int>>& get_vertid() { return vertid_; }
|
const std::vector<std::vector<int>>& get_vertid() const { return vertid_; }
|
||||||
std::vector<std::vector<float>>& get_vertweight() { return vertweight_; }
|
const std::vector<std::vector<float>>& get_vertweight() const { return vertweight_; }
|
||||||
void del_material() { material_.clear(); }
|
void del_material() { material_.clear(); }
|
||||||
|
|
||||||
void CopyFromSpec();
|
void CopyFromSpec();
|
||||||
@@ -1082,7 +1082,7 @@ class mjCMaterial : public mjCMaterial_, private mjsMaterial {
|
|||||||
void PointToLocal();
|
void PointToLocal();
|
||||||
void NameSpace(const mjCModel* m);
|
void NameSpace(const mjCModel* m);
|
||||||
|
|
||||||
std::string get_texture() { return texture_; }
|
const std::string& get_texture() const { return texture_; }
|
||||||
void del_texture() { texture_.clear(); }
|
void del_texture() { texture_.clear(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1124,8 +1124,8 @@ class mjCPair : public mjCPair_, private mjsPair {
|
|||||||
void ResolveReferences(const mjCModel* m);
|
void ResolveReferences(const mjCModel* m);
|
||||||
void NameSpace(const mjCModel* m);
|
void NameSpace(const mjCModel* m);
|
||||||
|
|
||||||
std::string get_geomname1() { return geomname1_; }
|
const std::string& get_geomname1() const { return geomname1_; }
|
||||||
std::string get_geomname2() { return geomname2_; }
|
const std::string& get_geomname2() const { return geomname2_; }
|
||||||
|
|
||||||
int GetSignature(void) {
|
int GetSignature(void) {
|
||||||
return signature;
|
return signature;
|
||||||
@@ -1258,7 +1258,7 @@ class mjCTendon : public mjCTendon_, private mjsTendon {
|
|||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
void set_material(std::string _material) { material_ = _material; }
|
void set_material(std::string _material) { material_ = _material; }
|
||||||
std::string& get_material() { return material_; }
|
const std::string& get_material() const { return material_; }
|
||||||
void del_material() { material_.clear(); }
|
void del_material() { material_.clear(); }
|
||||||
|
|
||||||
// API for adding wrapping objects
|
// API for adding wrapping objects
|
||||||
@@ -1268,12 +1268,12 @@ class mjCTendon : public mjCTendon_, private mjsTendon {
|
|||||||
void WrapPulley(double divisor, std::string_view info = ""); // pulley
|
void WrapPulley(double divisor, std::string_view info = ""); // pulley
|
||||||
|
|
||||||
// API for access to wrapping objects
|
// API for access to wrapping objects
|
||||||
int NumWraps(void); // number of wraps
|
int NumWraps() const; // number of wraps
|
||||||
mjCWrap* GetWrap(int); // pointer to wrap
|
const mjCWrap* GetWrap(int i) const; // pointer to wrap
|
||||||
std::vector<mjCWrap*> path; // wrapping objects
|
std::vector<mjCWrap*> path; // wrapping objects
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
const double* get_range() { return range; }
|
const double* get_range() { return range; }
|
||||||
|
|
||||||
void CopyFromSpec();
|
void CopyFromSpec();
|
||||||
@@ -1391,10 +1391,10 @@ class mjCActuator : public mjCActuator_, private mjsActuator {
|
|||||||
using mjCBase::info;
|
using mjCBase::info;
|
||||||
|
|
||||||
// used by mjXWriter and mjCModel
|
// used by mjXWriter and mjCModel
|
||||||
const std::vector<double>& get_userdata() { return userdata_; }
|
const std::vector<double>& get_userdata() const { return userdata_; }
|
||||||
const std::string& get_target() { return spec_target_; }
|
const std::string& get_target() const { return spec_target_; }
|
||||||
const std::string& get_slidersite() { return spec_slidersite_; }
|
const std::string& get_slidersite() const { return spec_slidersite_; }
|
||||||
const std::string& get_refsite() { return spec_refsite_; }
|
const std::string& get_refsite() const { return spec_refsite_; }
|
||||||
|
|
||||||
bool is_ctrllimited() const;
|
bool is_ctrllimited() const;
|
||||||
bool is_forcelimited() const;
|
bool is_forcelimited() const;
|
||||||
@@ -1615,13 +1615,29 @@ class mjCDef : public mjElement {
|
|||||||
friend class mjXWriter;
|
friend class mjXWriter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
mjCDef(void); // constructor
|
mjCDef();
|
||||||
mjCDef(const mjCDef& other); // copy constructor
|
mjCDef(const mjCDef& other);
|
||||||
void Compile(const mjCModel* model); // compiler
|
mjCDef& operator=(const mjCDef& other);
|
||||||
mjCDef& operator=(const mjCDef& other); // copy assignment
|
|
||||||
void PointToLocal(void);
|
void PointToLocal(void);
|
||||||
void CopyFromSpec(void);
|
void CopyFromSpec(void);
|
||||||
|
|
||||||
|
void Compile(const mjCModel* model);
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
mjCJoint& Joint() { return joint_; }
|
||||||
|
mjCGeom& Geom() { return geom_; }
|
||||||
|
mjCSite& Site() { return site_; }
|
||||||
|
mjCCamera& Camera() { return camera_; }
|
||||||
|
mjCLight& Light() { return light_; }
|
||||||
|
mjCFlex& Flex() { return flex_; }
|
||||||
|
mjCMesh& Mesh() { return mesh_; }
|
||||||
|
mjCMaterial& Material() { return material_; }
|
||||||
|
mjCPair& Pair() { return pair_; }
|
||||||
|
mjCEquality& Equality() { return equality_; }
|
||||||
|
mjCTendon& Tendon() { return tendon_; }
|
||||||
|
mjCActuator& Actuator() { return actuator_; }
|
||||||
|
|
||||||
// identifiers
|
// identifiers
|
||||||
std::string name; // class name
|
std::string name; // class name
|
||||||
int parentid; // id of parent class
|
int parentid; // id of parent class
|
||||||
@@ -1629,19 +1645,19 @@ class mjCDef : public mjElement {
|
|||||||
|
|
||||||
mjsDefault spec;
|
mjsDefault spec;
|
||||||
|
|
||||||
// default objects (TODO: they should become private)
|
private:
|
||||||
mjCJoint joint;
|
mjCJoint joint_;
|
||||||
mjCGeom geom;
|
mjCGeom geom_;
|
||||||
mjCSite site;
|
mjCSite site_;
|
||||||
mjCCamera camera;
|
mjCCamera camera_;
|
||||||
mjCLight light;
|
mjCLight light_;
|
||||||
mjCFlex flex;
|
mjCFlex flex_;
|
||||||
mjCMesh mesh;
|
mjCMesh mesh_;
|
||||||
mjCMaterial material;
|
mjCMaterial material_;
|
||||||
mjCPair pair;
|
mjCPair pair_;
|
||||||
mjCEquality equality;
|
mjCEquality equality_;
|
||||||
mjCTendon tendon;
|
mjCTendon tendon_;
|
||||||
mjCActuator actuator;
|
mjCActuator actuator_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MUJOCO_SRC_USER_USER_OBJECTS_H_
|
#endif // MUJOCO_SRC_USER_USER_OBJECTS_H_
|
||||||
|
|||||||
+159
-159
@@ -84,7 +84,7 @@ XMLElement* mjXWriter::InsertEnd(XMLElement* parent, const char* name) {
|
|||||||
//---------------------------------- class mjXWriter: one-element writers --------------------------
|
//---------------------------------- class mjXWriter: one-element writers --------------------------
|
||||||
|
|
||||||
// write flex
|
// write flex
|
||||||
void mjXWriter::OneFlex(XMLElement* elem, mjCFlex* pflex) {
|
void mjXWriter::OneFlex(XMLElement* elem, const mjCFlex* pflex) {
|
||||||
string text;
|
string text;
|
||||||
mjCFlex defflex;
|
mjCFlex defflex;
|
||||||
|
|
||||||
@@ -152,7 +152,7 @@ void mjXWriter::OneFlex(XMLElement* elem, mjCFlex* pflex) {
|
|||||||
|
|
||||||
|
|
||||||
// write mesh
|
// write mesh
|
||||||
void mjXWriter::OneMesh(XMLElement* elem, mjCMesh* pmesh, mjCDef* def) {
|
void mjXWriter::OneMesh(XMLElement* elem, const mjCMesh* pmesh, mjCDef* def) {
|
||||||
string text;
|
string text;
|
||||||
|
|
||||||
// regular
|
// regular
|
||||||
@@ -188,17 +188,17 @@ void mjXWriter::OneMesh(XMLElement* elem, mjCMesh* pmesh, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttr(elem, "refpos", 3, pmesh->refpos, def->mesh.refpos);
|
WriteAttr(elem, "refpos", 3, pmesh->refpos, def->Mesh().refpos);
|
||||||
WriteAttr(elem, "refquat", 4, pmesh->refquat, def->mesh.refquat);
|
WriteAttr(elem, "refquat", 4, pmesh->refquat, def->Mesh().refquat);
|
||||||
WriteAttr(elem, "scale", 3, pmesh->scale, def->mesh.scale);
|
WriteAttr(elem, "scale", 3, pmesh->scale, def->Mesh().scale);
|
||||||
WriteAttrKey(elem, "smoothnormal", bool_map, 2, pmesh->get_smoothnormal(),
|
WriteAttrKey(elem, "smoothnormal", bool_map, 2, pmesh->get_smoothnormal(),
|
||||||
def->mesh.get_smoothnormal());
|
def->Mesh().get_smoothnormal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write skin
|
// write skin
|
||||||
void mjXWriter::OneSkin(XMLElement* elem, mjCSkin* pskin) {
|
void mjXWriter::OneSkin(XMLElement* elem, const mjCSkin* pskin) {
|
||||||
string text;
|
string text;
|
||||||
mjCDef mydef;
|
mjCDef mydef;
|
||||||
float zero = 0;
|
float zero = 0;
|
||||||
@@ -208,7 +208,7 @@ void mjXWriter::OneSkin(XMLElement* elem, mjCSkin* pskin) {
|
|||||||
WriteAttrTxt(elem, "file", pskin->get_file());
|
WriteAttrTxt(elem, "file", pskin->get_file());
|
||||||
WriteAttrTxt(elem, "material", pskin->get_material());
|
WriteAttrTxt(elem, "material", pskin->get_material());
|
||||||
WriteAttrInt(elem, "group", pskin->group, 0);
|
WriteAttrInt(elem, "group", pskin->group, 0);
|
||||||
WriteAttr(elem, "rgba", 4, pskin->rgba, mydef.geom.rgba);
|
WriteAttr(elem, "rgba", 4, pskin->rgba, mydef.Geom().rgba);
|
||||||
WriteAttr(elem, "inflate", 1, &pskin->inflate, &zero);
|
WriteAttr(elem, "inflate", 1, &pskin->inflate, &zero);
|
||||||
|
|
||||||
// write data if no file
|
// write data if no file
|
||||||
@@ -251,7 +251,7 @@ void mjXWriter::OneSkin(XMLElement* elem, mjCSkin* pskin) {
|
|||||||
|
|
||||||
|
|
||||||
// write material
|
// write material
|
||||||
void mjXWriter::OneMaterial(XMLElement* elem, mjCMaterial* pmat, mjCDef* def) {
|
void mjXWriter::OneMaterial(XMLElement* elem, const mjCMaterial* pmat, mjCDef* def) {
|
||||||
// regular
|
// regular
|
||||||
if (!writingdefaults) {
|
if (!writingdefaults) {
|
||||||
WriteAttrTxt(elem, "name", pmat->name);
|
WriteAttrTxt(elem, "name", pmat->name);
|
||||||
@@ -259,24 +259,24 @@ void mjXWriter::OneMaterial(XMLElement* elem, mjCMaterial* pmat, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
if (pmat->texture != def->material.texture) {
|
if (pmat->texture != def->Material().texture) {
|
||||||
WriteAttrTxt(elem, "texture", pmat->get_texture());
|
WriteAttrTxt(elem, "texture", pmat->get_texture());
|
||||||
}
|
}
|
||||||
WriteAttrKey(elem, "texuniform", bool_map, 2, pmat->texuniform, def->material.texuniform);
|
WriteAttrKey(elem, "texuniform", bool_map, 2, pmat->texuniform, def->Material().texuniform);
|
||||||
WriteAttr(elem, "texrepeat", 2, pmat->texrepeat, def->material.texrepeat);
|
WriteAttr(elem, "texrepeat", 2, pmat->texrepeat, def->Material().texrepeat);
|
||||||
WriteAttr(elem, "emission", 1, &pmat->emission, &def->material.emission);
|
WriteAttr(elem, "emission", 1, &pmat->emission, &def->Material().emission);
|
||||||
WriteAttr(elem, "specular", 1, &pmat->specular, &def->material.specular);
|
WriteAttr(elem, "specular", 1, &pmat->specular, &def->Material().specular);
|
||||||
WriteAttr(elem, "shininess", 1, &pmat->shininess, &def->material.shininess);
|
WriteAttr(elem, "shininess", 1, &pmat->shininess, &def->Material().shininess);
|
||||||
WriteAttr(elem, "reflectance", 1, &pmat->reflectance, &def->material.reflectance);
|
WriteAttr(elem, "reflectance", 1, &pmat->reflectance, &def->Material().reflectance);
|
||||||
WriteAttr(elem, "metallic", 1, &pmat->metallic, &def->material.metallic);
|
WriteAttr(elem, "metallic", 1, &pmat->metallic, &def->Material().metallic);
|
||||||
WriteAttr(elem, "roughness", 1, &pmat->roughness, &def->material.roughness);
|
WriteAttr(elem, "roughness", 1, &pmat->roughness, &def->Material().roughness);
|
||||||
WriteAttr(elem, "rgba", 4, pmat->rgba, def->material.rgba);
|
WriteAttr(elem, "rgba", 4, pmat->rgba, def->Material().rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write joint
|
// write joint
|
||||||
void mjXWriter::OneJoint(XMLElement* elem, mjCJoint* pjoint, mjCDef* def) {
|
void mjXWriter::OneJoint(XMLElement* elem, const mjCJoint* pjoint, mjCDef* def) {
|
||||||
double zero = 0;
|
double zero = 0;
|
||||||
|
|
||||||
// regular
|
// regular
|
||||||
@@ -292,42 +292,42 @@ void mjXWriter::OneJoint(XMLElement* elem, mjCJoint* pjoint, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
if (pjoint->type != def->joint.type) {
|
if (pjoint->type != def->Joint().type) {
|
||||||
WriteAttrTxt(elem, "type", FindValue(joint_map, joint_sz, pjoint->type));
|
WriteAttrTxt(elem, "type", FindValue(joint_map, joint_sz, pjoint->type));
|
||||||
}
|
}
|
||||||
WriteAttrInt(elem, "group", pjoint->group, def->joint.group);
|
WriteAttrInt(elem, "group", pjoint->group, def->Joint().group);
|
||||||
WriteAttr(elem, "ref", 1, &pjoint->ref, &zero);
|
WriteAttr(elem, "ref", 1, &pjoint->ref, &zero);
|
||||||
WriteAttr(elem, "springref", 1, &pjoint->springref, &zero);
|
WriteAttr(elem, "springref", 1, &pjoint->springref, &zero);
|
||||||
WriteAttr(elem, "solreflimit", mjNREF, pjoint->solref_limit, def->joint.solref_limit, true);
|
WriteAttr(elem, "solreflimit", mjNREF, pjoint->solref_limit, def->Joint().solref_limit, true);
|
||||||
WriteAttr(elem, "solimplimit", mjNIMP, pjoint->solimp_limit, def->joint.solimp_limit, true);
|
WriteAttr(elem, "solimplimit", mjNIMP, pjoint->solimp_limit, def->Joint().solimp_limit, true);
|
||||||
WriteAttr(elem, "solreffriction", mjNREF, pjoint->solref_friction, def->joint.solref_friction,
|
WriteAttr(elem, "solreffriction", mjNREF, pjoint->solref_friction, def->Joint().solref_friction,
|
||||||
true);
|
true);
|
||||||
WriteAttr(elem, "solimpfriction", mjNIMP, pjoint->solimp_friction, def->joint.solimp_friction,
|
WriteAttr(elem, "solimpfriction", mjNIMP, pjoint->solimp_friction, def->Joint().solimp_friction,
|
||||||
true);
|
true);
|
||||||
WriteAttr(elem, "stiffness", 1, &pjoint->stiffness, &def->joint.stiffness);
|
WriteAttr(elem, "stiffness", 1, &pjoint->stiffness, &def->Joint().stiffness);
|
||||||
WriteAttrKey(elem, "limited", TFAuto_map, 3, pjoint->limited, def->joint.limited);
|
WriteAttrKey(elem, "limited", TFAuto_map, 3, pjoint->limited, def->Joint().limited);
|
||||||
WriteAttr(elem, "range", 2, pjoint->range, def->joint.range);
|
WriteAttr(elem, "range", 2, pjoint->range, def->Joint().range);
|
||||||
WriteAttrKey(elem, "actuatorfrclimited", TFAuto_map, 3, pjoint->actfrclimited,
|
WriteAttrKey(elem, "actuatorfrclimited", TFAuto_map, 3, pjoint->actfrclimited,
|
||||||
def->joint.actfrclimited);
|
def->Joint().actfrclimited);
|
||||||
WriteAttrKey(elem, "actuatorgravcomp", bool_map, 2, pjoint->actgravcomp, def->joint.actgravcomp);
|
WriteAttrKey(elem, "actuatorgravcomp", bool_map, 2, pjoint->actgravcomp, def->Joint().actgravcomp);
|
||||||
WriteAttr(elem, "actuatorfrcrange", 2, pjoint->actfrcrange, def->joint.actfrcrange);
|
WriteAttr(elem, "actuatorfrcrange", 2, pjoint->actfrcrange, def->Joint().actfrcrange);
|
||||||
WriteAttr(elem, "margin", 1, &pjoint->margin, &def->joint.margin);
|
WriteAttr(elem, "margin", 1, &pjoint->margin, &def->Joint().margin);
|
||||||
WriteAttr(elem, "armature", 1, &pjoint->armature, &def->joint.armature);
|
WriteAttr(elem, "armature", 1, &pjoint->armature, &def->Joint().armature);
|
||||||
WriteAttr(elem, "damping", 1, &pjoint->damping, &def->joint.damping);
|
WriteAttr(elem, "damping", 1, &pjoint->damping, &def->Joint().damping);
|
||||||
WriteAttr(elem, "frictionloss", 1, &pjoint->frictionloss, &def->joint.frictionloss);
|
WriteAttr(elem, "frictionloss", 1, &pjoint->frictionloss, &def->Joint().frictionloss);
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", pjoint->get_userdata());
|
WriteVector(elem, "user", pjoint->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", pjoint->get_userdata(), def->joint.get_userdata());
|
WriteVector(elem, "user", pjoint->get_userdata(), def->Joint().get_userdata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write geom
|
// write geom
|
||||||
void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
|
void mjXWriter::OneGeom(XMLElement* elem, const mjCGeom* pgeom, mjCDef* def) {
|
||||||
double unitq[4] = {1, 0, 0, 0};
|
double unitq[4] = {1, 0, 0, 0};
|
||||||
double mass = 0;
|
double mass = 0;
|
||||||
|
|
||||||
@@ -336,10 +336,10 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
|
|||||||
WriteAttrTxt(elem, "name", pgeom->name);
|
WriteAttrTxt(elem, "name", pgeom->name);
|
||||||
WriteAttrTxt(elem, "class", pgeom->classname);
|
WriteAttrTxt(elem, "class", pgeom->classname);
|
||||||
if (mjGEOMINFO[pgeom->type]) {
|
if (mjGEOMINFO[pgeom->type]) {
|
||||||
WriteAttr(elem, "size", mjGEOMINFO[pgeom->type], pgeom->size, def->geom.size);
|
WriteAttr(elem, "size", mjGEOMINFO[pgeom->type], pgeom->size, def->Geom().size);
|
||||||
}
|
}
|
||||||
if (mjuu_defined(pgeom->mass)) {
|
if (mjuu_defined(pgeom->mass)) {
|
||||||
mass = pgeom->GetVolume() * def->geom.density;
|
mass = pgeom->GetVolume() * def->Geom().density;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mesh geom
|
// mesh geom
|
||||||
@@ -368,35 +368,35 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
|
|||||||
WriteAttr(elem, "quat", 4, pgeom->quat, unitq);
|
WriteAttr(elem, "quat", 4, pgeom->quat, unitq);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WriteAttr(elem, "size", 3, pgeom->size, def->geom.size);
|
WriteAttr(elem, "size", 3, pgeom->size, def->Geom().size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrKey(elem, "type", geom_map, mjNGEOMTYPES, pgeom->type, def->geom.type);
|
WriteAttrKey(elem, "type", geom_map, mjNGEOMTYPES, pgeom->type, def->Geom().type);
|
||||||
WriteAttrInt(elem, "contype", pgeom->contype, def->geom.contype);
|
WriteAttrInt(elem, "contype", pgeom->contype, def->Geom().contype);
|
||||||
WriteAttrInt(elem, "conaffinity", pgeom->conaffinity, def->geom.conaffinity);
|
WriteAttrInt(elem, "conaffinity", pgeom->conaffinity, def->Geom().conaffinity);
|
||||||
WriteAttrInt(elem, "condim", pgeom->condim, def->geom.condim);
|
WriteAttrInt(elem, "condim", pgeom->condim, def->Geom().condim);
|
||||||
WriteAttrInt(elem, "group", pgeom->group, def->geom.group);
|
WriteAttrInt(elem, "group", pgeom->group, def->Geom().group);
|
||||||
WriteAttrInt(elem, "priority", pgeom->priority, def->geom.priority);
|
WriteAttrInt(elem, "priority", pgeom->priority, def->Geom().priority);
|
||||||
WriteAttr(elem, "friction", 3, pgeom->friction, def->geom.friction, true);
|
WriteAttr(elem, "friction", 3, pgeom->friction, def->Geom().friction, true);
|
||||||
WriteAttr(elem, "solmix", 1, &pgeom->solmix, &def->geom.solmix);
|
WriteAttr(elem, "solmix", 1, &pgeom->solmix, &def->Geom().solmix);
|
||||||
WriteAttr(elem, "solref", mjNREF, pgeom->solref, def->geom.solref, true);
|
WriteAttr(elem, "solref", mjNREF, pgeom->solref, def->Geom().solref, true);
|
||||||
WriteAttr(elem, "solimp", mjNIMP, pgeom->solimp, def->geom.solimp, true);
|
WriteAttr(elem, "solimp", mjNIMP, pgeom->solimp, def->Geom().solimp, true);
|
||||||
WriteAttr(elem, "margin", 1, &pgeom->margin, &def->geom.margin);
|
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);
|
||||||
WriteAttr(elem, "gap", 1, &pgeom->gap, &def->geom.gap);
|
WriteAttr(elem, "gap", 1, &pgeom->gap, &def->Geom().gap);
|
||||||
WriteAttrKey(elem, "fluidshape", fluid_map, 2, pgeom->fluid_ellipsoid, def->geom.fluid_ellipsoid);
|
WriteAttrKey(elem, "fluidshape", fluid_map, 2, pgeom->fluid_ellipsoid, def->Geom().fluid_ellipsoid);
|
||||||
WriteAttr(elem, "fluidcoef", 5, pgeom->fluid_coefs, def->geom.fluid_coefs);
|
WriteAttr(elem, "fluidcoef", 5, pgeom->fluid_coefs, def->Geom().fluid_coefs);
|
||||||
WriteAttrKey(elem, "shellinertia", meshtype_map, 2, pgeom->typeinertia, def->geom.typeinertia);
|
WriteAttrKey(elem, "shellinertia", meshtype_map, 2, pgeom->typeinertia, def->Geom().typeinertia);
|
||||||
if (mjuu_defined(pgeom->mass)) {
|
if (mjuu_defined(pgeom->mass)) {
|
||||||
WriteAttr(elem, "mass", 1, &pgeom->mass_, &mass);
|
WriteAttr(elem, "mass", 1, &pgeom->mass_, &mass);
|
||||||
} else {
|
} else {
|
||||||
WriteAttr(elem, "density", 1, &pgeom->density, &def->geom.density);
|
WriteAttr(elem, "density", 1, &pgeom->density, &def->Geom().density);
|
||||||
}
|
}
|
||||||
if (pgeom->get_material() != def->geom.get_material()) {
|
if (pgeom->get_material() != def->Geom().get_material()) {
|
||||||
WriteAttrTxt(elem, "material", pgeom->get_material());
|
WriteAttrTxt(elem, "material", pgeom->get_material());
|
||||||
}
|
}
|
||||||
WriteAttr(elem, "rgba", 4, pgeom->rgba, def->geom.rgba);
|
WriteAttr(elem, "rgba", 4, pgeom->rgba, def->Geom().rgba);
|
||||||
|
|
||||||
// hfield and mesh attributes
|
// hfield and mesh attributes
|
||||||
if (pgeom->type==mjGEOM_HFIELD) {
|
if (pgeom->type==mjGEOM_HFIELD) {
|
||||||
@@ -410,7 +410,7 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
|
|||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", pgeom->get_userdata());
|
WriteVector(elem, "user", pgeom->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", pgeom->get_userdata(), def->geom.get_userdata());
|
WriteVector(elem, "user", pgeom->get_userdata(), def->Geom().get_userdata());
|
||||||
}
|
}
|
||||||
|
|
||||||
// write plugin
|
// write plugin
|
||||||
@@ -422,7 +422,7 @@ void mjXWriter::OneGeom(XMLElement* elem, mjCGeom* pgeom, mjCDef* def) {
|
|||||||
|
|
||||||
|
|
||||||
// write site
|
// write site
|
||||||
void mjXWriter::OneSite(XMLElement* elem, mjCSite* psite, mjCDef* def) {
|
void mjXWriter::OneSite(XMLElement* elem, const mjCSite* psite, mjCDef* def) {
|
||||||
double unitq[4] = {1, 0, 0, 0};
|
double unitq[4] = {1, 0, 0, 0};
|
||||||
|
|
||||||
// regular
|
// regular
|
||||||
@@ -432,32 +432,32 @@ void mjXWriter::OneSite(XMLElement* elem, mjCSite* psite, mjCDef* def) {
|
|||||||
WriteAttr(elem, "pos", 3, psite->pos);
|
WriteAttr(elem, "pos", 3, psite->pos);
|
||||||
WriteAttr(elem, "quat", 4, psite->quat, unitq);
|
WriteAttr(elem, "quat", 4, psite->quat, unitq);
|
||||||
if (mjGEOMINFO[psite->type]) {
|
if (mjGEOMINFO[psite->type]) {
|
||||||
WriteAttr(elem, "size", mjGEOMINFO[psite->type], psite->size, def->site.size);
|
WriteAttr(elem, "size", mjGEOMINFO[psite->type], psite->size, def->Site().size);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
WriteAttr(elem, "size", 3, psite->size, def->site.size);
|
WriteAttr(elem, "size", 3, psite->size, def->Site().size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrInt(elem, "group", psite->group, def->site.group);
|
WriteAttrInt(elem, "group", psite->group, def->Site().group);
|
||||||
WriteAttrKey(elem, "type", geom_map, mjNGEOMTYPES, psite->type, def->site.type);
|
WriteAttrKey(elem, "type", geom_map, mjNGEOMTYPES, psite->type, def->Site().type);
|
||||||
if (psite->get_material() != def->site.get_material()) {
|
if (psite->get_material() != def->Site().get_material()) {
|
||||||
WriteAttrTxt(elem, "material", psite->get_material());
|
WriteAttrTxt(elem, "material", psite->get_material());
|
||||||
}
|
}
|
||||||
WriteAttr(elem, "rgba", 4, psite->rgba, def->site.rgba);
|
WriteAttr(elem, "rgba", 4, psite->rgba, def->Site().rgba);
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", psite->get_userdata());
|
WriteVector(elem, "user", psite->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", psite->get_userdata(), def->site.get_userdata());
|
WriteVector(elem, "user", psite->get_userdata(), def->Site().get_userdata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write camera
|
// write camera
|
||||||
void mjXWriter::OneCamera(XMLElement* elem, mjCCamera* pcam, mjCDef* def) {
|
void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* pcam, mjCDef* def) {
|
||||||
double unitq[4] = {1, 0, 0, 0};
|
double unitq[4] = {1, 0, 0, 0};
|
||||||
|
|
||||||
// regular
|
// regular
|
||||||
@@ -470,36 +470,36 @@ void mjXWriter::OneCamera(XMLElement* elem, mjCCamera* pcam, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttr(elem, "ipd", 1, &pcam->ipd, &def->camera.ipd);
|
WriteAttr(elem, "ipd", 1, &pcam->ipd, &def->Camera().ipd);
|
||||||
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, pcam->mode, def->camera.mode);
|
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, pcam->mode, def->Camera().mode);
|
||||||
WriteAttr(elem, "resolution", 2, pcam->resolution, def->camera.resolution);
|
WriteAttr(elem, "resolution", 2, pcam->resolution, def->Camera().resolution);
|
||||||
|
|
||||||
// resolution if positive
|
// resolution if positive
|
||||||
WriteAttr(elem, "resolution", 2, pcam->resolution, def->camera.resolution);
|
WriteAttr(elem, "resolution", 2, pcam->resolution, def->Camera().resolution);
|
||||||
|
|
||||||
// camera intrinsics if specified
|
// camera intrinsics if specified
|
||||||
if (pcam->sensor_size[0]>0 && pcam->sensor_size[1]>0) {
|
if (pcam->sensor_size[0]>0 && pcam->sensor_size[1]>0) {
|
||||||
WriteAttr(elem, "sensorsize", 2, pcam->sensor_size);
|
WriteAttr(elem, "sensorsize", 2, pcam->sensor_size);
|
||||||
WriteAttr(elem, "focal", 2, pcam->focal_length, def->camera.focal_length);
|
WriteAttr(elem, "focal", 2, pcam->focal_length, def->Camera().focal_length);
|
||||||
WriteAttr(elem, "focalpixel", 2, pcam->focal_pixel, def->camera.focal_pixel);
|
WriteAttr(elem, "focalpixel", 2, pcam->focal_pixel, def->Camera().focal_pixel);
|
||||||
WriteAttr(elem, "principal", 2, pcam->principal_length, def->camera.principal_length);
|
WriteAttr(elem, "principal", 2, pcam->principal_length, def->Camera().principal_length);
|
||||||
WriteAttr(elem, "principalpixel", 2, pcam->principal_pixel, def->camera.principal_pixel);
|
WriteAttr(elem, "principalpixel", 2, pcam->principal_pixel, def->Camera().principal_pixel);
|
||||||
} else {
|
} else {
|
||||||
WriteAttr(elem, "fovy", 1, &pcam->fovy, &def->camera.fovy);
|
WriteAttr(elem, "fovy", 1, &pcam->fovy, &def->Camera().fovy);
|
||||||
}
|
}
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", pcam->get_userdata());
|
WriteVector(elem, "user", pcam->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", pcam->get_userdata(), def->camera.get_userdata());
|
WriteVector(elem, "user", pcam->get_userdata(), def->Camera().get_userdata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write light
|
// write light
|
||||||
void mjXWriter::OneLight(XMLElement* elem, mjCLight* plight, mjCDef* def) {
|
void mjXWriter::OneLight(XMLElement* elem, const mjCLight* plight, mjCDef* def) {
|
||||||
// regular
|
// regular
|
||||||
if (!writingdefaults) {
|
if (!writingdefaults) {
|
||||||
WriteAttrTxt(elem, "name", plight->name);
|
WriteAttrTxt(elem, "name", plight->name);
|
||||||
@@ -510,23 +510,23 @@ void mjXWriter::OneLight(XMLElement* elem, mjCLight* plight, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttr(elem, "bulbradius", 1, &plight->bulbradius, &def->light.bulbradius);
|
WriteAttr(elem, "bulbradius", 1, &plight->bulbradius, &def->Light().bulbradius);
|
||||||
WriteAttrKey(elem, "directional", bool_map, 2, plight->directional, def->light.directional);
|
WriteAttrKey(elem, "directional", bool_map, 2, plight->directional, def->Light().directional);
|
||||||
WriteAttrKey(elem, "castshadow", bool_map, 2, plight->castshadow, def->light.castshadow);
|
WriteAttrKey(elem, "castshadow", bool_map, 2, plight->castshadow, def->Light().castshadow);
|
||||||
WriteAttrKey(elem, "active", bool_map, 2, plight->active, def->light.active);
|
WriteAttrKey(elem, "active", bool_map, 2, plight->active, def->Light().active);
|
||||||
WriteAttr(elem, "attenuation", 3, plight->attenuation, def->light.attenuation);
|
WriteAttr(elem, "attenuation", 3, plight->attenuation, def->Light().attenuation);
|
||||||
WriteAttr(elem, "cutoff", 1, &plight->cutoff, &def->light.cutoff);
|
WriteAttr(elem, "cutoff", 1, &plight->cutoff, &def->Light().cutoff);
|
||||||
WriteAttr(elem, "exponent", 1, &plight->exponent, &def->light.exponent);
|
WriteAttr(elem, "exponent", 1, &plight->exponent, &def->Light().exponent);
|
||||||
WriteAttr(elem, "ambient", 3, plight->ambient, def->light.ambient);
|
WriteAttr(elem, "ambient", 3, plight->ambient, def->Light().ambient);
|
||||||
WriteAttr(elem, "diffuse", 3, plight->diffuse, def->light.diffuse);
|
WriteAttr(elem, "diffuse", 3, plight->diffuse, def->Light().diffuse);
|
||||||
WriteAttr(elem, "specular", 3, plight->specular, def->light.specular);
|
WriteAttr(elem, "specular", 3, plight->specular, def->Light().specular);
|
||||||
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, plight->mode, def->light.mode);
|
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, plight->mode, def->Light().mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write pair
|
// write pair
|
||||||
void mjXWriter::OnePair(XMLElement* elem, mjCPair* ppair, mjCDef* def) {
|
void mjXWriter::OnePair(XMLElement* elem, const mjCPair* ppair, mjCDef* def) {
|
||||||
// regular
|
// regular
|
||||||
if (!writingdefaults) {
|
if (!writingdefaults) {
|
||||||
WriteAttrTxt(elem, "class", ppair->classname);
|
WriteAttrTxt(elem, "class", ppair->classname);
|
||||||
@@ -536,20 +536,20 @@ void mjXWriter::OnePair(XMLElement* elem, mjCPair* ppair, mjCDef* def) {
|
|||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrTxt(elem, "name", ppair->name);
|
WriteAttrTxt(elem, "name", ppair->name);
|
||||||
WriteAttrInt(elem, "condim", ppair->condim, def->pair.spec.condim);
|
WriteAttrInt(elem, "condim", ppair->condim, def->Pair().spec.condim);
|
||||||
WriteAttr(elem, "margin", 1, &ppair->margin, &def->pair.spec.margin);
|
WriteAttr(elem, "margin", 1, &ppair->margin, &def->Pair().spec.margin);
|
||||||
WriteAttr(elem, "gap", 1, &ppair->gap, &def->pair.spec.gap);
|
WriteAttr(elem, "gap", 1, &ppair->gap, &def->Pair().spec.gap);
|
||||||
WriteAttr(elem, "solref", mjNREF, ppair->solref, def->pair.spec.solref, true);
|
WriteAttr(elem, "solref", mjNREF, ppair->solref, def->Pair().spec.solref, true);
|
||||||
WriteAttr(elem, "solreffriction", mjNREF, ppair->solreffriction, def->pair.spec.solreffriction,
|
WriteAttr(elem, "solreffriction", mjNREF, ppair->solreffriction, def->Pair().spec.solreffriction,
|
||||||
true);
|
true);
|
||||||
WriteAttr(elem, "solimp", mjNIMP, ppair->solimp, def->pair.spec.solimp, true);
|
WriteAttr(elem, "solimp", mjNIMP, ppair->solimp, def->Pair().spec.solimp, true);
|
||||||
WriteAttr(elem, "friction", 5, ppair->friction, def->pair.spec.friction); // all 5 values
|
WriteAttr(elem, "friction", 5, ppair->friction, def->Pair().spec.friction); // all 5 values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write equality
|
// write equality
|
||||||
void mjXWriter::OneEquality(XMLElement* elem, mjCEquality* peq, mjCDef* def) {
|
void mjXWriter::OneEquality(XMLElement* elem, const mjCEquality* peq, mjCDef* def) {
|
||||||
// regular
|
// regular
|
||||||
if (!writingdefaults) {
|
if (!writingdefaults) {
|
||||||
WriteAttrTxt(elem, "name", peq->name);
|
WriteAttrTxt(elem, "name", peq->name);
|
||||||
@@ -592,15 +592,15 @@ void mjXWriter::OneEquality(XMLElement* elem, mjCEquality* peq, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrKey(elem, "active", bool_map, 2, peq->active, def->equality.active);
|
WriteAttrKey(elem, "active", bool_map, 2, peq->active, def->Equality().active);
|
||||||
WriteAttr(elem, "solref", mjNREF, peq->solref, def->equality.solref, true);
|
WriteAttr(elem, "solref", mjNREF, peq->solref, def->Equality().solref, true);
|
||||||
WriteAttr(elem, "solimp", mjNIMP, peq->solimp, def->equality.solimp, true);
|
WriteAttr(elem, "solimp", mjNIMP, peq->solimp, def->Equality().solimp, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write tendon
|
// write tendon
|
||||||
void mjXWriter::OneTendon(XMLElement* elem, mjCTendon* pten, mjCDef* def) {
|
void mjXWriter::OneTendon(XMLElement* elem, const mjCTendon* pten, mjCDef* def) {
|
||||||
bool fixed = (pten->GetWrap(0) && pten->GetWrap(0)->type==mjWRAP_JOINT);
|
bool fixed = (pten->GetWrap(0) && pten->GetWrap(0)->type==mjWRAP_JOINT);
|
||||||
|
|
||||||
// regular
|
// regular
|
||||||
@@ -610,46 +610,46 @@ void mjXWriter::OneTendon(XMLElement* elem, mjCTendon* pten, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrInt(elem, "group", pten->group, def->tendon.group);
|
WriteAttrInt(elem, "group", pten->group, def->Tendon().group);
|
||||||
WriteAttr(elem, "solreflimit", mjNREF, pten->solref_limit, def->tendon.solref_limit, true);
|
WriteAttr(elem, "solreflimit", mjNREF, pten->solref_limit, def->Tendon().solref_limit, true);
|
||||||
WriteAttr(elem, "solimplimit", mjNIMP, pten->solimp_limit, def->tendon.solimp_limit, true);
|
WriteAttr(elem, "solimplimit", mjNIMP, pten->solimp_limit, def->Tendon().solimp_limit, true);
|
||||||
WriteAttr(elem, "solreffriction", mjNREF, pten->solref_friction, def->tendon.solref_friction,
|
WriteAttr(elem, "solreffriction", mjNREF, pten->solref_friction, def->Tendon().solref_friction,
|
||||||
true);
|
true);
|
||||||
WriteAttr(elem, "solimpfriction", mjNIMP, pten->solimp_friction, def->tendon.solimp_friction,
|
WriteAttr(elem, "solimpfriction", mjNIMP, pten->solimp_friction, def->Tendon().solimp_friction,
|
||||||
true);
|
true);
|
||||||
WriteAttrKey(elem, "limited", TFAuto_map, 3, pten->limited, def->tendon.limited);
|
WriteAttrKey(elem, "limited", TFAuto_map, 3, pten->limited, def->Tendon().limited);
|
||||||
WriteAttr(elem, "range", 2, pten->range, def->tendon.range);
|
WriteAttr(elem, "range", 2, pten->range, def->Tendon().range);
|
||||||
WriteAttr(elem, "margin", 1, &pten->margin, &def->tendon.margin);
|
WriteAttr(elem, "margin", 1, &pten->margin, &def->Tendon().margin);
|
||||||
WriteAttr(elem, "stiffness", 1, &pten->stiffness, &def->tendon.stiffness);
|
WriteAttr(elem, "stiffness", 1, &pten->stiffness, &def->Tendon().stiffness);
|
||||||
WriteAttr(elem, "damping", 1, &pten->damping, &def->tendon.damping);
|
WriteAttr(elem, "damping", 1, &pten->damping, &def->Tendon().damping);
|
||||||
WriteAttr(elem, "frictionloss", 1, &pten->frictionloss, &def->tendon.frictionloss);
|
WriteAttr(elem, "frictionloss", 1, &pten->frictionloss, &def->Tendon().frictionloss);
|
||||||
if (pten->springlength[0] != pten->springlength[1] ||
|
if (pten->springlength[0] != pten->springlength[1] ||
|
||||||
def->tendon.springlength[0] != def->tendon.springlength[1]) {
|
def->Tendon().springlength[0] != def->Tendon().springlength[1]) {
|
||||||
WriteAttr(elem, "springlength", 2, pten->springlength, def->tendon.springlength);
|
WriteAttr(elem, "springlength", 2, pten->springlength, def->Tendon().springlength);
|
||||||
} else {
|
} else {
|
||||||
WriteAttr(elem, "springlength", 1, pten->springlength, def->tendon.springlength);
|
WriteAttr(elem, "springlength", 1, pten->springlength, def->Tendon().springlength);
|
||||||
}
|
}
|
||||||
// spatial only
|
// spatial only
|
||||||
if (!fixed) {
|
if (!fixed) {
|
||||||
if (pten->get_material()!=def->tendon.get_material()) {
|
if (pten->get_material()!=def->Tendon().get_material()) {
|
||||||
WriteAttrTxt(elem, "material", pten->get_material());
|
WriteAttrTxt(elem, "material", pten->get_material());
|
||||||
}
|
}
|
||||||
WriteAttr(elem, "width", 1, &pten->width, &def->tendon.width);
|
WriteAttr(elem, "width", 1, &pten->width, &def->Tendon().width);
|
||||||
WriteAttr(elem, "rgba", 4, pten->rgba, def->tendon.rgba);
|
WriteAttr(elem, "rgba", 4, pten->rgba, def->Tendon().rgba);
|
||||||
}
|
}
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", pten->get_userdata());
|
WriteVector(elem, "user", pten->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", pten->get_userdata(), def->tendon.get_userdata());
|
WriteVector(elem, "user", pten->get_userdata(), def->Tendon().get_userdata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write actuator
|
// write actuator
|
||||||
void mjXWriter::OneActuator(XMLElement* elem, mjCActuator* pact, mjCDef* def) {
|
void mjXWriter::OneActuator(XMLElement* elem, const mjCActuator* pact, mjCDef* def) {
|
||||||
// regular
|
// regular
|
||||||
if (!writingdefaults) {
|
if (!writingdefaults) {
|
||||||
WriteAttrTxt(elem, "name", pact->name);
|
WriteAttrTxt(elem, "name", pact->name);
|
||||||
@@ -689,20 +689,20 @@ void mjXWriter::OneActuator(XMLElement* elem, mjCActuator* pact, mjCDef* def) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// defaults and regular
|
// defaults and regular
|
||||||
WriteAttrInt(elem, "group", pact->group, def->actuator.group);
|
WriteAttrInt(elem, "group", pact->group, def->Actuator().group);
|
||||||
WriteAttrKey(elem, "ctrllimited", TFAuto_map, 3, pact->ctrllimited, def->actuator.ctrllimited);
|
WriteAttrKey(elem, "ctrllimited", TFAuto_map, 3, pact->ctrllimited, def->Actuator().ctrllimited);
|
||||||
WriteAttr(elem, "ctrlrange", 2, pact->ctrlrange, def->actuator.ctrlrange);
|
WriteAttr(elem, "ctrlrange", 2, pact->ctrlrange, def->Actuator().ctrlrange);
|
||||||
WriteAttrKey(elem, "forcelimited", TFAuto_map, 3, pact->forcelimited, def->actuator.forcelimited);
|
WriteAttrKey(elem, "forcelimited", TFAuto_map, 3, pact->forcelimited, def->Actuator().forcelimited);
|
||||||
WriteAttr(elem, "forcerange", 2, pact->forcerange, def->actuator.forcerange);
|
WriteAttr(elem, "forcerange", 2, pact->forcerange, def->Actuator().forcerange);
|
||||||
WriteAttrKey(elem, "actlimited", TFAuto_map, 3, pact->actlimited, def->actuator.actlimited);
|
WriteAttrKey(elem, "actlimited", TFAuto_map, 3, pact->actlimited, def->Actuator().actlimited);
|
||||||
WriteAttr(elem, "actrange", 2, pact->actrange, def->actuator.actrange);
|
WriteAttr(elem, "actrange", 2, pact->actrange, def->Actuator().actrange);
|
||||||
WriteAttr(elem, "lengthrange", 2, pact->lengthrange, def->actuator.lengthrange);
|
WriteAttr(elem, "lengthrange", 2, pact->lengthrange, def->Actuator().lengthrange);
|
||||||
WriteAttr(elem, "gear", 6, pact->gear, def->actuator.gear);
|
WriteAttr(elem, "gear", 6, pact->gear, def->Actuator().gear);
|
||||||
WriteAttr(elem, "cranklength", 1, &pact->cranklength, &def->actuator.cranklength);
|
WriteAttr(elem, "cranklength", 1, &pact->cranklength, &def->Actuator().cranklength);
|
||||||
WriteAttrKey(elem, "actearly", bool_map, 2, pact->actearly,
|
WriteAttrKey(elem, "actearly", bool_map, 2, pact->actearly,
|
||||||
def->actuator.actearly);
|
def->Actuator().actearly);
|
||||||
WriteAttrKey(elem, "dyntype", dyn_map, dyn_sz, pact->dyntype, def->actuator.dyntype);
|
WriteAttrKey(elem, "dyntype", dyn_map, dyn_sz, pact->dyntype, def->Actuator().dyntype);
|
||||||
WriteAttr(elem, "dynprm", mjNDYN, pact->dynprm, def->actuator.dynprm);
|
WriteAttr(elem, "dynprm", mjNDYN, pact->dynprm, def->Actuator().dynprm);
|
||||||
|
|
||||||
// plugins: write config attributes
|
// plugins: write config attributes
|
||||||
if (pact->plugin.active) {
|
if (pact->plugin.active) {
|
||||||
@@ -713,29 +713,29 @@ void mjXWriter::OneActuator(XMLElement* elem, mjCActuator* pact, mjCDef* def) {
|
|||||||
else {
|
else {
|
||||||
// special handling of actdim which has default value of -1
|
// special handling of actdim which has default value of -1
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteAttrInt(elem, "actdim", pact->actdim, def->actuator.actdim);
|
WriteAttrInt(elem, "actdim", pact->actdim, def->Actuator().actdim);
|
||||||
} else {
|
} else {
|
||||||
int default_actdim = pact->dyntype == mjDYN_NONE ? 0 : 1;
|
int default_actdim = pact->dyntype == mjDYN_NONE ? 0 : 1;
|
||||||
WriteAttrInt(elem, "actdim", pact->actdim, default_actdim);
|
WriteAttrInt(elem, "actdim", pact->actdim, default_actdim);
|
||||||
}
|
}
|
||||||
WriteAttrKey(elem, "gaintype", gain_map, gain_sz, pact->gaintype, def->actuator.gaintype);
|
WriteAttrKey(elem, "gaintype", gain_map, gain_sz, pact->gaintype, def->Actuator().gaintype);
|
||||||
WriteAttrKey(elem, "biastype", bias_map, bias_sz, pact->biastype, def->actuator.biastype);
|
WriteAttrKey(elem, "biastype", bias_map, bias_sz, pact->biastype, def->Actuator().biastype);
|
||||||
WriteAttr(elem, "gainprm", mjNGAIN, pact->gainprm, def->actuator.gainprm, true);
|
WriteAttr(elem, "gainprm", mjNGAIN, pact->gainprm, def->Actuator().gainprm, true);
|
||||||
WriteAttr(elem, "biasprm", mjNBIAS, pact->biasprm, def->actuator.biasprm, true);
|
WriteAttr(elem, "biasprm", mjNBIAS, pact->biasprm, def->Actuator().biasprm, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// userdata
|
// userdata
|
||||||
if (writingdefaults) {
|
if (writingdefaults) {
|
||||||
WriteVector(elem, "user", pact->get_userdata());
|
WriteVector(elem, "user", pact->get_userdata());
|
||||||
} else {
|
} else {
|
||||||
WriteVector(elem, "user", pact->get_userdata(), def->actuator.get_userdata());
|
WriteVector(elem, "user", pact->get_userdata(), def->Actuator().get_userdata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// write plugin
|
// write plugin
|
||||||
void mjXWriter::OnePlugin(XMLElement* elem, mjsPlugin* plugin) {
|
void mjXWriter::OnePlugin(XMLElement* elem, const mjsPlugin* plugin) {
|
||||||
const std::string instance_name = std::string(mjs_getString(plugin->instance_name));
|
const std::string instance_name = std::string(mjs_getString(plugin->instance_name));
|
||||||
const std::string plugin_name = std::string(mjs_getString(plugin->name));
|
const std::string plugin_name = std::string(mjs_getString(plugin->name));
|
||||||
if (!instance_name.empty()) {
|
if (!instance_name.empty()) {
|
||||||
@@ -806,7 +806,7 @@ string mjXWriter::Write(char *error, size_t error_sz) {
|
|||||||
Visual(root);
|
Visual(root);
|
||||||
Statistic(root);
|
Statistic(root);
|
||||||
writingdefaults = true;
|
writingdefaults = true;
|
||||||
Default(root, model->Defaults()[0]);
|
Default(root, model->Defaults(0));
|
||||||
writingdefaults = false;
|
writingdefaults = false;
|
||||||
Extension(root);
|
Extension(root);
|
||||||
Custom(root);
|
Custom(root);
|
||||||
@@ -1136,7 +1136,7 @@ void mjXWriter::Default(XMLElement* root, mjCDef* def) {
|
|||||||
// pointer to parent defaults
|
// pointer to parent defaults
|
||||||
mjCDef* par;
|
mjCDef* par;
|
||||||
if (def->parentid>=0) {
|
if (def->parentid>=0) {
|
||||||
par = model->Defaults()[def->parentid];
|
par = model->Defaults(def->parentid);
|
||||||
} else {
|
} else {
|
||||||
par = new mjCDef;
|
par = new mjCDef;
|
||||||
}
|
}
|
||||||
@@ -1147,57 +1147,57 @@ void mjXWriter::Default(XMLElement* root, mjCDef* def) {
|
|||||||
|
|
||||||
// mesh
|
// mesh
|
||||||
elem = InsertEnd(section, "mesh");
|
elem = InsertEnd(section, "mesh");
|
||||||
OneMesh(elem, &def->mesh, par);
|
OneMesh(elem, &def->Mesh(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// material
|
// material
|
||||||
elem = InsertEnd(section, "material");
|
elem = InsertEnd(section, "material");
|
||||||
OneMaterial(elem, &def->material, par);
|
OneMaterial(elem, &def->Material(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// joint
|
// joint
|
||||||
elem = InsertEnd(section, "joint");
|
elem = InsertEnd(section, "joint");
|
||||||
OneJoint(elem, &def->joint, par);
|
OneJoint(elem, &def->Joint(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// geom
|
// geom
|
||||||
elem = InsertEnd(section, "geom");
|
elem = InsertEnd(section, "geom");
|
||||||
OneGeom(elem, &def->geom, par);
|
OneGeom(elem, &def->Geom(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// site
|
// site
|
||||||
elem = InsertEnd(section, "site");
|
elem = InsertEnd(section, "site");
|
||||||
OneSite(elem, &def->site, par);
|
OneSite(elem, &def->Site(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
elem = InsertEnd(section, "camera");
|
elem = InsertEnd(section, "camera");
|
||||||
OneCamera(elem, &def->camera, par);
|
OneCamera(elem, &def->Camera(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// light
|
// light
|
||||||
elem = InsertEnd(section, "light");
|
elem = InsertEnd(section, "light");
|
||||||
OneLight(elem, &def->light, par);
|
OneLight(elem, &def->Light(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// pair
|
// pair
|
||||||
elem = InsertEnd(section, "pair");
|
elem = InsertEnd(section, "pair");
|
||||||
OnePair(elem, &def->pair, par);
|
OnePair(elem, &def->Pair(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// equality
|
// equality
|
||||||
elem = InsertEnd(section, "equality");
|
elem = InsertEnd(section, "equality");
|
||||||
OneEquality(elem, &def->equality, par);
|
OneEquality(elem, &def->Equality(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// tendon
|
// tendon
|
||||||
elem = InsertEnd(section, "tendon");
|
elem = InsertEnd(section, "tendon");
|
||||||
OneTendon(elem, &def->tendon, par);
|
OneTendon(elem, &def->Tendon(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// actuator
|
// actuator
|
||||||
elem = InsertEnd(section, "general");
|
elem = InsertEnd(section, "general");
|
||||||
OneActuator(elem, &def->actuator, par);
|
OneActuator(elem, &def->Actuator(), par);
|
||||||
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
if (!elem->FirstAttribute()) section->DeleteChild(elem);
|
||||||
|
|
||||||
// if top-level class has no members or children, delete it and return
|
// if top-level class has no members or children, delete it and return
|
||||||
@@ -1209,7 +1209,7 @@ void mjXWriter::Default(XMLElement* root, mjCDef* def) {
|
|||||||
|
|
||||||
// add children recursively
|
// add children recursively
|
||||||
for (int i=0; i<(int)def->childid.size(); i++) {
|
for (int i=0; i<(int)def->childid.size(); i++) {
|
||||||
Default(section, model->Defaults()[def->childid[i]]);
|
Default(section, model->Defaults(def->childid[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete parent defaults if allocated here
|
// delete parent defaults if allocated here
|
||||||
@@ -1677,7 +1677,7 @@ void mjXWriter::Tendon(XMLElement* root) {
|
|||||||
// write wraps
|
// write wraps
|
||||||
XMLElement* wrap;
|
XMLElement* wrap;
|
||||||
for (int j=0; j<pten->NumWraps(); j++) {
|
for (int j=0; j<pten->NumWraps(); j++) {
|
||||||
mjCWrap* pw = pten->GetWrap(j);
|
const mjCWrap* pw = pten->GetWrap(j);
|
||||||
switch (pw->type) {
|
switch (pw->type) {
|
||||||
case mjWRAP_JOINT:
|
case mjWRAP_JOINT:
|
||||||
wrap = InsertEnd(elem, "joint");
|
wrap = InsertEnd(elem, "joint");
|
||||||
|
|||||||
+14
-14
@@ -59,20 +59,20 @@ class mjXWriter : public mjXBase {
|
|||||||
void Keyframe(tinyxml2::XMLElement* root); // keyframe section
|
void Keyframe(tinyxml2::XMLElement* root); // keyframe section
|
||||||
|
|
||||||
// single element writers, used in defaults and main body
|
// single element writers, used in defaults and main body
|
||||||
void OneFlex(tinyxml2::XMLElement* elem, mjCFlex* pflex);
|
void OneFlex(tinyxml2::XMLElement* elem, const mjCFlex* pflex);
|
||||||
void OneMesh(tinyxml2::XMLElement* elem, mjCMesh* pmesh, mjCDef* def);
|
void OneMesh(tinyxml2::XMLElement* elem, const mjCMesh* pmesh, mjCDef* def);
|
||||||
void OneSkin(tinyxml2::XMLElement* elem, mjCSkin* pskin);
|
void OneSkin(tinyxml2::XMLElement* elem, const mjCSkin* pskin);
|
||||||
void OneMaterial(tinyxml2::XMLElement* elem, mjCMaterial* pmaterial, mjCDef* def);
|
void OneMaterial(tinyxml2::XMLElement* elem, const mjCMaterial* pmaterial, mjCDef* def);
|
||||||
void OneJoint(tinyxml2::XMLElement* elem, mjCJoint* pjoint, mjCDef* def);
|
void OneJoint(tinyxml2::XMLElement* elem, const mjCJoint* pjoint, mjCDef* def);
|
||||||
void OneGeom(tinyxml2::XMLElement* elem, mjCGeom* pgeom, mjCDef* def);
|
void OneGeom(tinyxml2::XMLElement* elem, const mjCGeom* pgeom, mjCDef* def);
|
||||||
void OneSite(tinyxml2::XMLElement* elem, mjCSite* psite, mjCDef* def);
|
void OneSite(tinyxml2::XMLElement* elem, const mjCSite* psite, mjCDef* def);
|
||||||
void OneCamera(tinyxml2::XMLElement* elem, mjCCamera* pcamera, mjCDef* def);
|
void OneCamera(tinyxml2::XMLElement* elem, const mjCCamera* pcamera, mjCDef* def);
|
||||||
void OneLight(tinyxml2::XMLElement* elem, mjCLight* plight, mjCDef* def);
|
void OneLight(tinyxml2::XMLElement* elem, const mjCLight* plight, mjCDef* def);
|
||||||
void OnePair(tinyxml2::XMLElement* elem, mjCPair* ppair, mjCDef* def);
|
void OnePair(tinyxml2::XMLElement* elem, const mjCPair* ppair, mjCDef* def);
|
||||||
void OneEquality(tinyxml2::XMLElement* elem, mjCEquality* pequality, mjCDef* def);
|
void OneEquality(tinyxml2::XMLElement* elem, const mjCEquality* pequality, mjCDef* def);
|
||||||
void OneTendon(tinyxml2::XMLElement* elem, mjCTendon* ptendon, mjCDef* def);
|
void OneTendon(tinyxml2::XMLElement* elem, const mjCTendon* ptendon, mjCDef* def);
|
||||||
void OneActuator(tinyxml2::XMLElement* elem, mjCActuator* pactuator, mjCDef* def);
|
void OneActuator(tinyxml2::XMLElement* elem, const mjCActuator* pactuator, mjCDef* def);
|
||||||
void OnePlugin(tinyxml2::XMLElement* elem, mjsPlugin* plugin);
|
void OnePlugin(tinyxml2::XMLElement* elem, const mjsPlugin* plugin);
|
||||||
tinyxml2::XMLElement* OneFrame(tinyxml2::XMLElement* elem, mjCFrame* frame);
|
tinyxml2::XMLElement* OneFrame(tinyxml2::XMLElement* elem, mjCFrame* frame);
|
||||||
|
|
||||||
bool writingdefaults; // true during defaults write
|
bool writingdefaults; // true during defaults write
|
||||||
|
|||||||
Reference in New Issue
Block a user