[Bf-blender-cvs] [fae122f12f5] master: Sculpt: Cleanup, grant expected usage with asserts

Sergey Sharybin noreply at git.blender.org
Wed Sep 25 12:45:34 CEST 2019


Commit: fae122f12f58a20eb26779bcdf171772b9636204
Author: Sergey Sharybin
Date:   Wed Sep 25 12:37:51 2019 +0200
Branches: master
https://developer.blender.org/rBfae122f12f58a20eb26779bcdf171772b9636204

Sculpt: Cleanup, grant expected usage with asserts

Don't just rely on a comment next top the code, do an assert as well.

Also, don't use `default` since that silences compiler warnings when
new enumerators are added and related code is to be verified.

More switch statements might need an adjustment, but this is something
what is easier to go over by Pablo.

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index bf194a8c867..c9e815bbf10 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -106,9 +106,11 @@ float *sculpt_vertex_co_get(SculptSession *ss, int index)
       return ss->mvert[index].co;
     case PBVH_BMESH:
       return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co;
-    default:
-      return NULL;
+    case PBVH_GRIDS:
+      BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
+      break;
   }
+  return NULL;
 }
 
 static void sculpt_vertex_random_access_init(SculptSession *ss)
@@ -120,14 +122,17 @@ static void sculpt_vertex_random_access_init(SculptSession *ss)
 
 static int sculpt_active_vertex_get(SculptSession *ss)
 {
+  BLI_assert(BKE_pbvh_type(ss->pbvh) != PBVH_GRIDS);
   switch (BKE_pbvh_type(ss->pbvh)) {
     case PBVH_FACES:
       return ss->active_vertex_index;
     case PBVH_BMESH:
       return ss->active_vertex_index;
-    default:
-      return 0;
+    case PBVH_GRIDS:
+      BLI_assert(!"This fuction is not supposed to be used for PBVH_GRIDS");
+      break;
   }
+  return 0;
 }
 
 static int sculpt_vertex_count_get(SculptSession *ss)



More information about the Bf-blender-cvs mailing list