[Bf-blender-cvs] [4aa2a5481ce] master: Bevel: Refactor "Vertex Only" to an enum

Hans Goudey noreply at git.blender.org
Tue Jul 21 22:31:57 CEST 2020


Commit: 4aa2a5481cec4edc4694ee1edbde4ed3f3986313
Author: Hans Goudey
Date:   Tue Jul 21 16:32:00 2020 -0400
Branches: master
https://developer.blender.org/rB4aa2a5481cec4edc4694ee1edbde4ed3f3986313

Bevel: Refactor "Vertex Only" to an enum

This matches the change that was done to the bevel modifier so that the
interface for the modifier, the active tool, and the operator are consistent.

 This commit extends the refactor to the bmesh implementation too, so
that the parameters in the implementation don't stray too far from what
is exposed.

Tests are adjusted and still pass.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/intern/bmesh_operators.h
M	source/blender/bmesh/operators/bmo_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.h
M	source/blender/editors/mesh/editmesh_bevel.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_bevel.c
M	tests/python/bevel_operator.py

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 9fdb62a7e8a..ef4e1a9f77b 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4456,9 +4456,9 @@ def km_mesh(params):
          {"properties": [("TRANSFORM_OT_edge_slide", [("release_confirm", False), ],)]}),
         ("mesh.inset", {"type": 'I', "value": 'PRESS'}, None),
         ("mesh.bevel", {"type": 'B', "value": 'PRESS', "ctrl": True},
-         {"properties": [("vertex_only", False)]}),
+         {"properties": [("affect", 'EDGES')]}),
         ("mesh.bevel", {"type": 'B', "value": 'PRESS', "shift": True, "ctrl": True},
-         {"properties": [("vertex_only", True)]}),
+         {"properties": [("affect", 'VERTICES')]}),
         # Selection modes.
         *_template_items_editmode_mesh_select_mode(params),
         # Loop Select with alt. Double click in case MMB emulation is on (below).
@@ -5210,7 +5210,7 @@ def km_bevel_modal_map(_params):
         ("SEGMENTS_DOWN", {"type": 'NUMPAD_MINUS', "value": 'PRESS', "any": True}, None),
         ("OFFSET_MODE_CHANGE", {"type": 'M', "value": 'PRESS', "any": True}, None),
         ("CLAMP_OVERLAP_TOGGLE", {"type": 'C', "value": 'PRESS', "any": True}, None),
-        ("VERTEX_ONLY_TOGGLE", {"type": 'V', "value": 'PRESS', "any": True}, None),
+        ("AFFECT_CHANGE", {"type": 'V', "value": 'PRESS', "any": True}, None),
         ("HARDEN_NORMALS_TOGGLE", {"type": 'H', "value": 'PRESS', "any": True}, None),
         ("MARK_SEAM_TOGGLE", {"type": 'U', "value": 'PRESS', "any": True}, None),
         ("MARK_SHARP_TOGGLE", {"type": 'K', "value": 'PRESS', "any": True}, None),
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index ce48b92c419..2b35eb15cdc 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -744,10 +744,14 @@ class _defs_edit_mesh:
 
             region_is_header = context.region.type == 'TOOL_HEADER'
 
+            edge_bevel = props.affect == 'EDGES'
+
             if not extra:
                 if region_is_header:
                     layout.prop(props, "offset_type", text="")
                 else:
+                    layout.row().prop(props, "affect", expand=True)
+
                     layout.prop(props, "offset_type")
 
                 layout.prop(props, "segments")
@@ -766,25 +770,33 @@ class _defs_edit_mesh:
                 layout.use_property_split = True
                 layout.use_property_decorate = False
 
+                if region_is_header:
+                    layout.row().prop(props, "affect", expand=True)
+
                 if props.profile_type == 'CUSTOM':
-                    layout.prop(props, "profile", text="Miter Shape", slider=True)
+                    col = layout.column()
+                    col.active = edge_bevel
+                    col.prop(props, "profile", text="Miter Shape", slider=True)
+
+                layout.prop(props, "material")
 
                 col = layout.column()
-                col.prop(props, "vertex_only")
+                col.prop(props, "harden_normals")
                 col.prop(props, "clamp_overlap")
                 col.prop(props, "loop_slide")
-                col.prop(props, "harden_normals")
 
                 col = layout.column(heading="Mark")
+                col.active = edge_bevel
                 col.prop(props, "mark_seam", text="Seam")
                 col.prop(props, "mark_sharp", text="Sharp")
 
-                layout.prop(props, "material")
 
-                layout.prop(props, "miter_outer", text="Outer Miter")
-                layout.prop(props, "miter_inner", text="Inner Miter")
+                col = layout.column()
+                col.active = edge_bevel
+                col.prop(props, "miter_outer", text="Miter Outer")
+                col.prop(props, "miter_inner", text="Inner")
                 if props.miter_inner == 'ARC':
-                    layout.prop(props, "spread")
+                    col.prop(props, "spread")
 
                 if props.profile_type == 'CUSTOM':
                     tool_settings = context.tool_settings
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 3a5efc30f50..8880d8c5378 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -3697,7 +3697,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
             col.separator()
 
             col.operator("mesh.extrude_vertices_move", text="Extrude Vertices")
