Reset free camera when loading a new model.
PiperOrigin-RevId: 871622663 Change-Id: I1f1a4681752f7436c7bc7adbe64dcea286c5620c
This commit is contained in:
committed by
Copybara-Service
parent
fa43e2c03b
commit
6b197e198a
@@ -149,6 +149,7 @@ void App::RequestModelLoad(std::string model_file) {
|
||||
void App::RequestModelReload() {
|
||||
if (model_kind_ == kModelFromFile) {
|
||||
pending_load_ = model_path_;
|
||||
preserve_camera_on_load_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +200,16 @@ void App::OnModelLoaded(std::string filename, ModelKind model_kind) {
|
||||
const int state_size = mj_stateSize(model, mjSTATE_INTEGRATION);
|
||||
history_.Init(state_size);
|
||||
|
||||
if (!preserve_camera_on_load_) {
|
||||
const int model_cam = model->vis.global.cameraid;
|
||||
if (model_cam >= 0 && model_cam < model->ncam) {
|
||||
ui_.camera_idx = platform::SetCamera(model, &camera_, model_cam);
|
||||
} else {
|
||||
mjv_defaultFreeCamera(model, &camera_);
|
||||
}
|
||||
}
|
||||
preserve_camera_on_load_ = false;
|
||||
|
||||
// Initialize the speed based on the model's default real-time setting.
|
||||
float min_error = FLT_MAX;
|
||||
const float desired = mju_log(100 * model->vis.global.realtime);
|
||||
|
||||
Reference in New Issue
Block a user