diff --git a/src/user/user_api.cc b/src/user/user_api.cc index cfe108a0..6f779b4c 100644 --- a/src/user/user_api.cc +++ b/src/user/user_api.cc @@ -27,7 +27,7 @@ // create model -mjSpec* mjm_createModel() { +mjSpec* mjm_createSpec() { mjCModel* modelC = new mjCModel; return &modelC->spec; } @@ -43,7 +43,7 @@ void mjm_copyBack(mjSpec* s, const mjModel* m) { // compile model -mjModel* mjm_compileModel(mjSpec* s, const mjVFS* vfs) { +mjModel* mjm_compile(mjSpec* s, const mjVFS* vfs) { mjCModel* modelC = reinterpret_cast(s->element); return modelC->Compile(vfs); } @@ -67,7 +67,7 @@ int mjm_isWarning(mjSpec* s) { // delete model -void mjm_deleteModel(mjSpec* s) { +void mjm_deleteSpec(mjSpec* s) { mjCModel* model = reinterpret_cast(s->element); delete model; } @@ -392,7 +392,7 @@ mjmDefault* mjm_findDefault(mjSpec* s, const char* classname) { // get default[0] from model -mjmDefault* mjm_getModelDefault(mjSpec* s) { +mjmDefault* mjm_getSpecDefault(mjSpec* s) { mjCModel* modelC = reinterpret_cast(s->element); mjCDef* def = modelC->defaults[0]; if (!def) { diff --git a/src/user/user_api.h b/src/user/user_api.h index 421cab7a..af5eb857 100644 --- a/src/user/user_api.h +++ b/src/user/user_api.h @@ -727,13 +727,13 @@ typedef struct _mjmDefault { // default specification //---------------------------------- API functions ------------------------------------------------- // Create model. -MJAPI mjSpec* mjm_createModel(); +MJAPI mjSpec* mjm_createSpec(); // Copy back model. MJAPI void mjm_copyBack(mjSpec* s, const mjModel* m); // Compile model. -MJAPI mjModel* mjm_compileModel(mjSpec* s, const mjVFS* vfs); +MJAPI mjModel* mjm_compile(mjSpec* s, const mjVFS* vfs); // Get error message from model. MJAPI const char* mjm_getError(mjSpec* s); @@ -742,7 +742,7 @@ MJAPI const char* mjm_getError(mjSpec* s); MJAPI int mjm_isWarning(mjSpec* s); // Delete model. -MJAPI void mjm_deleteModel(mjSpec* s); +MJAPI void mjm_deleteSpec(mjSpec* s); // Add child body to body, return child spec. MJAPI mjmBody* mjm_addBody(mjmBody* body, mjmDefault* def); @@ -790,7 +790,7 @@ MJAPI mjmMaterial* mjm_addMaterial(mjSpec* s, mjmDefault* def); MJAPI mjmPair* mjm_addPair(mjSpec* s, mjmDefault* def); // Add excluded body pair to model. -MJAPI mjmExclude* mjm_addExclude(mjSpec *model); +MJAPI mjmExclude* mjm_addExclude(mjSpec* s); // Add equality to model. MJAPI mjmEquality* mjm_addEquality(mjSpec* s, mjmDefault* def); @@ -844,7 +844,7 @@ MJAPI mjmDefault* mjm_getDefault(mjElement element); MJAPI mjmDefault* mjm_findDefault(mjSpec* s, const char* classname); // Get global default from model. -MJAPI mjmDefault* mjm_getModelDefault(mjSpec* s); +MJAPI mjmDefault* mjm_getSpecDefault(mjSpec* s); // Find body in model by name. MJAPI mjmBody* mjm_findBody(mjSpec* s, const char* name); @@ -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(mjSpec& model); +MJAPI void mjm_defaultSpec(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 ca5026dd..15a77caf 100644 --- a/src/user/user_composite.cc +++ b/src/user/user_composite.cc @@ -223,8 +223,8 @@ void mjCComposite::SetDefault(void) { // make composite object -bool mjCComposite::Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz) { - mjCModel* model = (mjCModel*)modelspec->element; +bool mjCComposite::Make(mjSpec* spec, mjmBody* body, char* error, int error_sz) { + mjCModel* model = (mjCModel*)spec->element; // check geom type if ((def[0].spec.geom->type!=mjGEOM_SPHERE && diff --git a/src/user/user_composite.h b/src/user/user_composite.h index bd8afc56..6b30e2fa 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(mjSpec* modelspec, mjmBody* body, char* error, int error_sz); + bool Make(mjSpec* spec, 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 089b6f43..0686065d 100644 --- a/src/user/user_flexcomp.cc +++ b/src/user/user_flexcomp.cc @@ -82,8 +82,8 @@ mjCFlexcomp::mjCFlexcomp(void) { // make flexcomp object -bool mjCFlexcomp::Make(mjSpec* modelspec, mjmBody* body, char* error, int error_sz) { - mjCModel* model = (mjCModel*)modelspec->element; +bool mjCFlexcomp::Make(mjSpec* spec, mjmBody* body, char* error, int error_sz) { + mjCModel* model = (mjCModel*)spec->element; mjmFlex* dflex = def.spec.flex; int dim = dflex->dim; bool radial = (type==mjFCOMPTYPE_BOX || diff --git a/src/user/user_flexcomp.h b/src/user/user_flexcomp.h index e7bef13c..54c44a4b 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(mjSpec* modelspec, mjmBody* body, char* error, int error_sz); + bool Make(mjSpec* spec, 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 72dba6a6..77716bdb 100644 --- a/src/user/user_init.cc +++ b/src/user/user_init.cc @@ -22,7 +22,7 @@ // default model attributes -void mjm_defaultModel(mjSpec& model) { +void mjm_defaultSpec(mjSpec& model) { memset(&model, 0, sizeof(mjSpec)); // default statistics diff --git a/src/user/user_model.cc b/src/user/user_model.cc index a8657627..7f424da9 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -83,7 +83,7 @@ static void copyvec(T1* dest, T2* src, int n) { // constructor mjCModel::mjCModel() { - mjm_defaultModel(spec); + mjm_defaultSpec(spec); spec_comment_.clear(); spec_modelfiledir_.clear(); spec_meshdir_.clear(); diff --git a/src/xml/xml.cc b/src/xml/xml.cc index 02a168d4..cbad8379 100644 --- a/src/xml/xml.cc +++ b/src/xml/xml.cc @@ -344,7 +344,7 @@ mjSpec* mjParseXML(const char* filename, const mjVFS* vfs, } // create model, set filedir - model = mjm_createModel(); + model = mjm_createSpec(); const char* dir; int ndir = 0; mju_getResourceDir(resource, &dir, &ndir); @@ -393,7 +393,7 @@ mjSpec* mjParseXML(const char* filename, const mjVFS* vfs, // catch known errors catch (mjXError err) { mjCopyError(error, err.message, error_sz); - mjm_deleteModel(model); + mjm_deleteSpec(model); return nullptr; } diff --git a/src/xml/xml_api.cc b/src/xml/xml_api.cc index 401b47f9..9b8a96e8 100644 --- a/src/xml/xml_api.cc +++ b/src/xml/xml_api.cc @@ -67,7 +67,7 @@ std::optional GlobalModel::ToXML(const mjModel* m, char* error, void GlobalModel::Set(mjSpec* model) { std::lock_guard lock(*mutex_); if (model_ != nullptr) { - mjm_deleteModel(model_); + mjm_deleteSpec(model_); } model_ = model; } @@ -93,13 +93,13 @@ mjModel* mj_loadXML(const char* filename, const mjVFS* vfs, // parse new model std::unique_ptr> model( mjParseXML(filename, vfs, error, error_sz), - [](mjSpec* m) { mjm_deleteModel(m); }); + [](mjSpec* m) { mjm_deleteSpec(m); }); if (!model) { return nullptr; } // compile new model - mjModel* m = mjm_compileModel(model.get(), vfs); + mjModel* m = mjm_compile(model.get(), vfs); if (!m) { mjCopyError(error, mjm_getError(model.get()), error_sz); return nullptr; diff --git a/src/xml/xml_native_reader.cc b/src/xml/xml_native_reader.cc index f678e0cf..1bcf5b7d 100644 --- a/src/xml/xml_native_reader.cc +++ b/src/xml/xml_native_reader.cc @@ -2643,7 +2643,7 @@ void mjXReader::Default(XMLElement* section, int parentid) { } } else { thisid = 0; - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); mjm_setString(def->name, text.c_str()); } @@ -3046,7 +3046,7 @@ void mjXReader::Asset(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // texture sub-element @@ -3418,7 +3418,7 @@ void mjXReader::Contact(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // geom pair to include @@ -3463,7 +3463,7 @@ void mjXReader::Equality(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // create equality constraint and parse @@ -3491,7 +3491,7 @@ void mjXReader::Deformable(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // flex sub-element @@ -3527,7 +3527,7 @@ void mjXReader::Tendon(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // create equality constraint and parse @@ -3593,7 +3593,7 @@ void mjXReader::Actuator(XMLElement* section) { // get class if specified, otherwise use default0 mjmDefault* def = GetClass(elem); if (!def) { - def = mjm_getModelDefault(model); + def = mjm_getSpecDefault(model); } // create actuator and parse diff --git a/test/user/user_api_test.cc b/test/user/user_api_test.cc index b572c427..acfa8501 100644 --- a/test/user/user_api_test.cc +++ b/test/user/user_api_test.cc @@ -38,8 +38,8 @@ using ::testing::NotNull; // ----------------------------- test set/get -------------------------------- TEST_F(MujocoTest, ReadWriteData) { - mjSpec* model = mjm_createModel(); - mjmBody* world = mjm_findBody(model, "world"); + mjSpec* spec = mjm_createSpec(); + mjmBody* world = mjm_findBody(spec, "world"); mjmBody* body = mjm_addBody(world, 0); mjmSite* site = mjm_addSite(body, 0); @@ -59,7 +59,7 @@ TEST_F(MujocoTest, ReadWriteData) { EXPECT_EQ(vec[i], i); } - mjm_deleteModel(model); + mjm_deleteSpec(spec); } // ------------------- test recompilation multiple files ---------------------- @@ -86,12 +86,12 @@ TEST_F(PluginTest, RecompileCompare) { // load model std::array error; - mjSpec* model = + mjSpec* spec = mjParseXML(xml.c_str(), nullptr, error.data(), error.size()); // compile twice - mjModel* m_old = mjm_compileModel(model, nullptr); - mjModel* m_new = mjm_compileModel(model, nullptr); + mjModel* m_old = mjm_compile(spec, nullptr); + mjModel* m_new = mjm_compile(spec, nullptr); ASSERT_THAT(m_old, NotNull()) << "Failed to compile " << xml << ": " << error.data(); @@ -108,7 +108,7 @@ TEST_F(PluginTest, RecompileCompare) { << "Different field: " << field << '\n'; // delete models - mjm_deleteModel(model); + mjm_deleteSpec(spec); mj_deleteModel(m_old); mj_deleteModel(m_new); }