diff --git a/simulate/simulate.cc b/simulate/simulate.cc index 2580c45a..be7318c5 100644 --- a/simulate/simulate.cc +++ b/simulate/simulate.cc @@ -1584,22 +1584,24 @@ void UiEvent(mjuiState* state) { // rendering section else if (it && it->sectionid==SECT_RENDERING) { - // set camera in mjvCamera - if (sim->camera==0) { - sim->cam.type = mjCAMERA_FREE; - } else if (sim->camera==1) { - if (sim->pert.select>0) { - sim->cam.type = mjCAMERA_TRACKING; - sim->cam.trackbodyid = sim->pert.select; - sim->cam.fixedcamid = -1; - } else { + // only update the camera when the camera itself changed + if (it->pdata == &sim->camera) { + if (sim->camera==0) { sim->cam.type = mjCAMERA_FREE; - sim->camera = 0; - mjui0_update_section(sim, SECT_RENDERING); + } else if (sim->camera==1) { + if (sim->pert.select>0) { + sim->cam.type = mjCAMERA_TRACKING; + sim->cam.trackbodyid = sim->pert.select; + sim->cam.fixedcamid = -1; + } else { + sim->cam.type = mjCAMERA_FREE; + sim->camera = 0; + mjui0_update_section(sim, SECT_RENDERING); + } + } else { + sim->cam.type = mjCAMERA_FIXED; + sim->cam.fixedcamid = sim->camera - 2; } - } else { - sim->cam.type = mjCAMERA_FIXED; - sim->cam.fixedcamid = sim->camera - 2; } // copy camera spec to clipboard (as MJCF element) if (it->itemid == 3) {