Fix bug in simulate where pressing '[' or ']' when a model is not loaded will causes a crash.

PiperOrigin-RevId: 436791755
Change-Id: I0bfec45eecef4bbb8db8f47f0d1e8a0276399b8f
This commit is contained in:
Yuval Tassa
2022-03-23 11:40:29 -07:00
committed by Saran Tunyasuvunakool
parent df048e54c0
commit 21338e6178
+2 -2
View File
@@ -1554,7 +1554,7 @@ void uiEvent(mjuiState* state) {
break;
case ']': // cycle up fixed cameras
if (m->ncam) {
if (m && m->ncam) {
cam.type = mjCAMERA_FIXED;
// settings.camera = {0 or 1} are reserved for the free and tracking cameras
if (settings.camera < 2 || settings.camera == 2 + m->ncam-1) {
@@ -1568,7 +1568,7 @@ void uiEvent(mjuiState* state) {
break;
case '[': // cycle down fixed cameras
if (m->ncam) {
if (m && m->ncam) {
cam.type = mjCAMERA_FIXED;
// settings.camera = {0 or 1} are reserved for the free and tracking cameras
if (settings.camera <= 2) {