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:
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_opdefines.c11
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.h6
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c56
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.h2
5 files changed, 47 insertions, 32 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 67c0fdba12b..4117ad67dd3 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1755,6 +1755,12 @@ static BMO_FlagSet bmo_enum_bevel_vmesh_method[] = {
{0, NULL},
};
+static BMO_FlagSet bmo_enum_bevel_affect_type[] = {
+ {BEVEL_AFFECT_VERTICES, "VERTICES"},
+ {BEVEL_AFFECT_EDGES, "EDGES"},
+ {0, NULL},
+};
+
/*
* Bevel.
*
@@ -1768,10 +1774,11 @@ static BMOpDefine bmo_bevel_def = {
{"offset_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
bmo_enum_bevel_offset_type}, /* how to measure the offset */
{"profile_type", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
- bmo_enum_bevel_profile_type}, /* The profile type to use for bevel. */
+ bmo_enum_bevel_profile_type}, /* The profile type to use for bevel. */
{"segments", BMO_OP_SLOT_INT}, /* number of segments in bevel */
{"profile", BMO_OP_SLOT_FLT}, /* profile shape, 0->1 (.5=>round) */
- {"vertex_only", BMO_OP_SLOT_BOOL}, /* only bevel vertices, not edges */
+ {"affect", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
+ bmo_enum_bevel_affect_type}, /* Whether to bevel vertices or edges. */
{"clamp_overlap", BMO_OP_SLOT_BOOL}, /* do not allow beveled edges/vertices to overlap each other */
{"material", BMO_OP_SLOT_INT}, /* material for bevel faces, -1 means get from adjacent faces */
{"loop_slide", BMO_OP_SLOT_BOOL}, /* prefer to slide along edges to having even widths */
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 29fcf7ca0ca..c0e59758120 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -139,6 +139,12 @@ enum {
BEVEL_VMESH_CUTOFF,
};
+/* Bevel affect option. */
+enum {
+ BEVEL_AFFECT_VERTICES = 0,
+ BEVEL_AFFECT_EDGES = 1,
+};
+
/* Normal Face Strength values */
enum {
FACE_STRENGTH_WEAK = -16384,
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 67f875ac262..4e708b595e0 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -35,7 +35,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
const int offset_type = BMO_slot_int_get(op->slots_in, "offset_type");
const int profile_type = BMO_slot_int_get(op->slots_in, "profile_type");
const int seg = BMO_slot_int_get(op->slots_in, "segments");
- const bool vonly = BMO_slot_bool_get(op->slots_in, "vertex_only");
+ const int affect_type = BMO_slot_int_get(op->slots_in, "affect");
const float profile = BMO_slot_float_get(op->slots_in, "profile");
const bool clamp_overlap = BMO_slot_bool_get(op->slots_in, "clamp_overlap");
const int material = BMO_slot_int_get(op->slots_in, "material");
@@ -79,7 +79,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
profile_type,
seg,
profile,
- vonly,
+ affect_type,
false,
clamp_overlap,
NULL,
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 8650d899398..236c759c06a 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -266,7 +266,7 @@ typedef struct BevVert {
int selcount;
/** Count of wire edges. */
int wirecount;
- /** Offset for this vertex, if vertex_only bevel. */
+ /** Offset for this vertex, if vertex only bevel. */
float offset;
/** Any seams on attached edges? */
bool any_seam;
@@ -325,14 +325,14 @@ typedef struct BevelParams {
int offset_type;
/** Profile type: radius, superellipse, or custom */
int profile_type;
+ /** Bevel vertices only or edges. */
+ int affect_type;
/** Number of segments in beveled edge profile. */
int seg;
/** User profile setting. */
float profile;
/** Superellipse parameter for edge profile. */
float pro_super_r;
- /** Bevel vertices only. */
- bool vertex_only;
/** Bevel amount affected by weights on edges or verts. */
bool use_weights;
/** Should bevel prefer to slide along edges rather than keep widths spec? */
@@ -350,9 +350,9 @@ typedef struct BevelParams {
char _pad[1];
/** The struct used to store the custom profile input. */
const struct CurveProfile *custom_profile;
- /** Vertex group array, maybe set if vertex_only. */
+ /** Vertex group array, maybe set if vertex only. */
const struct MDeformVert *dvert;
- /** Vertex group index, maybe set if vertex_only. */
+ /** Vertex group index, maybe set if vertex only. */
int vertex_group;
/** If >= 0, material number for bevel; else material comes from adjacent faces. */
int mat_nr;
@@ -1604,7 +1604,7 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
zero_v3(pro->proj_dir);
do_linear_interp = false;
}
- else if (bp->vertex_only) {
+ else if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
copy_v3_v3(pro->start, start);
copy_v3_v3(pro->middle, bv->v->co);
copy_v3_v3(pro->end, end);
@@ -2526,7 +2526,7 @@ static void build_boundary_vertex_only(BevelParams *bp, BevVert *bv, bool constr
BoundVert *v;
float co[3];
- BLI_assert(bp->vertex_only);
+ BLI_assert(bp->affect_type == BEVEL_AFFECT_VERTICES);
e = efirst = &bv->edges[0];
do {
@@ -2799,7 +2799,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
return;
}
- if (bp->vertex_only) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
build_boundary_vertex_only(bp, bv, construct);
return;
}
@@ -4332,7 +4332,7 @@ static int tri_corner_test(BevelParams *bp, BevVert *bv)
int in_plane_e = 0;
/* The superellipse snapping of this case isn't helpful with custom profiles enabled. */
- if (bp->vertex_only || bp->profile_type == BEVEL_PROFILE_CUSTOM) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES || bp->profile_type == BEVEL_PROFILE_CUSTOM) {
return -1;
}
if (bv->vmesh->count != 3) {
@@ -5156,7 +5156,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
else {
fc = NULL;
}
- if (bp->vertex_only) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
e = bndv->efirst;
}
else {
@@ -5177,7 +5177,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
bmv3 = mesh_vert(vm, i, j + 1, k + 1)->v;
bmv4 = mesh_vert(vm, i, j + 1, k)->v;
BLI_assert(bmv1 && bmv2 && bmv3 && bmv4);
- if (bp->vertex_only) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
if (j < k) {
if (k == ns2 && j == ns2 - 1) {
r_f = bev_create_quad_ex(bm,
@@ -5204,7 +5204,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
r_f = bev_create_quad(bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, mat_nr);
}
else { /* j == k */
- /* Only one edge attached to v, since vertex_only. */
+ /* Only one edge attached to v, since vertex only. */
if (e->is_seam) {
r_f = bev_create_quad_ex(
bm, bmv1, bmv2, bmv3, bmv4, f2, f2, f2, f2, bme, NULL, bme, NULL, f2, mat_nr);
@@ -5262,7 +5262,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert
}
} while ((bndv = bndv->next) != vm->boundstart);
bmv1 = mesh_vert(vm, 0, ns2, ns2)->v;
- if (bp->vertex_only || count_bound_vert_seams(bv) <= 1) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES || count_bound_vert_seams(bv) <= 1) {
bev_merge_uvs(bm, bmv1);
}
}
@@ -5572,7 +5572,7 @@ static void bevel_vert_two_edges(BevelParams *bp, BMesh *bm, BevVert *bv)
BoundVert *bndv;
int ns, k;
- BLI_assert(vm->count == 2 && bp->vertex_only);
+ BLI_assert(vm->count == 2 && bp->affect_type == BEVEL_AFFECT_VERTICES);
v1 = mesh_vert(vm, 0, 0, 0)->v;
v2 = mesh_vert(vm, 1, 0, 0)->v;
@@ -5733,7 +5733,7 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv)
switch (vm->mesh_kind) {
case M_NONE:
- if (n == 2 && bp->vertex_only) {
+ if (n == 2 && bp->affect_type == BEVEL_AFFECT_VERTICES) {
bevel_vert_two_edges(bp, bm, bv);
}
break;
@@ -6034,7 +6034,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
BM_ITER_ELEM (bme, &iter, v, BM_EDGES_OF_VERT) {
int face_count = BM_edge_face_count(bme);
BM_BEVEL_EDGE_TAG_DISABLE(bme);
- if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) {
+ if (BM_elem_flag_test(bme, BM_ELEM_TAG) && bp->affect_type != BEVEL_AFFECT_VERTICES) {
BLI_assert(face_count == 2);
nsel++;
if (!first_bme) {
@@ -6045,14 +6045,14 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
/* Good to start face chain from this edge. */
first_bme = bme;
}
- if (face_count > 0 || bp->vertex_only) {
+ if (face_count > 0 || bp->affect_type == BEVEL_AFFECT_VERTICES) {
tot_edges++;
}
if (BM_edge_is_wire(bme)) {
tot_wire++;
/* If edge beveling, exclude wire edges from edges array.
* Mark this edge as "chosen" so loop below won't choose it. */
- if (!bp->vertex_only) {
+ if (bp->affect_type != BEVEL_AFFECT_VERTICES) {
BM_BEVEL_EDGE_TAG_ENABLE(bme);
}
}
@@ -6061,7 +6061,8 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
first_bme = v->e;
}
- if ((nsel == 0 && !bp->vertex_only) || (tot_edges < 2 && bp->vertex_only)) {
+ if ((nsel == 0 && bp->affect_type != BEVEL_AFFECT_VERTICES) ||
+ (tot_edges < 2 && bp->affect_type == BEVEL_AFFECT_VERTICES)) {
/* Signal this vert isn't being beveled. */
BM_elem_flag_disable(v, BM_ELEM_TAG);
return NULL;
@@ -6091,7 +6092,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
for (i = 0; i < tot_edges; i++) {
e = &bv->edges[i];
bme = e->e;
- if (BM_elem_flag_test(bme, BM_ELEM_TAG) && !bp->vertex_only) {
+ if (BM_elem_flag_test(bme, BM_ELEM_TAG) && bp->affect_type != BEVEL_AFFECT_VERTICES) {
e->is_bev = true;
e->seg = bp->seg;
}
@@ -6130,7 +6131,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
}
}
- if (bp->vertex_only) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
/* Modify the offset by the vertex group or bevel weight if they are specified. */
if (bp->dvert != NULL && bp->vertex_group != -1) {
weight = BKE_defvert_find_weight(bp->dvert + BM_elem_index_get(v), bp->vertex_group);
@@ -6220,7 +6221,7 @@ static BevVert *bevel_vert_construct(BMesh *bm, BevelParams *bp, BMVert *v)
e->offset_r_spec *= weight;
}
}
- else if (bp->vertex_only) {
+ else if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
/* Weight has already been applied to bv->offset, if present.
* Transfer to e->offset_[lr]_spec according to offset_type. */
float edge_dir[3];
@@ -7371,7 +7372,7 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
}
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
- if (bp->vertex_only) {
+ if (bp->affect_type == BEVEL_AFFECT_VERTICES) {
collision_offset = vertex_collide_offset(bp, eh);
if (collision_offset < limited_offset) {
limited_offset = collision_offset;
@@ -7431,7 +7432,7 @@ void BM_mesh_bevel(BMesh *bm,
const int profile_type,
const int segments,
const float profile,
- const bool vertex_only,
+ const bool affect_type,
const bool use_weights,
const bool limit_offset,
const struct MDeformVert *dvert,
@@ -7462,11 +7463,12 @@ void BM_mesh_bevel(BMesh *bm,
bp.seg = segments;
bp.profile = profile;
bp.pro_super_r = -logf(2.0) / logf(sqrtf(profile)); /* Convert to superellipse exponent. */
- bp.vertex_only = vertex_only;
+ bp.affect_type = affect_type;
bp.use_weights = use_weights;
bp.loop_slide = loop_slide;
bp.limit_offset = limit_offset;
- bp.offset_adjust = !vertex_only && !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE);
+ bp.offset_adjust = bp.affect_type != BEVEL_AFFECT_VERTICES &&
+ !ELEM(offset_type, BEVEL_AMT_PERCENT, BEVEL_AMT_ABSOLUTE);
bp.dvert = dvert;
bp.vertex_group = vertex_group;
bp.mat_nr = mat;
@@ -7581,7 +7583,7 @@ void BM_mesh_bevel(BMesh *bm,
}
/* Build polygons for edges. */
- if (!bp.vertex_only) {
+ if (bp.affect_type != BEVEL_AFFECT_VERTICES) {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
bevel_build_edge_polygons(bm, &bp, e);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.h b/source/blender/bmesh/tools/bmesh_bevel.h
index 667482960d3..317ca05b68a 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.h
+++ b/source/blender/bmesh/tools/bmesh_bevel.h
@@ -30,7 +30,7 @@ void BM_mesh_bevel(BMesh *bm,
const int profile_type,
const int segments,
const float profile,
- const bool vertex_only,
+ const bool affect_type,
const bool use_weights,
const bool limit_offset,
const struct MDeformVert *dvert,