rename mjspec api structs and functions mjm -> mjs

PiperOrigin-RevId: 618017976
Change-Id: I5f790167e5ca670f8d5f92e8e1c920db8d236144
This commit is contained in:
Yuval Tassa
2024-03-21 18:04:06 -07:00
committed by Copybara-Service
parent f0ad80f268
commit 4660a297d1
22 changed files with 960 additions and 959 deletions
+64 -64
View File
@@ -49,7 +49,7 @@ static T& operator+(T& base, std::string_view suffix) {
// create model
mjSpec* mjm_createSpec() {
mjSpec* mjs_createSpec() {
mjCModel* modelC = new mjCModel;
return &modelC->spec;
}
@@ -57,7 +57,7 @@ mjSpec* mjm_createSpec() {
// copy model
mjSpec* mjm_copySpec(const mjSpec* s) {
mjSpec* mjs_copySpec(const mjSpec* s) {
mjCModel* modelC = new mjCModel(*reinterpret_cast<mjCModel*>(s->element));
return &modelC->spec;
}
@@ -65,7 +65,7 @@ mjSpec* mjm_copySpec(const mjSpec* s) {
// copy back model
void mjm_copyBack(mjSpec* s, const mjModel* m) {
void mjs_copyBack(mjSpec* s, const mjModel* m) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
modelC->CopyBack(m);
}
@@ -73,7 +73,7 @@ void mjm_copyBack(mjSpec* s, const mjModel* m) {
// compile model
mjModel* mjm_compile(mjSpec* s, const mjVFS* vfs) {
mjModel* mjs_compile(mjSpec* s, const mjVFS* vfs) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
return modelC->Compile(vfs);
}
@@ -81,7 +81,7 @@ mjModel* mjm_compile(mjSpec* s, const mjVFS* vfs) {
// attach body to a frame of the parent
int mjm_attachBody(mjmFrame* parent, const mjmBody* child,
int mjs_attachBody(mjsFrame* parent, const mjsBody* child,
const char* prefix, const char* suffix) {
mjCFrame* frame_parent = reinterpret_cast<mjCFrame*>(parent->element);
mjCBody* child_body = reinterpret_cast<mjCBody*>(child->element);
@@ -92,7 +92,7 @@ int mjm_attachBody(mjmFrame* parent, const mjmBody* child,
// get error message from model
const char* mjm_getError(mjSpec* s) {
const char* mjs_getError(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
return modelC->GetError().message;
}
@@ -100,7 +100,7 @@ const char* mjm_getError(mjSpec* s) {
// check if model has warnings
int mjm_isWarning(mjSpec* s) {
int mjs_isWarning(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
return modelC->GetError().warning;
}
@@ -108,7 +108,7 @@ int mjm_isWarning(mjSpec* s) {
// delete model
void mjm_deleteSpec(mjSpec* s) {
void mjs_deleteSpec(mjSpec* s) {
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
delete model;
}
@@ -116,7 +116,7 @@ void mjm_deleteSpec(mjSpec* s) {
// add child body to body, return child spec
mjmBody* mjm_addBody(mjmBody* bodyspec, mjmDefault* defspec) {
mjsBody* mjs_addBody(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element)->AddBody(def);
return &body->spec;
@@ -125,7 +125,7 @@ mjmBody* mjm_addBody(mjmBody* bodyspec, mjmDefault* defspec) {
// add site to body, return site spec
mjmSite* mjm_addSite(mjmBody* bodyspec, mjmDefault* defspec) {
mjsSite* mjs_addSite(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCSite* site = body->AddSite(def);
@@ -135,7 +135,7 @@ mjmSite* mjm_addSite(mjmBody* bodyspec, mjmDefault* defspec) {
// add joint to body
mjmJoint* mjm_addJoint(mjmBody* bodyspec, mjmDefault* defspec) {
mjsJoint* mjs_addJoint(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCJoint* joint = body->AddJoint(def);
@@ -145,7 +145,7 @@ mjmJoint* mjm_addJoint(mjmBody* bodyspec, mjmDefault* defspec) {
// add free joint to body
mjmJoint* mjm_addFreeJoint(mjmBody* bodyspec) {
mjsJoint* mjs_addFreeJoint(mjsBody* bodyspec) {
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCJoint* joint = body->AddFreeJoint();
return &joint->spec;
@@ -154,7 +154,7 @@ mjmJoint* mjm_addFreeJoint(mjmBody* bodyspec) {
// add geom to body
mjmGeom* mjm_addGeom(mjmBody* bodyspec, mjmDefault* defspec) {
mjsGeom* mjs_addGeom(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCGeom* geom = body->AddGeom(def);
@@ -164,7 +164,7 @@ mjmGeom* mjm_addGeom(mjmBody* bodyspec, mjmDefault* defspec) {
// add camera to body
mjmCamera* mjm_addCamera(mjmBody* bodyspec, mjmDefault* defspec) {
mjsCamera* mjs_addCamera(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCCamera* camera = body->AddCamera(def);
@@ -174,7 +174,7 @@ mjmCamera* mjm_addCamera(mjmBody* bodyspec, mjmDefault* defspec) {
// add light to body
mjmLight* mjm_addLight(mjmBody* bodyspec, mjmDefault* defspec) {
mjsLight* mjs_addLight(mjsBody* bodyspec, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCLight* light = body->AddLight(def);
@@ -184,7 +184,7 @@ mjmLight* mjm_addLight(mjmBody* bodyspec, mjmDefault* defspec) {
// add flex to model
mjmFlex* mjm_addFlex(mjSpec* s) {
mjsFlex* mjs_addFlex(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCFlex* flex = modelC->AddFlex();
return &flex->spec;
@@ -193,7 +193,7 @@ mjmFlex* mjm_addFlex(mjSpec* s) {
// add frame to body
mjmFrame* mjm_addFrame(mjmBody* bodyspec, mjmFrame* parentframe) {
mjsFrame* mjs_addFrame(mjsBody* bodyspec, mjsFrame* parentframe) {
mjCFrame* parentframeC = 0;
if (parentframe) {
parentframeC = reinterpret_cast<mjCFrame*>(parentframe->element);
@@ -207,7 +207,7 @@ mjmFrame* mjm_addFrame(mjmBody* bodyspec, mjmFrame* parentframe) {
// add mesh to model
mjmMesh* mjm_addMesh(mjSpec* s, mjmDefault* defspec) {
mjsMesh* mjs_addMesh(mjSpec* s, mjmDefault* defspec) {
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCMesh* mesh = modelC->AddMesh(def);
@@ -217,7 +217,7 @@ mjmMesh* mjm_addMesh(mjSpec* s, mjmDefault* defspec) {
// add height field to model
mjmHField* mjm_addHField(mjSpec* s) {
mjsHField* mjs_addHField(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCHField* heightField = modelC->AddHField();
return &heightField->spec;
@@ -226,7 +226,7 @@ mjmHField* mjm_addHField(mjSpec* s) {
// add skin to model
mjmSkin* mjm_addSkin(mjSpec* s) {
mjsSkin* mjs_addSkin(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCSkin* skin = modelC->AddSkin();
return &skin->spec;
@@ -235,7 +235,7 @@ mjmSkin* mjm_addSkin(mjSpec* s) {
// add texture to model
mjmTexture* mjm_addTexture(mjSpec* s) {
mjsTexture* mjs_addTexture(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCTexture* texture = modelC->AddTexture();
return &texture->spec;
@@ -244,7 +244,7 @@ mjmTexture* mjm_addTexture(mjSpec* s) {
// add material to model
mjmMaterial* mjm_addMaterial(mjSpec* s, mjmDefault* defspec) {
mjsMaterial* mjs_addMaterial(mjSpec* s, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCMaterial* material = modelC->AddMaterial(def);
@@ -254,7 +254,7 @@ mjmMaterial* mjm_addMaterial(mjSpec* s, mjmDefault* defspec) {
// add pair to model
mjmPair* mjm_addPair(mjSpec* s, mjmDefault* defspec) {
mjsPair* mjs_addPair(mjSpec* s, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCPair* pair = modelC->AddPair(def);
@@ -264,7 +264,7 @@ mjmPair* mjm_addPair(mjSpec* s, mjmDefault* defspec) {
// add pair exclusion to model
mjmExclude* mjm_addExclude(mjSpec* s) {
mjsExclude* mjs_addExclude(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCBodyPair* bodypair = modelC->AddExclude();
return &bodypair->spec;
@@ -273,7 +273,7 @@ mjmExclude* mjm_addExclude(mjSpec* s) {
// add equality to model
mjmEquality* mjm_addEquality(mjSpec* s, mjmDefault* defspec) {
mjsEquality* mjs_addEquality(mjSpec* s, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCEquality* equality = modelC->AddEquality(def);
@@ -283,7 +283,7 @@ mjmEquality* mjm_addEquality(mjSpec* s, mjmDefault* defspec) {
// add tendon to model
mjmTendon* mjm_addTendon(mjSpec* s, mjmDefault* defspec) {
mjsTendon* mjs_addTendon(mjSpec* s, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCTendon* tendon = modelC->AddTendon(def);
@@ -293,7 +293,7 @@ mjmTendon* mjm_addTendon(mjSpec* s, mjmDefault* defspec) {
// wrap site using tendon
MJAPI mjmWrap* mjm_wrapSite(mjmTendon* tendonspec, const char* name) {
MJAPI mjsWrap* mjs_wrapSite(mjsTendon* tendonspec, const char* name) {
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
tendon->WrapSite(name);
return &tendon->path.back()->spec;
@@ -302,7 +302,7 @@ MJAPI mjmWrap* mjm_wrapSite(mjmTendon* tendonspec, const char* name) {
// wrap geom using tendon
mjmWrap* mjm_wrapGeom(mjmTendon* 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);
tendon->WrapGeom(name, sidesite);
return &tendon->path.back()->spec;
@@ -311,7 +311,7 @@ mjmWrap* mjm_wrapGeom(mjmTendon* tendonspec, const char* name, const char* sides
// wrap joint using tendon
mjmWrap* mjm_wrapJoint(mjmTendon* tendonspec, const char* name, double coef) {
mjsWrap* mjs_wrapJoint(mjsTendon* tendonspec, const char* name, double coef) {
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
tendon->WrapJoint(name, coef);
return &tendon->path.back()->spec;
@@ -320,7 +320,7 @@ mjmWrap* mjm_wrapJoint(mjmTendon* tendonspec, const char* name, double coef) {
// wrap pulley using tendon
mjmWrap* mjm_wrapPulley(mjmTendon* tendonspec, double divisor) {
mjsWrap* mjs_wrapPulley(mjsTendon* tendonspec, double divisor) {
mjCTendon* tendon = reinterpret_cast<mjCTendon*>(tendonspec->element);
tendon->WrapPulley(divisor);
return &tendon->path.back()->spec;
@@ -329,7 +329,7 @@ mjmWrap* mjm_wrapPulley(mjmTendon* tendonspec, double divisor) {
// add actuator to model
mjmActuator* mjm_addActuator(mjSpec* s, mjmDefault* defspec) {
mjsActuator* mjs_addActuator(mjSpec* s, mjmDefault* defspec) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = defspec ? reinterpret_cast<mjCDef*>(defspec->element) : 0;
mjCActuator* actuator = modelC->AddActuator(def);
@@ -339,7 +339,7 @@ mjmActuator* mjm_addActuator(mjSpec* s, mjmDefault* defspec) {
// add sensor to model
mjmSensor* mjm_addSensor(mjSpec* s) {
mjsSensor* mjs_addSensor(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCSensor* sensor = modelC->AddSensor();
return &sensor->spec;
@@ -348,7 +348,7 @@ mjmSensor* mjm_addSensor(mjSpec* s) {
// add numeric to model
mjmNumeric* mjm_addNumeric(mjSpec* s) {
mjsNumeric* mjs_addNumeric(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCNumeric* numeric = modelC->AddNumeric();
return &numeric->spec;
@@ -357,7 +357,7 @@ mjmNumeric* mjm_addNumeric(mjSpec* s) {
// add text to model
mjmText* mjm_addText(mjSpec* s) {
mjsText* mjs_addText(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCText* text = modelC->AddText();
return &text->spec;
@@ -366,7 +366,7 @@ mjmText* mjm_addText(mjSpec* s) {
// add tuple to model
mjmTuple* mjm_addTuple(mjSpec* s) {
mjsTuple* mjs_addTuple(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCTuple* tuple = modelC->AddTuple();
return &tuple->spec;
@@ -375,7 +375,7 @@ mjmTuple* mjm_addTuple(mjSpec* s) {
// add keyframe to model
mjmKey* mjm_addKey(mjSpec* s) {
mjsKey* mjs_addKey(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCKey* key = modelC->AddKey();
return &key->spec;
@@ -384,7 +384,7 @@ mjmKey* mjm_addKey(mjSpec* s) {
// add plugin to model
mjmPlugin* mjm_addPlugin(mjSpec* s) {
mjsPlugin* mjs_addPlugin(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCPlugin* plugin = modelC->AddPlugin();
plugin->spec.instance = (mjElement)plugin;
@@ -394,7 +394,7 @@ mjmPlugin* mjm_addPlugin(mjSpec* s) {
// add default to model
mjmDefault* mjm_addDefault(mjSpec* s, const char* classname, int parentid, int* id) {
mjmDefault* mjs_addDefault(mjSpec* s, const char* classname, int parentid, int* id) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
*id = (int)modelC->defaults.size();
mjCDef* def = modelC->AddDef(classname, parentid);
@@ -408,21 +408,21 @@ mjmDefault* mjm_addDefault(mjSpec* s, const char* classname, int parentid, int*
// get objects
mjSpec* mjm_getSpec(mjmBody* body) {
mjSpec* mjs_getSpec(mjsBody* body) {
return &(reinterpret_cast<mjCBody*>(body->element)->model->spec);
}
// get default
mjmDefault* mjm_getDefault(mjElement element) {
mjmDefault* mjs_getDefault(mjElement element) {
return &(reinterpret_cast<mjCBase*>(element)->def->spec);
}
// Find default with given name in model.
mjmDefault* mjm_findDefault(mjSpec* s, const char* classname) {
mjmDefault* mjs_findDefault(mjSpec* s, const char* classname) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* cdef = modelC->FindDef(classname);
if (!cdef) {
@@ -434,7 +434,7 @@ mjmDefault* mjm_findDefault(mjSpec* s, const char* classname) {
// get default[0] from model
mjmDefault* mjm_getSpecDefault(mjSpec* s) {
mjmDefault* mjs_getSpecDefault(mjSpec* s) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
mjCDef* def = modelC->defaults[0];
if (!def) {
@@ -446,7 +446,7 @@ mjmDefault* mjm_getSpecDefault(mjSpec* s) {
// find body in model by name
mjmBody* mjm_findBody(mjSpec* s, const char* name) {
mjsBody* mjs_findBody(mjSpec* s, const char* name) {
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
mjCBase* body = 0;
if (model->IsCompiled()) {
@@ -460,7 +460,7 @@ mjmBody* mjm_findBody(mjSpec* s, const char* name) {
// find child of a body by name
mjmBody* mjm_findChild(mjmBody* bodyspec, const char* name) {
mjsBody* mjs_findChild(mjsBody* bodyspec, const char* name) {
mjCBody* body = reinterpret_cast<mjCBody*>(bodyspec->element);
mjCBase* child = body->FindObject(mjOBJ_BODY, std::string(name));
return child ? &(static_cast<mjCBody*>(child)->spec) : nullptr;
@@ -469,7 +469,7 @@ mjmBody* mjm_findChild(mjmBody* bodyspec, const char* name) {
// find mesh by name
mjmMesh* mjm_findMesh(mjSpec* s, const char* name) {
mjsMesh* mjs_findMesh(mjSpec* s, const char* name) {
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, std::string(name));
return mesh ? &(static_cast<mjCMesh*>(mesh)->spec) : nullptr;
@@ -478,7 +478,7 @@ mjmMesh* mjm_findMesh(mjSpec* s, const char* name) {
// find frame by name
mjmFrame* mjm_findFrame(mjSpec* s, const char* name) {
mjsFrame* mjs_findFrame(mjSpec* s, const char* name) {
mjCModel* model = reinterpret_cast<mjCModel*>(s->element);
mjCFrame* frame = (mjCFrame*)model->FindFrame(model->GetWorld(), std::string(name));
return frame ? &(static_cast<mjCFrame*>(frame)->spec) : nullptr;
@@ -487,7 +487,7 @@ mjmFrame* mjm_findFrame(mjSpec* s, const char* name) {
// set frame
void mjm_setFrame(mjElement dest, mjmFrame* frame) {
void mjs_setFrame(mjElement dest, mjsFrame* frame) {
if (!frame) {
return;
}
@@ -499,14 +499,14 @@ void mjm_setFrame(mjElement dest, mjmFrame* frame) {
// get id
int mjm_getId(mjElement element) {
int mjs_getId(mjElement element) {
return reinterpret_cast<mjCBase*>(element)->id;
}
// set default
void mjm_setDefault(mjElement element, mjmDefault* defspec) {
void mjs_setDefault(mjElement element, mjmDefault* defspec) {
mjCBase* baseC = reinterpret_cast<mjCBase*>(element);
baseC->def = reinterpret_cast<mjCDef*>(defspec->element);
}
@@ -514,7 +514,7 @@ void mjm_setDefault(mjElement element, mjmDefault* defspec) {
// set string
void mjm_setString(mjString dest, const char* text) {
void mjs_setString(mjString dest, const char* text) {
std::string* str = reinterpret_cast<std::string*>(dest);
*str = std::string(text);
}
@@ -522,10 +522,10 @@ void mjm_setString(mjString dest, const char* text) {
// Set specific entry in destination string vector.
mjtByte mjm_setInStringVec(mjStringVec dest, int i, const char* text) {
mjtByte mjs_setInStringVec(mjStringVec dest, int i, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest);
if (v->size() <= i) {
mju_error("Requested index in mjm_setInStringVec is out of bounds");
mju_error("Requested index in mjs_setInStringVec is out of bounds");
return 0;
}
v->at(i) = std::string(text);
@@ -535,7 +535,7 @@ mjtByte mjm_setInStringVec(mjStringVec dest, int i, const char* text) {
// split text and copy into string array
void mjm_setStringVec(mjStringVec dest, const char* text) {
void mjs_setStringVec(mjStringVec dest, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest);
*v = mjXUtil::String2Vector<std::string>(text);
}
@@ -543,14 +543,14 @@ void mjm_setStringVec(mjStringVec dest, const char* text) {
// add text entry to destination string vector
void mjm_appendString(mjStringVec dest, const char* text) {
void mjs_appendString(mjStringVec dest, const char* text) {
std::vector<std::string>* v = reinterpret_cast<std::vector<std::string>*>(dest);
v->push_back(std::string(text));
}
// copy int array to vector
void mjm_setInt(mjIntVec dest, const int* array, int size) {
void mjs_setInt(mjIntVec dest, const int* array, int size) {
std::vector<int>* v = reinterpret_cast<std::vector<int>*>(dest);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) {
@@ -561,7 +561,7 @@ void mjm_setInt(mjIntVec dest, const int* array, int size) {
// append int array to vector of arrays
void mjm_appendIntVec(mjIntVecVec dest, const int* array, int size) {
void mjs_appendIntVec(mjIntVecVec dest, const int* array, int size) {
std::vector<std::vector<int>>* v = reinterpret_cast<std::vector<std::vector<int>>*>(dest);
v->push_back(std::vector<int>(array, array + size));
}
@@ -569,7 +569,7 @@ void mjm_appendIntVec(mjIntVecVec dest, const int* array, int size) {
// copy float array to vector
void mjm_setFloat(mjFloatVec dest, const float* array, int size) {
void mjs_setFloat(mjFloatVec dest, const float* array, int size) {
std::vector<float>* v = reinterpret_cast<std::vector<float>*>(dest);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) {
@@ -581,7 +581,7 @@ void mjm_setFloat(mjFloatVec dest, const float* array, int size) {
// append float array to vector of arrays
void mjm_appendFloatVec(mjFloatVecVec dest, const float* array, int size) {
void mjs_appendFloatVec(mjFloatVecVec dest, const float* array, int size) {
std::vector<std::vector<float>>* v = reinterpret_cast<std::vector<std::vector<float>>*>(dest);
v->push_back(std::vector<float>(array, array + size));
}
@@ -589,7 +589,7 @@ void mjm_appendFloatVec(mjFloatVecVec dest, const float* array, int size) {
// copy double array to vector
void mjm_setDouble(mjDoubleVec dest, const double* array, int size) {
void mjs_setDouble(mjDoubleVec dest, const double* array, int size) {
std::vector<double>* v = reinterpret_cast<std::vector<double>*>(dest);
v->assign(size, 0.0);
for (int i = 0; i < size; ++i) {
@@ -600,7 +600,7 @@ void mjm_setDouble(mjDoubleVec dest, const double* array, int size) {
// get string
const char* mjm_getString(const mjString source) {
const char* mjs_getString(const mjString source) {
std::string* str = reinterpret_cast<std::string*>(source);
if (!str) {
return nullptr;
@@ -611,7 +611,7 @@ const char* mjm_getString(const mjString source) {
// get double array
const double* mjm_getDouble(const mjDoubleVec source, int* size) {
const double* mjs_getDouble(const mjDoubleVec source, int* size) {
std::vector<double>* v = reinterpret_cast<std::vector<double>*>(source);
if (size) {
*size = v->size();
@@ -622,7 +622,7 @@ const double* mjm_getDouble(const mjDoubleVec source, int* size) {
// set plugin attributes
void mjm_setPluginAttributes(mjmPlugin* plugin, void* attributes) {
void mjs_setPluginAttributes(mjsPlugin* plugin, void* attributes) {
mjCPlugin* pluginC = reinterpret_cast<mjCPlugin*>(plugin->instance);
std::map<std::string, std::string, std::less<>>* config_attribs =
reinterpret_cast<std::map<std::string, std::string, std::less<>>*>(attributes);
@@ -632,7 +632,7 @@ void mjm_setPluginAttributes(mjmPlugin* plugin, void* attributes) {
// Set active plugins.
void mjm_setActivePlugins(mjSpec* s, void* activeplugins) {
void mjs_setActivePlugins(mjSpec* s, void* activeplugins) {
mjCModel* modelC = reinterpret_cast<mjCModel*>(s->element);
std::vector<std::pair<const mjpPlugin*, int>>* active_plugins =
reinterpret_cast<std::vector<std::pair<const mjpPlugin*, int>>*>(activeplugins);
@@ -642,7 +642,7 @@ void mjm_setActivePlugins(mjSpec* s, void* activeplugins) {
// compute full inertia
const char* mjm_setFullInertia(mjmBody* 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);
return body->FullInertia(quat, inertia);
}