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/modifiers/intern/MOD_bevel.c
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/modifiers/intern/MOD_bevel.c')
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 0c00bb572be..17384f133b1 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -31,6 +31,7 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_curveprofile_types.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
@@ -40,6 +41,7 @@
#include "bmesh.h"
#include "bmesh_tools.h"
+#include "BKE_curveprofile.h"
#include "DEG_depsgraph_query.h"
@@ -47,7 +49,7 @@ static void initData(ModifierData *md)
{
BevelModifierData *bmd = (BevelModifierData *)md;
- bmd->value = 0.1f;
+ bmd->value = 1.0f;
bmd->res = 1;
bmd->flags = 0;
bmd->val_flags = MOD_BEVEL_AMT_OFFSET;
@@ -62,11 +64,16 @@ static void initData(ModifierData *md)
bmd->profile = 0.5f;
bmd->bevel_angle = DEG2RADF(30.0f);
bmd->defgrp_name[0] = '\0';
+ bmd->custom_profile = BKE_curveprofile_add(PROF_PRESET_LINE);
}
static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag)
{
+ const BevelModifierData *bmd_src = (const BevelModifierData *)md_src;
+ BevelModifierData *bmd_dst = (BevelModifierData *)md_dst;
+
modifier_copyData_generic(md_src, md_dst, flag);
+ bmd_dst->custom_profile = BKE_curveprofile_copy(bmd_src->custom_profile);
}
static void requiredDataMask(Object *UNUSED(ob),
@@ -109,6 +116,8 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
const int miter_outer = bmd->miter_outer;
const int miter_inner = bmd->miter_inner;
const float spread = bmd->spread;
+ const bool use_custom_profile = (bmd->flags & MOD_BEVEL_CUSTOM_PROFILE);
+ const int vmesh_method = bmd->vmesh_method;
bm = BKE_mesh_to_bmesh_ex(mesh,
&(struct BMeshCreateParams){0},
@@ -210,7 +219,10 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes
miter_outer,
miter_inner,
spread,
- mesh->smoothresh);
+ mesh->smoothresh,
+ use_custom_profile,
+ bmd->custom_profile,
+ vmesh_method);
result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh);
@@ -229,6 +241,18 @@ static bool dependsOnNormals(ModifierData *UNUSED(md))
return true;
}
+static void freeData(ModifierData *md)
+{
+ BevelModifierData *bmd = (BevelModifierData *)md;
+ BKE_curveprofile_free(bmd->custom_profile);
+}
+
+static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
+{
+ BevelModifierData *bmd = (BevelModifierData *)md;
+ return (bmd->value == 0.0f);
+}
+
ModifierTypeInfo modifierType_Bevel = {
/* name */ "Bevel",
/* structName */ "BevelModifierData",
@@ -236,19 +260,16 @@ ModifierTypeInfo modifierType_Bevel = {
/* type */ eModifierTypeType_Constructive,
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode |
eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_AcceptsCVs,
-
/* copyData */ copyData,
-
/* deformVerts */ NULL,
/* deformMatrices */ NULL,
/* deformVertsEM */ NULL,
/* deformMatricesEM */ NULL,
/* applyModifier */ applyModifier,
-
/* initData */ initData,
/* requiredDataMask */ requiredDataMask,
- /* freeData */ NULL,
- /* isDisabled */ NULL,
+ /* freeData */ freeData,
+ /* isDisabled */ isDisabled,
/* updateDepsgraph */ NULL,
/* dependsOnTime */ NULL,
/* dependsOnNormals */ dependsOnNormals,