Preserve time when recompiling a model.
Fixes #1890. PiperOrigin-RevId: 662084324 Change-Id: I6aed40761cee5044e63426935d102123db295b25
This commit is contained in:
committed by
Copybara-Service
parent
d3a976e10d
commit
648fd56ed1
@@ -91,13 +91,16 @@ mjModel* mj_compile(mjSpec* s, const mjVFS* vfs) {
|
||||
// recompile spec into existing model and data while preserving the state
|
||||
void mj_recompile(mjSpec* s, const mjVFS* vfs, mjModel* m, mjData* d) {
|
||||
mjCModel* modelC = static_cast<mjCModel*>(s->element);
|
||||
mjtNum time = 0;
|
||||
if (d) {
|
||||
time = d->time;
|
||||
modelC->SaveState(d->qpos, d->qvel, d->act);
|
||||
}
|
||||
modelC->Compile(vfs, &m);
|
||||
if (d) {
|
||||
modelC->MakeData(m, &d);
|
||||
modelC->RestoreState(d->qpos, d->qvel, d->act);
|
||||
d->time = time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user