diff --git a/src/user/user_api.cc b/src/user/user_api.cc index 6a78ad3b..cfe108a0 100644 --- a/src/user/user_api.cc +++ b/src/user/user_api.cc @@ -27,7 +27,7 @@ // create model -mjmModel* mjm_createModel() { +mjSpec* mjm_createModel() { mjCModel* modelC = new mjCModel; return &modelC->spec; } @@ -35,40 +35,40 @@ mjmModel* mjm_createModel() { // copy back model -void mjm_copyBack(mjmModel* model, const mjModel* m) { - mjCModel* modelC = reinterpret_cast(model->element); +void mjm_copyBack(mjSpec* s, const mjModel* m) { + mjCModel* modelC = reinterpret_cast(s->element); modelC->CopyBack(m); } // compile model -mjModel* mjm_compileModel(mjmModel* model, const mjVFS* vfs) { - mjCModel* modelC = reinterpret_cast(model->element); +mjModel* mjm_compileModel(mjSpec* s, const mjVFS* vfs) { + mjCModel* modelC = reinterpret_cast(s->element); return modelC->Compile(vfs); } // get error message from model -const char* mjm_getError(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +const char* mjm_getError(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); return modelC->GetError().message; } // check if model has warnings -int mjm_isWarning(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +int mjm_isWarning(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); return modelC->GetError().warning; } // delete model -void mjm_deleteModel(mjmModel* modelspec) { - mjCModel* model = reinterpret_cast(modelspec->element); +void mjm_deleteModel(mjSpec* s) { + mjCModel* model = reinterpret_cast(s->element); delete model; } @@ -143,8 +143,8 @@ mjmLight* mjm_addLight(mjmBody* bodyspec, mjmDefault* defspec) { // add flex to model -mjmFlex* mjm_addFlex(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmFlex* mjm_addFlex(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCFlex* flex = modelC->AddFlex(); return &flex->spec; } @@ -165,9 +165,9 @@ mjmFrame* mjm_addFrame(mjmBody* bodyspec, mjmFrame* parentframe) { // add mesh to model -mjmMesh* mjm_addMesh(mjmModel* model, mjmDefault* defspec) { +mjmMesh* mjm_addMesh(mjSpec* s, mjmDefault* defspec) { mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; - mjCModel* modelC = reinterpret_cast(model->element); + mjCModel* modelC = reinterpret_cast(s->element); mjCMesh* mesh = modelC->AddMesh(def); return &mesh->spec; } @@ -175,8 +175,8 @@ mjmMesh* mjm_addMesh(mjmModel* model, mjmDefault* defspec) { // add height field to model -mjmHField* mjm_addHField(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmHField* mjm_addHField(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCHField* heightField = modelC->AddHField(); return &heightField->spec; } @@ -184,8 +184,8 @@ mjmHField* mjm_addHField(mjmModel* model) { // add skin to model -mjmSkin* mjm_addSkin(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmSkin* mjm_addSkin(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCSkin* skin = modelC->AddSkin(); return &skin->spec; } @@ -193,8 +193,8 @@ mjmSkin* mjm_addSkin(mjmModel* model) { // add texture to model -mjmTexture* mjm_addTexture(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmTexture* mjm_addTexture(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCTexture* texture = modelC->AddTexture(); return &texture->spec; } @@ -202,8 +202,8 @@ mjmTexture* mjm_addTexture(mjmModel* model) { // add material to model -mjmMaterial* mjm_addMaterial(mjmModel* model, mjmDefault* defspec) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmMaterial* mjm_addMaterial(mjSpec* s, mjmDefault* defspec) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; mjCMaterial* material = modelC->AddMaterial(def); return &material->spec; @@ -212,8 +212,8 @@ mjmMaterial* mjm_addMaterial(mjmModel* model, mjmDefault* defspec) { // add pair to model -mjmPair* mjm_addPair(mjmModel* model, mjmDefault* defspec) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmPair* mjm_addPair(mjSpec* s, mjmDefault* defspec) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; mjCPair* pair = modelC->AddPair(def); return &pair->spec; @@ -222,8 +222,8 @@ mjmPair* mjm_addPair(mjmModel* model, mjmDefault* defspec) { // add pair exclusion to model -mjmExclude* mjm_addExclude(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmExclude* mjm_addExclude(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCBodyPair* bodypair = modelC->AddExclude(); return &bodypair->spec; } @@ -231,8 +231,8 @@ mjmExclude* mjm_addExclude(mjmModel* model) { // add equality to model -mjmEquality* mjm_addEquality(mjmModel* model, mjmDefault* defspec) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmEquality* mjm_addEquality(mjSpec* s, mjmDefault* defspec) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; mjCEquality* equality = modelC->AddEquality(def); return &equality->spec; @@ -241,8 +241,8 @@ mjmEquality* mjm_addEquality(mjmModel* model, mjmDefault* defspec) { // add tendon to model -mjmTendon* mjm_addTendon(mjmModel* model, mjmDefault* defspec) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmTendon* mjm_addTendon(mjSpec* s, mjmDefault* defspec) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; mjCTendon* tendon = modelC->AddTendon(def); return &tendon->spec; @@ -287,8 +287,8 @@ mjmWrap* mjm_wrapPulley(mjmTendon* tendonspec, double divisor) { // add actuator to model -mjmActuator* mjm_addActuator(mjmModel* model, mjmDefault* defspec) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmActuator* mjm_addActuator(mjSpec* s, mjmDefault* defspec) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = defspec ? reinterpret_cast(defspec->element) : 0; mjCActuator* actuator = modelC->AddActuator(def); return &actuator->spec; @@ -297,8 +297,8 @@ mjmActuator* mjm_addActuator(mjmModel* model, mjmDefault* defspec) { // add sensor to model -mjmSensor* mjm_addSensor(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmSensor* mjm_addSensor(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCSensor* sensor = modelC->AddSensor(); return &sensor->spec; } @@ -306,8 +306,8 @@ mjmSensor* mjm_addSensor(mjmModel* model) { // add numeric to model -mjmNumeric* mjm_addNumeric(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmNumeric* mjm_addNumeric(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCNumeric* numeric = modelC->AddNumeric(); return &numeric->spec; } @@ -315,8 +315,8 @@ mjmNumeric* mjm_addNumeric(mjmModel* model) { // add text to model -mjmText* mjm_addText(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmText* mjm_addText(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCText* text = modelC->AddText(); return &text->spec; } @@ -324,8 +324,8 @@ mjmText* mjm_addText(mjmModel* model) { // add tuple to model -mjmTuple* mjm_addTuple(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmTuple* mjm_addTuple(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCTuple* tuple = modelC->AddTuple(); return &tuple->spec; } @@ -333,8 +333,8 @@ mjmTuple* mjm_addTuple(mjmModel* model) { // add keyframe to model -mjmKey* mjm_addKey(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmKey* mjm_addKey(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCKey* key = modelC->AddKey(); return &key->spec; } @@ -342,8 +342,8 @@ mjmKey* mjm_addKey(mjmModel* model) { // add plugin to model -mjmPlugin* mjm_addPlugin(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmPlugin* mjm_addPlugin(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCPlugin* plugin = modelC->AddPlugin(); plugin->spec.instance = (mjElement)plugin; return &plugin->spec; @@ -352,8 +352,8 @@ mjmPlugin* mjm_addPlugin(mjmModel* model) { // add default to model -mjmDefault* mjm_addDefault(mjmModel* model, const char* classname, int parentid, int* id) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmDefault* mjm_addDefault(mjSpec* s, const char* classname, int parentid, int* id) { + mjCModel* modelC = reinterpret_cast(s->element); *id = (int)modelC->defaults.size(); mjCDef* def = modelC->AddDef(classname, parentid); if (def) { @@ -366,8 +366,8 @@ mjmDefault* mjm_addDefault(mjmModel* model, const char* classname, int parentid, // get objects -mjmModel* mjm_getModel(mjmBody* bodyspec) { - return &(reinterpret_cast(bodyspec->element)->model->spec); +mjSpec* mjm_getSpec(mjmBody* body) { + return &(reinterpret_cast(body->element)->model->spec); } @@ -380,8 +380,8 @@ mjmDefault* mjm_getDefault(mjElement element) { // Find default with given name in model. -mjmDefault* mjm_findDefault(mjmModel* model, const char* classname) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmDefault* mjm_findDefault(mjSpec* s, const char* classname) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* cdef = modelC->FindDef(classname); if (!cdef) { return nullptr; @@ -392,8 +392,8 @@ mjmDefault* mjm_findDefault(mjmModel* model, const char* classname) { // get default[0] from model -mjmDefault* mjm_getModelDefault(mjmModel* model) { - mjCModel* modelC = reinterpret_cast(model->element); +mjmDefault* mjm_getModelDefault(mjSpec* s) { + mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = modelC->defaults[0]; if (!def) { return nullptr; @@ -404,8 +404,8 @@ mjmDefault* mjm_getModelDefault(mjmModel* model) { // find body in model by name -mjmBody* mjm_findBody(mjmModel* modelspec, const char* name) { - mjCModel* model = reinterpret_cast(modelspec->element); +mjmBody* mjm_findBody(mjSpec* s, const char* name) { + mjCModel* model = reinterpret_cast(s->element); mjCBase* body = model->FindObject(mjOBJ_BODY, std::string(name)); if (!body) { return 0; @@ -428,8 +428,8 @@ mjmBody* mjm_findChild(mjmBody* bodyspec, const char* name) { // find mesh by name -mjmMesh* mjm_findMesh(mjmModel* modelspec, const char* name) { - mjCModel* model = reinterpret_cast(modelspec->element); +mjmMesh* mjm_findMesh(mjSpec* s, const char* name) { + mjCModel* model = reinterpret_cast(s->element); mjCMesh* mesh = (mjCMesh*)model->FindObject(mjOBJ_MESH, std::string(name)); if (!mesh) { return nullptr; @@ -585,8 +585,8 @@ void mjm_setPluginAttributes(mjmPlugin* plugin, void* attributes) { // Set active plugins. -void mjm_setActivePlugins(mjmModel* model, void* activeplugins) { - mjCModel* modelC = reinterpret_cast(model->element); +void mjm_setActivePlugins(mjSpec* s, void* activeplugins) { + mjCModel* modelC = reinterpret_cast(s->element); std::vector>* active_plugins = reinterpret_cast>*>(activeplugins); modelC->active_plugins = std::move(*active_plugins); diff --git a/src/user/user_api.h b/src/user/user_api.h index 18aa2cb1..421cab7a 100644 --- a/src/user/user_api.h +++ b/src/user/user_api.h @@ -79,7 +79,7 @@ typedef enum _mjtInertiaFromGeom { //---------------------------------- attribute structs (mjm) --------------------------------------- -typedef struct _mjmModel { // model specification +typedef struct _mjSpec { // model specification mjElement element; // internal, do not modify mjStatistic stat; // statistics override (if defined) @@ -132,7 +132,7 @@ typedef struct _mjmModel { // model specification // other bool hasImplicitPluginElem; // already encountered an implicit plugin sensor/actuator -} mjmModel; +} mjSpec; typedef struct _mjmOrientation { // alternative orientation specifiers @@ -727,22 +727,22 @@ typedef struct _mjmDefault { // default specification //---------------------------------- API functions ------------------------------------------------- // Create model. -MJAPI mjmModel* mjm_createModel(); +MJAPI mjSpec* mjm_createModel(); // Copy back model. -MJAPI void mjm_copyBack(mjmModel* model, const mjModel* m); +MJAPI void mjm_copyBack(mjSpec* s, const mjModel* m); // Compile model. -MJAPI mjModel* mjm_compileModel(mjmModel* model, const mjVFS* vfs); +MJAPI mjModel* mjm_compileModel(mjSpec* s, const mjVFS* vfs); // Get error message from model. -MJAPI const char* mjm_getError(mjmModel* model); +MJAPI const char* mjm_getError(mjSpec* s); // Return 1 if model has warnings. -MJAPI int mjm_isWarning(mjmModel* model); +MJAPI int mjm_isWarning(mjSpec* s); // Delete model. -MJAPI void mjm_deleteModel(mjmModel* modelspec); +MJAPI void mjm_deleteModel(mjSpec* s); // Add child body to body, return child spec. MJAPI mjmBody* mjm_addBody(mjmBody* body, mjmDefault* def); @@ -769,34 +769,34 @@ MJAPI mjmLight* mjm_addLight(mjmBody* body, mjmDefault* def); MJAPI mjmFrame* mjm_addFrame(mjmBody* body, mjmFrame* parentframe); // Add flex to model. -MJAPI mjmFlex* mjm_addFlex(mjmModel* model); +MJAPI mjmFlex* mjm_addFlex(mjSpec* s); // Add mesh to model. -MJAPI mjmMesh* mjm_addMesh(mjmModel* model, mjmDefault* def); +MJAPI mjmMesh* mjm_addMesh(mjSpec* s, mjmDefault* def); // Add height field to model. -MJAPI mjmHField* mjm_addHField(mjmModel* model); +MJAPI mjmHField* mjm_addHField(mjSpec* s); // Add skin to model. -MJAPI mjmSkin* mjm_addSkin(mjmModel* model); +MJAPI mjmSkin* mjm_addSkin(mjSpec* s); // Add texture to model. -MJAPI mjmTexture* mjm_addTexture(mjmModel* model); +MJAPI mjmTexture* mjm_addTexture(mjSpec* s); // Add material to model. -MJAPI mjmMaterial* mjm_addMaterial(mjmModel* model, mjmDefault* def); +MJAPI mjmMaterial* mjm_addMaterial(mjSpec* s, mjmDefault* def); // Add pair to model. -MJAPI mjmPair* mjm_addPair(mjmModel* model, mjmDefault* def); +MJAPI mjmPair* mjm_addPair(mjSpec* s, mjmDefault* def); // Add excluded body pair to model. -MJAPI mjmExclude* mjm_addExclude(mjmModel *model); +MJAPI mjmExclude* mjm_addExclude(mjSpec *model); // Add equality to model. -MJAPI mjmEquality* mjm_addEquality(mjmModel* model, mjmDefault* def); +MJAPI mjmEquality* mjm_addEquality(mjSpec* s, mjmDefault* def); // Add tendon to model. -MJAPI mjmTendon* mjm_addTendon(mjmModel* model, mjmDefault* def); +MJAPI mjmTendon* mjm_addTendon(mjSpec* s, mjmDefault* def); // Wrap site using tendon. MJAPI mjmWrap* mjm_wrapSite(mjmTendon* tendon, const char* name); @@ -811,49 +811,49 @@ MJAPI mjmWrap* mjm_wrapJoint(mjmTendon* tendon, const char* name, double coef); MJAPI mjmWrap* mjm_wrapPulley(mjmTendon* tendon, double divisor); // Add actuator to model. -MJAPI mjmActuator* mjm_addActuator(mjmModel* model, mjmDefault* def); +MJAPI mjmActuator* mjm_addActuator(mjSpec* s, mjmDefault* def); // Add sensor to model. -MJAPI mjmSensor* mjm_addSensor(mjmModel* model); +MJAPI mjmSensor* mjm_addSensor(mjSpec* s); // Add numeric to model. -MJAPI mjmNumeric* mjm_addNumeric(mjmModel* model); +MJAPI mjmNumeric* mjm_addNumeric(mjSpec* s); // Add text to model. -MJAPI mjmText* mjm_addText(mjmModel* model); +MJAPI mjmText* mjm_addText(mjSpec* s); // Add tuple to model. -MJAPI mjmTuple* mjm_addTuple(mjmModel* model); +MJAPI mjmTuple* mjm_addTuple(mjSpec* s); // Add keyframe to model. -MJAPI mjmKey* mjm_addKey(mjmModel* model); +MJAPI mjmKey* mjm_addKey(mjSpec* s); // Add plugin to model. -MJAPI mjmPlugin* mjm_addPlugin(mjmModel* model); +MJAPI mjmPlugin* mjm_addPlugin(mjSpec* s); // Add default to model. -MJAPI mjmDefault* mjm_addDefault(mjmModel* model, const char* classname, int parentid, int* id); +MJAPI mjmDefault* mjm_addDefault(mjSpec* s, const char* classname, int parentid, int* id); -// Get model from body. -MJAPI mjmModel* mjm_getModel(mjmBody* body); +// Get model spec from body. +MJAPI mjSpec* mjm_getSpec(mjmBody* body); // Get default corresponding to an mjElement. MJAPI mjmDefault* mjm_getDefault(mjElement element); // Find default in model by class name. -MJAPI mjmDefault* mjm_findDefault(mjmModel* model, const char* classname); +MJAPI mjmDefault* mjm_findDefault(mjSpec* s, const char* classname); // Get global default from model. -MJAPI mjmDefault* mjm_getModelDefault(mjmModel* model); +MJAPI mjmDefault* mjm_getModelDefault(mjSpec* s); // Find body in model by name. -MJAPI mjmBody* mjm_findBody(mjmModel* model, const char* name); +MJAPI mjmBody* mjm_findBody(mjSpec* s, const char* name); // Find child body by name. MJAPI mjmBody* mjm_findChild(mjmBody* body, const char* name); // Find mesh by name. -MJAPI mjmMesh* mjm_findMesh(mjmModel* model, const char* name); +MJAPI mjmMesh* mjm_findMesh(mjSpec* s, const char* name); // Get element id. MJAPI int mjm_getId(mjElement element); @@ -895,7 +895,7 @@ MJAPI const double* mjm_getDouble(mjDoubleVec source, int* size); MJAPI void mjm_setPluginAttributes(mjmPlugin* plugin, void* attributes); // Set active plugins. -MJAPI void mjm_setActivePlugins(mjmModel* model, void* activeplugins); +MJAPI void mjm_setActivePlugins(mjSpec* s, void* activeplugins); // Set default. MJAPI void mjm_setDefault(mjElement element, mjmDefault* def); @@ -910,7 +910,7 @@ MJAPI const char* mjm_setFullInertia(mjmBody* body, double quat[4], double inert //---------------------------------- Initialization functions -------------------------------------- // Default model attributes. -MJAPI void mjm_defaultModel(mjmModel& model); +MJAPI void mjm_defaultModel(mjSpec& model); // Default body attributes. MJAPI void mjm_defaultBody(mjmBody& body); diff --git a/src/user/user_composite.cc b/src/user/user_composite.cc index fd43b916..ca5026dd 100644 --- a/src/user/user_composite.cc +++ b/src/user/user_composite.cc @@ -223,7 +223,7 @@ void mjCComposite::SetDefault(void) { // make composite object -bool mjCComposite::Make(mjmModel* modelspec, mjmBody* body, char* error, int error_sz) { +bool mjCComposite::Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz) { mjCModel* model = (mjCModel*)modelspec->element; // check geom type diff --git a/src/user/user_composite.h b/src/user/user_composite.h index e2f4c350..bd8afc56 100644 --- a/src/user/user_composite.h +++ b/src/user/user_composite.h @@ -69,7 +69,7 @@ class mjCComposite { bool AddDefaultJoint(char* error = NULL, int error_sz = 0); void AdjustSoft(mjtNum* solref, mjtNum* solimp, int level); - bool Make(mjmModel* modelspec, mjmBody* body, char* error, int error_sz); + bool Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz); bool MakeParticle(mjCModel* model, mjmBody* body, char* error, int error_sz); bool MakeGrid(mjCModel* model, mjmBody* body, char* error, int error_sz); diff --git a/src/user/user_flexcomp.cc b/src/user/user_flexcomp.cc index 641631b1..089b6f43 100644 --- a/src/user/user_flexcomp.cc +++ b/src/user/user_flexcomp.cc @@ -82,7 +82,7 @@ mjCFlexcomp::mjCFlexcomp(void) { // make flexcomp object -bool mjCFlexcomp::Make(mjmModel* modelspec, mjmBody* body, char* error, int error_sz) { +bool mjCFlexcomp::Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz) { mjCModel* model = (mjCModel*)modelspec->element; mjmFlex* dflex = def.spec.flex; int dim = dflex->dim; diff --git a/src/user/user_flexcomp.h b/src/user/user_flexcomp.h index c8f07a4a..e7bef13c 100644 --- a/src/user/user_flexcomp.h +++ b/src/user/user_flexcomp.h @@ -42,7 +42,7 @@ typedef enum _mjtFcompType { class mjCFlexcomp { public: mjCFlexcomp(void); - bool Make(mjmModel* modelspec, mjmBody* body, char* error, int error_sz); + bool Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz); bool MakeGrid(char* error, int error_sz); bool MakeBox(char* error, int error_sz); diff --git a/src/user/user_init.cc b/src/user/user_init.cc index 2f0d4ecd..72dba6a6 100644 --- a/src/user/user_init.cc +++ b/src/user/user_init.cc @@ -22,8 +22,8 @@ // default model attributes -void mjm_defaultModel(mjmModel& model) { - memset(&model, 0, sizeof(mjmModel)); +void mjm_defaultModel(mjSpec& model) { + memset(&model, 0, sizeof(mjSpec)); // default statistics model.stat.meaninertia = mjNAN; diff --git a/src/user/user_model.cc b/src/user/user_model.cc index 054eb4db..a8657627 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -193,7 +193,7 @@ void mjCModel::PointToLocal() { void mjCModel::CopyFromSpec() { - *static_cast(this) = spec; + *static_cast(this) = spec; comment_ = spec_comment_; modelfiledir_ = spec_modelfiledir_; modelname_ = spec_modelname_; diff --git a/src/user/user_model.h b/src/user/user_model.h index c23cb38d..6aceefc4 100644 --- a/src/user/user_model.h +++ b/src/user/user_model.h @@ -39,7 +39,7 @@ typedef std::array mjListKeyMap; // by loading an XML file via mjCXML. Once an mjCModel object is // constructed, 'Compile' can be called to generate the corresponding mjModel object // (which is the low-level model). The mjCModel object can then be deleted. -class mjCModel : private mjmModel { +class mjCModel : private mjSpec { friend class mjCBody; friend class mjCCamera; friend class mjCGeom; @@ -66,7 +66,7 @@ class mjCModel : private mjmModel { void CopyFromSpec(); // copy spec to private attributes void PointToLocal(); - mjmModel spec; + mjSpec spec; mjModel* Compile(const mjVFS* vfs = nullptr); // construct mjModel bool CopyBack(const mjModel*); // DECOMPILER: copy numeric back diff --git a/src/xml/xml.cc b/src/xml/xml.cc index f5dd73fb..02a168d4 100644 --- a/src/xml/xml.cc +++ b/src/xml/xml.cc @@ -99,7 +99,7 @@ class LocaleOverride { } // namespace // Main writer function - calls mjXWrite -std::string mjWriteXML(mjmModel* model, char* error, int error_sz) { +std::string mjWriteXML(mjSpec* model, char* error, int error_sz) { LocaleOverride locale_override; // check for empty model @@ -272,7 +272,7 @@ static void mjIncludeXML(mjXReader& reader, XMLElement* elem, // Main parser function -mjmModel* mjParseXML(const char* filename, const mjVFS* vfs, +mjSpec* mjParseXML(const char* filename, const mjVFS* vfs, char* error, int error_sz) { LocaleOverride locale_override; @@ -285,7 +285,7 @@ mjmModel* mjParseXML(const char* filename, const mjVFS* vfs, } // clear - mjmModel* model = nullptr; + mjSpec* model = nullptr; if (error) { error[0] = '\0'; } diff --git a/src/xml/xml.h b/src/xml/xml.h index a97d6a65..4e91abf3 100644 --- a/src/xml/xml.h +++ b/src/xml/xml.h @@ -24,10 +24,10 @@ // Top level API // Main writer function -std::string mjWriteXML(mjmModel* model, char* error, int error_sz); +std::string mjWriteXML(mjSpec* model, char* error, int error_sz); // Main parser function -MJAPI mjmModel* mjParseXML(const char* filename, const mjVFS* vfs, char* error, int error_sz); +MJAPI mjSpec* mjParseXML(const char* filename, const mjVFS* vfs, char* error, int error_sz); #endif // MUJOCO_SRC_XML_XML_H_ diff --git a/src/xml/xml_api.cc b/src/xml/xml_api.cc index 8cc68422..401b47f9 100644 --- a/src/xml/xml_api.cc +++ b/src/xml/xml_api.cc @@ -37,7 +37,7 @@ class GlobalModel { public: // deletes current model and takes ownership of model - void Set(mjmModel* model = nullptr); + void Set(mjSpec* model = nullptr); // writes XML to string std::optional ToXML(const mjModel* m, char* error, @@ -46,7 +46,7 @@ class GlobalModel { private: // using raw pointers as GlobalModel needs to be trivially destructible std::mutex* mutex_ = new std::mutex(); - mjmModel* model_ = nullptr; + mjSpec* model_ = nullptr; }; std::optional GlobalModel::ToXML(const mjModel* m, char* error, @@ -64,7 +64,7 @@ std::optional GlobalModel::ToXML(const mjModel* m, char* error, return result; } -void GlobalModel::Set(mjmModel* model) { +void GlobalModel::Set(mjSpec* model) { std::lock_guard lock(*mutex_); if (model_ != nullptr) { mjm_deleteModel(model_); @@ -91,9 +91,9 @@ mjModel* mj_loadXML(const char* filename, const mjVFS* vfs, char* error, int error_sz) { // parse new model - std::unique_ptr> model( + std::unique_ptr> model( mjParseXML(filename, vfs, error, error_sz), - [](mjmModel* m) { mjm_deleteModel(m); }); + [](mjSpec* m) { mjm_deleteModel(m); }); if (!model) { return nullptr; } diff --git a/src/xml/xml_base.cc b/src/xml/xml_base.cc index ae21fd8d..60a854b5 100644 --- a/src/xml/xml_base.cc +++ b/src/xml/xml_base.cc @@ -44,7 +44,7 @@ mjXBase::mjXBase() { // set model field -void mjXBase::SetModel(mjmModel* _model) { +void mjXBase::SetModel(mjSpec* _model) { model = _model; } diff --git a/src/xml/xml_base.h b/src/xml/xml_base.h index bf9d9f3f..662d9e7e 100644 --- a/src/xml/xml_base.h +++ b/src/xml/xml_base.h @@ -87,13 +87,13 @@ class mjXBase : public mjXUtil { }; // set the model allocated externally - virtual void SetModel(mjmModel*); + virtual void SetModel(mjSpec*); // read alternative orientation specification static int ReadAlternative(tinyxml2::XMLElement* elem, mjmOrientation& alt); protected: - mjmModel* model; // internally-allocated model + mjSpec* model; // internally-allocated model }; #endif // MUJOCO_SRC_XML_XML_BASE_H_ diff --git a/src/xml/xml_native_reader.cc b/src/xml/xml_native_reader.cc index a2b8aea3..f678e0cf 100644 --- a/src/xml/xml_native_reader.cc +++ b/src/xml/xml_native_reader.cc @@ -913,7 +913,7 @@ void mjXReader::Parse(XMLElement* root) { // compiler section parser -void mjXReader::Compiler(XMLElement* section, mjmModel* mod) { +void mjXReader::Compiler(XMLElement* section, mjSpec* mod) { string text; int n; @@ -1100,7 +1100,7 @@ void mjXReader::Option(XMLElement* section, mjOption* opt) { // size section parser -void mjXReader::Size(XMLElement* section, mjmModel* mod) { +void mjXReader::Size(XMLElement* section, mjSpec* mod) { // read memory bytes { constexpr char err_msg[] = diff --git a/src/xml/xml_native_reader.h b/src/xml/xml_native_reader.h index c84c15e3..2d2c177d 100644 --- a/src/xml/xml_native_reader.h +++ b/src/xml/xml_native_reader.h @@ -42,9 +42,9 @@ class mjXReader : public mjXBase { void SetTextureDir(std::string texturedir); // XML sections embedded in all formats - static void Compiler(tinyxml2::XMLElement* section, mjmModel* mod); // compiler section + static void Compiler(tinyxml2::XMLElement* section, mjSpec* mod); // compiler section static void Option(tinyxml2::XMLElement* section, mjOption* opt); // option section - static void Size(tinyxml2::XMLElement* section, mjmModel* mod); // size section + static void Size(tinyxml2::XMLElement* section, mjSpec* mod); // size section private: // XML section specific to MJCF diff --git a/src/xml/xml_native_writer.cc b/src/xml/xml_native_writer.cc index edc12d83..93c9e91a 100644 --- a/src/xml/xml_native_writer.cc +++ b/src/xml/xml_native_writer.cc @@ -765,7 +765,7 @@ mjXWriter::mjXWriter(void) { // cast model -void mjXWriter::SetModel(mjmModel* modelspec) { +void mjXWriter::SetModel(mjSpec* modelspec) { if (modelspec) { model = (mjCModel*)modelspec->element; } diff --git a/src/xml/xml_native_writer.h b/src/xml/xml_native_writer.h index 8a05e0a6..16830d38 100644 --- a/src/xml/xml_native_writer.h +++ b/src/xml/xml_native_writer.h @@ -27,7 +27,7 @@ class mjXWriter : public mjXBase { public: mjXWriter(); // constructor virtual ~mjXWriter() = default; // destructor - void SetModel(mjmModel* modelspec); + void SetModel(mjSpec* modelspec); // write XML document to string std::string Write(char *error, std::size_t error_sz); diff --git a/test/user/user_api_test.cc b/test/user/user_api_test.cc index 1c215760..b572c427 100644 --- a/test/user/user_api_test.cc +++ b/test/user/user_api_test.cc @@ -38,7 +38,7 @@ using ::testing::NotNull; // ----------------------------- test set/get -------------------------------- TEST_F(MujocoTest, ReadWriteData) { - mjmModel* model = mjm_createModel(); + mjSpec* model = mjm_createModel(); mjmBody* world = mjm_findBody(model, "world"); mjmBody* body = mjm_addBody(world, 0); mjmSite* site = mjm_addSite(body, 0); @@ -86,7 +86,7 @@ TEST_F(PluginTest, RecompileCompare) { // load model std::array error; - mjmModel* model = + mjSpec* model = mjParseXML(xml.c_str(), nullptr, error.data(), error.size()); // compile twice