[Bf-blender-cvs] [3e02f15e528] soc-2019-bevel-profiles: Moved "Sample Straight Edges" option from bevel operator to ProfileWidget.
Hans Goudey
noreply at git.blender.org
Thu Jul 11 03:47:30 CEST 2019
Commit: 3e02f15e528495e7c3749ba7e1e69b1b81f3468e
Author: Hans Goudey
Date: Wed Jul 10 21:36:50 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB3e02f15e528495e7c3749ba7e1e69b1b81f3468e
Moved "Sample Straight Edges" option from bevel operator to ProfileWidget.
Added initial code for vertex mesh method selection with a "Cut Off" option
to start. (Implementation of this option not included.)
===================================================================
M release/scripts/startup/bl_ui/properties_data_modifier.py
M source/blender/bmesh/intern/bmesh_opdefines.c
M source/blender/bmesh/intern/bmesh_operators.h
M source/blender/bmesh/operators/bmo_bevel.c
M source/blender/bmesh/tools/bmesh_bevel.c
M source/blender/bmesh/tools/bmesh_bevel.h
M source/blender/editors/interface/interface_templates.c
M source/blender/editors/mesh/editmesh_bevel.c
M source/blender/makesdna/DNA_modifier_types.h
M source/blender/makesdna/DNA_profilewidget_types.h
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/makesrna/intern/rna_profile.c
M source/blender/modifiers/intern/MOD_bevel.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 5f11674b2b3..9c1211cd262 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -171,10 +171,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
if md.miter_inner == 'MITER_PATCH' or md.miter_inner == 'MITER_ARC':
layout.row().prop(md, "spread")
+ layout.label(text="Vertex Mesh Method")
+ layout.row().prop(md, "vmesh_method", expand=True)
layout.row().prop(md, "use_custom_profile")
if md.use_custom_profile:
layout.template_profilewidget(md, "prwdgt")
- layout.row().prop(md, "sample_straight_edges")
def BOOLEAN(self, layout, _ob, md):
split = layout.split()
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 0d14762f9c8..245d5ce7a52 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1779,7 +1779,7 @@ static BMOpDefine bmo_bevel_def = {
{"use_custom_profile", BMO_OP_SLOT_BOOL}, /* Whether to use custom profile feature */
/* the ProfileWiget struct for the custom profile shape */
{"prwdgt", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_STRUCT}},
- {"sample_straight_edges", BMO_OP_SLOT_BOOL},
+ {"vmesh_method", BMO_OP_SLOT_INT},
{{'\0'}},
},
/* slots_out */
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 78e8ce04115..9f0107db693 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -126,6 +126,12 @@ enum {
BEVEL_MITER_ARC,
};
+/* Bevel vertex mesh creation methods */
+enum {
+ BEVEL_VMESH_ADJ,
+ BEVEL_VMESH_CUTOFF,
+};
+
/* 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 0a545ef81f0..ae785b9ebb4 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -49,7 +49,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
const float smoothresh = BMO_slot_float_get(op->slots_in, "smoothresh");
const bool use_custom_profile = BMO_slot_bool_get(op->slots_in, "use_custom_profile");
const ProfileWidget *prwdgt = BMO_slot_ptr_get(op->slots_in, "prwdgt");
- const bool sample_straight_edges = BMO_slot_bool_get(op->slots_in, "sample_straight_edges");
+ const int vmesh_method = BMO_slot_int_get(op->slots_in, "vmesh_method");
if (offset > 0) {
BMOIter siter;
@@ -95,7 +95,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
smoothresh,
use_custom_profile,
prwdgt,
- sample_straight_edges);
+ vmesh_method);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 5c618e64ddc..12a86adf5b6 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -101,9 +101,8 @@ typedef struct EdgeHalf {
bool is_bev; /* is this edge beveled? */
bool is_rev; /* is e->v2 the vertex at this end? */
bool is_seam; /* is e a seam for custom loopdata (e.g., UVs)? */
- /** Used during the custom profile orientation pass */
- bool visited_custom;
- char _pad[5];
+ bool visited_custom; /* Used during the custom profile orientation pass */
+ char _pad[4];
} EdgeHalf;
/* Profile specification.
@@ -179,11 +178,10 @@ typedef struct BoundVert {
/** Is this boundvert the side of the custom profile's start */
bool is_profile_start;
/** Length of seam starting from current boundvert to next boundvert with ccw ordering */
+ char _pad[3];
int seam_len;
/** Same as seam_len but defines length of sharp edges */
int sharp_len;
-
- int _pad;
} BoundVert;
/* Mesh structure replacing a vertex */
@@ -197,6 +195,7 @@ typedef struct VMesh {
M_POLY, /* a simple polygon */
M_ADJ, /* "adjacent edges" mesh pattern */
M_TRI_FAN, /* a simple polygon - fan filled */
+ M_CUTOFF, /* A triangulated face at the end of each profile */
} mesh_kind;
int _pad;
@@ -283,9 +282,8 @@ typedef struct BevelParams {
bool harden_normals;
/** Should we use the custom profiles feature? */
bool use_custom_profile;
- /** Whether to sample straight edges from the profile widget */
- bool sample_straight_edges;
/** The struct used to store the custom profile input */
+ char _pad[3];
const struct ProfileWidget *prwdgt;
/** Vertex group array, maybe set if vertex_only. */
const struct MDeformVert *dvert;
@@ -299,6 +297,8 @@ typedef struct BevelParams {
int miter_outer;
/** What kind of miter pattern to use on non-reflex angles. */
int miter_inner;
+ /** The method to use for vertex mesh creation */
+ int vmesh_method;
/** Amount to spread when doing inside miter. */
float spread;
/** Mesh's smoothresh, used if hardening. */
@@ -2770,7 +2770,14 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
vm->mesh_kind = M_POLY;
}
else {
- vm->mesh_kind = M_ADJ;
+ switch (bp->vmesh_method) {
+ case BEVEL_VMESH_ADJ:
+ vm->mesh_kind = M_ADJ;
+ break;
+ case BEVEL_VMESH_CUTOFF:
+ vm->mesh_kind = M_CUTOFF;
+ break;
+ }
}
}
}
@@ -3369,7 +3376,7 @@ static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
/* Use the solution to set new widths */
v = vstart;
i = 0;
- do {
+ do {k
val = EIG_linear_solver_variable_get(solver, 0, i);
if (iscycle || i < np - 1) {
eright = v->efirst;
@@ -4472,70 +4479,6 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3])
}
}
-/* HANS-TODO: I can probably replace this with creating a new profile for each ring along the
- * direction of the pipe and snapping to that with snap_to_custom_profile */
-static void snap_to_pipe_profile_custom(BoundVert *vpipe, float co[3], int seg)
-{
- float va[3], vb[3], edir[3], va0[3], vb0[3], vmid0[3];
- float plane[4], m[4][4], minv[4][4], p[3], snap[3];
-
- float distance, min_distance, prof_v1[3], prof_v2[3];
- int min_i = 0;
- /* HANS-TODO: Merge new variables with old ones where possible */
-
- Profile *pro = &vpipe->profile;
- EdgeHalf *e = vpipe->ebev;
-
- copy_v3_v3(va, pro->coa);
- copy_v3_v3(vb, pro->cob);
-
- /* Get a plane with the normal pointing along the beveled edge */
- sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
- plane_from_point_normal_v3(plane, co, edir);
-
- closest_to_plane_v3(va0, plane, va);
- closest_to_plane_v3(vb0, plane, vb);
-#if DEBUG_CUSTOM_PROFILE_ORIGINAL
- printf("snap to superellipsoid co argument: (%0.3f, %0.3f, %0.3f)\n", (double)va0[0],
- (double)va0[1],
- (double)va0[2]);
-#endif
-
- closest_to_plane_v3(vmid0, plane, pro->midco);
- if (make_unit_square_map(va0, vmid0, vb0, m)) {
- /* Transform co and project it onto superellipse */
- if (!invert_m4_m4(minv, m)) {
- /* shouldn't happen */
- BLI_assert(!"failed inverse during pipe profile snap custom");
- return;
- }
- mul_v3_m4v3(p, minv, co);
-
- /* Find (index of) the profile's closest line segment to the point */
- min_distance = FLT_MAX;
- for (int i = 0; i < seg - 1; i++) {
- closest_to_plane_v3(prof_v1, plane, &pro->prof_co_2[3 * i]);
- closest_to_plane_v3(prof_v2, plane, &pro->prof_co_2[3 * (i + 1)]);
- distance = dist_to_line_segment_v3(p, prof_v1, prof_v2);
- if (distance < min_distance) {
- min_distance = distance;
- min_i = i;
- }
- }
-
- /* Snap the point to the closest line segment we just found */
- closest_to_line_segment_v3(p, p, &pro->prof_co_2[3 * min_i], &pro->prof_co_2[3 * (min_i + 1)]);
-
- mul_v3_m4v3(snap, m, p);
- copy_v3_v3(co, snap);
- }
- else {
- /* planar case: just snap to line va0--vb0 */
- closest_to_line_segment_v3(p, co, va0, vb0);
- copy_v3_v3(co, p);
- }
-}
-
/* See pipe_test for conditions that make 'pipe'; vpipe is the return value from that.
* We want to make an ADJ mesh but then snap the vertices to the profile in a plane
* perpendicular to the pipes.
@@ -4566,14 +4509,7 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
continue;
}
midline = even && k == ns2 && ((i == 0 && j == ns2) || (i == ipipe1 || i == ipipe2));
- if (!bp->use_custom_profile) {
- snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
- }
- else {
- snap_to_pipe_profile_custom(vpipe,
- mesh_vert(vm, i, j, k)->co,
- power_of_2_max_i(bp->seg));
- }
+ snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co);
}
}
}
@@ -5021,13 +4957,13 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv)
vm1 = tri_corner_adj_vmesh(bp, bv);
/* the PRO_SQUARE_IN_R profile has boundary edges that merge
* and no internal ring polys except possibly center ngon */
- if (bp->pro_super_r == PRO_SQUARE_IN_R) {
+ if (bp->pro_super_r == PRO_SQUARE_IN_R && !bp->use_custom_profile) {
build_square_in_vmesh(bp, bm, bv, vm1);
return;
}
}
else {
- vm1 = adj_vmesh(bp, bv);
+ vm1 = adj_vmesh(bp, bv);
}
/* copy final vmesh into bv->vmesh, make BMVerts and BMFaces */
@@ -5153,6 +5089,13 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list