Copy UIDs during mj_copySpec.
This will produce the same mjSpec signature after a deep copy. PiperOrigin-RevId: 743538018 Change-Id: Ic0f5b06a00e8883cb92dc98159db3bea02cb7a36
This commit is contained in:
committed by
Copybara-Service
parent
54f132f3f0
commit
8941f56e86
@@ -297,7 +297,7 @@ void mjCModel::CopyList(std::vector<T*>& dest,
|
||||
// copy the element from the other model to this model
|
||||
if (deepcopy_) {
|
||||
source[i]->ForgetKeyframes();
|
||||
candidate->uid = GetUid();
|
||||
candidate->uid = source[i]->uid;
|
||||
} else {
|
||||
candidate->AddRef();
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ mjCBody::mjCBody(mjCModel* _model) {
|
||||
|
||||
mjCBody::mjCBody(const mjCBody& other, mjCModel* _model) {
|
||||
model = _model;
|
||||
uid = model->GetUid();
|
||||
uid = other.uid;
|
||||
mjSpec* origin = model->FindSpec(other.compiler);
|
||||
compiler = origin ? &origin->compiler : &model->spec.compiler;
|
||||
*this = other;
|
||||
@@ -944,7 +944,7 @@ mjCBody& mjCBody::operator+=(const mjCFrame& other) {
|
||||
frames.back()->frame = other.frame;
|
||||
if (model->deepcopy_) {
|
||||
frames.back()->NameSpace(other_model);
|
||||
frames.back()->uid = model->GetUid();
|
||||
frames.back()->uid = other.uid;
|
||||
} else {
|
||||
frames.back()->AddRef();
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ void mjCBody::CopyList(std::vector<T*>& dst, const std::vector<T*>& src,
|
||||
if (!model->deepcopy_) {
|
||||
dst.back()->AddRef();
|
||||
} else {
|
||||
dst.back()->uid = model->GetUid();
|
||||
dst.back()->uid = src[i]->uid;
|
||||
}
|
||||
|
||||
// set namespace
|
||||
|
||||
@@ -538,6 +538,9 @@ TEST_F(PluginTest, RecompileCompare) {
|
||||
// copy spec
|
||||
mjSpec* s_copy = mj_copySpec(s);
|
||||
|
||||
// compare signature
|
||||
EXPECT_EQ(s->element->signature, s_copy->element->signature) << xml;
|
||||
|
||||
// compile twice and compare
|
||||
mjModel* m_old = mj_compile(s, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user