[Bf-blender-cvs] [e64f58756f8] soc-2019-bevel-profiles: Custom Profile Editing: Added a profile editor widget

Hans Goudey noreply at git.blender.org
Fri Jun 21 06:57:13 CEST 2019


Commit: e64f58756f8a28135b7c8abcc1cc77281bef472d
Author: Hans Goudey
Date:   Fri Jun 21 00:52:28 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rBe64f58756f8a28135b7c8abcc1cc77281bef472d

Custom Profile Editing: Added a profile editor widget

This ProfileWidget and related drawing and interface code mirrors much of the
functionality of the CurveMapping code, but with the important different that
it's evaluation results in a 2D result, the X and Y of a position along the
profile generated in the widget. Because of this fundamental change to the
purpose of the widget, it made sense to split it into a new widget rather
than increasing the complexity of both areas.

This is incomplete and buggy at the moment, but it lays the groundwork for
future changes that I'll work on in the coming days, and it does compile.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/CMakeLists.txt
M	source/blender/blenkernel/BKE_profile_path.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/profile_path.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/bmesh/intern/bmesh_opdefines.c
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/space_node/drawnode.c
M	source/blender/makesdna/DNA_modifier_types.h
A	source/blender/makesdna/DNA_profilepath_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/CMakeLists.txt
M	source/blender/makesrna/intern/makesrna.c
M	source/blender/makesrna/intern/rna_internal.h
M	source/blender/makesrna/intern/rna_modifier.c
A	source/blender/makesrna/intern/rna_profile.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/modifiers/intern/MOD_bevel.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 1a39c4c06f3..a922901accd 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -173,7 +173,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         layout.row().prop(md, "use_custom_profile")
         if md.use_custom_profile:
-            layout.template_curve_mapping(md, "profile_curve")
+            layout.template_profilewidget(md, "prwdgt")
             layout.row().prop(md, "sample_points")
 
     def BOOLEAN(self, layout, _ob, md):
diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 76442048594..b8c5f72e41c 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_profilepath_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_profile_path.h b/source/blender/blenkernel/BKE_profile_path.h
index f7fbb499c71..b472c6b7277 100644
--- a/source/blender/blenkernel/BKE_profile_path.h
+++ b/source/blender/blenkernel/BKE_profile_path.h
@@ -13,79 +13,70 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2006 Blender Foundation.
+ * Copyright (C) 2019 Blender Foundation.
  * All rights reserved.
  */
-#ifdef __NO_NO_NO__
-#define __NO_NO_NO_
-//#ifndef __BKE_PROFILEPATH_H__
-//#define __BKE_PROFILEPATH_H__
+/* HANS-TODO: Check right copyright info for new files */
+#ifndef BKE_PROFILEPATH_H
+#define BKE_PROFILEPATH_H
 
 /** \file
  * \ingroup bke
  */
 
-struct CurveMap;
-struct CurveMapPoint;
-struct CurveMapping;
-
-void profilepath_set_defaults(
-    struct CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy);
-struct CurveMapping *profilepath_add(int tot, float minx, float miny, float maxx, float maxy);
-void profilepath_free_data(struct CurveMapping *cumap);
-void profilepath_free(struct CurveMapping *cumap);
-void profilepath_copy_data(struct CurveMapping *target, const struct CurveMapping *cumap);
-struct CurveMapping *profilepath_copy(const struct CurveMapping *cumap);
-void profilepath_set_black_white_ex(const float black[3], const float white[3], float r_bwmul[3]);
-void profilepath_set_black_white(struct CurveMapping *cumap,
-                                  const float black[3],
-                                  const float white[3]);
-
-/* Used for a path where the curve isn't necessarily a function. */
-
-/* Initialized with the number of segments to fill the table with */
-void profilepath_initialize(
-    struct CurveMapping *cumap,
-    int nsegments);  // HANS-TODO: Hmm, this assumes there is only one curve
+struct ProfileWidget;
+struct ProfilePath;
+struct ProfilePoint;
+
+void profilewidget_set_defaults(struct ProfileWidget *prwdgt);
+
+struct ProfileWidget *profilewidget_add(int preset);
+
+void profilewidget_free_data(struct ProfileWidget *prwdgt);
+
+void profilewidget_free(struct ProfileWidget *prwdgt);
+
+void profilewidget_copy_data(struct ProfileWidget *target, const struct ProfileWidget *prwdgt);
+
+struct ProfileWidget *profilewidget_copy(const struct ProfileWidget *prwdgt);
+
 /* Evaluates along the length of the path rather than with X coord */
