[Bf-blender-cvs] [ba1e9ae4733] master: Bevel: Custom Profile and CurveProfile Widget

Hans Goudey noreply at git.blender.org
Wed Nov 20 22:26:52 CET 2019


Commit: ba1e9ae4733ae956331c7e8899f6939997205298
Author: Hans Goudey
Date:   Wed Nov 20 16:12:32 2019 -0500
Branches: master
https://developer.blender.org/rBba1e9ae4733ae956331c7e8899f6939997205298

Bevel: Custom Profile and CurveProfile Widget

Custom profiles in bevel allows the profile curve to be controlled by
manually placed control points. Orientation is regularized along
groups of edges, and the 'pipe case' is updated. This commit includes
many updates to comments and changed variable names as well.

A 'cutoff' vertex mesh method is added to bevel in addition to the
existing grid fill option for replacing vertices.

The UI of the bevel modifier and tool are updated and unified.

Also, a 'CurveProfile' widget is added to BKE for defining the profile
in the interface, which may be useful in other situations.

Many thanks to Howard, my mentor for this GSoC project.

Reviewers: howardt, campbellbarton

Differential Revision: https://developer.blender.org/D5516

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/CMakeLists.txt
A	source/blender/blenkernel/BKE_curveprofile.h
M	source/blender/blenkernel/CMakeLists.txt
A	source/blender/blenkernel/intern/curveprofile.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/intern/bmesh_operator_api.h
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/include/UI_interface.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_query.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/mesh/editmesh_bevel.c
A	source/blender/makesdna/DNA_curveprofile_types.h
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/RNA_enum_types.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
A	source/blender/makesrna/intern/rna_curveprofile.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/makesrna/intern/rna_scene.c
M	source/blender/makesrna/intern/rna_ui_api.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 b2ce3c8e608..f86b017806f 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -4680,6 +4680,8 @@ 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),
+        ("VERTEX_MESH_CHANGE", {"type": 'N', "value": 'PRESS', "any": True}, None),
     ])
 
     return keymap
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 05e8f0fce38..f576a29a783 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -133,43 +133,55 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.prop(md, "end_cap")
 
     def BEVEL(self, layout, ob, md):
-        split = layout.split()
-
-        col = split.column()
-        if md.offset_type == 'PERCENT':
-            col.prop(md, "width_pct")
+        offset_type = md.offset_type
+        if offset_type == 'PERCENT':
+            layout.prop(md, "width_pct")
         else:
-            col.prop(md, "width")
-        col.prop(md, "segments")
-        col.prop(md, "profile")
-        col.prop(md, "material")
+            offset_text = "Width"
+            if offset_type == 'DEPTH':
+                offset_text = "Depth"
+            elif offset_type == 'OFFSET':
+                offset_text = "Offset"
+            layout.prop(md, "width", text=offset_text)
+        layout.row().prop(md, "offset_type", expand=True)
 
+        split = layout.split()
         col = split.column()
         col.prop(md, "use_only_vertices")
         col.prop(md, "use_clamp_overlap")
         col.prop(md, "loop_slide")
+        col = split.column()
         col.prop(md, "mark_seam")
         col.prop(md, "mark_sharp")
         col.prop(md, "harden_normals")
 
+        layout.row().prop(md, "segments")
+        layout.row().prop(md, "profile")
+        layout.row().prop(md, "material")
+
+        layout.label(text="Miter Type:")
+        layout.row().prop(md, "miter_outer", text="Outer")
+        layout.row().prop(md, "miter_inner", text="Inner")
+        if md.miter_inner in {'MITER_PATCH', 'MITER_ARC'}:
+            layout.row().prop(md, "spread")
+
         layout.label(text="Limit Method:")
         layout.row().prop(md, "limit_method", expand=True)
         if md.limit_method == 'ANGLE':
             layout.prop(md, "angle_limit")
         elif md.limit_method == 'VGROUP':
-            layout.label(text="Vertex Group:")
             layout.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
 
-        layout.label(text="Width Method:")
-        layout.row().prop(md, "offset_type", expand=True)
-
-        layout.label(text="Set Face Strength Mode")
+        layout.label(text="Face Strength Mode:")
         layout.row().prop(md, "face_strength_mode", expand=True)
 
