[Bf-blender-cvs] [6703c7f7f1f] master: Bevel: Refactor profile type input to use an enum

Hans Goudey noreply at git.blender.org
Tue Jun 23 04:26:03 CEST 2020


Commit: 6703c7f7f1f68ae59f9ccbf4fcabc3c035d648bf
Author: Hans Goudey
Date:   Mon Jun 22 22:25:55 2020 -0400
Branches: master
https://developer.blender.org/rB6703c7f7f1f68ae59f9ccbf4fcabc3c035d648bf

Bevel: Refactor profile type input to use an enum

This will allow the easier addition of a constant radius mode in the
future and some changes in the UI to mirror the recent similar change
from "Only Vertices" to the "Affect" enum.

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.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

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 68340443a78..33c16b99348 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5179,7 +5179,7 @@ def km_bevel_modal_map(_params):
         ("MARK_SHARP_TOGGLE", {"type": 'K', "value": 'PRESS', "any": True}, None),
         ("OUTER_MITER_CHANGE", {"type": 'O', "value": 'PRESS', "any": True}, None),
         ("INNER_MITER_CHANGE", {"type": 'I', "value": 'PRESS', "any": True}, None),
-        ("CUSTOM_PROFILE_TOGGLE", {"type": 'Z', "value": 'PRESS', "any": True}, None),
+        ("PROFILE_TYPE_CHANGE", {"type": 'Z', "value": 'PRESS', "any": True}, None),
         ("VERTEX_MESH_CHANGE", {"type": 'N', "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 9f26abec805..bfd5be8862d 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -747,18 +747,30 @@ class _defs_edit_mesh:
                     layout.prop(props, "offset_type")
 
                 layout.prop(props, "segments")
-                layout.prop(props, "profile", slider=True)
+
+                row = layout.row()
+                row.prop(props, "profile_type", expand=True)
+                if props.profile_type == 'SUPERELLIPSE':
+                    layout.prop(props, "profile", text="Shape", slider=True)
 
                 if region_type == 'TOOL_HEADER':
                     layout.popover("TOPBAR_PT_tool_settings_extra", text="...")
                 else:
                     extra = True
 
-            if extra or region_type != 'TOOL_HEADER':
-                layout.prop(props, "vertex_only")
-                layout.prop(props, "clamp_overlap")
-                layout.prop(props, "loop_slide")
-                layout.prop(props, "harden_normals")
+            if extra:
+                layout.use_property_split = True
+                layout.use_property_decorate = False
+
+                if props.profile_type == 'CUSTOM':
+                    layout.prop(props, "profile", text="Miter Shape", slider=True)
+
+                col = layout.column()
+                col.prop(props, "vertex_only")
+                col.prop(props, "clamp_overlap")
+                col.prop(props, "loop_slide")
+                col.prop(props, "harden_normals")
+
                 col = layout.column(heading="Mark")
                 col.prop(props, "mark_seam", text="Seam")
                 col.prop(props, "mark_sharp", text="Sharp")
@@ -770,8 +782,7 @@ class _defs_edit_mesh:
                 if props.miter_inner == 'ARC':
                     layout.prop(props, "spread")
 
-                layout.prop(props, "use_custom_profile")
-                if props.use_custom_profile:
+                if props.profile_type == 'CUSTOM':
                     tool_settings = context.tool_settings
                     layout.template_curveprofile(tool_settings, "custom_bevel_profile_preset")
 
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index bf4ed270e33..843bf4c98d9 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -333,4 +333,18 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
   }
+
+  /* Refactor bevel profile type to use an enum. */
+  if (!DNA_struct_elem_find(fd->filesdna, "BevelModifier", "short", "profile_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;
+          bool use_custom_profile = bmd->flags & MOD_BEVEL_CUSTOM_PROFILE_DEPRECATED;
+          bmd->profile_type = use_custom_profile ? MOD_BEVEL_PROFILE_CUSTOM :
+                                                   MOD_BEVEL_PROFILE_SUPERELLIPSE;
+        }
+      }
+    }
+  }
 }
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index ca34cd7d7e5..67c0fdba12b 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1728,6 +1728,12 @@ static BMO_FlagSet bmo_enum_bevel_offset_type[] = {
   {0, NULL},
 };
 
