Add spec lookup in the attached spec array using the compiler option pointer.

This enables to find the spec associated with the compiler option stored in the objects, which do not necessarily belong to the model that owns them.

PiperOrigin-RevId: 713259419
Change-Id: I579c770147ff07ed2a5edd20e7a795ee7cc27147
This commit is contained in:
Alessio Quaglino
2025-01-08 05:42:59 -08:00
committed by Copybara-Service
parent 8a5f092081
commit 6654d63438
6 changed files with 161 additions and 39 deletions
+7
View File
@@ -236,6 +236,7 @@ class mjCModel : public mjCModel_, private mjSpec {
mjCBase* FindObject(mjtObj type, std::string name) const; // find object given type and name
mjCBase* FindTree(mjCBody* body, mjtObj type, std::string name); // find tree object given name
mjSpec* FindSpec(std::string name) const; // find spec given name
mjSpec* FindSpec(const mjsCompiler* compiler_) const; // find spec given mjsCompiler
void ActivatePlugin(const mjpPlugin* plugin, int slot); // activate plugin
// accessors
@@ -303,10 +304,16 @@ class mjCModel : public mjCModel_, private mjSpec {
// map from default class name to default class pointer
std::unordered_map<std::string, mjCDef*> def_map;
// get the spec from which this model was created
mjSpec* GetSourceSpec() const;
private:
// settings for each defaults class
std::vector<mjCDef*> defaults_;
// spec from which this model was created in copy constructor
mjSpec* source_spec_;
// list of active plugins
std::vector<std::pair<const mjpPlugin*, int>> active_plugins_;