Change mjSpec and mjModel signature mechanism.

The signature now contains the necessary information to safely perform `bind`. The private UIDs are now removed.

Fixes an issue of changing signature when compiling a copy of an mjSpec.

PiperOrigin-RevId: 744670626
Change-Id: Id3c66419cf2afbe78e91bc4b37d2299f5ec00ab1
This commit is contained in:
Alessio Quaglino
2025-04-07 04:20:17 -07:00
committed by Copybara-Service
parent 93251f07d9
commit cc2f57d820
7 changed files with 85 additions and 40 deletions
+3 -4
View File
@@ -324,9 +324,6 @@ class mjCModel : public mjCModel_, private mjSpec {
// set attached flag
void SetAttached(bool deepcopy) { attached_ |= !deepcopy; }
// get new uid
int GetUid() { return uid_count_++; }
private:
// settings for each defaults class
std::vector<mjCDef*> defaults_;
@@ -441,6 +438,9 @@ class mjCModel : public mjCModel_, private mjSpec {
void MarkPluginInstance(std::unordered_map<std::string, bool>& instances,
const std::vector<T*>& list);
// print the tree of a body
std::string PrintTree(const mjCBody* body, std::string indent = "");
// generate a signature for the model
uint64_t Signature();
@@ -449,7 +449,6 @@ class mjCModel : public mjCModel_, private mjSpec {
std::vector<mjKeyInfo> key_pending_; // attached keyframes
bool deepcopy_; // copy objects when attaching
bool attached_ = false; // true if model is attached to a parent model
int uid_count_ = 0; // unique id count for all objects
std::unordered_map<const mjsCompiler*, mjSpec*> compiler2spec_; // map from compiler to spec
};
#endif // MUJOCO_SRC_USER_USER_MODEL_H_