@@ -245,6 +245,10 @@ mjCModel& mjCModel::operator=(const mjCModel& other) {
245
245
mjCBody* world = new mjCBody (*other.bodies_ [0 ], this );
246
246
bodies_.push_back (world);
247
247
248
+ // update tree lists
249
+ ResetTreeLists ();
250
+ MakeTreeLists ();
251
+
248
252
// add everything else
249
253
*this += other;
250
254
@@ -259,6 +263,9 @@ mjCModel& mjCModel::operator=(const mjCModel& other) {
259
263
for (int i=0 ; i < mjNOBJECT; i++) {
260
264
ids[i] = other.ids [i];
261
265
}
266
+
267
+ // update signature after we updated everything
268
+ spec.element ->signature = Signature ();
262
269
}
263
270
deepcopy_ = other.deepcopy_ ;
264
271
return *this ;
@@ -504,10 +511,11 @@ mjCModel& mjCModel::operator+=(const mjCModel& other) {
504
511
nq = nv = na = nu = nmocap = 0 ;
505
512
}
506
513
507
- // update signature before we reset the tree lists
508
- spec.element ->signature = Signature ();
509
-
514
+ // update pointers to local elements
510
515
PointToLocal ();
516
+
517
+ // update signature after we updated the tree lists and we updated the pointers
518
+ spec.element ->signature = Signature ();
511
519
return *this ;
512
520
}
513
521
@@ -814,12 +822,12 @@ void mjCModel::DeleteElement(mjsElement* el) {
814
822
break ;
815
823
}
816
824
817
- // update signature before we reset the tree lists
818
- spec.element ->signature = Signature ();
819
-
820
825
ResetTreeLists (); // in case of a nested delete
821
826
MakeTreeLists ();
822
827
ProcessLists (/* checkrepeat=*/ false );
828
+
829
+ // update signature after we updated everything
830
+ spec.element ->signature = Signature ();
823
831
}
824
832
825
833
@@ -4593,6 +4601,17 @@ void mjCModel::TryCompile(mjModel*& m, mjData*& d, const mjVFS* vfs) {
4593
4601
4594
4602
// save signature
4595
4603
m->signature = Signature ();
4604
+
4605
+ // special cases that are not caused by user edits
4606
+ if (compiler.fusestatic || compiler.discardvisual ||
4607
+ !spec.element ->signature || !pairs_.empty () || !excludes_.empty ()) {
4608
+ spec.element ->signature = m->signature ;
4609
+ }
4610
+
4611
+ // check that the signature matches the spec
4612
+ if (m->signature != spec.element ->signature ) {
4613
+ throw mjCError (0 , " signature mismatch" ); // SHOULD NOT OCCUR
4614
+ }
4596
4615
}
4597
4616
4598
4617
0 commit comments