[Bf-blender-cvs] [774de995f38] soc-2017-sculpting_improvements: Added Backside to the shape. Frontside and backside still need to be connected.

Sebastian Witt noreply at git.blender.org
Mon Jul 24 16:59:50 CEST 2017


Commit: 774de995f386703bade192f9204b7c38001b4b0b
Author: Sebastian Witt
Date:   Mon Jul 24 16:58:38 2017 +0200
Branches: soc-2017-sculpting_improvements
https://developer.blender.org/rB774de995f386703bade192f9204b7c38001b4b0b

Added Backside to the shape. Frontside and backside still need to be connected.

===================================================================

M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 14b82f7e616..7d34a008899 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5546,9 +5546,9 @@ static Spine *silhouette_generate_spine(SilhouetteData *sil, SilhouetteStroke *s
  * Interpolate between the three points resulting in a vertex line between a and c.
  * Smoothness regulates the cutoff to start a circular interpolation
  */
-static void calc_vert_quarter(Mesh *me, float a[3], float b[3], float c[3], int v_steps, int w_h_steps, float smoothness, bool flip){
+static void calc_vert_quarter(Mesh *me, float a[3], float b[3], float c[3], int v_steps, int w_h_steps, float smoothness, bool flip, bool flip_side){
 	int v_start = me->totvert;
-	int v_pos = flip ? v_start + v_steps + w_h_steps - 1 : v_start;
+	int v_pos = flip ? v_start + v_steps + w_h_steps - 1 - (flip_side ? 1 : 0): v_start;
 	float inv_smooth = 1.0f - smoothness;
 	float v1[3], v2[3], v3[3], v4[3], v5[3], up[3], side[3], d[3];
 	float f_sin, f_cos;
@@ -5556,7 +5556,7 @@ static void calc_vert_quarter(Mesh *me, float a[3], float b[3], float c[3], int
 	int s_steps_v = inv_smooth * v_steps;
 	int s_steps_c = v_steps - s_steps_v + w_h_steps - s_steps_w;
 
-	ED_mesh_vertices_add(me, NULL, v_steps + w_h_steps);
+	ED_mesh_vertices_add(me, NULL, v_steps + w_h_steps - (flip_side ? 1 : 0));
 
 	sub_v3_v3v3(up, c, b);
 	add_v3_v3v3(d, a, up);
@@ -5570,10 +5570,12 @@ static void calc_vert_quarter(Mesh *me, float a[3], float b[3], float c[3], int
 
 	copy_v3_v3(v1, a);
 	for (int v = 0; v < s_steps_v; v++) {
-		copy_v3_v3(me->mvert[v_pos].co, v1);
-		me->mvert[v_pos].flag = 0;
-		me->mvert[v_pos].bweight = 0;
-		v_pos += flip ? - 1 : 1;
+		if (!flip_side || v > 0) {
+			copy_v3_v3(me->mvert[v_pos].co, v1);
+			me->mvert[v_pos].flag = 0;
+			me->mvert[v_pos].bweight = 0;
+			v_pos += flip ? - 1 : 1;
+		}
 		if (v < s_steps_v - 1) {
 			add_v3_v3(v1, up);
 		}
@@ -5609,15 +5611,15 @@ static void calc_vert_quarter(Mesh *me, float a[3], float b[3], float c[3], int
 }
 
 /* W_steps needs to be uneven! */
-static void calc_vert_half(Mesh *me, float left[3], float right[3], float center[3], float upper_center[3], int v_steps, int w_steps, float smoothness)
+static void calc_vert_half(Mesh *me, float left[3], float right[3], float center[3], float upper_center[3], int v_steps, int w_steps, float smoothness, bool flip_side)
 {
 	int half_w = w_steps / 2;
-	calc_vert_quarter(me, left, center, upper_center, v_steps, half_w, smoothness, false);
+	calc_vert_quarter(me, left, center, upper_center, v_steps, half_w, smoothness, false, flip_side);
 	ED_mesh_vertices_add(me, NULL, 1);
 	copy_v3_v3(me->mvert[me->totvert - 1].co, upper_center);
 	me->mvert[me->totvert - 1].flag = 0;
 	me->mvert[me->totvert - 1].bweight = 0;
-	calc_vert_quarter(me, right, center, upper_center, v_steps, half_w, smoothness, true);
+	calc_vert_quarter(me, right, center, upper_center, v_steps, half_w, smoothness, true, flip_side);
 }
 
 /* Create standardised Mesh. Simple UxV rectangular grid. (Edges, Loops, Polys):*/
@@ -5837,7 +5839,7 @@ static int cmpfunc (const void * a, const void * b)
 }
 
 /* Generate the Tube shape for branches with two ends. */
-static void fill_tube(Mesh *me, float *left, float *right, int totl, int totr, int u_steps, float z_vec[3], int v_steps, int w_steps, float smoothness, int *r_edge_loop_ends, bool n_g_flip)
+static void fill_tube(Mesh *me, float *left, float *right, int totl, int totr, int u_steps, float z_vec[3], int v_steps, int w_steps, float smoothness, int *r_edge_loop_ends, bool n_g_flip, bool flip_side)
 {
 	float step_l = left[totl * 4 - 1] / (float)u_steps;
 	float step_r = right[totr * 4 - 1] / (float)u_steps;
@@ -5889,13 +5891,20 @@ static void fill_tube(Mesh *me, float *left, float *right, int totl, int totr, i
 		add_v3_v3v3(v4, v3, z_vec);
 
 		/* v1 left, v2 right, v3 center bottom, v4 center top */
-		calc_vert_half(me, v1, v2, v3, v4, v_steps, w_steps, smoothness);
+		calc_vert_half(me, v1, v2, v3, v4, v_steps, w_steps, smoothness, flip_side);
+	}
+	generate_mesh_grid_f_e(me, u_steps, v_steps * 2 + w_steps - (flip_side ? 2 : 0), v_start, n_g_flip);
+	if (!flip_side) {
+		r_edge_loop_ends[0] = e_start;
+		r_edge_loop_ends[1] = 2;
+		r_edge_loop_ends[2] = me->totedge - v_steps * 2 - w_steps + 1;
+		r_edge_loop_ends[3] = 1;
+	} else {
+		r_edge_loop_ends[4] = e_start;
+		r_edge_loop_ends[5] = 2;
+		r_edge_loop_ends[6] = me->totedge - v_steps * 2 - w_steps + 3;
+		r_edge_loop_ends[7] = 1;
 	}
-	generate_mesh_grid_f_e(me, u_steps, v_steps * 2 + w_steps, v_start, n_g_flip);
-	r_edge_loop_ends[0] = e_start;
-	r_edge_loop_ends[1] = 2;
-	r_edge_loop_ends[2] = me->totedge - v_steps * 2 - w_steps + 1;
-	r_edge_loop_ends[3] = 1;
 }
 
 static int get_cyclic_offset(SpineBranch *branch)
@@ -5919,7 +5928,7 @@ static int get_cyclic_offset(SpineBranch *branch)
 }
 
 /* Generate the Cap for branches with one ends. */
-static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float z_vec[3], float depth, int v_steps, int w_steps, float smoothness, bool n_g_flip)
+static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float z_vec[3], float depth, int v_steps, int w_steps, float smoothness, bool n_g_flip, bool flip_side)
 {
 	float *cap_p = NULL;
 	float v1[3], m_center[3], m_center_up[3], left_ref[3], right_ref[3];
@@ -5948,7 +5957,7 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	}
 
 	if (!(branch->flag & BRANCH_EDGE_GEN)) {
-		branch->e_start_arr = MEM_callocN(sizeof(int) * 2,"edge startposition array");
+		branch->e_start_arr = MEM_callocN(sizeof(int) * 4,"edge startposition array");
 		branch->flag |= BRANCH_EDGE_GEN;
 	}
 
@@ -5961,7 +5970,7 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	int u_pos_i = 0;
 	int v_start = me->totvert;
 	int u_steps;
-	int e_start_tube[4];
+	int e_start_tube[8];
 	int totl = 0, totr = 0;
 
 	/* If the cap is big enough a tube is added between the cap and the last branch. */
@@ -5999,7 +6008,7 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 
 		if (totl >= 1 && totr >= 1) {
 			u_steps = fmax(2.0f, fmax(left[totl * 4 - 1], right[totr * 4 - 1]) / (float)(2 * depth / v_steps));
-			fill_tube(me, left, right, totl, totr, u_steps, z_vec, v_steps, w_steps, smoothness, e_start_tube, n_g_flip);
+			fill_tube(me, left, right, totl, totr, u_steps, z_vec, v_steps, w_steps, smoothness, e_start_tube, n_g_flip, flip_side);
 			copy_v3_v3(left_ref, &left[totl * 4 - 4]);
 			copy_v3_v3(right_ref, &right[0]);
 			cap_length = totlength - left[totl * 4 - 1] - right[totr * 4 - 1];
@@ -6019,6 +6028,7 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	interp_v3_v3v3(m_center, left_ref, right_ref, 0.5f);
 	add_v3_v3v3(m_center_up, m_center, z_vec);
 
+	/* Add connecting edge */
 	v_start = me->totvert;
 	e_cap_start_a = me->totedge;
 	calc_vert_half(me,
@@ -6028,10 +6038,11 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 				   m_center_up,
 				   v_steps,
 				   w_steps,
-				   smoothness);
+				   smoothness,
+				   flip_side);
 
-	ED_mesh_edges_add(me, NULL, v_steps * 2 + w_steps - 1);
-	for(int v = 0; v < v_steps * 2 + w_steps - 1; v++){
+	ED_mesh_edges_add(me, NULL, v_steps * 2 + w_steps - 1 - (flip_side ? 2 : 0));
+	for(int v = 0; v < v_steps * 2 + w_steps - 1 - (flip_side ? 2 : 0); v++){
 		me->medge[e_cap_start_a + v].v1 = v_start + v;
 		me->medge[e_cap_start_a + v].v2 = v_start + v + 1;
 		me->medge[e_cap_start_a + v].crease = 0;
@@ -6068,18 +6079,19 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 						  v_steps,
 						  0,
 						  smoothness,
-						  false);
+						  false,
+						  flip_side);
 
 		cap_pos += step_size;
 	}
 	e_cap_start_b = me->totedge;
-	generate_mesh_grid_f_e(me, w_steps, v_steps, v_start, n_g_flip);
+	generate_mesh_grid_f_e(me, w_steps, v_steps - (flip_side ? 1 : 0), v_start, n_g_flip);
 	e_cap_start_c = me->totedge;
 
 	bridge_loops(me,
 				 e_cap_start_a,
 				 e_cap_start_b,
-				 v_steps,
+				 v_steps - (flip_side ? 1 : 0),
 				 false,
 				 1,
 				 2,
@@ -6088,20 +6100,20 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	e_corner_a = me->totedge - 1;
 
 	bridge_loops(me,
-				 e_cap_start_a + v_steps,
-				 e_cap_start_b + 2 * v_steps - 2,
+				 e_cap_start_a + v_steps - (flip_side ? 1 : 0),
+				 e_cap_start_b + 2 * v_steps - 2 - (flip_side ? 2 : 0),
 				 w_steps,
 				 false,
 				 1,
-				 2 * v_steps - 1,
+				 2 * v_steps - 1 - (flip_side ? 2 : 0),
 				 !n_g_flip);
 
 	e_corner_b = me->totedge - 1;
 
 	bridge_loops(me,
-				 e_cap_start_a + v_steps + w_steps,
+				 e_cap_start_a + v_steps - (flip_side ? 1 : 0) + w_steps,
 				 e_cap_start_c - 1,
-				 v_steps,
+				 v_steps - (flip_side ? 1 : 0),
 				 true,
 				 1,
 				 1,
@@ -6110,8 +6122,8 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	ED_mesh_loops_add(me, NULL, 6);
 	ED_mesh_polys_add(me, NULL, 2);
 	/* corner a */
-	me->mloop[me->totloop - 6].v = me->medge[e_cap_start_a + v_steps - 1].v1;
-	me->mloop[me->totloop - 6].e = e_cap_start_a + v_steps - 1;
+	me->mloop[me->totloop - 6].v = me->medge[e_cap_start_a + v_steps -(flip_side ? 1 : 0) - 1].v1;
+	me->mloop[me->totloop - 6].e = e_cap_start_a + v_steps -(flip_side ? 1 : 0) - 1;
 
 	me->mloop[me->totloop - (n_g_flip ? 5 : 4)].v = me->medge[e_corner_a + 1].v1;
 	me->mloop[me->totloop - (n_g_flip ? 5 : 4)].e = e_corner_a + 1;
@@ -6126,8 +6138,8 @@ static void add_ss_cap(SilhouetteData *sil, SpineBranch *branch, Mesh *me, float
 	me->mpoly[me->totpoly - 2].pad = 0;
 
 	/* corner b*/
-	me->mloop[me->totloop - 3].v = me->medge[e_cap_start_a + v_steps + w_steps - 1].v1;
-	me->mloop[me->totloop - 3].e = e_cap_start_a + v_steps + w_steps - 1;
+	me->mloop[me->totloop - 3].v = me->medge[e_cap_start_a + v_steps -(flip_side ? 1 : 0) + w_steps - 1].v1;
+	me->mloop[me->totloop - 3].e = e_cap_start_a + v_steps -(flip_side ? 1 : 0) + w_steps -

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list