From 39cf62607fe5439008ae2c3114918dfb844f8877 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 24 Jan 2020 18:12:30 -0500 Subject: Bevel: Remove Debugging Code Remove old / trivial print statements and drawing code. Reviewed By: howardt Differential Revision: https://developer.blender.org/D6661 --- source/blender/bmesh/tools/bmesh_bevel.c | 309 +++++-------------------------- 1 file changed, 48 insertions(+), 261 deletions(-) (limited to 'source') diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 57dbbcbfca4..bc84c6872c4 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -60,16 +60,7 @@ #define BEVEL_MATCH_SPEC_WEIGHT 0.2 //#define DEBUG_CUSTOM_PROFILE_CUTOFF -//#define DEBUG_CUSTOM_PROFILE_SAMPLE - -#if defined(DEBUG_PROFILE_ORIENTATION_DRAW) || defined(DEBUG_CUSTOM_PROFILE_PIPE) -static float debug_color_red[4] = {1.0f, 0.0f, 0.0f, 1.0f}; -static float debug_color_blue[4] = {0.0f, 0.0f, 1.0f, 1.0f}; -extern void DRW_debug_sphere(const float center[3], const float radius, const float color[4]); -extern void DRW_debug_line_v3v3(const float v1[3], const float v2[3], const float color[4]); -#endif - -/* happens far too often, uncomment for development */ +/* Happens far too often, uncomment for development. */ // #define BEVEL_ASSERT_PROJECT /* for testing */ @@ -268,7 +259,7 @@ typedef struct BevVert { VMesh *vmesh; } BevVert; -/* face classification: note depend on F_RECON > F_EDGE > F_VERT */ +/* Face classification. Note: depends on F_RECON > F_EDGE > F_VERT */ typedef enum { /** Used when there is no face at all */ F_NONE, @@ -292,10 +283,6 @@ enum { ANGLE_LARGER = 1, }; -#if 0 -static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */ -#endif - /** Bevel parameters and state */ typedef struct BevelParams { /** Records BevVerts made: key BMVert*, value BevVert* */ @@ -364,13 +351,6 @@ typedef struct BevelParams { /* Only for debugging, shouldn't be in blender repo. */ // #include "bevdebug.c" -/* Some flags to re-enable old behavior for a while, - * in case fixes broke things not caught by regression tests. */ -static int bev_debug_flags = 0; -#define DEBUG_OLD_PLANE_SPECIAL (bev_debug_flags & 1) -#define DEBUG_OLD_PROJ_TO_PERP_PLANE (bev_debug_flags & 2) -#define DEBUG_OLD_FLAT_MID (bev_debug_flags & 4) - /* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) * of edge-polygons. */ #define BM_ELEM_LONG_TAG (1 << 6) @@ -1355,23 +1335,8 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) } normalize_v3(pro->proj_dir); project_to_edge(e->e, start, end, pro->middle); - if (DEBUG_OLD_PROJ_TO_PERP_PLANE) { - /* Put arc endpoints on plane with normal proj_dir, containing middle. */ - add_v3_v3v3(co3, start, pro->proj_dir); - if (!isect_line_plane_v3(pro->start, start, co3, pro->middle, pro->proj_dir)) { - /* Shouldn't happen. */ - copy_v3_v3(pro->start, start); - } - add_v3_v3v3(co3, end, pro->proj_dir); - if (!isect_line_plane_v3(pro->end, end, co3, pro->middle, pro->proj_dir)) { - /* Shouldn't happen. */ - copy_v3_v3(pro->end, end); - } - } - else { - copy_v3_v3(pro->start, start); - copy_v3_v3(pro->end, end); - } + copy_v3_v3(pro->start, start); + copy_v3_v3(pro->end, end); /* Default plane to project onto is the one with triangle start - middle - end in it. */ sub_v3_v3v3(d1, pro->middle, start); sub_v3_v3v3(d2, pro->middle, end); @@ -1389,64 +1354,50 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv) * If the profile is going to lead into unbeveled edges on each side * (that is, both BoundVerts are "on-edge" points on non-beveled edges) */ - if (DEBUG_OLD_PLANE_SPECIAL && (e->prev->is_bev || e->next->is_bev)) { - do_linear_interp = true; - } - else { - if (DEBUG_OLD_PROJ_TO_PERP_PLANE) { - copy_v3_v3(pro->start, start); - copy_v3_v3(pro->end, end); - } - if (DEBUG_OLD_FLAT_MID) { - copy_v3_v3(pro->middle, bv->v->co); - } - else { - copy_v3_v3(pro->middle, bv->v->co); - if (e->prev->is_bev && e->next->is_bev && bv->selcount >= 3) { - /* Want mid at the meet point of next and prev offset edges. */ - float d3[3], d4[3], co4[3], meetco[3], isect2[3]; - int isect_kind; - - sub_v3_v3v3(d3, e->prev->e->v1->co, e->prev->e->v2->co); - sub_v3_v3v3(d4, e->next->e->v1->co, e->next->e->v2->co); - normalize_v3(d3); - normalize_v3(d4); - if (nearly_parallel(d3, d4)) { - /* Offset lines are collinear - want linear interpolation. */ - mid_v3_v3v3(pro->middle, start, end); - do_linear_interp = true; - } - else { - add_v3_v3v3(co3, start, d3); - add_v3_v3v3(co4, end, d4); - isect_kind = isect_line_line_v3(start, co3, end, co4, meetco, isect2); - if (isect_kind != 0) { - copy_v3_v3(pro->middle, meetco); - } - else { - /* Offset lines don't intersect - want linear interpolation. */ - mid_v3_v3v3(pro->middle, start, end); - do_linear_interp = true; - } - } - } - } - copy_v3_v3(pro->end, end); - sub_v3_v3v3(d1, pro->middle, start); - normalize_v3(d1); - sub_v3_v3v3(d2, pro->middle, end); - normalize_v3(d2); - cross_v3_v3v3(pro->plane_no, d1, d2); - normalize_v3(pro->plane_no); - if (nearly_parallel(d1, d2)) { - /* Whole profile is collinear with edge: just interpolate. */ + copy_v3_v3(pro->middle, bv->v->co); + if (e->prev->is_bev && e->next->is_bev && bv->selcount >= 3) { + /* Want mid at the meet point of next and prev offset edges. */ + float d3[3], d4[3], co4[3], meetco[3], isect2[3]; + int isect_kind; + + sub_v3_v3v3(d3, e->prev->e->v1->co, e->prev->e->v2->co); + sub_v3_v3v3(d4, e->next->e->v1->co, e->next->e->v2->co); + normalize_v3(d3); + normalize_v3(d4); + if (nearly_parallel(d3, d4)) { + /* Offset lines are collinear - want linear interpolation. */ + mid_v3_v3v3(pro->middle, start, end); do_linear_interp = true; } else { - copy_v3_v3(pro->plane_co, bv->v->co); - copy_v3_v3(pro->proj_dir, pro->plane_no); + add_v3_v3v3(co3, start, d3); + add_v3_v3v3(co4, end, d4); + isect_kind = isect_line_line_v3(start, co3, end, co4, meetco, isect2); + if (isect_kind != 0) { + copy_v3_v3(pro->middle, meetco); + } + else { + /* Offset lines don't intersect - want linear interpolation. */ + mid_v3_v3v3(pro->middle, start, end); + do_linear_interp = true; + } } } + copy_v3_v3(pro->end, end); + sub_v3_v3v3(d1, pro->middle, start); + normalize_v3(d1); + sub_v3_v3v3(d2, pro->middle, end); + normalize_v3(d2); + cross_v3_v3v3(pro->plane_no, d1, d2); + normalize_v3(pro->plane_no); + if (nearly_parallel(d1, d2)) { + /* Whole profile is collinear with edge: just interpolate. */ + do_linear_interp = true; + } + else { + copy_v3_v3(pro->plane_co, bv->v->co); + copy_v3_v3(pro->proj_dir, pro->plane_no); + } } copy_v3_v3(pro->plane_co, start); } @@ -2532,17 +2483,6 @@ static void build_boundary_terminal_edge(BevelParams *bp, vm->mesh_kind = M_POLY; } } -#ifdef DEBUG_CUSTOM_PROFILE_WELD - if (bp->seg > 1) { - printf("Terminal Edge Profile Coordinates:\n"); - for (int k = 0; k < bp->seg; k++) { - printf("%0.4f, %0.4f, %0.4f\n", - (double)vm->boundstart->profile.prof_co[3 * k], - (double)vm->boundstart->profile.prof_co[3 * k + 1], - (double)vm->boundstart->profile.prof_co[3 * k + 2]); - } - } -#endif } /* Helper for build_boundary to handle special miters */ @@ -3209,53 +3149,6 @@ static void regularize_profile_orientation(BevelParams *bp, BMEdge *bme) } } -#ifdef DEBUG_PROFILE_ORIENTATION_DRAW -/** - * Draws markers on beveled edges showing the side that the profile starts on. A sphere shows - * the start side of the profile where it starts, and the lines connected to the sphere show which - * edge the orientation corresponds to. - * \note Only drawn while bevel is calculating, the debug geometry is not persistent. - */ -static void debug_draw_profile_orientation(BevelParams *bp, BMesh *bm) -{ - BMIter iter; - BMEdge *bmedge; - float middle[3]; - - BM_ITER_MESH (bmedge, &iter, bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(bmedge, BM_ELEM_TAG)) { - mid_v3_v3v3(middle, bmedge->v1->co, bmedge->v2->co); - - /* Draw the orientation for the first side of the edge. */ - EdgeHalf *edge_half = find_edge_half(find_bevvert(bp, bmedge->v1), bmedge); - if (edge_half->leftv->is_profile_start) { /* The left boundvert defines the profiles. */ - DRW_debug_sphere(edge_half->leftv->nv.co, 0.04f, debug_color_red); - DRW_debug_line_v3v3(middle, edge_half->leftv->nv.co, debug_color_red); - DRW_debug_line_v3v3(bmedge->v1->co, edge_half->leftv->nv.co, debug_color_red); - } - else { - DRW_debug_sphere(edge_half->rightv->nv.co, 0.04f, debug_color_red); - DRW_debug_line_v3v3(middle, edge_half->rightv->nv.co, debug_color_red); - DRW_debug_line_v3v3(bmedge->v1->co, edge_half->rightv->nv.co, debug_color_red); - } - - /* Draw the orientation for the second side of the edge. */ - edge_half = find_edge_half(find_bevvert(bp, bmedge->v2), bmedge); - if (edge_half->leftv->is_profile_start) { - DRW_debug_sphere(edge_half->leftv->nv.co, 0.05f, debug_color_blue); - DRW_debug_line_v3v3(middle, edge_half->leftv->nv.co, debug_color_blue); - DRW_debug_line_v3v3(bmedge->v2->co, edge_half->leftv->nv.co, debug_color_blue); - } - else { - DRW_debug_sphere(edge_half->rightv->nv.co, 0.05f, debug_color_blue); - DRW_debug_line_v3v3(middle, edge_half->rightv->nv.co, debug_color_blue); - DRW_debug_line_v3v3(bmedge->v2->co, edge_half->rightv->nv.co, debug_color_blue); - } - } - } -} -#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 @@ -3667,9 +3560,6 @@ static void vmesh_copy_equiv_verts(VMesh *vm) /* Calculate and return in r_cent the centroid of the center poly */ static void vmesh_center(VMesh *vm, float r_cent[3]) { -#ifdef DEBUG_CUSTOM_PROFILE_ADJ - printf("VMESH CENTER\n"); -#endif int n, ns2, i; n = vm->count; @@ -4417,14 +4307,6 @@ static void snap_to_pipe_profile(BoundVert *vpipe, bool midline, float co[3]) */ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) { -#ifdef DEBUG_CUSTOM_PROFILE_PIPE - printf("PIPE ADJ VMESH\n"); - float green[4] = {0.0f, 1.0f, 0.0f, 1.0f}; - float blue[4] = {0.0f, 0.0f, 1.0f, 1.0f}; - float red[4] = {1.0f, 0.0f, 0.0f, 1.0f}; - float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; - float *color; -#endif int i, j, k, n_bndv, ns, half_ns, ipipe1, ipipe2, ring; VMesh *vm; bool even, midline; @@ -4441,11 +4323,6 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) ipipe1 = vpipe->index; ipipe2 = vpipe->next->next->index; -#ifdef DEBUG_CUSTOM_PROFILE_PIPE - printf("ipipe1: %d\n", ipipe1); - printf("ipipe2: %d\n", ipipe2); -#endif - for (i = 0; i < n_bndv; i++) { for (j = 1; j <= half_ns; j++) { for (k = 0; k <= half_ns; k++) { @@ -4479,18 +4356,6 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) /* Place the vertex by interpolatin between the two profile points using the factor. */ interp_v3_v3v3(mesh_vert(vm, i, j, k)->co, profile_point_pipe1, profile_point_pipe2, f); -#ifdef DEBUG_CUSTOM_PROFILE_PIPE - printf("(%d, %d, %d)\n", i, j, k); - printf("f: %.3f\n", f); - printf("point 1: (%.3f, %.3f, %.3f)\n", - profile_point_pipe1[0], - profile_point_pipe1[1], - profile_point_pipe1[2]); - printf("point 2: (%.3f, %.3f, %.3f)\n", - profile_point_pipe2[0], - profile_point_pipe2[1], - profile_point_pipe2[2]); -#endif } else { /* A tricky case is for the 'square' profiles and an even nseg: we want certain @@ -4502,33 +4367,6 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) } } } -#ifdef DEBUG_CUSTOM_PROFILE_PIPE - /* Draw the locations of all the vertices after the "snapping" process */ - for (i = 0; i < n_bndv; i++) { - for (j = 1; j <= half_ns; j++) { - for (k = 1; k <= ns; k++) { - if (!is_canon(vm, i, j, k)) { - continue; - } - switch (i) { - case 0: - color = red; - break; - case 1: - color = green; - break; - case 2: - color = blue; - break; - case 3: - color = white; - break; - } - DRW_debug_sphere(mesh_vert(vm, i, j, k)->co, 0.01f, color); - } - } - } -#endif return vm; } @@ -5114,6 +4952,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) { #ifdef DEBUG_CUSTOM_PROFILE_CUTOFF printf("BEVEL BUILD CUTOFF\n"); +# define F3(v) (v)[0], (v)[1], (v)[2] int j; #endif int i; @@ -5152,10 +4991,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) #ifdef DEBUG_CUSTOM_PROFILE_CUTOFF printf("Corner vertices:\n"); for (j = 0; j < n_bndv; j++) { - printf(" (%.3f, %.3f, %.3f)\n", - (double)mesh_vert(bv->vmesh, j, 1, 0)->co[0], - (double)mesh_vert(bv->vmesh, j, 1, 0)->co[1], - (double)mesh_vert(bv->vmesh, j, 1, 0)->co[2]); + printf(" (%.3f, %.3f, %.3f)\n", F3(mesh_vert(bv->vmesh, j, 1, 0)->co)); } #endif @@ -5213,21 +5049,14 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) if (bndv->is_patch_start || bndv->is_arc_start) { printf(" Miter profile\n"); } - printf(" Corner 1: (%0.3f, %0.3f, %0.3f)\n", - (double)mesh_vert(bv->vmesh, i, 1, 0)->co[0], - (double)mesh_vert(bv->vmesh, i, 1, 0)->co[1], - (double)mesh_vert(bv->vmesh, i, 1, 0)->co[2]); + printf(" Corner 1: (%0.3f, %0.3f, %0.3f)\n", F3(mesh_vert(bv->vmesh, i, 1, 0)->co)); #endif /* Add profile point vertices to the face, including the last one. */ for (int k = 0; k < bp->seg + 1; k++) { face_bmverts[k + 1] = mesh_vert(bv->vmesh, i, 0, k)->v; /* Leave room for first vert. */ #ifdef DEBUG_CUSTOM_PROFILE_CUTOFF - printf(" Profile %d: (%0.3f, %0.3f, %0.3f)\n", - k, - (double)mesh_vert(bv->vmesh, i, 0, k)->co[0], - (double)mesh_vert(bv->vmesh, i, 0, k)->co[1], - (double)mesh_vert(bv->vmesh, i, 0, k)->co[2]); + printf(" Profile %d: (%0.3f, %0.3f, %0.3f)\n", k, F3(mesh_vert(bv->vmesh, i, 0, k)->co)); #endif } @@ -5235,10 +5064,7 @@ static void bevel_build_cutoff(BevelParams *bp, BMesh *bm, BevVert *bv) if (build_center_face) { face_bmverts[bp->seg + 2] = mesh_vert(bv->vmesh, i, 1, 1)->v; #ifdef DEBUG_CUSTOM_PROFILE_CUTOFF - printf(" Corner 2: (%0.3f, %0.3f, %0.3f)\n", - (double)mesh_vert(bv->vmesh, i, 1, 1)->co[0], - (double)mesh_vert(bv->vmesh, i, 1, 1)->co[1], - (double)mesh_vert(bv->vmesh, i, 1, 1)->co[2]); + printf(" Corner 2: (%0.3f, %0.3f, %0.3f)\n", F3(mesh_vert(bv->vmesh, i, 1, 1)->co)); #endif } @@ -5593,24 +5419,6 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) copy_mesh_vert(bv->vmesh, weld2->index, 0, ns - k, weld1->index, 0, k); } } -#ifdef DEBUG_CUSTOM_PROFILE_WELD - if (weld && ns > 1) { - printf("Weld1 profile coordinates:\n"); - for (k = 0; k < ns; k++) { - printf("%0.4f, %0.4f, %0.4f\n", - (double)weld1->profile.prof_co[3 * k], - (double)weld1->profile.prof_co[3 * k + 1], - (double)weld1->profile.prof_co[3 * k + 2]); - } - printf("Weld2 profile coordinates\n"); - for (k = 0; k < ns; k++) { - printf("%0.4f, %0.4f, %0.4f\n", - (double)weld2->profile.prof_co[3 * k], - (double)weld2->profile.prof_co[3 * k + 1], - (double)weld2->profile.prof_co[3 * k + 2]); - } - } -#endif /* Make sure the pipe case ADJ mesh is used for both the "Grid Fill" (ADJ) and cutoff options. */ vpipe = NULL; @@ -7435,11 +7243,6 @@ void BM_mesh_bevel(BMesh *bm, } } } -#ifdef DEBUG_PROFILE_ORIENTATION_DRAW - if (bp.use_custom_profile) { - debug_draw_profile_orientation(&bp, bm); - } -#endif /* Build the meshes around vertices, now that positions are final */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { @@ -7515,22 +7318,6 @@ void BM_mesh_bevel(BMesh *bm, BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { BM_elem_flag_disable(l, BM_ELEM_LONG_TAG); } - -#ifdef DEBUG_CUSTOM_PROFILE_SAMPLE - printf("Profile spacing:\n"); - printf("Seg values:\n"); - if (bp.pro_spacing.xvals != NULL) { - for (int i = 0; i < bp.seg; i++) { - printf("(%.3f, %.3f)\n", bp.pro_spacing.xvals[i], bp.pro_spacing.yvals[i]); - } - } - if (bp.pro_spacing.seg_2 != bp.seg && bp.pro_spacing.seg_2 != 0) { - printf("Seg_2 values:\n"); - for (int i = 0; i < bp.pro_spacing.seg_2; i++) { - printf("(%0.2f, %0.2f)\n", bp.pro_spacing.xvals_2[i], bp.pro_spacing.yvals_2[i]); - } - } -#endif } /* primary free */ -- cgit v1.2.3