[Bf-blender-cvs] [c3870b6009a] soc-2019-bevel-profiles: Terminal edge bevel case obeys marked profile orientation. Relocated Regularize Profile Orientation Code.
Hans Goudey
noreply at git.blender.org
Tue Jun 18 20:33:12 CEST 2019
Commit: c3870b6009adba386be1fe64a62f91bd13079dd6
Author: Hans Goudey
Date: Tue Jun 18 14:30:57 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rBc3870b6009adba386be1fe64a62f91bd13079dd6
Terminal edge bevel case obeys marked profile orientation. Relocated Regularize Profile Orientation Code.
===================================================================
M source/blender/bmesh/tools/bmesh_bevel.c
===================================================================
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 61e9d78ed88..d76d41570ab 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -61,7 +61,7 @@
#define DEBUG_CUSTOM_PROFILE_SAMPLE 0
#define DEBUG_CUSTOM_PROFILE 0
#define DEBUG_CUSTOM_PROFILE_WELD 0
-#define DEBUG_CUSTOM_PROFILE_ORIENTATION 1
+#define DEBUG_CUSTOM_PROFILE_ORIENTATION 0
#if DEBUG_CUSTOM_PROFILE_ORIENTATION
extern void DRW_debug_sphere(const float center[3], const float radius, const float color[4]);
@@ -105,15 +105,6 @@ typedef struct EdgeHalf {
char _pad[5]; // HANS-TODO: Delete these pads
} EdgeHalf;
-/* This is the custom profile data after it has been sampled and received by bmesh_bevel
- * We only need to store an array of the point's locations
- * whether they are interpolated with curves or lines HANS-TODO: Probably don't need this */
-typedef struct CustomProfile {
- /** A list of all of the nodes that make up the curve */
- float *xvals;
- float *yvals;
-} CustomProfile;
-
/* Profile specification.
* Many interesting profiles are in family of superellipses:
* (abs(x/a))^r + abs(y/b))^r = 1
@@ -138,10 +129,6 @@ typedef struct Profile {
int _pad;
float *prof_co; /* seg+1 profile coordinates (triples of floats) */
float *prof_co_2; /* like prof_co, but for seg power of 2 >= seg */
- struct CustomProfile custom_profile; /* The sampled locations on the custom profile */
- /* HANS-TODO: I shouldn't actually need this, because the Profile struct
- * just stores the locations of the verts. I may need to put some extra information in here,
- * but I doubt I will need to a whole separate struct for it */
} Profile;
#define PRO_SQUARE_R 1e4f
#define PRO_CIRCLE_R 2.0f
@@ -325,7 +312,7 @@ typedef struct BevelParams {
// #pragma GCC diagnostic ignored "-Wpadded"
-// #include "bevdebug.c" /* HANS-TODO: Comment this back out before commit! */
+// #include "bevdebug.c" /* HANS-TODO: Uncomment this before commit! */
/* Some flags to re-enable old behavior for a while,
* in case fixes broke things not caught by regression tests. */
@@ -1670,7 +1657,7 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
* function in certain cases where I am working on the custom profile. This also checks for
* is_profile_start and flips the profile if it isn't the start of the boundary
* HANS-TODO: Get rid of this function when all custom profile cases are completed */
-static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv)
+static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv, bool reversed)
{
int i, k, ns;
const double *xvals, *yvals;
@@ -1680,14 +1667,6 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv)
bool need_2, map_ok;
Profile *pro = &bndv->profile;
- /* HANS-TODO: If the goal of this function is to translate the 2D coords of the profile spacing
- * into 3D for the actual placement of the profile verts, I'm not sure that this function will
- * actually have to be changed, because that process should be the same for different vert
- * locations. So figure out if that's what this function does. */
-
- /* This function should do the exact same thing for the custom profiles, so it shouldn't need to
- * be changed */
-
if (bp->seg == 1) {
return;
}
@@ -1741,13 +1720,17 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv)
}
else {
if (map_ok) {
- p[0] = (float)xvals[k];
- p[1] = (float)yvals[k];
+ if (reversed) {
+ p[0] = (float)yvals[k];
+ p[1] = (float)xvals[k];
+ }
+ else {
+ p[0] = (float)xvals[k];
+ p[1] = (float)yvals[k];
+ }
p[2] = 0.0f;
- mul_v3_m4v3(
- co,
- m,
- p); /* HANS-QUESTION: What's the reason to have this and the final projection? */
+ mul_v3_m4v3(co, m, p);
+ /* HANS-QUESTION: What's the reason to have this and the final projection? */
}
else {
interp_v3_v3v3(co, pro->coa, pro->cob, (float)k / (float)ns);
@@ -1757,7 +1740,7 @@ static void calculate_profile_custom(BevelParams *bp, BoundVert *bndv)
prof_co_k = prof_co + 3 * k; /* 3 times deeper because each coord takes up 3 spaces */
if (!is_zero_v3(pro->proj_dir)) {
add_v3_v3v3(co2, co, pro->proj_dir);
- /* pro->plane_co and pro->plane_no are build in "set_profile_params" */
+ /* pro->plane_co and pro->plane_no are built in "set_profile_params" */
if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) {
/* shouldn't happen */
copy_v3_v3(prof_co_k, co);
@@ -1787,9 +1770,6 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
bool need_2, map_ok;
Profile *pro = &bndv->profile;
- /* This function should do the exact same thing for the custom profiles, so it shouldn't need to
- * be changed */
-
if (bp->seg == 1) {
return;
}
@@ -1846,10 +1826,8 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
p[0] = (float)xvals[k];
p[1] = (float)yvals[k];
p[2] = 0.0f;
- mul_v3_m4v3(
- co,
- m,
- p); /* HANS-QUESTION: What's the reason to have this and the final projection? */
+ mul_v3_m4v3(co, m, p);
+ /* HANS-QUESTION: What's the reason to have this and the final projection? */
}
else {
interp_v3_v3v3(co, pro->coa, pro->cob, (float)k / (float)ns);
@@ -1859,7 +1837,7 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
prof_co_k = prof_co + 3 * k; /* 3 times deeper because each coord takes up 3 spaces */
if (!is_zero_v3(pro->proj_dir)) {
add_v3_v3v3(co2, co, pro->proj_dir);
- /* pro->plane_co and pro->plane_no are build in "set_profile_params" */
+ /* pro->plane_co and pro->plane_no are built in "set_profile_params" */
if (!isect_line_plane_v3(prof_co_k, co, co2, pro->plane_co, pro->plane_no)) {
/* shouldn't happen */
copy_v3_v3(prof_co_k, co);
@@ -2378,7 +2356,7 @@ static void calculate_vm_profiles_custom(BevelParams *bp, BevVert *bv, VMesh *vm
v = vm->boundstart;
do {
set_profile_params(bp, bv, v);
- calculate_profile_custom(bp, v);
+ calculate_profile_custom(bp, v, false); /* HANS-TODO: Possibly choose whether to reverse here */
} while ((v = v->next) != vm->boundstart);
}
@@ -2445,7 +2423,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
{
MemArena *mem_arena = bp->mem_arena;
VMesh *vm = bv->vmesh;
- BoundVert *v;
+ BoundVert *v1, *v2, *v;
EdgeHalf *e;
const float *no;
float co[3], d;
@@ -2456,9 +2434,9 @@ static void build_boundary_terminal_edge(BevelParams *bp,
no = e->fprev ? e->fprev->no : (e->fnext ? e->fnext->no : NULL);
offset_in_plane(e, no, true, co);
if (construct) {
- v = add_new_bound_vert(mem_arena, vm, co);
- v->efirst = v->elast = v->ebev = e;
- e->leftv = v;
+ v1 = add_new_bound_vert(mem_arena, vm, co);
+ v1->efirst = v->elast = v1->ebev = e;
+ e->leftv = v1;
}
else {
adjust_bound_vert(e->leftv, co);
@@ -2466,9 +2444,10 @@ static void build_boundary_terminal_edge(BevelParams *bp,
no = e->fnext ? e->fnext->no : (e->fprev ? e->fprev->no : NULL);
offset_in_plane(e, no, false, co);
if (construct) {
- v = add_new_bound_vert(mem_arena, vm, co);
- v->efirst = v->elast = e;
- e->rightv = v;
+ v2 = add_new_bound_vert(mem_arena, vm, co);
+ v2->efirst = v2->elast = e;
+ e->rightv = v2;
+ v = v2;
}
else {
adjust_bound_vert(e->rightv, co);
@@ -2545,7 +2524,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
calculate_profile(bp, v);
}
else {
- calculate_profile_custom(bp, v); /* HANS-TODO: Change back when all cases are converted */
+ calculate_profile_custom(bp, v, false); /* HANS-TODO: Change back when all cases are converted */
}
}
@@ -3084,536 +3063,819 @@ static bool adjust_the_cycle_or_chain_fast(BoundVert *vstart, int np, bool iscyc
}
#endif
-/* Adjust the offsets for a single cycle or chain.
- * For chains and some cycles, a fast solution exists.
- * Otherwise, we set up and solve a linear least squares problem
- * that tries to minimize the squared differences of lengths
- * at each end of an edge, and (with smaller weight) the
- * squared differences of the offsets from their specs.
- */
-static void adjust_the_cycle_or_chain(BoundVert *vstart, bool iscycle)
+/* HANS-TODO: Maybe move (and rename?) this function to the top with the other helpers? */
+/** Helper function to return the next Beveled EdgeHalf along a path.
+ *
+ * \note Right now this returns the most parallel edge if it's the most parallel by
+ * at least 10 degrees. This is a somewhat arbitrary choice, and we may find it's not even
+ * worth it to continue the path across a BevVert with 3 or more connected beveled edges
+ *
+ * \param toward_bv Whether the direction to travel points toward or away from the BevVert
+ * connected to the current EdgeHalf
+ * \param r_bv The BevVert conencted to the EdgeHalf which is updated if the we switch
+ EdgeHalves in the current edge */
+static EdgeHalf *next_edgehalf_bev(BevelParams *bp,
+ EdgeHalf *start_edge,
+ bool toward_bv,
+ BevVert **r_bv)
{
- BoundVert *v;
- EdgeHalf *eleft, *eright, *enextleft;
- LinearSolver *solver;
- double weight, val;
- int i, np, nrows, row;
-
- np = 0;
-#ifdef DEBUG_ADJUST
- printf("\nadjust the %s (with eigen)\n", iscycle ? "cycle" : "chain");
-#endif
- v = vstart;
- do {
-#ifdef DEBUG_ADJUST
- eleft = v->elast;
- eright = v->efirst;
- printf(" (left=e%d, right=e%d)", BM_elem_index_get(eleft->e), BM_elem_index_get(eright->e));
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list