[Bf-blender-cvs] [37f1b71] master: Bevel code cleanup: get rid of old 'ADJ' code.

Howard Trickey noreply at git.blender.org
Tue Jan 28 13:09:05 CET 2014


Commit: 37f1b717eb4680ab5b3cab482fb5c6f200d1eb9e
Author: Howard Trickey
Date:   Tue Jan 28 07:01:55 2014 -0500
https://developer.blender.org/rB37f1b717eb4680ab5b3cab482fb5c6f200d1eb9e

Bevel code cleanup: get rid of old 'ADJ' code.

The new subdiv 'adj' pattern is working well, so removing the
old code and taking opportunity to remove 'subdiv' from a number
of names.

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

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 fa2c9b1..39e43db 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -49,9 +49,6 @@
 
 #include "./intern/bmesh_private.h"
 
-/* use new way of doing ADJ pattern */
-#define USE_ADJ_SUBDIV
-
 #define BEVEL_EPSILON_D  1e-6
 #define BEVEL_EPSILON    1e-6f
 #define BEVEL_EPSILON_SQ 1e-12f
@@ -151,7 +148,6 @@ typedef struct VMesh {
 		M_NONE,         /* no polygon mesh needed */
 		M_POLY,         /* a simple polygon */
 		M_ADJ,          /* "adjacent edges" mesh pattern */
-		M_ADJ_SUBDIV,   /* like M_ADJ, but using subdivision */
 		M_TRI_FAN,      /* a simple polygon - fan filled */
 		M_QUAD_STRIP,   /* a simple polygon - cut into parallel strips */
 	} mesh_kind;
@@ -1081,37 +1077,6 @@ static void make_unit_cube_map(const float va[3], const float vb[3], const float
 	r_mat[3][3] = 1.0f;
 }
 
-#ifndef USE_ADJ_SUBDIV
-/*
- * Find the point (/n) of the way around the round profile for e,
- * where start point is va, midarc point is vmid, and end point is vb.
- * Return the answer in r_co.
- * If va -- vmid -- vb is approximately a straight line, just
- * interpolate along the line.
- */
-static void get_point_on_round_edge(EdgeHalf *e, int k,
-                                    const float va[3], const float vmid[3], const float vb[3],
-                                    float r_co[3])
-{
-	float p[3], angle;
-	float m[4][4];
-	int n = e->seg;
-
-	if (make_unit_square_map(va, vmid, vb, m)) {
-		/* Find point k/(e->seg) along quarter circle from (0,1,0) to (1,0,0) */
-		angle = (float)M_PI * (float)k / (2.0f * (float)n);  /* angle from y axis */
-		p[0] = sinf(angle);
-		p[1] = cosf(angle);
-		p[2] = 0.0f;
-		mul_v3_m4v3(r_co, m, p);
-	}
-	else {
-		/* degenerate case: profile is a line */
-		interp_v3_v3v3(r_co, va, vb, (float)k / (float)n);
-	}
-}
-#endif
-
 /* Get the coordinate on the superellipse (exponent r),
  * at parameter value u.  u goes from u to 2 as the
  * superellipse moves on the quadrant (0,1) to (1,0). */
@@ -1202,7 +1167,7 @@ static void get_profile_point(BevelParams *bp, const Profile *pro, int i, int n,
  * Allocate the space for them if that hasn't been done already.
  * If bp->seg is not a power of 2, also need to calculate
  * the coordinate values for the power of 2 >= bp->seg,
- * because the ADJ_SUBDIV pattern needs power-of-2 boundaries
+ * because the ADJ pattern needs power-of-2 boundaries
  * during construction. */
 static void calculate_profile(BevelParams *bp, BoundVert *bndv)
 {
@@ -1275,45 +1240,6 @@ static void calculate_profile(BevelParams *bp, BoundVert *bndv)
 	}
 }
 
