Convert mjElement to struct rather than opaque pointer.
By making mjElement the parent of mjCBase, mjCModel, and mjCDef, this CL enables safer casting using static_cast instead of reinterpret_cast and C-style casting. PiperOrigin-RevId: 619526291 Change-Id: Ifa2b4bd3ecd95bade61f41a7005c62212f456c00
This commit is contained in:
committed by
Copybara-Service
parent
e6bf6fc327
commit
dfe2b75378
+72
-72
@@ -58,7 +58,7 @@ mjSpec* mjs_createSpec() {
|
|||||||
|
|
||||||
// copy model
|
// copy model
|
||||||
mjSpec* mjs_copySpec(const mjSpec* s) {
|
mjSpec* mjs_copySpec(const mjSpec* s) {
|
||||||
mjCModel* modelC = new mjCModel(*reinterpret_cast<mjCModel*>(s->element));
|
mjCModel* modelC = new mjCModel(*static_cast<mjCModel*>(s->element));
|
||||||
return &modelC->spec;
|
return &modelC->spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ mjSpec* mjs_copySpec(const mjSpec* s) {
|
|||||||
|
|
||||||
// copy back model
|
// copy back model
|
||||||
void mjs_copyBack(mjSpec* s, const mjModel* m) {
|
void mjs_copyBack(mjSpec* s, const mjModel* m) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
modelC->CopyBack(m);
|
modelC->CopyBack(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ void mjs_copyBack(mjSpec* s, const mjModel* m) {
|
|||||||
|
|
||||||
// compile model
|
// compile model
|
||||||
mjModel* mjs_compile(mjSpec* s, const mjVFS* vfs) {
|
mjModel* mjs_compile(mjSpec* s, const mjVFS* vfs) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
return modelC->Compile(vfs);
|
return modelC->Compile(vfs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@ mjModel* mjs_compile(mjSpec* s, const mjVFS* vfs) {
|
|||||||
// attach body to a frame of the parent
|
// attach body to a frame of the parent
|
||||||
int mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
int mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
||||||
const char* prefix, const char* suffix) {
|
const char* prefix, const char* suffix) {
|
||||||
mjCFrame* frame_parent = reinterpret_cast<mjCFrame*>(parent->element);
|
mjCFrame* frame_parent = static_cast<mjCFrame*>(parent->element);
|
||||||
mjCBody* child_body = reinterpret_cast<mjCBody*>(child->element);
|
mjCBody* child_body = static_cast<mjCBody*>(child->element);
|
||||||
*frame_parent += std::string(prefix) + *child_body + std::string(suffix);
|
*frame_parent += std::string(prefix) + *child_body + std::string(suffix);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ int mjs_attachBody(mjsFrame* parent, const mjsBody* child,
|
|||||||
|
|
||||||
// get error message from model
|
// get error message from model
|
||||||
const char* mjs_getError(mjSpec* s) {
|
const char* mjs_getError(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
return modelC->GetError().message;
|
return modelC->GetError().message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ const char* mjs_getError(mjSpec* s) {
|
|||||||
|
|
||||||
// check if model has warnings
|
// check if model has warnings
|
||||||
int mjs_isWarning(mjSpec* s) {
|
int mjs_isWarning(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
return modelC->GetError().warning;
|
return modelC->GetError().warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ int mjs_isWarning(mjSpec* s) {
|
|||||||
|
|
||||||
// delete model
|
// delete model
|
||||||
void mjs_deleteSpec(mjSpec* s) {
|
void mjs_deleteSpec(mjSpec* s) {
|
||||||
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||||
delete model;
|
delete model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,8 +117,8 @@ void mjs_deleteSpec(mjSpec* s) {
|
|||||||
|
|
||||||
// add child body to body, return child spec
|
// add child body to body, return child spec
|
||||||
mjsBody* mjs_addBody(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsBody* mjs_addBody(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element)->AddBody(def);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element)->AddBody(def);
|
||||||
return &body->spec;
|
return &body->spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +126,8 @@ mjsBody* mjs_addBody(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add site to body, return site spec
|
// add site to body, return site spec
|
||||||
mjsSite* mjs_addSite(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsSite* mjs_addSite(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCSite* site = body->AddSite(def);
|
mjCSite* site = body->AddSite(def);
|
||||||
return &site->spec;
|
return &site->spec;
|
||||||
}
|
}
|
||||||
@@ -136,8 +136,8 @@ mjsSite* mjs_addSite(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add joint to body
|
// add joint to body
|
||||||
mjsJoint* mjs_addJoint(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsJoint* mjs_addJoint(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCJoint* joint = body->AddJoint(def);
|
mjCJoint* joint = body->AddJoint(def);
|
||||||
return &joint->spec;
|
return &joint->spec;
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ mjsJoint* mjs_addJoint(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add free joint to body
|
// add free joint to body
|
||||||
mjsJoint* mjs_addFreeJoint(mjsBody* bodyspec) {
|
mjsJoint* mjs_addFreeJoint(mjsBody* bodyspec) {
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCJoint* joint = body->AddFreeJoint();
|
mjCJoint* joint = body->AddFreeJoint();
|
||||||
return &joint->spec;
|
return &joint->spec;
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,8 @@ mjsJoint* mjs_addFreeJoint(mjsBody* bodyspec) {
|
|||||||
|
|
||||||
// add geom to body
|
// add geom to body
|
||||||
mjsGeom* mjs_addGeom(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsGeom* mjs_addGeom(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCGeom* geom = body->AddGeom(def);
|
mjCGeom* geom = body->AddGeom(def);
|
||||||
return &geom->spec;
|
return &geom->spec;
|
||||||
}
|
}
|
||||||
@@ -165,8 +165,8 @@ mjsGeom* mjs_addGeom(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add camera to body
|
// add camera to body
|
||||||
mjsCamera* mjs_addCamera(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsCamera* mjs_addCamera(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCCamera* camera = body->AddCamera(def);
|
mjCCamera* camera = body->AddCamera(def);
|
||||||
return &camera->spec;
|
return &camera->spec;
|
||||||
}
|
}
|
||||||
@@ -175,8 +175,8 @@ mjsCamera* mjs_addCamera(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add light to body
|
// add light to body
|
||||||
mjsLight* mjs_addLight(mjsBody* bodyspec, mjsDefault* defspec) {
|
mjsLight* mjs_addLight(mjsBody* bodyspec, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCLight* light = body->AddLight(def);
|
mjCLight* light = body->AddLight(def);
|
||||||
return &light->spec;
|
return &light->spec;
|
||||||
}
|
}
|
||||||
@@ -185,7 +185,7 @@ mjsLight* mjs_addLight(mjsBody* bodyspec, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add flex to model
|
// add flex to model
|
||||||
mjsFlex* mjs_addFlex(mjSpec* s) {
|
mjsFlex* mjs_addFlex(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCFlex* flex = modelC->AddFlex();
|
mjCFlex* flex = modelC->AddFlex();
|
||||||
return &flex->spec;
|
return &flex->spec;
|
||||||
}
|
}
|
||||||
@@ -196,9 +196,9 @@ mjsFlex* mjs_addFlex(mjSpec* s) {
|
|||||||
mjsFrame* mjs_addFrame(mjsBody* bodyspec, mjsFrame* parentframe) {
|
mjsFrame* mjs_addFrame(mjsBody* bodyspec, mjsFrame* parentframe) {
|
||||||
mjCFrame* parentframeC = 0;
|
mjCFrame* parentframeC = 0;
|
||||||
if (parentframe) {
|
if (parentframe) {
|
||||||
parentframeC = reinterpret_cast<mjCFrame*>(parentframe->element);
|
parentframeC = static_cast<mjCFrame*>(parentframe->element);
|
||||||
}
|
}
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCFrame* frameC = body->AddFrame(parentframeC);
|
mjCFrame* frameC = body->AddFrame(parentframeC);
|
||||||
frameC->SetParent(body);
|
frameC->SetParent(body);
|
||||||
return &frameC->spec;
|
return &frameC->spec;
|
||||||
@@ -208,8 +208,8 @@ mjsFrame* mjs_addFrame(mjsBody* bodyspec, mjsFrame* parentframe) {
|
|||||||
|
|
||||||
// add mesh to model
|
// add mesh to model
|
||||||
mjsMesh* mjs_addMesh(mjSpec* s, mjsDefault* defspec) {
|
mjsMesh* mjs_addMesh(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCMesh* mesh = modelC->AddMesh(def);
|
mjCMesh* mesh = modelC->AddMesh(def);
|
||||||
return &mesh->spec;
|
return &mesh->spec;
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ mjsMesh* mjs_addMesh(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add height field to model
|
// add height field to model
|
||||||
mjsHField* mjs_addHField(mjSpec* s) {
|
mjsHField* mjs_addHField(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCHField* heightField = modelC->AddHField();
|
mjCHField* heightField = modelC->AddHField();
|
||||||
return &heightField->spec;
|
return &heightField->spec;
|
||||||
}
|
}
|
||||||
@@ -227,7 +227,7 @@ mjsHField* mjs_addHField(mjSpec* s) {
|
|||||||
|
|
||||||
// add skin to model
|
// add skin to model
|
||||||
mjsSkin* mjs_addSkin(mjSpec* s) {
|
mjsSkin* mjs_addSkin(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCSkin* skin = modelC->AddSkin();
|
mjCSkin* skin = modelC->AddSkin();
|
||||||
return &skin->spec;
|
return &skin->spec;
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ mjsSkin* mjs_addSkin(mjSpec* s) {
|
|||||||
|
|
||||||
// add texture to model
|
// add texture to model
|
||||||
mjsTexture* mjs_addTexture(mjSpec* s) {
|
mjsTexture* mjs_addTexture(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCTexture* texture = modelC->AddTexture();
|
mjCTexture* texture = modelC->AddTexture();
|
||||||
return &texture->spec;
|
return &texture->spec;
|
||||||
}
|
}
|
||||||
@@ -245,8 +245,8 @@ mjsTexture* mjs_addTexture(mjSpec* s) {
|
|||||||
|
|
||||||
// add material to model
|
// add material to model
|
||||||
mjsMaterial* mjs_addMaterial(mjSpec* s, mjsDefault* defspec) {
|
mjsMaterial* mjs_addMaterial(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCMaterial* material = modelC->AddMaterial(def);
|
mjCMaterial* material = modelC->AddMaterial(def);
|
||||||
return &material->spec;
|
return &material->spec;
|
||||||
}
|
}
|
||||||
@@ -255,8 +255,8 @@ mjsMaterial* mjs_addMaterial(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add pair to model
|
// add pair to model
|
||||||
mjsPair* mjs_addPair(mjSpec* s, mjsDefault* defspec) {
|
mjsPair* mjs_addPair(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCPair* pair = modelC->AddPair(def);
|
mjCPair* pair = modelC->AddPair(def);
|
||||||
return &pair->spec;
|
return &pair->spec;
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ mjsPair* mjs_addPair(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add pair exclusion to model
|
// add pair exclusion to model
|
||||||
mjsExclude* mjs_addExclude(mjSpec* s) {
|
mjsExclude* mjs_addExclude(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCBodyPair* bodypair = modelC->AddExclude();
|
mjCBodyPair* bodypair = modelC->AddExclude();
|
||||||
return &bodypair->spec;
|
return &bodypair->spec;
|
||||||
}
|
}
|
||||||
@@ -274,8 +274,8 @@ mjsExclude* mjs_addExclude(mjSpec* s) {
|
|||||||
|
|
||||||
// add equality to model
|
// add equality to model
|
||||||
mjsEquality* mjs_addEquality(mjSpec* s, mjsDefault* defspec) {
|
mjsEquality* mjs_addEquality(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCEquality* equality = modelC->AddEquality(def);
|
mjCEquality* equality = modelC->AddEquality(def);
|
||||||
return &equality->spec;
|
return &equality->spec;
|
||||||
}
|
}
|
||||||
@@ -284,8 +284,8 @@ mjsEquality* mjs_addEquality(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add tendon to model
|
// add tendon to model
|
||||||
mjsTendon* mjs_addTendon(mjSpec* s, mjsDefault* defspec) {
|
mjsTendon* mjs_addTendon(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCTendon* tendon = modelC->AddTendon(def);
|
mjCTendon* tendon = modelC->AddTendon(def);
|
||||||
return &tendon->spec;
|
return &tendon->spec;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ mjsTendon* mjs_addTendon(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// wrap site using tendon
|
// wrap site using tendon
|
||||||
MJAPI mjsWrap* mjs_wrapSite(mjsTendon* tendonspec, const char* name) {
|
MJAPI mjsWrap* mjs_wrapSite(mjsTendon* tendonspec, const char* name) {
|
||||||
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
|
mjCTendon* tendon = static_cast<mjCTendon*>(tendonspec->element);
|
||||||
tendon->WrapSite(name);
|
tendon->WrapSite(name);
|
||||||
return &tendon->path.back()->spec;
|
return &tendon->path.back()->spec;
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ MJAPI mjsWrap* mjs_wrapSite(mjsTendon* tendonspec, const char* name) {
|
|||||||
|
|
||||||
// wrap geom using tendon
|
// wrap geom using tendon
|
||||||
mjsWrap* mjs_wrapGeom(mjsTendon* tendonspec, const char* name, const char* sidesite) {
|
mjsWrap* mjs_wrapGeom(mjsTendon* tendonspec, const char* name, const char* sidesite) {
|
||||||
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
|
mjCTendon* tendon = static_cast<mjCTendon*>(tendonspec->element);
|
||||||
tendon->WrapGeom(name, sidesite);
|
tendon->WrapGeom(name, sidesite);
|
||||||
return &tendon->path.back()->spec;
|
return &tendon->path.back()->spec;
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,7 @@ mjsWrap* mjs_wrapGeom(mjsTendon* tendonspec, const char* name, const char* sides
|
|||||||
|
|
||||||
// wrap joint using tendon
|
// wrap joint using tendon
|
||||||
mjsWrap* mjs_wrapJoint(mjsTendon* tendonspec, const char* name, double coef) {
|
mjsWrap* mjs_wrapJoint(mjsTendon* tendonspec, const char* name, double coef) {
|
||||||
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
|
mjCTendon* tendon = static_cast<mjCTendon*>(tendonspec->element);
|
||||||
tendon->WrapJoint(name, coef);
|
tendon->WrapJoint(name, coef);
|
||||||
return &tendon->path.back()->spec;
|
return &tendon->path.back()->spec;
|
||||||
}
|
}
|
||||||
@@ -321,7 +321,7 @@ mjsWrap* mjs_wrapJoint(mjsTendon* tendonspec, const char* name, double coef) {
|
|||||||
|
|
||||||
// wrap pulley using tendon
|
// wrap pulley using tendon
|
||||||
mjsWrap* mjs_wrapPulley(mjsTendon* tendonspec, double divisor) {
|
mjsWrap* mjs_wrapPulley(mjsTendon* tendonspec, double divisor) {
|
||||||
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
|
mjCTendon* tendon = static_cast<mjCTendon*>(tendonspec->element);
|
||||||
tendon->WrapPulley(divisor);
|
tendon->WrapPulley(divisor);
|
||||||
return &tendon->path.back()->spec;
|
return &tendon->path.back()->spec;
|
||||||
}
|
}
|
||||||
@@ -330,8 +330,8 @@ mjsWrap* mjs_wrapPulley(mjsTendon* tendonspec, double divisor) {
|
|||||||
|
|
||||||
// add actuator to model
|
// add actuator to model
|
||||||
mjsActuator* mjs_addActuator(mjSpec* s, mjsDefault* defspec) {
|
mjsActuator* mjs_addActuator(mjSpec* s, mjsDefault* defspec) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
|
mjCDef* def = defspec ? static_cast<mjCDef*>(defspec->element) : 0;
|
||||||
mjCActuator* actuator = modelC->AddActuator(def);
|
mjCActuator* actuator = modelC->AddActuator(def);
|
||||||
return &actuator->spec;
|
return &actuator->spec;
|
||||||
}
|
}
|
||||||
@@ -340,7 +340,7 @@ mjsActuator* mjs_addActuator(mjSpec* s, mjsDefault* defspec) {
|
|||||||
|
|
||||||
// add sensor to model
|
// add sensor to model
|
||||||
mjsSensor* mjs_addSensor(mjSpec* s) {
|
mjsSensor* mjs_addSensor(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCSensor* sensor = modelC->AddSensor();
|
mjCSensor* sensor = modelC->AddSensor();
|
||||||
return &sensor->spec;
|
return &sensor->spec;
|
||||||
}
|
}
|
||||||
@@ -349,7 +349,7 @@ mjsSensor* mjs_addSensor(mjSpec* s) {
|
|||||||
|
|
||||||
// add numeric to model
|
// add numeric to model
|
||||||
mjsNumeric* mjs_addNumeric(mjSpec* s) {
|
mjsNumeric* mjs_addNumeric(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCNumeric* numeric = modelC->AddNumeric();
|
mjCNumeric* numeric = modelC->AddNumeric();
|
||||||
return &numeric->spec;
|
return &numeric->spec;
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ mjsNumeric* mjs_addNumeric(mjSpec* s) {
|
|||||||
|
|
||||||
// add text to model
|
// add text to model
|
||||||
mjsText* mjs_addText(mjSpec* s) {
|
mjsText* mjs_addText(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCText* text = modelC->AddText();
|
mjCText* text = modelC->AddText();
|
||||||
return &text->spec;
|
return &text->spec;
|
||||||
}
|
}
|
||||||
@@ -367,7 +367,7 @@ mjsText* mjs_addText(mjSpec* s) {
|
|||||||
|
|
||||||
// add tuple to model
|
// add tuple to model
|
||||||
mjsTuple* mjs_addTuple(mjSpec* s) {
|
mjsTuple* mjs_addTuple(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCTuple* tuple = modelC->AddTuple();
|
mjCTuple* tuple = modelC->AddTuple();
|
||||||
return &tuple->spec;
|
return &tuple->spec;
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ mjsTuple* mjs_addTuple(mjSpec* s) {
|
|||||||
|
|
||||||
// add keyframe to model
|
// add keyframe to model
|
||||||
mjsKey* mjs_addKey(mjSpec* s) {
|
mjsKey* mjs_addKey(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCKey* key = modelC->AddKey();
|
mjCKey* key = modelC->AddKey();
|
||||||
return &key->spec;
|
return &key->spec;
|
||||||
}
|
}
|
||||||
@@ -385,9 +385,9 @@ mjsKey* mjs_addKey(mjSpec* s) {
|
|||||||
|
|
||||||
// add plugin to model
|
// add plugin to model
|
||||||
mjsPlugin* mjs_addPlugin(mjSpec* s) {
|
mjsPlugin* mjs_addPlugin(mjSpec* s) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCPlugin* plugin = modelC->AddPlugin();
|
mjCPlugin* plugin = modelC->AddPlugin();
|
||||||
plugin->spec.instance = (mjElement)plugin;
|
plugin->spec.instance = static_cast<mjElement*>(plugin);
|
||||||
return &plugin->spec;
|
return &plugin->spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,7 +395,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 = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
*id = (int)modelC->defaults.size();
|
*id = (int)modelC->defaults.size();
|
||||||
mjCDef* def = modelC->AddDef(classname, parentid);
|
mjCDef* def = modelC->AddDef(classname, parentid);
|
||||||
if (def) {
|
if (def) {
|
||||||
@@ -409,21 +409,21 @@ mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, int parentid, int*
|
|||||||
|
|
||||||
// get objects
|
// get objects
|
||||||
mjSpec* mjs_getSpec(mjsBody* body) {
|
mjSpec* mjs_getSpec(mjsBody* body) {
|
||||||
return &(reinterpret_cast<mjCBody*>(body->element)->model->spec);
|
return &(static_cast<mjCBody*>(body->element)->model->spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// get default
|
// get default
|
||||||
mjsDefault* mjs_getDefault(mjElement element) {
|
mjsDefault* mjs_getDefault(mjElement* element) {
|
||||||
return &(reinterpret_cast<mjCBase*>(element)->def->spec);
|
return &(static_cast<mjCBase*>(element)->def->spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Find default with given name in model.
|
// Find default with given name in model.
|
||||||
mjsDefault* mjs_findDefault(mjSpec* s, const char* classname) {
|
mjsDefault* mjs_findDefault(mjSpec* s, const char* classname) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
mjCDef* cdef = modelC->FindDef(classname);
|
mjCDef* cdef = modelC->FindDef(classname);
|
||||||
if (!cdef) {
|
if (!cdef) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -435,7 +435,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 = reinterpret_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;
|
||||||
@@ -447,7 +447,7 @@ mjsDefault* mjs_getSpecDefault(mjSpec* s) {
|
|||||||
|
|
||||||
// find body in model by name
|
// find body in model by name
|
||||||
mjsBody* mjs_findBody(mjSpec* s, const char* name) {
|
mjsBody* mjs_findBody(mjSpec* s, const char* name) {
|
||||||
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||||
mjCBase* body = 0;
|
mjCBase* body = 0;
|
||||||
if (model->IsCompiled()) {
|
if (model->IsCompiled()) {
|
||||||
body = model->FindObject(mjOBJ_BODY, std::string(name)); // fast lookup
|
body = model->FindObject(mjOBJ_BODY, std::string(name)); // fast lookup
|
||||||
@@ -461,7 +461,7 @@ mjsBody* mjs_findBody(mjSpec* s, const char* name) {
|
|||||||
|
|
||||||
// find child of a body by name
|
// find child of a body by name
|
||||||
mjsBody* mjs_findChild(mjsBody* bodyspec, const char* name) {
|
mjsBody* mjs_findChild(mjsBody* bodyspec, const char* name) {
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
mjCBase* child = body->FindObject(mjOBJ_BODY, std::string(name));
|
mjCBase* child = body->FindObject(mjOBJ_BODY, std::string(name));
|
||||||
return child ? &(static_cast<mjCBody*>(child)->spec) : nullptr;
|
return child ? &(static_cast<mjCBody*>(child)->spec) : nullptr;
|
||||||
}
|
}
|
||||||
@@ -470,7 +470,7 @@ mjsBody* mjs_findChild(mjsBody* bodyspec, const char* name) {
|
|||||||
|
|
||||||
// find mesh by name
|
// find mesh by name
|
||||||
mjsMesh* mjs_findMesh(mjSpec* s, const char* name) {
|
mjsMesh* mjs_findMesh(mjSpec* s, const char* name) {
|
||||||
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||||
mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, std::string(name));
|
mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, std::string(name));
|
||||||
return mesh ? &(static_cast<mjCMesh*>(mesh)->spec) : nullptr;
|
return mesh ? &(static_cast<mjCMesh*>(mesh)->spec) : nullptr;
|
||||||
}
|
}
|
||||||
@@ -479,7 +479,7 @@ mjsMesh* mjs_findMesh(mjSpec* s, const char* name) {
|
|||||||
|
|
||||||
// find frame by name
|
// find frame by name
|
||||||
mjsFrame* mjs_findFrame(mjSpec* s, const char* name) {
|
mjsFrame* mjs_findFrame(mjSpec* s, const char* name) {
|
||||||
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* model = static_cast<mjCModel*>(s->element);
|
||||||
mjCFrame* frame = (mjCFrame*)model->FindFrame(model->GetWorld(), std::string(name));
|
mjCFrame* frame = (mjCFrame*)model->FindFrame(model->GetWorld(), std::string(name));
|
||||||
return frame ? &(static_cast<mjCFrame*>(frame)->spec) : nullptr;
|
return frame ? &(static_cast<mjCFrame*>(frame)->spec) : nullptr;
|
||||||
}
|
}
|
||||||
@@ -487,12 +487,12 @@ mjsFrame* mjs_findFrame(mjSpec* s, const char* name) {
|
|||||||
|
|
||||||
|
|
||||||
// set frame
|
// set frame
|
||||||
void mjs_setFrame(mjElement dest, mjsFrame* frame) {
|
void mjs_setFrame(mjElement* dest, mjsFrame* frame) {
|
||||||
if (!frame) {
|
if (!frame) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mjCFrame* frameC = reinterpret_cast<mjCFrame*>(frame->element);
|
mjCFrame* frameC = static_cast<mjCFrame*>(frame->element);
|
||||||
mjCBase* baseC = reinterpret_cast<mjCBase*>(dest);
|
mjCBase* baseC = static_cast<mjCBase*>(dest);
|
||||||
baseC->SetFrame(frameC);
|
baseC->SetFrame(frameC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,16 +507,16 @@ const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* s
|
|||||||
|
|
||||||
|
|
||||||
// get id
|
// get id
|
||||||
int mjs_getId(mjElement element) {
|
int mjs_getId(mjElement* element) {
|
||||||
return reinterpret_cast<mjCBase*>(element)->id;
|
return static_cast<mjCBase*>(element)->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// set default
|
// set default
|
||||||
void mjs_setDefault(mjElement element, mjsDefault* defspec) {
|
void mjs_setDefault(mjElement* element, mjsDefault* defspec) {
|
||||||
mjCBase* baseC = reinterpret_cast<mjCBase*>(element);
|
mjCBase* baseC = static_cast<mjCBase*>(element);
|
||||||
baseC->def = reinterpret_cast<mjCDef*>(defspec->element);
|
baseC->def = static_cast<mjCDef*>(defspec->element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -631,7 +631,7 @@ const double* mjs_getDouble(const mjDoubleVec source, int* size) {
|
|||||||
|
|
||||||
// set plugin attributes
|
// set plugin attributes
|
||||||
void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes) {
|
void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes) {
|
||||||
mjCPlugin* pluginC = reinterpret_cast<mjCPlugin*>(plugin->instance);
|
mjCPlugin* pluginC = static_cast<mjCPlugin*>(plugin->instance);
|
||||||
std::map<std::string, std::string, std::less<>>* config_attribs =
|
std::map<std::string, std::string, std::less<>>* config_attribs =
|
||||||
reinterpret_cast<std::map<std::string, std::string, std::less<>>*>(attributes);
|
reinterpret_cast<std::map<std::string, std::string, std::less<>>*>(attributes);
|
||||||
pluginC->config_attribs = std::move(*config_attribs);
|
pluginC->config_attribs = std::move(*config_attribs);
|
||||||
@@ -641,7 +641,7 @@ void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes) {
|
|||||||
|
|
||||||
// Set active plugins.
|
// Set active plugins.
|
||||||
void mjs_setActivePlugins(mjSpec* s, void* activeplugins) {
|
void mjs_setActivePlugins(mjSpec* s, void* activeplugins) {
|
||||||
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
|
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||||
std::vector<std::pair<const mjpPlugin*, int>>* active_plugins =
|
std::vector<std::pair<const mjpPlugin*, int>>* active_plugins =
|
||||||
reinterpret_cast<std::vector<std::pair<const mjpPlugin*, int>>*>(activeplugins);
|
reinterpret_cast<std::vector<std::pair<const mjpPlugin*, int>>*>(activeplugins);
|
||||||
modelC->active_plugins = std::move(*active_plugins);
|
modelC->active_plugins = std::move(*active_plugins);
|
||||||
@@ -651,7 +651,7 @@ void mjs_setActivePlugins(mjSpec* s, void* activeplugins) {
|
|||||||
|
|
||||||
// compute full inertia
|
// compute full inertia
|
||||||
const char* mjs_setFullInertia(mjsBody* bodyspec, double quat[4], double inertia[3]) {
|
const char* mjs_setFullInertia(mjsBody* bodyspec, double quat[4], double inertia[3]) {
|
||||||
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
|
mjCBody* body = static_cast<mjCBody*>(bodyspec->element);
|
||||||
return body->FullInertia(quat, inertia);
|
return body->FullInertia(quat, inertia);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+37
-33
@@ -29,7 +29,6 @@ extern "C" {
|
|||||||
|
|
||||||
//---------------------------------- handles to internal objects -----------------------------------
|
//---------------------------------- handles to internal objects -----------------------------------
|
||||||
|
|
||||||
typedef struct _mjElement* mjElement;
|
|
||||||
typedef struct _mjString* mjString;
|
typedef struct _mjString* mjString;
|
||||||
typedef struct _mjStringVec* mjStringVec;
|
typedef struct _mjStringVec* mjStringVec;
|
||||||
typedef struct _mjIntVec* mjIntVec;
|
typedef struct _mjIntVec* mjIntVec;
|
||||||
@@ -77,10 +76,15 @@ typedef enum _mjtInertiaFromGeom {
|
|||||||
} mjtInertiaFromGeom;
|
} mjtInertiaFromGeom;
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------- attribute structs (mjm) ---------------------------------------
|
//---------------------------------- attribute structs (mjs) ---------------------------------------
|
||||||
|
|
||||||
|
typedef struct _mjElement { // element type, do not modify
|
||||||
|
mjtObj elemtype; // element type
|
||||||
|
} mjElement;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjSpec { // model specification
|
typedef struct _mjSpec { // model specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjStatistic stat; // statistics override (if defined)
|
mjStatistic stat; // statistics override (if defined)
|
||||||
|
|
||||||
// compiler settings
|
// compiler settings
|
||||||
@@ -144,7 +148,7 @@ typedef struct _mjsOrientation { // alternative orientation specifiers
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsPlugin { // plugin specification
|
typedef struct _mjsPlugin { // plugin specification
|
||||||
mjElement instance; // internal, do not modify
|
mjElement* instance; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString instance_name; // instance name
|
mjString instance_name; // instance name
|
||||||
int plugin_slot; // global registered slot number of the plugin
|
int plugin_slot; // global registered slot number of the plugin
|
||||||
@@ -154,7 +158,7 @@ typedef struct _mjsPlugin { // plugin specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsBody { // body specification
|
typedef struct _mjsBody { // body specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString childclass; // childclass name
|
mjString childclass; // childclass name
|
||||||
|
|
||||||
@@ -182,7 +186,7 @@ typedef struct _mjsBody { // body specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsFrame { // frame specification
|
typedef struct _mjsFrame { // frame specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString childclass; // childclass name
|
mjString childclass; // childclass name
|
||||||
double pos[3]; // position
|
double pos[3]; // position
|
||||||
@@ -193,7 +197,7 @@ typedef struct _mjsFrame { // frame specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsJoint { // joint specification
|
typedef struct _mjsJoint { // joint specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjtJoint type; // joint type
|
mjtJoint type; // joint type
|
||||||
@@ -233,7 +237,7 @@ typedef struct _mjsJoint { // joint specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsGeom { // geom specification
|
typedef struct _mjsGeom { // geom specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // classname
|
mjString classname; // classname
|
||||||
mjtGeom type; // geom type
|
mjtGeom type; // geom type
|
||||||
@@ -282,7 +286,7 @@ typedef struct _mjsGeom { // geom specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsSite { // site specification
|
typedef struct _mjsSite { // site specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -306,7 +310,7 @@ typedef struct _mjsSite { // site specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsCamera { // camera specification
|
typedef struct _mjsCamera { // camera specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -335,7 +339,7 @@ typedef struct _mjsCamera { // camera specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsLight { // light specification
|
typedef struct _mjsLight { // light specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -362,7 +366,7 @@ typedef struct _mjsLight { // light specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsFlex {
|
typedef struct _mjsFlex {
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -403,7 +407,7 @@ typedef struct _mjsFlex {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsMesh { // mesh specification
|
typedef struct _mjsMesh { // mesh specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString content_type; // content type of file
|
mjString content_type; // content type of file
|
||||||
@@ -424,7 +428,7 @@ typedef struct _mjsMesh { // mesh specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsHField { // height field specification
|
typedef struct _mjsHField { // height field specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString content_type; // content type of file
|
mjString content_type; // content type of file
|
||||||
mjString file; // file: (nrow, ncol, [elevation data])
|
mjString file; // file: (nrow, ncol, [elevation data])
|
||||||
@@ -438,7 +442,7 @@ typedef struct _mjsHField { // height field specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsSkin { // skin specification
|
typedef struct _mjsSkin { // skin specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString file; // skin file
|
mjString file; // skin file
|
||||||
@@ -465,7 +469,7 @@ typedef struct _mjsSkin { // skin specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsTexture { // texture specification
|
typedef struct _mjsTexture { // texture specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjtTexture type; // texture type
|
mjtTexture type; // texture type
|
||||||
@@ -499,7 +503,7 @@ typedef struct _mjsTexture { // texture specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsMaterial { // material specification
|
typedef struct _mjsMaterial { // material specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString texture; // name of texture (empty: none)
|
mjString texture; // name of texture (empty: none)
|
||||||
@@ -515,7 +519,7 @@ typedef struct _mjsMaterial { // material specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsPair {
|
typedef struct _mjsPair {
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjString geomname1; // name of geom 1
|
mjString geomname1; // name of geom 1
|
||||||
@@ -534,7 +538,7 @@ typedef struct _mjsPair {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsExclude {
|
typedef struct _mjsExclude {
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString bodyname1; // name of geom 1
|
mjString bodyname1; // name of geom 1
|
||||||
mjString bodyname2; // name of geom 2
|
mjString bodyname2; // name of geom 2
|
||||||
@@ -543,7 +547,7 @@ typedef struct _mjsExclude {
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsEquality { // equality specification
|
typedef struct _mjsEquality { // equality specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
mjtEq type; // constraint type
|
mjtEq type; // constraint type
|
||||||
@@ -558,7 +562,7 @@ typedef struct _mjsEquality { // equality specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsTendon { // tendon specification
|
typedef struct _mjsTendon { // tendon specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -590,13 +594,13 @@ typedef struct _mjsTendon { // tendon specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsWrap { // wrapping object specification
|
typedef struct _mjsWrap { // wrapping object specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString info; // message appended to errors
|
mjString info; // message appended to errors
|
||||||
} mjsWrap;
|
} mjsWrap;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _mjsActuator { // actuator specification
|
typedef struct _mjsActuator { // actuator specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -640,7 +644,7 @@ typedef struct _mjsActuator { // actuator specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsSensor { // sensor specification
|
typedef struct _mjsSensor { // sensor specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString classname; // class name
|
mjString classname; // class name
|
||||||
|
|
||||||
@@ -668,7 +672,7 @@ typedef struct _mjsSensor { // sensor specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsNumeric { // custom numeric field specification
|
typedef struct _mjsNumeric { // custom numeric field specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjDoubleVec data; // initialization data
|
mjDoubleVec data; // initialization data
|
||||||
int size; // array size, can be bigger than data size
|
int size; // array size, can be bigger than data size
|
||||||
@@ -677,7 +681,7 @@ typedef struct _mjsNumeric { // custom numeric field specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsText { // custom text specification
|
typedef struct _mjsText { // custom text specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjString data; // text string
|
mjString data; // text string
|
||||||
mjString info; // message appended to compiler errors
|
mjString info; // message appended to compiler errors
|
||||||
@@ -685,7 +689,7 @@ typedef struct _mjsText { // custom text specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsTuple { // tuple specification
|
typedef struct _mjsTuple { // tuple specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjIntVec objtype; // object types
|
mjIntVec objtype; // object types
|
||||||
mjStringVec objname; // object names
|
mjStringVec objname; // object names
|
||||||
@@ -695,7 +699,7 @@ typedef struct _mjsTuple { // tuple specification
|
|||||||
|
|
||||||
|
|
||||||
typedef struct _mjsKey { // keyframe specification
|
typedef struct _mjsKey { // keyframe specification
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
double time; // time
|
double time; // time
|
||||||
mjDoubleVec qpos; // qpos
|
mjDoubleVec qpos; // qpos
|
||||||
@@ -710,7 +714,7 @@ typedef struct _mjsKey { // keyframe specification
|
|||||||
|
|
||||||
typedef struct _mjsDefault { // default specification
|
typedef struct _mjsDefault { // default specification
|
||||||
mjString name; // name
|
mjString name; // name
|
||||||
mjElement element; // internal, do not modify
|
mjElement* element; // object type
|
||||||
mjsJoint* joint; // joint defaults
|
mjsJoint* joint; // joint defaults
|
||||||
mjsGeom* geom; // geom defaults
|
mjsGeom* geom; // geom defaults
|
||||||
mjsSite* site; // site defaults
|
mjsSite* site; // site defaults
|
||||||
@@ -847,7 +851,7 @@ MJAPI mjsDefault* mjs_addDefault(mjSpec* s, const char* classname, int parentid,
|
|||||||
MJAPI mjSpec* mjs_getSpec(mjsBody* body);
|
MJAPI mjSpec* mjs_getSpec(mjsBody* body);
|
||||||
|
|
||||||
// Get default corresponding to an mjElement.
|
// Get default corresponding to an mjElement.
|
||||||
MJAPI mjsDefault* mjs_getDefault(mjElement element);
|
MJAPI mjsDefault* mjs_getDefault(mjElement* element);
|
||||||
|
|
||||||
// Find default in model by class name.
|
// Find default in model by class name.
|
||||||
MJAPI mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
|
MJAPI mjsDefault* mjs_findDefault(mjSpec* s, const char* classname);
|
||||||
@@ -868,7 +872,7 @@ MJAPI mjsMesh* mjs_findMesh(mjSpec* s, const char* name);
|
|||||||
MJAPI mjsFrame* mjs_findFrame(mjSpec* s, const char* name);
|
MJAPI mjsFrame* mjs_findFrame(mjSpec* s, const char* name);
|
||||||
|
|
||||||
// Get element id.
|
// Get element id.
|
||||||
MJAPI int mjs_getId(mjElement element);
|
MJAPI int mjs_getId(mjElement* element);
|
||||||
|
|
||||||
// Copy text to string.
|
// Copy text to string.
|
||||||
MJAPI void mjs_setString(mjString dest, const char* text);
|
MJAPI void mjs_setString(mjString dest, const char* text);
|
||||||
@@ -910,10 +914,10 @@ MJAPI void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes);
|
|||||||
MJAPI void mjs_setActivePlugins(mjSpec* s, void* activeplugins);
|
MJAPI void mjs_setActivePlugins(mjSpec* s, void* activeplugins);
|
||||||
|
|
||||||
// Set default.
|
// Set default.
|
||||||
MJAPI void mjs_setDefault(mjElement element, mjsDefault* def);
|
MJAPI void mjs_setDefault(mjElement* element, mjsDefault* def);
|
||||||
|
|
||||||
// Set frame.
|
// Set frame.
|
||||||
MJAPI void mjs_setFrame(mjElement dest, mjsFrame* frame);
|
MJAPI void mjs_setFrame(mjElement* dest, mjsFrame* frame);
|
||||||
|
|
||||||
// Resolve alternative orientations to quat.
|
// Resolve alternative orientations to quat.
|
||||||
MJAPI const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* sequence,
|
MJAPI const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* sequence,
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ bool mjCComposite::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz)
|
|||||||
// overwrite plugin name
|
// overwrite plugin name
|
||||||
if (plugin_instance_name.empty() && plugin.active) {
|
if (plugin_instance_name.empty() && plugin.active) {
|
||||||
plugin_instance_name = "composite" + prefix;
|
plugin_instance_name = "composite" + prefix;
|
||||||
((mjCPlugin*)plugin.instance)->name = plugin_instance_name;
|
(static_cast<mjCPlugin*>(plugin.instance))->name = plugin_instance_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dispatch
|
// dispatch
|
||||||
@@ -432,7 +432,7 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjsBody* body, char* error, int
|
|||||||
mjtNum t = 1;
|
mjtNum t = 1;
|
||||||
if (dim == 2 && plugin.active) {
|
if (dim == 2 && plugin.active) {
|
||||||
try {
|
try {
|
||||||
mjCPlugin* pplugin = (mjCPlugin*)plugin.instance;
|
mjCPlugin* pplugin = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
t = std::stod(pplugin->config_attribs["thickness"], nullptr);
|
t = std::stod(pplugin->config_attribs["thickness"], nullptr);
|
||||||
} catch (const std::invalid_argument& e) {
|
} catch (const std::invalid_argument& e) {
|
||||||
return comperr(error, "Invalid thickness attribute", error_sz);
|
return comperr(error, "Invalid thickness attribute", error_sz);
|
||||||
@@ -512,9 +512,9 @@ bool mjCComposite::MakeParticle(mjCModel* model, mjsBody* body, char* error, int
|
|||||||
// add plugin
|
// add plugin
|
||||||
if (plugin.active) {
|
if (plugin.active) {
|
||||||
mjsPlugin* pplugin = &b->plugin;
|
mjsPlugin* pplugin = &b->plugin;
|
||||||
mjCPlugin* cplugin = (mjCPlugin*)plugin.instance;
|
mjCPlugin* cplugin = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
pplugin->active = true;
|
pplugin->active = true;
|
||||||
pplugin->instance = (mjElement)plugin.instance;
|
pplugin->instance = plugin.instance;
|
||||||
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
||||||
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
||||||
|
|
||||||
@@ -868,7 +868,7 @@ mjsBody* mjCComposite::AddCableBody(mjCModel* model, mjsBody* body, int ix, mjtN
|
|||||||
if (plugin.active) {
|
if (plugin.active) {
|
||||||
mjsPlugin* pplugin = &body->plugin;
|
mjsPlugin* pplugin = &body->plugin;
|
||||||
pplugin->active = true;
|
pplugin->active = true;
|
||||||
pplugin->instance = (mjElement)plugin.instance;
|
pplugin->instance = plugin.instance;
|
||||||
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
||||||
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
// overwrite plugin name
|
// overwrite plugin name
|
||||||
if (plugin.active && plugin_instance_name.empty()) {
|
if (plugin.active && plugin_instance_name.empty()) {
|
||||||
plugin_instance_name = "flexcomp_" + name;
|
plugin_instance_name = "flexcomp_" + name;
|
||||||
((mjCPlugin*)plugin.instance)->name = plugin_instance_name;
|
static_cast<mjCPlugin*>(plugin.instance)->name = plugin_instance_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create bodies, construct flex vert and vertbody
|
// create bodies, construct flex vert and vertbody
|
||||||
@@ -430,7 +430,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
if (plugin.active) {
|
if (plugin.active) {
|
||||||
mjsPlugin* pplugin = &body->plugin;
|
mjsPlugin* pplugin = &body->plugin;
|
||||||
pplugin->active = true;
|
pplugin->active = true;
|
||||||
pplugin->instance = (mjElement)plugin.instance;
|
pplugin->instance = static_cast<mjElement*>(plugin.instance);
|
||||||
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
||||||
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
||||||
}
|
}
|
||||||
@@ -494,7 +494,7 @@ bool mjCFlexcomp::Make(mjSpec* spec, mjsBody* body, char* error, int error_sz) {
|
|||||||
if (plugin.active) {
|
if (plugin.active) {
|
||||||
mjsPlugin* pplugin = &pb->plugin;
|
mjsPlugin* pplugin = &pb->plugin;
|
||||||
pplugin->active = true;
|
pplugin->active = true;
|
||||||
pplugin->instance = (mjElement)plugin.instance;
|
pplugin->instance = static_cast<mjElement*>(plugin.instance);
|
||||||
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
mjs_setString(pplugin->name, mjs_getString(plugin.name));
|
||||||
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
mjs_setString(pplugin->instance_name, plugin_instance_name.c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-6
@@ -131,6 +131,7 @@ static void ReadFromBuffer(T* dst, const char* src) {
|
|||||||
|
|
||||||
mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) {
|
mjCMesh::mjCMesh(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultMesh(spec);
|
mjs_defaultMesh(spec);
|
||||||
|
elemtype = mjOBJ_MESH;
|
||||||
|
|
||||||
// clear internal variables
|
// clear internal variables
|
||||||
mjuu_setvec(pos_surface_, 0, 0, 0);
|
mjuu_setvec(pos_surface_, 0, 0, 0);
|
||||||
@@ -253,7 +254,7 @@ mjCMesh& mjCMesh::operator=(const mjCMesh& other) {
|
|||||||
this->graph_ = NULL;
|
this->graph_ = NULL;
|
||||||
}
|
}
|
||||||
if (other.plugin.instance) {
|
if (other.plugin.instance) {
|
||||||
mjCPlugin* new_plugin = new mjCPlugin(*reinterpret_cast<mjCPlugin*>(other.plugin.instance));
|
mjCPlugin* new_plugin = new mjCPlugin(*static_cast<mjCPlugin*>(other.plugin.instance));
|
||||||
plugin = new_plugin->spec;
|
plugin = new_plugin->spec;
|
||||||
model->plugins.push_back(new_plugin);
|
model->plugins.push_back(new_plugin);
|
||||||
}
|
}
|
||||||
@@ -265,7 +266,7 @@ mjCMesh& mjCMesh::operator=(const mjCMesh& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCMesh::PointToLocal() {
|
void mjCMesh::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.file = (mjString)&spec_file_;
|
spec.file = (mjString)&spec_file_;
|
||||||
@@ -358,8 +359,9 @@ void mjCMesh::LoadSDF() {
|
|||||||
name.c_str(), id);
|
name.c_str(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
mjCPlugin* plugin_instance = (mjCPlugin*)plugin.instance;
|
mjCPlugin* plugin_instance = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
||||||
|
plugin.instance = plugin_instance;
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
||||||
if (!(pplugin->capabilityflags & mjPLUGIN_SDF)) {
|
if (!(pplugin->capabilityflags & mjPLUGIN_SDF)) {
|
||||||
throw mjCError(this, "plugin '%s' does not support signed distance fields", pplugin->name);
|
throw mjCError(this, "plugin '%s' does not support signed distance fields", pplugin->name);
|
||||||
@@ -2056,6 +2058,7 @@ void mjCMesh::MakeCenter(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCSkin::mjCSkin(mjCModel* _model) {
|
mjCSkin::mjCSkin(mjCModel* _model) {
|
||||||
mjs_defaultSkin(spec);
|
mjs_defaultSkin(spec);
|
||||||
|
elemtype = mjOBJ_SKIN;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -2103,7 +2106,7 @@ mjCSkin& mjCSkin::operator=(const mjCSkin& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCSkin::PointToLocal() {
|
void mjCSkin::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.file = (mjString)&spec_file_;
|
spec.file = (mjString)&spec_file_;
|
||||||
@@ -2480,6 +2483,7 @@ constexpr int eledge[3][6][2] = {{{ 0, 1}, {-1, -1}, {-1, -1},
|
|||||||
// constructor
|
// constructor
|
||||||
mjCFlex::mjCFlex(mjCModel* _model) {
|
mjCFlex::mjCFlex(mjCModel* _model) {
|
||||||
mjs_defaultFlex(spec);
|
mjs_defaultFlex(spec);
|
||||||
|
elemtype = mjOBJ_FLEX;
|
||||||
|
|
||||||
// set model
|
// set model
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -2514,7 +2518,7 @@ mjCFlex& mjCFlex::operator=(const mjCFlex& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCFlex::PointToLocal() {
|
void mjCFlex::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.material = (mjString)&spec_material_;
|
spec.material = (mjString)&spec_material_;
|
||||||
@@ -2756,7 +2760,8 @@ void mjCFlex::Compile(const mjVFS* vfs) {
|
|||||||
|
|
||||||
for (int i=0; i<(int)vertbodyid.size(); i++) {
|
for (int i=0; i<(int)vertbodyid.size(); i++) {
|
||||||
if (model->bodies[vertbodyid[i]]->plugin.instance) {
|
if (model->bodies[vertbodyid[i]]->plugin.instance) {
|
||||||
mjCPlugin* plugin_instance = (mjCPlugin*)model->bodies[vertbodyid[i]]->plugin.instance;
|
mjCPlugin* plugin_instance =
|
||||||
|
static_cast<mjCPlugin*>(model->bodies[vertbodyid[i]]->plugin.instance);
|
||||||
plugin_instance->config_attribs["face"] = userface;
|
plugin_instance->config_attribs["face"] = userface;
|
||||||
plugin_instance->config_attribs["edge"] = useredge;
|
plugin_instance->config_attribs["edge"] = useredge;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ static void copyvec(T1* dest, T2* src, int n) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCModel::mjCModel() {
|
mjCModel::mjCModel() {
|
||||||
mjs_defaultSpec(spec);
|
mjs_defaultSpec(spec);
|
||||||
|
elemtype = mjOBJ_UNKNOWN;
|
||||||
spec_comment_.clear();
|
spec_comment_.clear();
|
||||||
spec_modelfiledir_.clear();
|
spec_modelfiledir_.clear();
|
||||||
spec_meshdir_.clear();
|
spec_meshdir_.clear();
|
||||||
@@ -319,7 +320,7 @@ void mjCModel::CreateObjectLists() {
|
|||||||
|
|
||||||
|
|
||||||
void mjCModel::PointToLocal() {
|
void mjCModel::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.comment = (mjString)&spec_comment_;
|
spec.comment = (mjString)&spec_comment_;
|
||||||
spec.modelfiledir = (mjString)&spec_modelfiledir_;
|
spec.modelfiledir = (mjString)&spec_modelfiledir_;
|
||||||
spec.modelname = (mjString)&spec_modelname_;
|
spec.modelname = (mjString)&spec_modelname_;
|
||||||
@@ -3226,7 +3227,7 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
|||||||
std::vector<std::vector<int>> plugin_to_actuators(nplugin);
|
std::vector<std::vector<int>> plugin_to_actuators(nplugin);
|
||||||
for (int i = 0; i < nu; ++i) {
|
for (int i = 0; i < nu; ++i) {
|
||||||
if (actuators[i]->plugin.active) {
|
if (actuators[i]->plugin.active) {
|
||||||
int actuator_plugin = ((mjCPlugin*)actuators[i]->plugin.instance)->id;
|
int actuator_plugin = static_cast<mjCPlugin*>(actuators[i]->plugin.instance)->id;
|
||||||
m->actuator_plugin[i] = actuator_plugin;
|
m->actuator_plugin[i] = actuator_plugin;
|
||||||
plugin_to_actuators[actuator_plugin].push_back(i);
|
plugin_to_actuators[actuator_plugin].push_back(i);
|
||||||
} else {
|
} else {
|
||||||
@@ -3236,7 +3237,7 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
|||||||
|
|
||||||
for (int i = 0; i < nbody; ++i) {
|
for (int i = 0; i < nbody; ++i) {
|
||||||
if (bodies[i]->plugin.active) {
|
if (bodies[i]->plugin.active) {
|
||||||
m->body_plugin[i] = ((mjCPlugin*)bodies[i]->plugin.instance)->id;
|
m->body_plugin[i] = static_cast<mjCPlugin*>(bodies[i]->plugin.instance)->id;
|
||||||
} else {
|
} else {
|
||||||
m->body_plugin[i] = -1;
|
m->body_plugin[i] = -1;
|
||||||
}
|
}
|
||||||
@@ -3244,7 +3245,7 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
|||||||
|
|
||||||
for (int i = 0; i < ngeom; ++i) {
|
for (int i = 0; i < ngeom; ++i) {
|
||||||
if (geoms[i]->plugin.active) {
|
if (geoms[i]->plugin.active) {
|
||||||
m->geom_plugin[i] = ((mjCPlugin*)geoms[i]->plugin.instance)->id;
|
m->geom_plugin[i] = static_cast<mjCPlugin*>(geoms[i]->plugin.instance)->id;
|
||||||
} else {
|
} else {
|
||||||
m->geom_plugin[i] = -1;
|
m->geom_plugin[i] = -1;
|
||||||
}
|
}
|
||||||
@@ -3253,7 +3254,7 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
|
|||||||
std::vector<std::vector<int>> plugin_to_sensors(nplugin);
|
std::vector<std::vector<int>> plugin_to_sensors(nplugin);
|
||||||
for (int i = 0; i < nsensor; ++i) {
|
for (int i = 0; i < nsensor; ++i) {
|
||||||
if (sensors[i]->type == mjSENS_PLUGIN) {
|
if (sensors[i]->type == mjSENS_PLUGIN) {
|
||||||
int sensor_plugin = ((mjCPlugin*)sensors[i]->plugin.instance)->id;
|
int sensor_plugin = static_cast<mjCPlugin*>(sensors[i]->plugin.instance)->id;
|
||||||
m->sensor_plugin[i] = sensor_plugin;
|
m->sensor_plugin[i] = sensor_plugin;
|
||||||
plugin_to_sensors[sensor_plugin].push_back(i);
|
plugin_to_sensors[sensor_plugin].push_back(i);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
typedef std::map<std::string, int, std::less<> > mjKeyMap;
|
typedef std::map<std::string, int, std::less<> > mjKeyMap;
|
||||||
typedef std::array<mjKeyMap, mjNOBJECT> mjListKeyMap;
|
typedef std::array<mjKeyMap, mjNOBJECT> mjListKeyMap;
|
||||||
|
|
||||||
class mjCModel_ {
|
class mjCModel_ : public mjElement {
|
||||||
public:
|
public:
|
||||||
// attach namespaces
|
// attach namespaces
|
||||||
std::string prefix;
|
std::string prefix;
|
||||||
|
|||||||
+60
-34
@@ -516,7 +516,7 @@ void mjCDef::PointToLocal() {
|
|||||||
equality.PointToLocal();
|
equality.PointToLocal();
|
||||||
tendon.PointToLocal();
|
tendon.PointToLocal();
|
||||||
actuator.PointToLocal();
|
actuator.PointToLocal();
|
||||||
spec.element = (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;
|
||||||
@@ -632,6 +632,7 @@ mjCBody::mjCBody(mjCModel* _model) {
|
|||||||
model = _model;
|
model = _model;
|
||||||
|
|
||||||
mjs_defaultBody(spec);
|
mjs_defaultBody(spec);
|
||||||
|
elemtype = mjOBJ_BODY;
|
||||||
parentid = -1;
|
parentid = -1;
|
||||||
weldid = -1;
|
weldid = -1;
|
||||||
dofnum = 0;
|
dofnum = 0;
|
||||||
@@ -745,7 +746,7 @@ mjCBody& mjCBody::operator+=(mjCBody& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCBody::PointToLocal() {
|
void mjCBody::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.childclass = (mjString)&classname;
|
spec.childclass = (mjString)&classname;
|
||||||
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
||||||
@@ -1337,9 +1338,10 @@ void mjCBody::Compile(void) {
|
|||||||
name.c_str(), id);
|
name.c_str(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
mjCPlugin** plugin_instance = (mjCPlugin**)&plugin.instance;
|
mjCPlugin* plugin_instance = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
model->ResolvePlugin(this, plugin_name, plugin_instance_name, plugin_instance);
|
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot((*plugin_instance)->spec.plugin_slot);
|
plugin.instance = plugin_instance;
|
||||||
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
||||||
if (!(pplugin->capabilityflags & mjPLUGIN_PASSIVE)) {
|
if (!(pplugin->capabilityflags & mjPLUGIN_PASSIVE)) {
|
||||||
throw mjCError(this, "plugin '%s' does not support passive forces", pplugin->name);
|
throw mjCError(this, "plugin '%s' does not support passive forces", pplugin->name);
|
||||||
}
|
}
|
||||||
@@ -1365,6 +1367,7 @@ void mjCBody::Compile(void) {
|
|||||||
// initialize frame
|
// initialize frame
|
||||||
mjCFrame::mjCFrame(mjCModel* _model, mjCFrame* _frame) {
|
mjCFrame::mjCFrame(mjCModel* _model, mjCFrame* _frame) {
|
||||||
mjs_defaultFrame(spec);
|
mjs_defaultFrame(spec);
|
||||||
|
elemtype = mjOBJ_FRAME;
|
||||||
compiled = false;
|
compiled = false;
|
||||||
model = _model;
|
model = _model;
|
||||||
body = NULL;
|
body = NULL;
|
||||||
@@ -1417,7 +1420,7 @@ void mjCFrame::SetParent(mjCBody* _body) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCFrame::PointToLocal() {
|
void mjCFrame::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.childclass = (mjString)&classname;
|
spec.childclass = (mjString)&classname;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
@@ -1461,6 +1464,7 @@ void mjCFrame::Compile() {
|
|||||||
// initialize default joint
|
// initialize default joint
|
||||||
mjCJoint::mjCJoint(mjCModel* _model, mjCDef* _def) {
|
mjCJoint::mjCJoint(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultJoint(spec);
|
mjs_defaultJoint(spec);
|
||||||
|
elemtype = mjOBJ_JOINT;
|
||||||
|
|
||||||
// clear internal variables
|
// clear internal variables
|
||||||
spec_userdata_.clear();
|
spec_userdata_.clear();
|
||||||
@@ -1508,7 +1512,7 @@ bool mjCJoint::is_actfrclimited() const { return islimited(actfrclimited, actfrc
|
|||||||
|
|
||||||
|
|
||||||
void mjCJoint::PointToLocal() {
|
void mjCJoint::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
||||||
@@ -1658,6 +1662,7 @@ int mjCJoint::Compile(void) {
|
|||||||
// initialize default geom
|
// initialize default geom
|
||||||
mjCGeom::mjCGeom(mjCModel* _model, mjCDef* _def) {
|
mjCGeom::mjCGeom(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultGeom(spec);
|
mjs_defaultGeom(spec);
|
||||||
|
elemtype = mjOBJ_GEOM;
|
||||||
|
|
||||||
mass_ = 0;
|
mass_ = 0;
|
||||||
body = 0;
|
body = 0;
|
||||||
@@ -1715,7 +1720,7 @@ mjCGeom& mjCGeom::operator=(const mjCGeom& other) {
|
|||||||
|
|
||||||
// to be called after any default copy constructor
|
// to be called after any default copy constructor
|
||||||
void mjCGeom::PointToLocal(void) {
|
void mjCGeom::PointToLocal(void) {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
@@ -2263,9 +2268,10 @@ void mjCGeom::Compile(void) {
|
|||||||
name.c_str(), id);
|
name.c_str(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
mjCPlugin** plugin_instance = (mjCPlugin**)&plugin.instance;
|
mjCPlugin* plugin_instance = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
model->ResolvePlugin(this, plugin_name, plugin_instance_name, plugin_instance);
|
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot((*plugin_instance)->spec.plugin_slot);
|
plugin.instance = plugin_instance;
|
||||||
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
||||||
if (!(pplugin->capabilityflags & mjPLUGIN_SDF)) {
|
if (!(pplugin->capabilityflags & mjPLUGIN_SDF)) {
|
||||||
throw mjCError(this, "plugin '%s' does not support sign distance fields", pplugin->name);
|
throw mjCError(this, "plugin '%s' does not support sign distance fields", pplugin->name);
|
||||||
}
|
}
|
||||||
@@ -2284,6 +2290,7 @@ void mjCGeom::Compile(void) {
|
|||||||
// initialize default site
|
// initialize default site
|
||||||
mjCSite::mjCSite(mjCModel* _model, mjCDef* _def) {
|
mjCSite::mjCSite(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultSite(spec);
|
mjs_defaultSite(spec);
|
||||||
|
elemtype = mjOBJ_SITE;
|
||||||
|
|
||||||
// clear internal variables
|
// clear internal variables
|
||||||
body = 0;
|
body = 0;
|
||||||
@@ -2328,7 +2335,7 @@ mjCSite& mjCSite::operator=(const mjCSite& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCSite::PointToLocal() {
|
void mjCSite::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
@@ -2440,6 +2447,7 @@ void mjCSite::Compile(void) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCCamera::mjCCamera(mjCModel* _model, mjCDef* _def) {
|
mjCCamera::mjCCamera(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultCamera(spec);
|
mjs_defaultCamera(spec);
|
||||||
|
elemtype = mjOBJ_CAMERA;
|
||||||
|
|
||||||
// clear private variables
|
// clear private variables
|
||||||
body = 0;
|
body = 0;
|
||||||
@@ -2483,7 +2491,7 @@ mjCCamera& mjCCamera::operator=(const mjCCamera& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCCamera::PointToLocal() {
|
void mjCCamera::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
||||||
@@ -2590,6 +2598,7 @@ void mjCCamera::Compile(void) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCLight::mjCLight(mjCModel* _model, mjCDef* _def) {
|
mjCLight::mjCLight(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultLight(spec);
|
mjs_defaultLight(spec);
|
||||||
|
elemtype = mjOBJ_LIGHT;
|
||||||
|
|
||||||
// clear private variables
|
// clear private variables
|
||||||
body = 0;
|
body = 0;
|
||||||
@@ -2630,7 +2639,7 @@ mjCLight& mjCLight::operator=(const mjCLight& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCLight::PointToLocal() {
|
void mjCLight::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.targetbody = (mjString)&spec_targetbody_;
|
spec.targetbody = (mjString)&spec_targetbody_;
|
||||||
@@ -2686,6 +2695,7 @@ void mjCLight::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCHField::mjCHField(mjCModel* _model) {
|
mjCHField::mjCHField(mjCModel* _model) {
|
||||||
mjs_defaultHField(spec);
|
mjs_defaultHField(spec);
|
||||||
|
elemtype = mjOBJ_HFIELD;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -2723,7 +2733,7 @@ mjCHField& mjCHField::operator=(const mjCHField& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCHField::PointToLocal() {
|
void mjCHField::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.file = (mjString)&spec_file_;
|
spec.file = (mjString)&spec_file_;
|
||||||
spec.content_type = (mjString)&spec_content_type_;
|
spec.content_type = (mjString)&spec_content_type_;
|
||||||
@@ -2938,6 +2948,7 @@ void mjCHField::Compile(const mjVFS* vfs) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCTexture::mjCTexture(mjCModel* _model) {
|
mjCTexture::mjCTexture(mjCModel* _model) {
|
||||||
mjs_defaultTexture(spec);
|
mjs_defaultTexture(spec);
|
||||||
|
elemtype = mjOBJ_TEXTURE;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -2979,7 +2990,7 @@ mjCTexture& mjCTexture::operator=(const mjCTexture& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCTexture::PointToLocal() {
|
void mjCTexture::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.file = (mjString)&spec_file_;
|
spec.file = (mjString)&spec_file_;
|
||||||
@@ -3680,6 +3691,7 @@ void mjCTexture::Compile(const mjVFS* vfs) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCMaterial::mjCMaterial(mjCModel* _model, mjCDef* _def) {
|
mjCMaterial::mjCMaterial(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultMaterial(spec);
|
mjs_defaultMaterial(spec);
|
||||||
|
elemtype = mjOBJ_MATERIAL;
|
||||||
|
|
||||||
// clear internal
|
// clear internal
|
||||||
spec_texture_.clear();
|
spec_texture_.clear();
|
||||||
@@ -3722,7 +3734,7 @@ mjCMaterial& mjCMaterial::operator=(const mjCMaterial& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCMaterial::PointToLocal() {
|
void mjCMaterial::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.texture = (mjString)&spec_texture_;
|
spec.texture = (mjString)&spec_texture_;
|
||||||
@@ -3751,6 +3763,7 @@ void mjCMaterial::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCPair::mjCPair(mjCModel* _model, mjCDef* _def) {
|
mjCPair::mjCPair(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultPair(spec);
|
mjs_defaultPair(spec);
|
||||||
|
elemtype = mjOBJ_PAIR;
|
||||||
|
|
||||||
// set defaults
|
// set defaults
|
||||||
spec_geomname1_.clear();
|
spec_geomname1_.clear();
|
||||||
@@ -3800,7 +3813,7 @@ mjCPair& mjCPair::operator=(const mjCPair& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCPair::PointToLocal() {
|
void mjCPair::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.geomname1 = (mjString)&spec_geomname1_;
|
spec.geomname1 = (mjString)&spec_geomname1_;
|
||||||
@@ -4010,7 +4023,7 @@ mjCBodyPair& mjCBodyPair::operator=(const mjCBodyPair& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCBodyPair::PointToLocal() {
|
void mjCBodyPair::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.bodyname1 = (mjString)&spec_bodyname1_;
|
spec.bodyname1 = (mjString)&spec_bodyname1_;
|
||||||
spec.bodyname2 = (mjString)&spec_bodyname2_;
|
spec.bodyname2 = (mjString)&spec_bodyname2_;
|
||||||
@@ -4086,6 +4099,7 @@ void mjCBodyPair::Compile(void) {
|
|||||||
// initialize default constraint
|
// initialize default constraint
|
||||||
mjCEquality::mjCEquality(mjCModel* _model, mjCDef* _def) {
|
mjCEquality::mjCEquality(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultEquality(spec);
|
mjs_defaultEquality(spec);
|
||||||
|
elemtype = mjOBJ_EQUALITY;
|
||||||
|
|
||||||
// clear internal variables
|
// clear internal variables
|
||||||
spec_name1_.clear();
|
spec_name1_.clear();
|
||||||
@@ -4129,7 +4143,7 @@ mjCEquality& mjCEquality::operator=(const mjCEquality& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCEquality::PointToLocal() {
|
void mjCEquality::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.name1 = (mjString)&spec_name1_;
|
spec.name1 = (mjString)&spec_name1_;
|
||||||
@@ -4248,6 +4262,7 @@ void mjCEquality::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCTendon::mjCTendon(mjCModel* _model, mjCDef* _def) {
|
mjCTendon::mjCTendon(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultTendon(spec);
|
mjs_defaultTendon(spec);
|
||||||
|
elemtype = mjOBJ_TENDON;
|
||||||
|
|
||||||
// clear internal variables
|
// clear internal variables
|
||||||
spec_material_.clear();
|
spec_material_.clear();
|
||||||
@@ -4299,7 +4314,7 @@ bool mjCTendon::is_limited() const { return islimited(limited, range); }
|
|||||||
|
|
||||||
|
|
||||||
void mjCTendon::PointToLocal() {
|
void mjCTendon::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.material = (mjString)&spec_material_;
|
spec.material = (mjString)&spec_material_;
|
||||||
@@ -4576,6 +4591,8 @@ void mjCTendon::Compile(void) {
|
|||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
mjCWrap::mjCWrap(mjCModel* _model, mjCTendon* _tendon) {
|
mjCWrap::mjCWrap(mjCModel* _model, mjCTendon* _tendon) {
|
||||||
|
elemtype = mjOBJ_UNKNOWN;
|
||||||
|
|
||||||
// set model and tendon pointer
|
// set model and tendon pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
tendon = _tendon;
|
tendon = _tendon;
|
||||||
@@ -4613,7 +4630,7 @@ mjCWrap& mjCWrap::operator=(const mjCWrap& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCWrap::PointToLocal() {
|
void mjCWrap::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4705,6 +4722,7 @@ void mjCWrap::ResolveReferences(const mjCModel* m) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCActuator::mjCActuator(mjCModel* _model, mjCDef* _def) {
|
mjCActuator::mjCActuator(mjCModel* _model, mjCDef* _def) {
|
||||||
mjs_defaultActuator(spec);
|
mjs_defaultActuator(spec);
|
||||||
|
elemtype = mjOBJ_ACTUATOR;
|
||||||
|
|
||||||
// clear private variables
|
// clear private variables
|
||||||
ptarget = nullptr;
|
ptarget = nullptr;
|
||||||
@@ -4758,7 +4776,7 @@ bool mjCActuator::is_actlimited() const { return islimited(actlimited, actrange)
|
|||||||
|
|
||||||
|
|
||||||
void mjCActuator::PointToLocal() {
|
void mjCActuator::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
||||||
@@ -5032,9 +5050,10 @@ void mjCActuator::Compile(void) {
|
|||||||
name.c_str(), id);
|
name.c_str(), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
mjCPlugin** plugin_instance = (mjCPlugin**)&plugin.instance;
|
mjCPlugin* plugin_instance = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
model->ResolvePlugin(this, plugin_name, plugin_instance_name, plugin_instance);
|
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot((*plugin_instance)->spec.plugin_slot);
|
plugin.instance = plugin_instance;
|
||||||
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
||||||
if (!(pplugin->capabilityflags & mjPLUGIN_ACTUATOR)) {
|
if (!(pplugin->capabilityflags & mjPLUGIN_ACTUATOR)) {
|
||||||
throw mjCError(this, "plugin '%s' does not support actuators", pplugin->name);
|
throw mjCError(this, "plugin '%s' does not support actuators", pplugin->name);
|
||||||
}
|
}
|
||||||
@@ -5048,6 +5067,7 @@ void mjCActuator::Compile(void) {
|
|||||||
// initialize defaults
|
// initialize defaults
|
||||||
mjCSensor::mjCSensor(mjCModel* _model) {
|
mjCSensor::mjCSensor(mjCModel* _model) {
|
||||||
mjs_defaultSensor(spec);
|
mjs_defaultSensor(spec);
|
||||||
|
elemtype = mjOBJ_SENSOR;
|
||||||
|
|
||||||
// set model
|
// set model
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -5090,7 +5110,7 @@ mjCSensor& mjCSensor::operator=(const mjCSensor& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCSensor::PointToLocal() {
|
void mjCSensor::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.classname = (mjString)&classname;
|
spec.classname = (mjString)&classname;
|
||||||
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
spec.userdata = (mjDoubleVec)&spec_userdata_;
|
||||||
@@ -5504,9 +5524,10 @@ void mjCSensor::Compile(void) {
|
|||||||
|
|
||||||
// resolve plugin instance, or create one if using the "plugin" attribute shortcut
|
// resolve plugin instance, or create one if using the "plugin" attribute shortcut
|
||||||
{
|
{
|
||||||
mjCPlugin** plugin_instance = (mjCPlugin**)&plugin.instance;
|
mjCPlugin* plugin_instance = static_cast<mjCPlugin*>(plugin.instance);
|
||||||
model->ResolvePlugin(this, plugin_name, plugin_instance_name, plugin_instance);
|
model->ResolvePlugin(this, plugin_name, plugin_instance_name, &plugin_instance);
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot((*plugin_instance)->spec.plugin_slot);
|
plugin.instance = plugin_instance;
|
||||||
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(plugin_instance->spec.plugin_slot);
|
||||||
if (!(pplugin->capabilityflags & mjPLUGIN_SENSOR)) {
|
if (!(pplugin->capabilityflags & mjPLUGIN_SENSOR)) {
|
||||||
throw mjCError(this, "plugin '%s' does not support sensors", pplugin->name);
|
throw mjCError(this, "plugin '%s' does not support sensors", pplugin->name);
|
||||||
}
|
}
|
||||||
@@ -5534,6 +5555,7 @@ void mjCSensor::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCNumeric::mjCNumeric(mjCModel* _model) {
|
mjCNumeric::mjCNumeric(mjCModel* _model) {
|
||||||
mjs_defaultNumeric(spec);
|
mjs_defaultNumeric(spec);
|
||||||
|
elemtype = mjOBJ_NUMERIC;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -5569,7 +5591,7 @@ mjCNumeric& mjCNumeric::operator=(const mjCNumeric& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCNumeric::PointToLocal() {
|
void mjCNumeric::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.data = (mjDoubleVec)&spec_data_;
|
spec.data = (mjDoubleVec)&spec_data_;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
@@ -5622,6 +5644,7 @@ void mjCNumeric::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCText::mjCText(mjCModel* _model) {
|
mjCText::mjCText(mjCModel* _model) {
|
||||||
mjs_defaultText(spec);
|
mjs_defaultText(spec);
|
||||||
|
elemtype = mjOBJ_TEXT;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -5657,7 +5680,7 @@ mjCText& mjCText::operator=(const mjCText& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCText::PointToLocal() {
|
void mjCText::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.data = (mjString)&spec_data_;
|
spec.data = (mjString)&spec_data_;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
@@ -5698,6 +5721,7 @@ void mjCText::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCTuple::mjCTuple(mjCModel* _model) {
|
mjCTuple::mjCTuple(mjCModel* _model) {
|
||||||
mjs_defaultTuple(spec);
|
mjs_defaultTuple(spec);
|
||||||
|
elemtype = mjOBJ_TUPLE;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -5736,7 +5760,7 @@ mjCTuple& mjCTuple::operator=(const mjCTuple& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCTuple::PointToLocal() {
|
void mjCTuple::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.objtype = (mjIntVec)&spec_objtype_;
|
spec.objtype = (mjIntVec)&spec_objtype_;
|
||||||
spec.objname = (mjStringVec)&spec_objname_;
|
spec.objname = (mjStringVec)&spec_objname_;
|
||||||
@@ -5830,6 +5854,7 @@ void mjCTuple::Compile(void) {
|
|||||||
// constructor
|
// constructor
|
||||||
mjCKey::mjCKey(mjCModel* _model) {
|
mjCKey::mjCKey(mjCModel* _model) {
|
||||||
mjs_defaultKey(spec);
|
mjs_defaultKey(spec);
|
||||||
|
elemtype = mjOBJ_KEY;
|
||||||
|
|
||||||
// set model pointer
|
// set model pointer
|
||||||
model = _model;
|
model = _model;
|
||||||
@@ -5870,7 +5895,7 @@ mjCKey& mjCKey::operator=(const mjCKey& other) {
|
|||||||
|
|
||||||
|
|
||||||
void mjCKey::PointToLocal() {
|
void mjCKey::PointToLocal() {
|
||||||
spec.element = (mjElement)this;
|
spec.element = static_cast<mjElement*>(this);
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.qpos = (mjDoubleVec)&spec_qpos_;
|
spec.qpos = (mjDoubleVec)&spec_qpos_;
|
||||||
spec.qvel = (mjDoubleVec)&spec_qvel_;
|
spec.qvel = (mjDoubleVec)&spec_qvel_;
|
||||||
@@ -6013,6 +6038,7 @@ mjCPlugin::mjCPlugin(mjCModel* _model) {
|
|||||||
|
|
||||||
// public interface
|
// public interface
|
||||||
mjs_defaultPlugin(spec);
|
mjs_defaultPlugin(spec);
|
||||||
|
elemtype = mjOBJ_PLUGIN;
|
||||||
spec.name = (mjString)&name;
|
spec.name = (mjString)&name;
|
||||||
spec.instance_name = (mjString)&instance_name;
|
spec.instance_name = (mjString)&instance_name;
|
||||||
spec.info = (mjString)&info;
|
spec.info = (mjString)&info;
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class mjCBoundingVolumeHierarchy : public mjCBoundingVolumeHierarchy_ {
|
|||||||
//------------------------- class mjCBase ----------------------------------------------------------
|
//------------------------- class mjCBase ----------------------------------------------------------
|
||||||
// Generic functionality for all derived classes
|
// Generic functionality for all derived classes
|
||||||
|
|
||||||
class mjCBase_ {
|
class mjCBase_ : public mjElement {
|
||||||
public:
|
public:
|
||||||
int id; // object id
|
int id; // object id
|
||||||
std::string name; // object name
|
std::string name; // object name
|
||||||
@@ -1606,7 +1606,7 @@ class mjCKey : public mjCKey_, private mjsKey {
|
|||||||
//------------------------- class mjCDef -----------------------------------------------------------
|
//------------------------- class mjCDef -----------------------------------------------------------
|
||||||
// Describes one set of defaults
|
// Describes one set of defaults
|
||||||
|
|
||||||
class mjCDef {
|
class mjCDef : public mjElement {
|
||||||
friend class mjXWriter;
|
friend class mjXWriter;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -739,8 +739,8 @@ void mjXWriter::OnePlugin(XMLElement* elem, mjsPlugin* plugin) {
|
|||||||
} else {
|
} else {
|
||||||
WriteAttrTxt(elem, "plugin", plugin_name);
|
WriteAttrTxt(elem, "plugin", plugin_name);
|
||||||
const mjpPlugin* pplugin = mjp_getPluginAtSlot(
|
const mjpPlugin* pplugin = mjp_getPluginAtSlot(
|
||||||
((mjCPlugin*)plugin->instance)->spec.plugin_slot);
|
static_cast<mjCPlugin*>(plugin->instance)->spec.plugin_slot);
|
||||||
const char* c = &((mjCPlugin*)plugin->instance)->flattened_attributes[0];
|
const char* c = &(static_cast<mjCPlugin*>(plugin->instance)->flattened_attributes[0]);
|
||||||
for (int i = 0; i < pplugin->nattribute; ++i) {
|
for (int i = 0; i < pplugin->nattribute; ++i) {
|
||||||
std::string value(c);
|
std::string value(c);
|
||||||
if (!value.empty()) {
|
if (!value.empty()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user