Make switch statements over enums in engine source use a typed expression to support compiler checking of full coverage.

PiperOrigin-RevId: 556854229
Change-Id: I36a5d146d776e10b946e2f9b51ace4ef3866471b
This commit is contained in:
Yuval Tassa
2023-08-14 11:16:53 -07:00
committed by Copybara-Service
parent 13490962a8
commit e4dddea42a
15 changed files with 71 additions and 51 deletions
+4 -4
View File
@@ -266,7 +266,7 @@ static void convert2D(mjtNum* res, int action, mjtNum dx, mjtNum dy, const mjtNu
mjtNum vec[3];
// construct 3D vector
switch (action) {
switch ((mjtMouse) action) {
case mjMOUSE_ROTATE_V:
vec[0] = dy;
vec[1] = 0;
@@ -316,7 +316,7 @@ void mjv_moveCamera(const mjModel* m, int action, mjtNum reldx, mjtNum reldy,
}
// process action
switch (action) {
switch ((mjtMouse) action) {
case mjMOUSE_ROTATE_V:
case mjMOUSE_ROTATE_H:
cam->azimuth -= reldx * 180.0;
@@ -384,7 +384,7 @@ void mjv_movePerturb(const mjModel* m, const mjData* d, int action, mjtNum reldx
convert2D(vec, action, reldx, reldy, forward);
// process action
switch (action) {
switch ((mjtMouse) action) {
case mjMOUSE_MOVE_V:
case mjMOUSE_MOVE_H:
mju_addToScl3(pert->refpos, vec, pert->scale);
@@ -463,7 +463,7 @@ void mjv_moveModel(const mjModel* m, int action, mjtNum reldx, mjtNum reldy,
mju_normalize3(roomright);
// process action
switch (action) {
switch ((mjtMouse) action) {
case mjMOUSE_ROTATE_V:
case mjMOUSE_ROTATE_H:
// construct rotation vector