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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user