diff --git a/simulate/main.cc b/simulate/main.cc index 15316383..ac4d7b36 100644 --- a/simulate/main.cc +++ b/simulate/main.cc @@ -245,13 +245,6 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) { auto load_interval = mj::Simulate::Clock::now() - load_start; double load_seconds = Seconds(load_interval).count(); - // if no error and load took more than 1/4 seconds, report load time - if (!loadError[0] && load_seconds > 0.25) { - mju::sprintf_arr(loadError, "Model loaded in %.2g seconds", load_seconds); - } - - mju::strcpy_arr(sim.load_error, loadError); - if (!mnew) { std::printf("%s\n", loadError); return nullptr; @@ -264,6 +257,13 @@ mjModel* LoadModel(const char* file, mj::Simulate& sim) { sim.run = 0; } + // if no error and load took more than 1/4 seconds, report load time + if (!loadError[0] && load_seconds > 0.25) { + mju::sprintf_arr(loadError, "Model loaded in %.2g seconds", load_seconds); + } + + mju::strcpy_arr(sim.load_error, loadError); + return mnew; }