-void profilepath_evaluate(const struct CurveMapping *cumap,
-                                int segment,
-                                float *x_out,
-                                float *y_out);
-/* Length portion is the fraction of the total path length where we want the location */
-void profile_evaluate(const struct CurveMap *cuma,
-                            float length_portion,
+void profilewidget_evaluate(const struct ProfileWidget *prwdgt,
+                            int segment,
                             float *x_out,
                             float *y_out);
+
+/* Length portion is the fraction of the total path length where we want the location */
+void profilepath_evaluate(const struct ProfilePath *prpath,
+                          float length_portion,
+                          float *x_out,
+                          float *y_out);
+
 /* Need to find the total length of the curve to sample a portion of it */
-float profile_total_length(const struct CurveMap *cuma);
+float profilepath_total_length(const struct ProfilePath *prpath);
+
 /* Distance in 2D to the next point */
-float profile_linear_distance_to_next_point(const struct CurveMap *cuma, int i);
+float profilepath_linear_distance_to_next_point(const struct ProfilePath *prpath, int i);
+
+
+void profilepath_reset(struct ProfilePath *prpath, int preset);
+
+void profilepath_remove(struct ProfilePath *prpath, const short flag);
+
+bool profilepath_remove_point(struct ProfilePath *prpath, struct ProfilePoint *point);
 
-enum {
-  CURVEMAP_SLOPE_NEGATIVE = 0,
-  CURVEMAP_SLOPE_POSITIVE = 1,
-  CURVEMAP_SLOPE_POS_NEG = 2,
-};
+struct ProfilePoint *profilepath_insert(struct ProfilePath *prpath, float x, float y);
 
-void profile_reset(struct CurveMap *cuma, const struct rctf *clipr, int preset, int slope);
-void profile_remove(struct CurveMap *cuma, const short flag);
-bool profile_remove_point(struct CurveMap *cuma, struct CurveMapPoint *cmp);
-struct CurveMapPoint *curvemap_insert(struct CurveMap *cuma, float x, float y);
-void profile_handle_set(struct CurveMap *cuma, int type);
+void profilepath_handle_set(struct ProfilePath *prpath, int type);
 
-void profilepath_changed(struct CurveMapping *cumap, const bool rem_doubles);
-void profilepath_changed_all(struct CurveMapping *cumap);
+/* Called for a complete update of the widget after modifications */
+void profilewidget_changed(struct ProfileWidget *prwdgt, const bool rem_doubles);
 
 /* call before _all_ evaluation functions */
-void profilepath_initialize2(struct CurveMapping *cumap);
+void profilewidget_initialize(struct ProfileWidget *prwdgt, int nsegments);
 
-/* keep these (const CurveMap) - to help with thread safety */
+/* HANS-TODO: Remove these, they only sample in 1D, so they won't be useful */
 /* single curve, no table check */
-float profile_evaluateF(const struct CurveMap *cuma, float value);
-/* single curve, with table check */
-float profilepath_evaluateF(const struct CurveMapping *cumap, int cur, float value);
-/* non-const, these modify the curve */
-void profilepath_premultiply(struct CurveMapping *cumap, int restore);
+float profilepath_evaluateF(const struct ProfilePath *prpath, float value);
 
 #endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index e564e91749c..c15df299e1f 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -177,6 +177,7 @@ set(SRC
   intern/pbvh.c
   intern/pbvh_bmesh.c
   intern/pointcache.c
+  intern/profile_path.c
   intern/report.c
   intern/rigidbody.c
   intern/scene.c
@@ -316,6 +317,7 @@ set(SRC
   BKE_particle.h
   BKE_pbvh.h
   BKE_pointcache.h
+  BKE_profile_path.h
   BKE_report.h
   BKE_rigidbody.h
   BKE_scene.h
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 99ae19c3c30..88605c8a248 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -100,6 +100,7 @@ void BKE_paint_invalidate_overlay_tex(Scene *scene, ViewLayer *view_layer, const
   }
 }
 
+/* HANS-TODO: Update?! */
 void BKE_paint_invalidate_cursor_overlay(Scene *scene, ViewLayer *view_layer, CurveMapping *curve)
 {
   Paint *p = BKE_paint_get_active(scene, view_layer);
diff --git a/source/blender/blenkernel/intern/profile_path.c b/source/blender/blenkernel/intern/profile_path.c
index 89ea709ef98..6b9d49acfd0 100644
--- a/source/blender/blenkernel/intern/profile_path.c
+++ b/source/blender/blenkernel/intern/profile_path.c
@@ -13,7 +13,7 @@
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * The Original Code is Copyright (C) 2005 Blender Foundation.
+ * Copyright (C) 2019 Blender Foundation.
  * All rights reserved.
  */
 
@@ -28,7 +28,7 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "DNA_color_types.h"
+#include "DNA_profilepath_types.h"
 #include "DNA_curve_types.h"
 
 #include "BLI_blenlib.h"
@@ -41,162 +41,119 @@
 #include "BKE_curve.h"
 #include "BKE_fcurve.h"
 
-#include "IMB_colormanagement.h"
-#include "IMB_imbuf_types.h"
+#define DEBUG_PRWDGT 0
 
-void profilepath_set_defaults(
-    CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy)
+void profilewidget_set_defaults(ProfileWidget *prwdgt)
 {
-  int a;
-  float clipminx, clipminy, clipmaxx, clipmaxy;
+  prwdgt->flag = PROF_DO_CLIP;
 
-  cumap->flag = CUMA_DO_CLIP;
-  if (tot == 4) {
-    cumap->cur = 3; /* rhms, hack for 'col' curve? */
-  }
-
-  clipminx = min_ff(minx, maxx);
-  clipminy = min_ff(miny, maxy);
-  clipmaxx = max_ff(minx, maxx);
-  clipmaxy = max_ff(miny, maxy);
-
-  BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy);
-  cumap->clipr = cumap->curr;
+  BLI_rctf_init(&prwdgt->curr, 0.0f, 1.0f, 0.0f, 1.0f);
+  prwdgt->clipr = prwdgt->curr;
 
-  cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f;
-  cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f;
+  prwdgt->profile->totpoint = 2;
+  prwdgt->profile->path = MEM_callocN(2 * sizeof(ProfilePoint), "path points");
 
-  for (a = 0; a < tot; a++) {
-    cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE;
-    cumap->cm[a].totpoint = 2;
-    cumap->cm[a].curve = MEM_callocN(2 * sizeof(CurveMapPoint), "curve points");
-
-    cumap->cm[a].curve[0].x = minx;
-    cumap->cm[a].curve[0].y = 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list