[Bf-blender-cvs] [6820c2d847f] soc-2019-bevel-profiles: Cleanup: Comments and code, some variable names
Hans Goudey
noreply at git.blender.org
Sat Aug 17 22:49:52 CEST 2019
Commit: 6820c2d847fa5dbddd2bd92664f5da683b7cf7a5
Author: Hans Goudey
Date: Sat Aug 17 16:49:40 2019 -0400
Branches: soc-2019-bevel-profiles
https://developer.blender.org/rB6820c2d847fa5dbddd2bd92664f5da683b7cf7a5
Cleanup: Comments and code, some variable names
===================================================================
M source/blender/bmesh/tools/bmesh_bevel.c
M source/blender/editors/interface/interface_draw.c
M source/blender/editors/interface/interface_handlers.c
===================================================================
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 6beac8dcdb8..dc3584b00f5 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -60,6 +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};
@@ -232,7 +233,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 vmesh profile */
+ M_CUTOFF, /* A triangulated face at the end of each profile */
} mesh_kind;
int _pad;
@@ -2422,7 +2423,7 @@ static void build_boundary_terminal_edge(BevelParams *bp,
/* TODO: should do something else if angle between e and e->prev > 180 */
offset_meet(e->prev, e, bv->v, e->fprev, false, co);
if (construct) {
- bndv = add_new_bound_vert(mem_arena, vm, co);
+ bndv = add_new_bound_vert(mem_arena, vm, co);
bndv->efirst = e->prev;
bndv->elast = bndv->ebev = e;
e->leftv = bndv;
@@ -2458,7 +2459,6 @@ static void build_boundary_terminal_edge(BevelParams *bp,
else {
adjust_bound_vert(e->leftv, co);
}
-
}
}
calculate_vm_profiles(bp, bv, vm);
@@ -2500,9 +2500,10 @@ static void build_boundary_terminal_edge(BevelParams *bp,
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]);
+ 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
@@ -2655,7 +2656,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
* The "non-in-plane" edges affect the silhouette and we prefer to slide along one of those if
* possible. */
in_plane = not_in_plane = 0; /* Counts of in-plane / not-in-plane */
- enip = eip = NULL; /* representatives of each */
+ enip = eip = NULL; /* representatives of each */
for (e2 = e->next; !e2->is_bev; e2 = e2->next) {
if (eh_on_plane(e2)) {
in_plane++;
@@ -3170,7 +3171,8 @@ static BMEdge *next_orientation_edge(BevelParams *bp, BMEdge *start_edge, BMVert
BevVert *bv = find_bevvert(bp, bmv); /* For checking if edges are already visited. */
float dir_start_edge[3], dir_new_edge[3];
float new_dot;
- float second_best_dot = 0.0f, best_dot = 0.0f; /* Initialize these to the least parallel angle. */
+ float second_best_dot = 0.0f,
+ best_dot = 0.0f; /* Initialize these to the least parallel angle. */
/* Find the direction vector of the current edge (pointing INTO the vertex). */
if (start_edge->v1 == bmv) {
@@ -3306,7 +3308,8 @@ static void regularize_profile_orientation(BMesh *bm, BevelParams *bp, BMEdge *b
* 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) {
+static void debug_draw_profile_orientation(BevelParams *bp, BMesh *bm)
+{
BMIter iter;
BMEdge *bmedge;
float middle[3];
@@ -3677,8 +3680,8 @@ static VMesh *new_adj_vmesh(MemArena *mem_arena, int count, int seg, BoundVert *
vm->count = count;
vm->seg = seg;
vm->boundstart = bounds;
- vm->mesh = (NewVert *)BLI_memarena_alloc(mem_arena, (size_t)(count * (1 + seg / 2) * (1 + seg)) *
- sizeof(NewVert));
+ vm->mesh = (NewVert *)BLI_memarena_alloc(
+ mem_arena, (size_t)(count * (1 + seg / 2) * (1 + seg)) * sizeof(NewVert));
vm->mesh_kind = M_ADJ;
return vm;
}
@@ -3774,8 +3777,8 @@ static void vmesh_center(VMesh *vm, float r_cent[3])
}
}
-static void avg4(float co[3], const NewVert *v0, const NewVert *v1, const NewVert *v2,
- const NewVert *v3)
+static void avg4(
+ float co[3], const NewVert *v0, const NewVert *v1, const NewVert *v2, const NewVert *v3)
{
add_v3_v3v3(co, v0->co, v1->co);
add_v3_v3(co, v2->co);
@@ -3987,13 +3990,13 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
ns_out = 2 * ns_in;
vm_out = new_adj_vmesh(bp->mem_arena, n_boundary, ns_out, vm_in->boundstart);
- /* First we adjust the boundary vertices of the input mesh, storing in output mesh */
+ /* First we adjust the boundary vertices of the input mesh, storing in output mesh. */
for (i = 0; i < n_boundary; i++) {
copy_v3_v3(mesh_vert(vm_out, i, 0, 0)->co, mesh_vert(vm_in, i, 0, 0)->co);
for (k = 1; k < ns_in; k++) {
copy_v3_v3(co, mesh_vert(vm_in, i, 0, k)->co);
- /* Smooth boundary rule. Custom profiles shouldn't be smoothed */
+ /* Smooth boundary rule. Custom profiles shouldn't be smoothed. */
if (!bp->use_custom_profile) {
copy_v3_v3(co1, mesh_vert(vm_in, i, 0, k - 1)->co);
copy_v3_v3(co2, mesh_vert(vm_in, i, 0, k + 1)->co);
@@ -4006,13 +4009,13 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
copy_v3_v3(mesh_vert_canon(vm_out, i, 0, 2 * k)->co, co);
}
}
- /* now do odd ones in output mesh, based on even ones */
+ /* Now adjust odd boundary vertices in output mesh, based on even ones. */
bndv = vm_out->boundstart;
for (i = 0; i < n_boundary; i++) {
for (k = 1; k < ns_out; k += 2) {
get_profile_point(bp, &bndv->profile, k, ns_out, co);
- /* Only smooth if using a non-custom profile */
+ /* Smooth if using a non-custom profile. */
if (!bp->use_custom_profile) {
copy_v3_v3(co1, mesh_vert_canon(vm_out, i, 0, k - 1)->co);
copy_v3_v3(co2, mesh_vert_canon(vm_out, i, 0, k + 1)->co);
@@ -4028,8 +4031,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
vmesh_copy_equiv_verts(vm_out);
- /* Copy adjusted verts back into vm_in */
- /* HANS-QUESTION: Why are they copied back into the original? */
+ /* Copy adjusted verts back into vm_in. */
for (i = 0; i < n_boundary; i++) {
for (k = 0; k < ns_in; k++) {
copy_v3_v3(mesh_vert(vm_in, i, 0, k)->co, mesh_vert(vm_out, i, 0, 2 * k)->co);
@@ -4056,7 +4058,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
}
- /* The new vertical edge vertices */
+ /* The new vertical edge vertices */
for (i = 0; i < n_boundary; i++) {
for (j = 0; j < ns_in2; j++) {
for (k = 1; k <= ns_in2; k++) {
@@ -4071,7 +4073,7 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
}
}
- /* The new horizontal edge vertices */
+ /* The new horizontal edge vertices */
for (i = 0; i < n_boundary; i++) {
for (j = 1; j < ns_in2; j++) {
for (k = 0; k < ns_in2; k++) {
@@ -4141,8 +4143,6 @@ static VMesh *cubic_subdiv(BevelParams *bp, VMesh *vm_in)
for (k = 0; k <= ns_out; k++) {
get_profile_point(bp, &bndv->profile, k, ns_out, co);
copy_v3_v3(mesh_vert(vm_out, i, 0, k)->co, co);
- /* HANS-QUESTION: Disabling these following lines doesn't seem to do anything in my test
- * files, and I'm having a hard time understanding why they're necessary. */
if (k >= ns_in && k < ns_out) {
copy_v3_v3(mesh_vert(vm_out, inext, ns_out - k, 0)->co, co);
}
@@ -4162,7 +4162,7 @@ static VMesh *make_cube_corner_square(MemArena *mem_arena, int nseg)
ns2 = nseg / 2;
vm = new_adj_vmesh(mem_arena, 3, nseg, NULL);
- vm->count = 0; /* Reset, so the following loop will end up with correct count. */
+ vm->count = 0; /* Reset, so the following loop will end up with correct count. */
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
@@ -4252,11 +4252,10 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp)
/* Initial mesh has 3 sides and 2 segments on each side */
vm0 = new_adj_vmesh(mem_arena, 3, 2, NULL);
- vm0->count = 0; /* Reset, so the following loop will end up with correct count. */
+ vm0->count = 0; /* Reset, so the following loop will end up with correct count. */
for (i = 0; i < 3; i++) {
zero_v3(co);
co[i] = 1.0f;
- /* HANS-QUESTION: Why are we adding new boundverts now? I thought they already been created? */
add_new_bound_vert(mem_arena, vm0, co);
}
bndv = vm0->boundstart;
@@ -4406,9 +4405,6 @@ static VMesh *adj_vmesh(BevelParams *bp, BevVert *bv)
n_bndv = bv->vmesh->count;
/* Same bevel as that of 3 edges of vert in a cube */
- /* HANS-QUESTION: It should be possible to disable this, because this function is only called in
- * two places, and the only one of them where this could happen already checks for this case
- * before calling this function. */
if (n_bndv == 3 && tri_corner_test(bp, bv) != -1 && bp->pro_super_r != PRO_SQUARE_IN_R) {
return tri_corner_adj_vmesh(bp, bv);
}
@@ -4536,8 +4532,8 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
ipipe2 = vpipe->next->next->index;
#ifdef DEBUG_CUSTOM_PROFILE_PIPE
- printf("ipipe1: %d\n", ipipe1);
- printf("ipipe2: %d\n", ipipe2);
+ printf("ipipe1: %d\n", ipipe1);
+ printf("ipipe2: %d\n", ipipe2);
#endif
for (i = 0; i < n_bndv; i++) {
@@ -4576,50 +4572,52 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe)
#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],
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list