Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2019-11-21 00:12:32 +0300
committerHans Goudey <h.goudey@me.com>2019-11-21 00:25:28 +0300
commitba1e9ae4733ae956331c7e8899f6939997205298 (patch)
tree007362ed2c9ee4564b67404f552906d6e66848db /source/blender/makesdna
parent8c6ce742391b2b8798143a4a2c2224ebbeb7f1ec (diff)
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
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r--source/blender/makesdna/DNA_curveprofile_types.h91
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h19
-rw-r--r--source/blender/makesdna/DNA_scene_types.h9
-rw-r--r--source/blender/makesdna/intern/makesdna.c2
4 files changed, 116 insertions, 5 deletions
diff --git a/source/blender/makesdna/DNA_curveprofile_types.h b/source/blender/makesdna/DNA_curveprofile_types.h
new file mode 100644
index 00000000000..d7e3591a9b8
--- /dev/null
+++ b/source/blender/makesdna/DNA_curveprofile_types.h
@@ -0,0 +1,91 @@
+/*
+ * 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 DNA
+ */
+
+#ifndef DNA_PROFILEPATH_TYPES_H
+#define DNA_PROFILEPATH_TYPES_H
+
+#include "DNA_vec_types.h"
+
+/** Number of points in high resolution table is dynamic up to a maximum. */
+#define PROF_TABLE_MAX 512
+/** Number of table points per control point. */
+#define PROF_RESOL 16
+/** Dynamic size of widget's high resolution table. Input should be profile->totpoint. */
+#define PROF_N_TABLE(n_pts) min_ii(PROF_TABLE_MAX, (((n_pts - 1)) * PROF_RESOL) + 1)
+
+/** Each control point that makes up the profile.
+ * \note The flags use the same enum as Bezier curves, but they aren't garanteed
+ * to have identical functionality, and all types aren't implemented. */
+typedef struct CurveProfilePoint {
+ /** Location of the point, keep together. */
+ float x, y;
+ /** Flag selection state and others. */
+ short flag;
+ /** Flags for both handle's type (eBezTriple_Handle). */
+ char h1, h2;
+} CurveProfilePoint;
+
+/** #CurveProfilePoint.flag */
+enum {
+ PROF_SELECT = (1 << 0),
+};
+
+/** Defines a profile */
+typedef struct CurveProfile {
+ /** Number of user-added points that define the profile. */
+ short path_len;
+ /** Number of sampled points. */
+ short segments_len;
+ /** Preset to use when reset. */
+ int preset;
+ /** Sequence of points defining the shape of the curve. */
+ CurveProfilePoint *path;
+ /** Display and evaluation table at higher resolution for curves. */
+ CurveProfilePoint *table;
+ /** The positions of the sampled points. Used to display a preview of where they will be. */
+ CurveProfilePoint *segments;
+ /** Flag for mode states, sampling options, etc... */
+ int flag;
+ /** Used for keeping track how many times the widget is changed. */
+ int changed_timestamp;
+ /** Widget's current view, and clipping rect (is default rect too). */
+ rctf view_rect, clip_rect;
+} CurveProfile;
+
+/** #CurveProfile.flag */
+enum {
+ PROF_USE_CLIP = (1 << 0), /* Keep control points inside bounding rectangle. */
+ PROF_SYMMETRY_MODE = (1 << 1), /* Unused for now. */
+ PROF_SAMPLE_STRAIGHT_EDGES = (1 << 2), /* Sample extra points on straight edges. */
+ PROF_SAMPLE_EVEN_LENGTHS = (1 << 3), /* Put segments evenly spaced along the path. */
+};
+
+typedef enum eCurveProfilePresets {
+ PROF_PRESET_LINE = 0, /* Default simple line between end points. */
+ PROF_PRESET_SUPPORTS = 1, /* Support loops for a regular curved profile. */
+ PROF_PRESET_CORNICE = 2, /* Moulding type example. */
+ PROF_PRESET_CROWN = 3, /* Second moulding example. */
+ PROF_PRESET_STEPS = 4, /* Dynamic number of steps defined by totsegments. */
+} eCurveProfilePresets;
+
+#endif
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 9c4d7bcd3b1..a8db46238d8 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -377,10 +377,11 @@ typedef struct BevelModifierData {
short mat;
short edge_flags;
short face_str_mode;
- /* patterns to use for mitering non-reflex and reflex miter edges */
+ /** Patterns to use for mitering non-reflex and reflex miter edges */
short miter_inner;
short miter_outer;
- char _pad0[2];
+ /** The method to use for creating >2-way intersections */
+ short vmesh_method;
/** Controls profile shape (0->1, .5 is round). */
float profile;
/** if the MOD_BEVEL_ANGLE is set,
@@ -390,6 +391,10 @@ typedef struct BevelModifierData {
/** if the MOD_BEVEL_VWEIGHT option is set,
* this will be the name of the vert group, MAX_VGROUP_NAME */
char defgrp_name[64];
+
+ /** Curve info for the custom profile */
+ struct CurveProfile *custom_profile;
+
} BevelModifierData;
/* BevelModifierData->flags and BevelModifierData->lim_flags */
@@ -399,8 +404,8 @@ enum {
MOD_BEVEL_ANGLE = (1 << 3),
MOD_BEVEL_WEIGHT = (1 << 4),
MOD_BEVEL_VGROUP = (1 << 5),
- /* unused = (1 << 7), */
- /* unused = (1 << 8), */
+ MOD_BEVEL_CUSTOM_PROFILE = (1 << 7),
+ MOD_BEVEL_SAMPLE_STRAIGHT = (1 << 8),
/* unused = (1 << 9), */
/* unused = (1 << 10), */
/* unused = (1 << 11), */
@@ -439,6 +444,12 @@ enum {
MOD_BEVEL_MITER_ARC,
};
+/* BevelModifier->vmesh_method */
+enum {
+ MOD_BEVEL_VMESH_ADJ,
+ MOD_BEVEL_VMESH_CUTOFF,
+};
+
typedef struct SmokeModifierData {
ModifierData modifier;
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 2ca9e3b2ef7..e60b16453b2 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -33,7 +33,8 @@
extern "C" {
#endif
-#include "DNA_color_types.h" /* color management */
+#include "DNA_color_types.h" /* color management */
+#include "DNA_curveprofile_types.h"
#include "DNA_customdata_types.h" /* Scene's runtime cddata masks. */
#include "DNA_vec_types.h"
#include "DNA_listBase.h"
@@ -50,6 +51,7 @@ struct Brush;
struct Collection;
struct ColorSpace;
struct CurveMapping;
+struct CurveProfile;
struct CustomData_MeshMasks;
struct Editing;
struct Image;
@@ -1515,6 +1517,11 @@ typedef struct ToolSettings {
/* Normal Editing */
float normal_vector[3];
char _pad6[4];
+
+ /* Custom Curve Profile for bevel tool:
+ * Temporary until there is a proper preset system that stores the profiles or maybe stores
+ * entire bevel configurations. */
+ struct CurveProfile *custom_bevel_profile_preset;
} ToolSettings;
/* *************************************************************** */
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 80d37d89f14..d6f52e48ebe 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -131,6 +131,7 @@ static const char *includefiles[] = {
"DNA_layer_types.h",
"DNA_workspace_types.h",
"DNA_lightprobe_types.h",
+ "DNA_curveprofile_types.h",
/* see comment above before editing! */
@@ -1590,6 +1591,7 @@ int main(int argc, char **argv)
#include "DNA_layer_types.h"
#include "DNA_workspace_types.h"
#include "DNA_lightprobe_types.h"
+#include "DNA_curveprofile_types.h"
/* end of list */