-            col.operator("mesh.bevel", text="Bevel Vertices").vertex_only = True
+            col.operator("mesh.bevel", text="Bevel Vertices").affect = 'VERTICES'
 
             if selected_verts_len > 1:
                 col.separator()
@@ -3746,7 +3746,7 @@ class VIEW3D_MT_edit_mesh_context_menu(Menu):
             col.separator()
 
             col.operator("mesh.extrude_edges_move", text="Extrude Edges")
-            col.operator("mesh.bevel", text="Bevel Edges").vertex_only = False
+            col.operator("mesh.bevel", text="Bevel Edges").affect = 'EDGES'
             if selected_edges_len >= 2:
                 col.operator("mesh.bridge_edge_loops")
             if selected_edges_len >= 1:
@@ -3920,7 +3920,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu):
         layout.operator_context = 'INVOKE_REGION_WIN'
 
         layout.operator("mesh.extrude_vertices_move", text="Extrude Vertices")
-        layout.operator("mesh.bevel", text="Bevel Vertices").vertex_only = True
+        layout.operator("mesh.bevel", text="Bevel Vertices").affect = 'VERTICES'
 
         layout.separator()
 
@@ -4005,7 +4005,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu):
         layout.operator_context = 'INVOKE_REGION_WIN'
 
         layout.operator("mesh.extrude_edges_move", text="Extrude Edges")
-        layout.operator("mesh.bevel", text="Bevel Edges").vertex_only = False
+        layout.operator("mesh.bevel", text="Bevel Edges").affect = 'EDGES'
         layout.operator("mesh.bridge_edge_loops")
         layout.operator("mesh.screw")
 
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index a84d9711491..b6caa018756 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -413,5 +413,19 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
       FOREACH_NODETREE_END;
     }
+
+    /* Refactor bevel affect type to use an enum. */
+    if (!DNA_struct_elem_find(fd->filesdna, "BevelModifierData", "char", "affect_type")) {
+      for (Object *object = bmain->objects.first; object != NULL; object = object->id.next) {
+        LISTBASE_FOREACH (ModifierData *, md, &object->modifiers) {
+          if (md->type == eModifierType_Bevel) {
+            BevelModifierData *bmd = (BevelModifierData *)md;
+            const bool use_vertex_bevel = bmd->flags & MOD_BEVEL_VERT_DEPRECATED;
+            bmd->affect_type = use_vertex_bevel ? MOD_BEVEL_AFFECT_VERTICES :
+                                                  MOD_BEVEL_AFFECT_EDGES;
+          }
+        }
+      }
+    }
   }
 }
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 67c0fdba12b..4117ad67dd3 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1755,6 +1755,12 @@ static BMO_FlagSet bmo_enum_bevel_vmesh_method[] = {
   {0, NULL},
 };
 
+static BMO_FlagSet bmo_enum_bevel_affect_type[] = {
+  {BEVEL_AFFECT_VERTICES, "VERTICES"},
+  {BEVEL_AFFECT_EDGES, "EDGES"},
+  {0, NULL},
+};
+
 /*
  * Bevel.
  *
@@ -1768,10 +1774,11 @@ static BMOpDefine bmo_bevel_def = {
    {"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
     bmo_enum_bevel_offset_type},          /* how to measure the offset */
    {"profile_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
-    bmo_enum_bevel_profile_type},      /* The profile type to use for bevel. */
+    bmo_enum_bevel_profile_type},         /* The profile type to use for bevel. */
    {"segments", BMO_OP_SLOT_INT},         /* number of segments in bevel */
    {"profile", BMO_OP_SLOT_FLT},          /* profile shape, 0->1 (.5=>round) */
-   {"vertex_only", BMO_OP_SLOT_BOOL},     /* only bevel vertices, not edges */
+   {"affect", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
+    bmo_enum_bevel_affect_type},          /* Whether to bevel vertices or edges. */
    {"clamp_overlap", BMO_OP_SLOT_BOOL},   /* do not allow beveled edges/vertices to overlap each other */
    {"material", BMO_OP_SLOT_INT},         /* material for bevel faces, -1 means get from adjacent faces */
    {"loop_slide", BMO_OP_SLOT_BOOL},      /* prefer to slide along edges to having even widths */
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 29fcf7ca0ca..c0e59758120 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -139,6 +139,12 @@ enum {
   BEVEL_VMESH_CUTOFF,
 };
 
+/* Bevel affect option. */
+enum {
+  BEVEL_AFFECT_VERTICES = 0,
+  BEVEL_AFFECT_EDGES = 1,
+};
+
 /* Normal Face Strength values */
 enum {
   FACE_STRENGTH_WEAK = -16384,
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 67f875ac262..4e708b595e0 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -35,7 +35,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
   const int offset_type = BMO_slot_int_get(op->slots_in, "offset_type");
   const int profile_type = BMO_slot_int_get(op->slots_in, "profile_type");
   const int seg = BMO_slot_int_get(op->slots_in, "segments");
-  const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only");
+  const int affect_type = BMO_slot_int_get(op-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list