[Bf-blender-cvs] [ee743204b0b] master: Cleanup: build warnings.

Bastien Montagne noreply at git.blender.org
Tue Oct 26 09:52:47 CEST 2021


Commit: ee743204b0b7fddd4a3cf315f2996467ca786500
Author: Bastien Montagne
Date:   Tue Oct 26 09:52:08 2021 +0200
Branches: master
https://developer.blender.org/rBee743204b0b7fddd4a3cf315f2996467ca786500

Cleanup: build warnings.

`NULL` instead of `nullptr` in cpp code, and `else` statements after
returns.

===================================================================

M	source/blender/blenkernel/intern/icons.cc
M	source/blender/windowmanager/xr/intern/wm_xr_operators.c

===================================================================

diff --git a/source/blender/blenkernel/intern/icons.cc b/source/blender/blenkernel/intern/icons.cc
index c48f3934a19..f820b345c59 100644
--- a/source/blender/blenkernel/intern/icons.cc
+++ b/source/blender/blenkernel/intern/icons.cc
@@ -363,7 +363,7 @@ PreviewImage **BKE_previewimg_id_get_p(const ID *id)
       Object *ob = (Object *)id;
       /* Currently, only object types with real geometry can be rendered as preview. */
       if (!OB_TYPE_IS_GEOMETRY(ob->type)) {
-        return NULL;
+        return nullptr;
       }
       return &ob->preview;
     }
diff --git a/source/blender/windowmanager/xr/intern/wm_xr_operators.c b/source/blender/windowmanager/xr/intern/wm_xr_operators.c
index 652e357b6d5..308abc4fca4 100644
--- a/source/blender/windowmanager/xr/intern/wm_xr_operators.c
+++ b/source/blender/windowmanager/xr/intern/wm_xr_operators.c
@@ -449,10 +449,8 @@ static bool wm_xr_navigation_grab_is_locked(const XrGrabData *data, const bool b
   if (bimanual) {
     return data->loc_lock && data->rot_lock && data->scale_lock;
   }
-  else {
-    /* Ignore scale lock, as one-handed interaction cannot change navigation scale. */
-    return data->loc_lock && data->rot_lock;
-  }
+  /* Ignore scale lock, as one-handed interaction cannot change navigation scale. */
+  return data->loc_lock && data->rot_lock;
 }
 
 static void wm_xr_navigation_grab_apply(wmXrData *xr,
@@ -558,17 +556,17 @@ static int wm_xr_navigation_grab_modal(bContext *C, wmOperator *op, const wmEven
    dispatching (see #wm_xr_session_action_states_interpret()). For modal XR operators, modal
    handling starts when an input is "pressed" (action state exceeds the action threshold) and
    ends when the input is "released" (state falls below the threshold). */
-  if (event->val == KM_PRESS) {
-    return OPERATOR_RUNNING_MODAL;
-  }
-  else if (event->val == KM_RELEASE) {
-    wm_xr_grab_uninit(op);
-    return OPERATOR_FINISHED;
+  switch (event->val) {
+    case KM_PRESS:
+      return OPERATOR_RUNNING_MODAL;
+    case KM_RELEASE:
+      wm_xr_grab_uninit(op);
+      return OPERATOR_FINISHED;
+    default:
+      BLI_assert_unreachable();
+      wm_xr_grab_uninit(op);
+      return OPERATOR_CANCELLED;
   }
-
-  BLI_assert_unreachable();
-  wm_xr_grab_uninit(op);
-  return OPERATOR_CANCELLED;
 }
 
 static void WM_OT_xr_navigation_grab(wmOperatorType *ot)
@@ -1317,39 +1315,41 @@ static int wm_xr_navigation_teleport_modal(bContext *C, wmOperator *op, const wm
 
   wm_xr_raycast_update(op, xr, actiondata);
 
-  if (event->val == KM_PRESS) {
-    return OPERATOR_RUNNING_MODAL;
-  }
-  else if (event->val == KM_RELEASE) {
-    XrRaycastData *data = op->customdata;
-    bool selectable_only, teleport_axes[3];
-    float teleport_t, teleport_ofs, ray_dist;
-
-    RNA_boolean_get_array(op->ptr, "teleport_axes", teleport_axes);
-    teleport_t = RNA_float_get(op->ptr, "interpolation");
-    teleport_ofs = RNA_float_get(op->ptr, "offset");
-    selectable_only = RNA_boolean_get(op->ptr, "selectable_only");
-    ray_dist = RNA_float_get(op->ptr, "distance");
-
-    wm_xr_navigation_teleport(C,
-                              xr,
-                              data->origin,
-                              data->direction,
-                              &ray_dist,
-                              selectable_only,
-                              teleport_axes,
-                              teleport_t,
-                              teleport_ofs);
-
-    wm_xr_raycast_uninit(op);
+  switch (event->val) {
+    case KM_PRESS:
+      return OPERATOR_RUNNING_MODAL;
+    case KM_RELEASE: {
+      XrRaycastData *data = op->customdata;
+      bool selectable_only, teleport_axes[3];
+      float teleport_t, teleport_ofs, ray_dist;
+
+      RNA_boolean_get_array(op->ptr, "teleport_axes", teleport_axes);
+      teleport_t = RNA_float_get(op->ptr, "interpolation");
+      teleport_ofs = RNA_float_get(op->ptr, "offset");
+      selectable_only = RNA_boolean_get(op->ptr, "selectable_only");
+      ray_dist = RNA_float_get(op->ptr, "distance");
+
+      wm_xr_navigation_teleport(C,
+                                xr,
+                                data->origin,
+                                data->direction,
+                                &ray_dist,
+                                selectable_only,
+                                teleport_axes,
+                                teleport_t,
+                                teleport_ofs);
+
+      wm_xr_raycast_uninit(op);
+
+      return OPERATOR_FINISHED;
+    }
+    default:
 
-    return OPERATOR_FINISHED;
+      /* XR events currently only support press and release. */
+      BLI_assert_unreachable();
+      wm_xr_raycast_uninit(op);
+      return OPERATOR_CANCELLED;
   }
-
-  /* XR events currently only support press and release. */
-  BLI_assert_unreachable();
-  wm_xr_raycast_uninit(op);
-  return OPERATOR_CANCELLED;
 }
 
 static void WM_OT_xr_navigation_teleport(wmOperatorType *ot)



More information about the Bf-blender-cvs mailing list