[Bf-blender-cvs] [96c8b0a86a6] soc-2019-bevel-profiles: Small updates and progress on adding profile widget to bevel tool.

Hans Goudey noreply at git.blender.org
Tue Jul 9 15:58:35 CEST 2019


Commit: 96c8b0a86a6fa9522fe9dc187dc95d43014eb56c
Author: Hans Goudey
Date:   Tue Jul 9 09:59:18 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB96c8b0a86a6fa9522fe9dc187dc95d43014eb56c

Small updates and progress on adding profile widget to bevel tool.

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

M	source/blender/blenkernel/intern/profile_widget.c
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/mesh/editmesh_bevel.c

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

diff --git a/source/blender/blenkernel/intern/profile_widget.c b/source/blender/blenkernel/intern/profile_widget.c
index b4577ca7b99..11f301e8421 100644
--- a/source/blender/blenkernel/intern/profile_widget.c
+++ b/source/blender/blenkernel/intern/profile_widget.c
@@ -573,6 +573,7 @@ static void calchandle_profile(BezTriple *bezt, const BezTriple *prev, const Bez
  * curvature of the edge after each of them in the table. Works by comparing the angle between the
  * handles that make up the edge: the secong handle of the first point and the first handle
  * of the second. */
+/* HANS-TODO: This doesn't work so well, so maybe just assign the remainders to the longest edges */
 static int compare_curvature_bezt_edge_i(const BezTriple *bezt, const int i_a, const int i_b)
 {
   float handle_angle_a, handle_angle_b;
@@ -699,7 +700,7 @@ void profilewidget_create_samples(const ProfileWidget *prwdgt,
   for (i = 0; i < totedges; i++) {
     /* Place the new index (i) at the first spot where its edge has less curvature */
     for (i_insert = 0; i_insert < i; i_insert++) {
-      if (compare_curvature_bezt_edge_i(bezt, i, i_curve_sorted[i_insert])) {
+      if (!compare_curvature_bezt_edge_i(bezt, i, i_curve_sorted[i_insert])) {
         break;
       }
     }
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 82dc8aca8eb..d54f12bdf34 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1769,15 +1769,16 @@ static BMOpDefine bmo_bevel_def = {
    {"mark_sharp", BMO_OP_SLOT_BOOL},      /* extend edge data to allow sharp edges to run across bevels */
    {"harden_normals", BMO_OP_SLOT_BOOL},  /* harden normals */
    {"face_strength_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
-    bmo_enum_bevel_face_strength_type}, /* whether to set face strength, and which faces to set if so */
+    bmo_enum_bevel_face_strength_type},   /* whether to set face strength, and which faces to set if so */
    {"miter_outer", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
-    bmo_enum_bevel_miter_type},         /* outer miter kind */
+    bmo_enum_bevel_miter_type},           /* outer miter kind */
    {"miter_inner", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
-    bmo_enum_bevel_miter_type},         /* outer miter kind */
+    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 */
-   {"prwdgt", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_WIDGET}},    /* the ProfileWiget struct for the custom profile shape */
+   /* the ProfileWiget struct for the custom profile shape */
+   {"prwdgt", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_WIDGET}},
    /* HANS-TODO: Figure out how to get the struct through here using the required subtype */
    {"sample_straight_edges", BMO_OP_SLOT_BOOL},
    {{'\0'}},
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 7ba7ac3be2b..454e1f9b3c2 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -7182,7 +7182,7 @@ void BM_mesh_bevel(BMesh *bm,
   if (bp.use_custom_profile) {
     /* For now we need to sample the custom profile with at least as many segments as points */
     if (bp.seg < bp.prwdgt->totpoint) {
-      bp.seg = bp.prwdgt->totpoint;
+      bp.seg = bp.prwdgt->totpoint - 1;
     }
 //    profilewidget_initialize(bp.prwdgt, (short)bp.seg + 1);
   }
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index a01968cae2a..3bf204182e7 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -2329,8 +2329,8 @@ void ui_draw_but_PROFILE(ARegion *ar, uiBut *but, const uiWidgetColors *wcol, co
   GPU_line_smooth(false);
   GPU_blend(false);
   GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f)));
-  immBegin(GPU_PRIM_POINTS, tot_points - 1);
-  for (i = 0; i < tot_points - 1; i++) {
+  immBegin(GPU_PRIM_POINTS, tot_points);
+  for (i = 0; i < tot_points; i++) {
     fx = rect->xmin + zoomx * (pts[i].x - offsx);
     fy = rect->ymin + zoomy * (pts[i].y - offsy);
     immAttr4fv(col, (pts[i].flag & PROF_SELECT) ? color_vert_select : color_vert);
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 20063500926..5fe0c5d0b6d 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4658,8 +4658,6 @@ static void profilewidget_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAU
 
 /** Template for a path creation widget intended for custom bevel profiles.
   * This section is quite similar to uiTemplateCurveMapping, but with reduced complexity */
-/* HANS-STRETCH-GOAL: Add the ability to lengthen the height of the UI to keep the grid square
- * (or shrink the width I guess) */
 void uiTemplateProfileWidget(uiLayout *layout, PointerRNA *ptr, const char *propname)
 {
   RNAUpdateCb *cb;
diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c
index 4a536cc9109..69fad5044fb 100644
--- a/source/blender/editors/mesh/editmesh_bevel.c
+++ b/source/blender/editors/mesh/editmesh_bevel.c
@@ -45,6 +45,7 @@
 #include "WM_types.h"
 
 #include "UI_interface.h"
+#include "UI_resources.h"
 
 #include "ED_mesh.h"
 #include "ED_numinput.h"
@@ -324,6 +325,7 @@ static bool edbm_bevel_calc(wmOperator *op)
   const float spread = RNA_float_get(op->ptr, "spread");
   const bool use_custom_profile = RNA_boolean_get(op->ptr, "use_custom_profile");
   const PointerRNA prwdgt_ptr = RNA_pointer_get(op->ptr, "prwdgt");
+  const bool sample_straight_edges = RNA_boolean_get(op->ptr, "sample_straight_edges");
 
   const ProfileWidget *prwdgt = prwdgt_ptr.data;
 
@@ -371,7 +373,8 @@ static bool edbm_bevel_calc(wmOperator *op)
                  spread,
                  me->smoothresh,
                  use_custom_profile,
-                 prwdgt);
+                 prwdgt,
+                 sample_straight_edges);
 
     BMO_op_exec(em->bm, &bmop);
 
@@ -492,6 +495,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event,
 
 static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
+  printf("EDBM BEVEL INVOKE");
   RegionView3D *rv3d = CTX_wm_region_view3d(C);
   BevelData *opdata;
   float center_3d[3];
@@ -855,6 +859,33 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
   return OPERATOR_RUNNING_MODAL;
 }
 
+static void edbm_bevel_ui(bContext *UNUSED(C), wmOperator *op)
+{
+  uiLayout *layout = op->layout;
+  PointerRNA ptr;
+
+  RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
+
+  uiItemR(layout, &ptr, "offset_type", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "offset", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "offset_pct", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "segments", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "profile", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "vertex_only", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "clamp_overlap", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "loop_slide", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "mark_seam", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "mark_sharp", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "material", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "harden_normals", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "face_strength_mode", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "miter_outer", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "miter_inner", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "spread", 0, NULL, ICON_NONE);
+  uiItemR(layout, &ptr, "use_custom_profile", 0, NULL, ICON_NONE);
+  uiTemplateProfileWidget(layout, &ptr, "prwdgt");
+}
+
 void MESH_OT_bevel(wmOperatorType *ot)
 {
   printf("MESH OT BEVEL\n");
@@ -893,8 +924,7 @@ void MESH_OT_bevel(wmOperatorType *ot)
 
   /* identifiers */
   ot->name = "Bevel";
-  ot->description =
-      "Cut into selected items at an angle to create flat or rounded bevel or chamfer";
+  ot->description = "Cut into selected items at an angle to create bevel or chamfer";
   ot->idname = "MESH_OT_bevel";
 
   /* api callbacks */
@@ -904,6 +934,7 @@ void MESH_OT_bevel(wmOperatorType *ot)
   ot->cancel = edbm_bevel_cancel;
   ot->poll = ED_operator_editmesh;
   ot->poll_property = edbm_bevel_poll_property;
+  ot->ui = edbm_bevel_ui;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR_XY | OPTYPE_BLOCKING;
@@ -960,8 +991,10 @@ void MESH_OT_bevel(wmOperatorType *ot)
                   "Define a custom profile for the bevel");
 
   /* HANS-TODO: Add the profile widget here somehow */
-  RNA_def_pointer(ot->srna, "prwdgt", "ProfileWidget", "Profile Widget",
-                  "Widget for editing profile path");
+  RNA_def_pointer(ot->srna, "prwdgt", "ProfileWidget", "", "Widget for editing profile path");
+
+  RNA_def_boolean(ot->srna, "sample_straight_edges", false, "Custom Profile",
+                  "Define a custom profile for the bevel");
 
   prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "");
   RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);



More information about the Bf-blender-cvs mailing list