-#ifndef USE_ADJ_SUBDIV
-/* Calculate a snapped point to the transformed profile of edge e, extended as
- * in a cylinder-like surface in the direction of e.
- * co is the point to snap and is modified in place.
- * va and vb are the limits of the profile (with peak on e). */
-static void snap_to_edge_profile(EdgeHalf *e, const float va[3], const float vb[3],
-                                 float co[3])
-{
-	float m[4][4], minv[4][4];
-	float edir[3], va0[3], vb0[3], vmid0[3], p[3], snap[3], plane[4];
-
-	sub_v3_v3v3(edir, e->e->v1->co, e->e->v2->co);
-
-	/* project va and vb onto plane P, with normal edir and containing co */
-	plane_from_point_normal_v3(plane, co, edir);
-	closest_to_plane_v3(va0, plane, va);
-	closest_to_plane_v3(vb0, plane, vb);
-	project_to_edge(e->e, va0, vb0, vmid0);
-	if (make_unit_square_map(va0, vmid0, vb0, m)) {
-		/* Transform co and project it onto the unit circle.
-		 * Projecting is in fact just normalizing the transformed co */
-		if (!invert_m4_m4(minv, m)) {
-			/* shouldn't happen, by angle test and construction of vd */
-			BLI_assert(!"failed inverse during profile snap");
-			return;
-		}
-		mul_v3_m4v3(p, minv, co);
-		normalize_v3(p);
-		mul_v3_m4v3(snap, m, p);
-		copy_v3_v3(co, snap);
-	}
-	else {
-		/* planar case: just snap to line va--vb */
-		closest_to_line_segment_v3(p, co, va, vb);
-		copy_v3_v3(co, p);
-	}
-}
-#endif
-
 /* Snap a direction co to a superellipsoid with parameter super_r */
 static void snap_to_superellipsoid(float co[3], const float super_r)
 {
@@ -1613,7 +1539,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
 			if (vm->count == 2)
 				vm->mesh_kind = M_NONE;
 			else if (bp->seg > 1)
-				vm->mesh_kind = M_ADJ_SUBDIV;
+				vm->mesh_kind = M_ADJ;
 			else
 				vm->mesh_kind = M_POLY;
 		}
@@ -1632,11 +1558,7 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
 			}
 		}
 		else {
-#ifdef USE_ADJ_SUBDIV
-			vm->mesh_kind = M_ADJ_SUBDIV;
-#else
 			vm->mesh_kind = M_ADJ;
-#endif
 		}
 	}
 }
@@ -1747,362 +1669,7 @@ static EdgeHalf *pipe_test(BevVert *bv)
 	return epipe;
 }
 
