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:
authorHoward Trickey <howard.trickey@gmail.com>2013-02-21 21:29:35 +0400
committerHoward Trickey <howard.trickey@gmail.com>2013-02-21 21:29:35 +0400
commit0a6e8a41b9d607e80f2fe375e9de6183844a8dea (patch)
tree58c843ba5bcb30f96ff98e301d89a9a11d865369 /source/blender/modifiers/intern/MOD_bevel.c
parent091d86b9cb769f535fa11d2c7b6274e5206476d3 (diff)
Enable new bevel tool code in bevel modifier.
Now modifier takes a segments parameter. Bevel edge weights will multiply the overall amount. For vertex-only, you can give a vertex group name, and the weights in that will multiply the overall amount.
Diffstat (limited to 'source/blender/modifiers/intern/MOD_bevel.c')
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 776adb57c13..1942fe12a54 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -31,19 +31,22 @@
/** \file blender/modifiers/intern/MOD_bevel.c
* \ingroup modifiers
*/
+
+#include "DNA_object_types.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
+#include "BKE_deform.h"
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_bmesh.h" /* only for defines */
-#include "bmesh.h"
+#include "MOD_util.h"
-#include "DNA_object_types.h"
+#include "bmesh.h"
#include "MEM_guardedalloc.h"
@@ -88,21 +91,12 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
-// #define USE_BM_BEVEL_OP_AS_MOD
-
#ifdef USE_BM_BEVEL_OP_AS_MOD
-/* BMESH_TODO
- *
- * this bevel calls the new bevel code (added since 2.64)
- * which is missing many of the options which the bevel modifier from 2.4x has.
- * - no vertex bevel
- * - no weight bevel
- *
- * These will need to be added to the bmesh operator.
- * - campbell
+/*
+ * This calls the new bevel code (added since 2.64)
*/
-static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
+static DerivedMesh *applyModifier(ModifierData *md, struct Object *ob,
DerivedMesh *dm,
ModifierApplyFlag UNUSED(flag))
{
@@ -110,13 +104,33 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
BMesh *bm;
BMIter iter;
BMEdge *e;
+ BMVert *v;
+ float weight;
+ int vgroup = -1;
+ MDeformVert *dvert = NULL;
BevelModifierData *bmd = (BevelModifierData *) md;
const float threshold = cosf((bmd->bevel_angle + 0.00001f) * (float)M_PI / 180.0f);
- const int segments = 16; /* XXX */
+ const bool vertex_only = bmd->flags & BME_BEVEL_VERT;
bm = DM_to_bmesh(dm);
- if (bmd->lim_flags & BME_BEVEL_ANGLE) {
+ if (vertex_only) {
+ if ((bmd->lim_flags & BME_BEVEL_VGROUP) && bmd->defgrp_name[0]) {
+ modifier_get_vgroup(ob, dm, bmd->defgrp_name, &dvert, &vgroup);
+ }
+ BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
+ if (!BM_vert_is_manifold(v))
+ continue;
+ if (vgroup != -1) {
+ /* Is it safe to assume bmesh indices and dvert array line up?? */
+ weight = defvert_array_find_weight_safe(dvert, BM_elem_index_get(v), vgroup);
+ if (weight <= 0.0f)
+ continue;
+ }
+ BM_elem_flag_enable(v, BM_ELEM_TAG);
+ }
+ }
+ else if (bmd->lim_flags & BME_BEVEL_ANGLE) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
/* check for 1 edge having 2 face users */
BMLoop *l_a, *l_b;
@@ -133,6 +147,11 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
/* crummy, is there a way just to operator on all? - campbell */
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_edge_is_manifold(e)) {
+ if (bmd->lim_flags & BME_BEVEL_WEIGHT) {
+ weight = BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT);
+ if (weight == 0.0f)
+ continue;
+ }
BM_elem_flag_enable(e, BM_ELEM_TAG);
BM_elem_flag_enable(e->v1, BM_ELEM_TAG);
BM_elem_flag_enable(e->v2, BM_ELEM_TAG);
@@ -140,11 +159,14 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob),
}
}
- BM_mesh_bevel(bm, bmd->value, segments, bmd->flags & BME_BEVEL_VERT);
+ BM_mesh_bevel(bm, bmd->value, bmd->res,
+ vertex_only, bmd->lim_flags & BME_BEVEL_WEIGHT, dvert, vgroup);
result = CDDM_from_bmesh(bm, TRUE);
- BLI_assert(bm->toolflagpool == NULL); /* make sure we never alloc'd this */
+ BLI_assert(bm->vtoolflagpool == NULL &&
+ bm->etoolflagpool == NULL &&
+ bm->ftoolflagpool == NULL); /* make sure we never alloc'd these */
BM_mesh_free(bm);
CDDM_calc_normals(result);