-        layout.label(text="Miter Patterns")
-        layout.row().prop(md, "miter_outer")
-        layout.row().prop(md, "miter_inner")
-        layout.row().prop(md, "spread")
+        layout.label(text="Intersection Type:")
+        layout.row().prop(md, "vmesh_method", expand=True)
+        layout.row().prop(md, "use_custom_profile")
+        row = layout.row()
+        row.enabled = md.use_custom_profile
+        if md.use_custom_profile:
+            layout.template_curveprofile(md, "custom_profile")
 
     def BOOLEAN(self, layout, _ob, md):
         split = layout.split()
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 203543b0ef0..62923d18b70 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -68,6 +68,7 @@ set(SRC_DNA_INC
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_outliner_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_packedFile_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_particle_types.h
+  ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_curveprofile_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_rigidbody_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_scene_types.h
   ${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_screen_types.h
diff --git a/source/blender/blenkernel/BKE_curveprofile.h b/source/blender/blenkernel/BKE_curveprofile.h
new file mode 100644
index 00000000000..1f6659d785a
--- /dev/null
+++ b/source/blender/blenkernel/BKE_curveprofile.h
@@ -0,0 +1,76 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (C) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+#ifndef __BKE_CURVEPROFILE_H__
+#define __BKE_CURVEPROFILE_H__
+
+/** \file
+ * \ingroup bke
+ */
+
+struct CurveProfile;
+struct CurveProfilePoint;
+
+void BKE_curveprofile_set_defaults(struct CurveProfile *profile);
+
+struct CurveProfile *BKE_curveprofile_add(int preset);
+
+void BKE_curveprofile_free_data(struct CurveProfile *profile);
+
+void BKE_curveprofile_free(struct CurveProfile *profile);
+
+void BKE_curveprofile_copy_data(struct CurveProfile *target, const struct CurveProfile *profile);
+
+struct CurveProfile *BKE_curveprofile_copy(const struct CurveProfile *profile);
+
+bool BKE_curveprofile_remove_point(struct CurveProfile *profile, struct CurveProfilePoint *point);
+
+void BKE_curveprofile_remove_by_flag(struct CurveProfile *profile, const short flag);
+
+struct CurveProfilePoint *BKE_curveprofile_insert(struct CurveProfile *profile, float x, float y);
+
+void BKE_curveprofile_selected_handle_set(struct CurveProfile *profile, int type_1, int type_2);
+
+void BKE_curveprofile_reverse(struct CurveProfile *profile);
+
+void BKE_curveprofile_reset(struct CurveProfile *profile);
+
+void BKE_curveprofile_create_samples(struct CurveProfile *profile,
+                                     int segments_len,
+                                     bool sample_straight_edges,
+                                     struct CurveProfilePoint *r_samples);
+
+void BKE_curveprofile_initialize(struct CurveProfile *profile, short segments_len);
+
+/* Called for a complete update of the widget after modifications */
+void BKE_curveprofile_update(struct CurveProfile *profile, const bool rem_doubles);
+
+/* Need to find the total length of the curve to sample a portion of it */
+float BKE_curveprofile_total_length(const struct CurveProfile *profile);
+
+void BKE_curveprofile_create_samples_even_spacing(struct CurveProfile *profile,
+                                                   int segments_len,
+                                                   struct CurveProfilePoint *r_samples);
+
+/* Length portion is the fraction of the total path length where we want the location */
+void BKE_curveprofile_evaluate_length_portion(const struct CurveProfile *profile,
+                                              float length_portion,
+                                              float *x_out,
+                                              float *y_out);
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 023980292fa..49cead5c003 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -185,6 +185,7 @@ set(SRC
   intern/pbvh_bmesh.c
   intern/pbvh_parallel.cc
   intern/pointcache.c
+  intern/curveprofile.c
   intern/report.c
   intern/rigidbody.c
   intern/scene.c
@@ -330,6 +331,7 @@ set(SRC
   BKE_particle.h
   BKE_pbvh.h
   BKE_pointcache.h
+  BKE_curveprofile.h
   BKE_report.h
   BKE_rigidbody.h
   BKE_scene.h
diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c
new file mode 100644
index 00000000000..6689eca132d
--- /dev/null
+++ b/source/blender/blenkernel/intern/curveprofile.c
@@ -0,0 +1,1011 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright (C) 2019 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include <string.h>
+#include <math.h>
+#include <stdlib.h>
+#include <float.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_curveprofile_types.h"
+#include "DNA_curve_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_task.h"
+#include "BLI_threads.h"
+
+#include "BKE_curveprofile.h"
+#include "BKE_curve.h"
+#include "BKE_fcurve.h"
+
+void BKE_curveprofile_free_data(CurveProfile *profile)
+{
+  MEM_SAFE_FREE(profile->path);
+  MEM_SAFE_FREE(profile->table)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list