Copy attached spec before attaching anything else.
Spec were copied after bodies are attached, so the reference to the source spec got lost during mj_copySpec(). PiperOrigin-RevId: 701287267 Change-Id: I55eff53c7ae9d42b03957be48ea506b80d274e03
This commit is contained in:
committed by
Copybara-Service
parent
300450f8b8
commit
82b6dbeb40
@@ -182,6 +182,11 @@ mjCModel& mjCModel::operator=(const mjCModel& other) {
|
||||
*static_cast<mjCModel_*>(this) = static_cast<const mjCModel_&>(other);
|
||||
*static_cast<mjSpec*>(this) = static_cast<const mjSpec&>(other);
|
||||
|
||||
// copy attached specs first so that we can resolve references to them
|
||||
for (const auto* s : other.specs_) {
|
||||
specs_.push_back(mj_copySpec(s));
|
||||
}
|
||||
|
||||
// the world copy constructor takes care of copying the tree
|
||||
mjCBody* world = new mjCBody(*other.bodies_[0], this);
|
||||
bodies_.push_back(world);
|
||||
@@ -398,9 +403,6 @@ mjCModel& mjCModel::operator+=(const mjCModel& other) {
|
||||
}
|
||||
CopyList(numerics_, other.numerics_);
|
||||
CopyList(texts_, other.texts_);
|
||||
for (const auto* s : other.specs_) {
|
||||
specs_.push_back(mj_copySpec(s));
|
||||
}
|
||||
}
|
||||
CopyList(flexes_, other.flexes_);
|
||||
CopyList(pairs_, other.pairs_);
|
||||
|
||||
Reference in New Issue
Block a user