-#ifndef USE_ADJ_SUBDIV
-/*
- * Given that the boundary is built and the boundary BMVerts have been made,
- * calculate the positions of the interior mesh points for the M_ADJ pattern,
- * then make the BMVerts and the new faces. */
-static void bevel_build_rings(BMesh *bm, BevVert *bv)
-{
-	int k, ring, i, n, ns, ns2, nn, odd;
-	VMesh *vm = bv->vmesh;
-	BoundVert *v, *vprev, *vnext;
-	NewVert *nv, *nvprev, *nvnext;
-	EdgeHalf *epipe;
-	BMVert *bmv, *bmv1, *bmv2, *bmv3, *bmv4;
-	BMFace *f, *f2, *f23;
-	float co[3], coa[3], cob[3], midco[3];
-	float va_pipe[3], vb_pipe[3];
-
-	n = vm->count;
-	ns = vm->seg;
-	ns2 = ns / 2;
-	odd = (ns % 2) != 0;
-	BLI_assert(n > 2 && ns > 1);
-
-	epipe = pipe_test(bv);
-
-	/* Make initial rings, going between points on neighbors.
-	 * After this loop, will have coords for all (i, r, k) where
-	 * BoundVert for i has a bevel, 0 <= r <= ns2, 0 <= k <= ns */
-	for (ring = 1; ring <= ns2; ring++) {
-		v = vm->boundstart;
-
-		do {
-			i = v->index;
-			if (v->ebev) {
-				/* get points coords of points a and b, on outer rings
-				 * of prev and next edges, k away from this edge */
-				vprev = v->prev;
-				vnext = v->next;
-
-				if (vprev->ebev)
-					nvprev = mesh_vert(vm, vprev->index, 0, ns - ring);
-				else
-					nvprev = mesh_vert(vm, vprev->index, 0, ns);
-				copy_v3_v3(coa, nvprev->co);
-				nv = mesh_vert(vm, i, ring, 0);
-				copy_v3_v3(nv->co, coa);
-				nv->v = nvprev->v;
-
-				if (vnext->ebev)
-					nvnext = mesh_vert(vm, vnext->index, 0, ring);
-				else
-					nvnext = mesh_vert(vm, vnext->index, 0, 0);
-				copy_v3_v3(cob, nvnext->co);
-				nv = mesh_vert(vm, i, ring, ns);
-				copy_v3_v3(nv->co, cob);
-				nv->v = nvnext->v;
-
-				/* TODO: better calculation of new midarc point? */
-				project_to_edge(v->ebev->e, coa, cob, midco);
-
-				for (k = 1; k < ns; k++) {
-					get_point_on_round_edge(v->ebev, k, coa, midco, cob, co);
-					copy_v3_v3(mesh_vert(vm, i, ring, k)->co, co);
-				}
-
-				if (v->ebev == epipe) {
-					/* save profile extremes for later snapping */
-					copy_v3_v3(va_pipe, mesh_vert(vm, i, 0, 0)->co);
-					copy_v3_v3(vb_pipe, mesh_vert(vm, i, 0, ns)->co);
-				}
-			}
-		} while ((v = v->next) != vm->boundstart);
-	}
-
-	/* Now make sure cross points of rings share coordinates and vertices.
-	 * After this loop, will have BMVerts for all (i, r, k) where
-	 * i is for a BoundVert that is beveled and has either a predecessor or
-	 * successor BoundVert beveled too, and
-	 * for odd ns: 0 <= r <= ns2, 0 <= k <= ns
-	 * for even ns: 0 <= r < ns2, 0 <= k <= ns except k=ns2 */
-	v = vm->boundstart;
-	do {
-		i = v->index;
-		if (v->ebev) {
-			vprev = v->prev;
-			vnext = v->next;
-			if (vprev->ebev) {
-				for (ring = 1; ring <= ns2; ring++) {
-					for (k = 1; k <= ns2; k++) {
-						if (!odd && (k == ns2 || ring == ns2))
-							continue;  /* center line is special case: do after the rest are done */
-						nv = mesh_vert(vm, i, ring, k);
-						nvprev = mesh_vert(vm, vprev->index, k, ns - ring);
-						mid_v3_v3v3(co, nv->co, nvprev->co);
-						if (epipe)
-							snap_to_edge_profile(epipe, va_pipe, vb_pipe, co);
-
-						copy_v3_v3(nv->co, co);
-						BLI_assert(nv->v == NULL && nvprev->v == NULL);
-						create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
-						copy_mesh_vert(vm, vprev->index, k, ns - ring, i, ring, k);
-					}
-				}
-				if (!vprev->prev->ebev) {
-					for (ring = 1; ring <= ns2; ring++) {
-						for (k = 1; k <= ns2; k++) {
-							if (!odd && (k == ns2 || ring == ns2))
-								continue;
-							create_mesh_bmvert(bm, vm, vprev->index, ring, k, bv->v);
-						}
-					}
-				}
-				if (!vnext->ebev) {
-					for (ring = 1; ring <= ns2; ring++) {
-						for (k = ns - ns2; k < ns; k++) {
-							if (!odd && (k == ns2 || ring == ns2))
-								continue;
-							create_mesh_bmvert(bm, vm, i, ring, k, bv->v);
-						}
-					}
-				}
-			}
-		}
-	} while ((v = v->next) != vm->boundstart);
-
-	if (!odd) {
-		/* Do special case center lines.
-		 * This loop makes verts for (i, ns2, k) for 1 <= k <= ns-1, k!=ns2
-		 * and for (i, r, ns2) for 1 <= r <= ns2-1,
-		 * whenever i is in a sequence of at least two beveled verts */
-		v = vm->boundstart;
-		do {
-			i = v->index;
-			if (v->ebev) {
-				vprev = v->prev;
-				vnext = v->next;
-				for (k = 1; k < ns2; k++) {
-					nv = mesh_vert(vm, i, k, ns2);
-					if (vprev->ebev)
-						nvprev = mesh_vert(vm, vprev->index, ns2, ns - k);
-					if (vnext->ebev)
-						nvnext = mesh_vert(vm, vnext->index, ns2, k);
-					if (vprev->ebev && vnext->ebev) {
-						mid_v3_v3v3v3(co, nvprev->co, nv->co, nvnext->co);
-						if (epipe)
-							snap_to_edge_profile(epipe, va_pipe, vb_pipe, co);
-						copy_v3_v3(nv->co, co);
-						create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
-						copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
-						copy_mesh_vert(vm, vnext->index, ns2, k, i, k, ns2);
-
-					}
-					else if (vprev->ebev) {
-						mid_v3_v3v3(co, nvprev->co, nv->co);
-						if (epipe)
-							snap_to_edge_profile(epipe, va_pipe, vb_pipe, co);
-						copy_v3_v3(nv->co, co);
-						create_mesh_bmvert(bm, vm, i, k, ns2, bv->v);
-						copy_mesh_vert(vm, vprev->index, ns2, ns - k, i, k, ns2);
-
-						create_mesh_bmvert(bm, vm, i, ns2, ns - k, bv->v);
-					}
-					else if (vnext->ebev) {
-						mid_v3_v3v3(co, nv->co, nvnext->co);
-						if (epipe)
-							snap_to_edge_profil

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list