+static BMO_FlagSet bmo_enum_bevel_profile_type[] = {
+  {BEVEL_PROFILE_SUPERELLIPSE, "SUPERELLIPSE"},
+  {BEVEL_PROFILE_CUSTOM, "CUSTOM"},
+  {0, NULL},
+};
+
 static BMO_FlagSet bmo_enum_bevel_face_strength_type[] = {
   {BEVEL_FACE_STRENGTH_NONE, "NONE"},
   {BEVEL_FACE_STRENGTH_NEW, "NEW"},
@@ -1760,7 +1766,9 @@ static BMOpDefine bmo_bevel_def = {
   {{"geom", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT | BM_EDGE | BM_FACE}},     /* input edges and vertices */
    {"offset", BMO_OP_SLOT_FLT},           /* amount to offset beveled edge */
    {"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
-    bmo_enum_bevel_offset_type}, /* how to measure the offset */
+    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. */
    {"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 */
@@ -1778,9 +1786,7 @@ static BMOpDefine bmo_bevel_def = {
     bmo_enum_bevel_miter_type},           /* outer miter kind */
    {"spread", BMO_OP_SLOT_FLT},           /* amount to offset beveled edge */
    {"smoothresh", BMO_OP_SLOT_FLT},       /* for passing mesh's smoothresh, used in hardening */
-   {"use_custom_profile", BMO_OP_SLOT_BOOL}, /* Whether to use custom profile feature */
-   /* the ProfileWiget struct for the custom profile shape */
-   {"custom_profile", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_STRUCT}},
+   {"custom_profile", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_STRUCT}}, /* CurveProfile */
    {"vmesh_method", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
     bmo_enum_bevel_vmesh_method},
    {{'\0'}},
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index b6c77c151e2..3bdf92c2552 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -112,6 +112,12 @@ enum {
   BEVEL_AMT_ABSOLUTE,
 };
 
+/* Bevel profile type */
+enum {
+  BEVEL_PROFILE_SUPERELLIPSE,
+  BEVEL_PROFILE_CUSTOM,
+};
+
 /* Bevel face_strength_mode values: should match face_str mode enum in DNA_modifer_types.h */
 enum {
   BEVEL_FACE_STRENGTH_NONE,
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 18193beff58..67f875ac262 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -33,6 +33,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 {
   const float offset = BMO_slot_float_get(op->slots_in, "offset");
   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 float profile = BMO_slot_float_get(op->slots_in, "profile");
@@ -47,7 +48,6 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
   const int miter_inner = BMO_slot_int_get(op->slots_in, "miter_inner");
   const float spread = BMO_slot_float_get(op->slots_in, "spread");
   const float smoothresh = BMO_slot_float_get(op->slots_in, "smoothresh");
-  const bool use_custom_profile = BMO_slot_bool_get(op->slots_in, "use_custom_profile");
   const CurveProfile *custom_profile = BMO_slot_ptr_get(op->slots_in, "custom_profile");
   const int vmesh_method = BMO_slot_int_get(op->slots_in, "vmesh_method");
 
@@ -76,6 +76,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
     BM_mesh_bevel(bm,
                   offset,
                   offset_type,
+                  profile_type,
                   seg,
                   profile,
                   vonly,
@@ -93,7 +94,6 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
                   miter_inner,
                   spread,
                   smoothresh,
-                  use_custom_profile,
                   custom_profile,
                   vmesh_method);
 
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 7929a686a16..e47b903cb10 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -302,6 +302,8 @@ typedef struct BevelParams {
   float offset;
   /** How offset is measured; enum defined in bmesh_operators.h. */
   int offset_type;
+  /** Profile type: radius, superellipse, or custom */
+  int profile_type;
   /** Number of segments in beveled edge profile. */
   int seg;
   /** User profile setting. */
@@ -324,9 +326,7 @@ typedef struct BevelParams {
   bool mark_sharp;
   /** Should we harden normals? */
   bool harden_normals;
-  /** Should we use the custom profiles feature? */
-  bool use_custom_profile;
-  char _pad[3];
+  char _pad[1];
   /** The struct used to store the custom profile input. */
   const struct CurveProfile *custom_profile;
   /** Vertex group array, maybe set if vertex_only. */
@@ -1737,7 +1737,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv, bool reversed, b
     }
   }
   r = pro->super_r;
-  if (!bp->use_custom_profile && r == PRO_LINE_R) {
+  if (bp->profile_type == BEVEL_PROFILE_SUPERELLIPSE && r == PRO_LINE_R) {
     map_ok = false;
   }
   else {
@@ -2334,7 +2334,7 @@ static void calculate_vm_profiles(BevelParams *bp, BevVert *bv, VMe

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list