[Bf-blender-cvs] [a662980] master: Remove already-ifdef'ed out PRE_275_ALGORITHM code from bevel.

Howard Trickey noreply at git.blender.org
Fri Aug 14 15:47:48 CEST 2015


Commit: a662980f31168f3d38e0475ad48025d4efa8d4e6
Author: Howard Trickey
Date:   Fri Aug 14 09:45:29 2015 -0400
Branches: master
https://developer.blender.org/rBa662980f31168f3d38e0475ad48025d4efa8d4e6

Remove already-ifdef'ed out PRE_275_ALGORITHM code from bevel.

The new algorithm has soaked enough that we are unlikely to go back now.

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

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 9cef385..3148f5c 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -58,9 +58,6 @@
 /* happens far too often, uncomment for development */
 // #define BEVEL_ASSERT_PROJECT
 
-/* will likely remove the code enabled by this soon, when sure that it is not needed */
-// #define PRE_275_ALGORITHM
-
 /* for testing */
 // #pragma GCC diagnostic error "-Wpadded"
 
@@ -940,84 +937,6 @@ static void offset_on_edge_between(
 		e2->offset_l = d;
 }
 
-#ifdef PRE_275_ALGORITHM
-/* Calculate the best place for a meeting point for the offsets from edges e1 and e2
- * when there is an in-between edge emid, and we prefer to have a point that may not
- * be on emid if that does a better job of keeping offsets at the user spec.
- * Viewed from the vertex normal side, the CCW order of the edges is e1, emid, e2.
- * The offset lines may not meet exactly: the lines may be angled so that they can't meet.
- * In that case, pick  the offset_on_edge_between. */
-static void offset_in_two_planes(
-        BevelParams *bp, EdgeHalf *e1, EdgeHalf *e2, EdgeHalf *emid,
-        BMVert *v,  float meetco[3])
-{
-	float dir1[3], dir2[3], dirmid[3], norm_perp1[3], norm_perp2[3],
-	      off1a[3], off1b[3], off2a[3], off2b[3], isect2[3],
-	      f1no[3], f2no[3], ang, d;
-	int iret;
-
-	/* get direction vectors for two offset lines */
-	sub_v3_v3v3(dir1, v->co, BM_edge_other_vert(e1->e, v)->co);
-	sub_v3_v3v3(dir2, BM_edge_other_vert(e2->e, v)->co, v->co);
-	sub_v3_v3v3(dirmid, BM_edge_other_vert(emid->e, v)->co, v->co);
-
-	/* get directions into offset planes */
-	/* calculate face normals at corner in case faces are nonplanar */
-	cross_v3_v3v3(f1no, dirmid, dir1);
-	cross_v3_v3v3(f2no, dirmid, dir2);
-
-	/* if e1-v-emid or emid-v-e2 are reflex angles, need to flip corner normals */
-	if (dot_v3v3(f1no, v->no) < 0.0f)
-		negate_v3(f1no);
-	if (dot_v3v3(f2no, v->no) < 0.0f)
-		negate_v3(f2no);
-
-	/* get vectors perpendicular to e1 and e2, pointing into the proper faces */
-	cross_v3_v3v3(norm_perp1, dir1, f1no);
-	normalize_v3(norm_perp1);
-	cross_v3_v3v3(norm_perp2, dir2, f2no);
-	normalize_v3(norm_perp2);
-
-	/* get points that are offset distances from each line, then another point on each line */
-	copy_v3_v3(off1a, v->co);
-	madd_v3_v3fl(off1a, norm_perp1, e1->offset_r);
-	sub_v3_v3v3(off1b, off1a, dir1);
-	copy_v3_v3(off2a, v->co);
-	madd_v3_v3fl(off2a, norm_perp2, e2->offset_l);
-	add_v3_v3v3(off2b, off2a, dir2);
-
-	ang = angle_v3v3(dir1, dir2);
-	if (ang < BEVEL_EPSILON_BIG) {
-		/* lines are parallel; put intersection on emid */
-		offset_on_edge_between(bp, e1, e2, emid, v, meetco);
-	}
-	else if (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_BIG) {
-		slide_dist(e2, v, e2->offset_l, meetco);
-		d = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e1->e, v)->co);
-		if (fabsf(d - e1->offset_r) > BEVEL_EPSILON)
-			e1->offset_r = d;
-	}
-	else {
-		iret = isect_line_line_v3(off1a, off1b, off2a, off2b, meetco, isect2);
-		if (iret == 0) {
-			/* lines colinear: another test says they are parallel. so shouldn't happen */
-			copy_v3_v3(meetco, off1a);
-			d = dist_to_line_v3(meetco, v->co, BM_edge_other_vert(e2->e, v)->co);
-			if (fabsf(d - e2->offset_l) > BEVEL_EPSILON)
-				e2->offset_l = d;
-		}
-		else if (iret == 2) {
-			/* lines are not coplanar and don't meet; meetco and isect2 are nearest to first and second lines */
-			if (len_squared_v3v3(meetco, isect2) > 100.0f * BEVEL_EPSILON_SQ) {
-				/* offset lines don't meet so can't preserve widths */
-				offset_on_edge_between(bp, e1, e2, emid, v, meetco);
-			}
-		}
-		/* else iret == 1 and the lines are coplanar so meetco has the intersection */
-	}
-}
-#endif
-
 /* Offset by e->offset in plane with normal plane_no, on left if left==true,
  * else on right.  If no is NULL, choose an arbitrary plane different
  * from eh's direction. */
@@ -1582,7 +1501,6 @@ static int count_bound_vert_seams(BevVert *bv)
 	return ans;
 }
 
-#ifndef PRE_275_ALGORITHM
 /* Is e between two planes where angle between is 180? */
 static bool eh_on_plane(EdgeHalf *e)
 {
@@ -1895,245 +1813,6 @@ static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
 		}
 	}
 }
-#endif
-
-#ifdef PRE_275_ALGORITHM
-/* This code was used prior to just before the 2.75 Blender release.
- * It treated multiple non-beveled edges between beveled ones differently */
- 
-/* Make a circular list of BoundVerts for bv, each of which has the coordinates
- * of a vertex on the boundary of the beveled vertex bv->v.
- * This may adjust some EdgeHalf widths, and there might have to be
- * a subsequent pass to make the widths as consistent as possible.
- * The first time through, construct will be true and we are making the BoundVerts
- * and setting up the BoundVert and EdgeHalf pointers appropriately.
- * For a width consistency path, we just recalculate the coordinates of the
- * BoundVerts. If the other ends have been (re)built already, then we
- * copy the offsets from there to match, else we use the ideal (user-specified)
- * widths.
- * Also, if construct, decide on the mesh pattern that will be used inside the boundary.
- * Doesn't make the actual BMVerts */
-static void build_boundary(BevelParams *bp, BevVert *bv, bool construct)
-{
-	MemArena *mem_arena = bp->mem_arena;
-	EdgeHalf *efirst, *e, *eother;
-	BoundVert *v;
-	BevVert *bvother;
-	VMesh *vm;
-	float co[3];
-	const float *no;
-	float lastd;
-
-	vm = bv->vmesh;
-
-	if (bp->vertex_only) {
-		e = efirst = &bv->edges[0];
-	}
-	else {
-		e = efirst = next_bev(bv, NULL);
-		do {
-			eother = find_other_end_edge_half(bp, e, &bvother);
-			if (eother && bvother->visited && bp->offset_type != BEVEL_AMT_PERCENT) {
-				/* try to keep bevel even by matching other end offsets */
-				e->offset_l = eother->offset_r;
-				e->offset_r = eother->offset_l;
-			}
-			else {
-				/* reset to user spec */
-				e->offset_l = e->offset_l_spec;
-				e->offset_r = e->offset_r_spec;
-			}
-		} while ((e = e->next) != efirst);
-		e = efirst;
-	}
-
-	BLI_assert(bv->edgecount >= 2);  /* since bevel edges incident to 2 faces */
-
-	if (bv->edgecount == 2 && bv->selcount == 1) {
-		/* special case: beveled edge meets non-beveled one at valence 2 vert */
-		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;
-		}
-		else {
-			adjust_bound_vert(e->leftv, co);
-		}
-		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;
-		}
-		else {
-			adjust_bound_vert(e->rightv, co);
-		}
-		/* make artifical extra point along unbeveled edge, and form triangle */
-		slide_dist(e->next, bv->v, e->offset_l, co);
-		if (construct) {
-			v = add_new_bound_vert(mem_arena, vm, co);
-			v->efirst = v->elast = e->next;
-			e->next->leftv = e->next->rightv = v;
-			/* could use M_POLY too, but tri-fan looks nicer)*/
-			vm->mesh_kind = M_TRI_FAN;
-			set_bound_vert_seams(bv);
-		}
-		else {
-			adjust_bound_vert(e->next->leftv, co);
-		}
-		set_profile_params(bp, bv, vm->boundstart);
-		calculate_profile(bp, vm->boundstart);
-		return;
-	}
-
-	lastd = e->offset_l;
-	do {
-		if (e->is_bev) {
-			/* handle only left side of beveled edge e here: next iteration should do right side */
-			if (e->prev->is_bev) {
-				BLI_assert(e->prev != e);  /* see: wire edge special case */
-				offset_meet(e->prev, e, bv->v, e->fprev, false, co);
-				if (construct) {
-					v = add_new_bound_vert(mem_arena, vm, co);
-					v->efirst = e->prev;
-					v->elast = v->ebev = e;
-					e->leftv = v;
-					e->prev->rightv = v;
-				}
-				else {
-					v = e->leftv;
-					adjust_bound_vert(v, co);
-				}
-			}
-			else {
-				/* e->prev is not beveled */
-				if (e->prev->prev->is_bev) {
-					BLI_assert(e->prev->prev != e); /* see: edgecount 2, selcount 1 case */
-					/* find meet point between e->prev->prev and e and attach e->prev there */
-					if (!bp->loop_slide)
-						offset_in_two_planes(bp, e->prev->prev, e, e->prev, bv->v, co);
-					else
-						offset_on_edge_between(bp, e->prev->prev, e, e->prev, bv->v, co);
-					if (construct) {
-						v = add_new_bound_vert(mem_arena, vm, co);
-						v->efirst = e->prev->prev;
-						v->elast = v->ebev = e;
-						e->leftv = v;
-						e->prev->leftv = v;
-						e->prev->prev->rightv = v;
-					}
-					else {
-						v = e->leftv;
-						adjust_bound_vert(v, co);
-					}
-				}
-				else {
-					/* neither e->prev nor e->prev->prev are beveled: make on-edge on e->prev */
-					offset_meet(e->prev, e, bv->v, e->fprev, false, co);
-					if (construct) {
-						v = add_new_bound_vert(mem_arena, vm, co);
-						v->efirst = e->prev;
-						v->elast = v->ebev = e;
-						e->leftv = v;
-						e->prev->leftv = v;
-					}
-					else {
-						v = e->leftv;
-						adjust_bound_vert(v, co);
-					}
-				}
-			}
-			lastd = len_v3v3(bv->v->co, v->nv.co);
-		}
-		else {
-			/* e is not beveled */
-			if (e->next->is_bev) {
-				/* next iteration will place e between beveled previous and next edges */
-				/* do nothing... */
-			}
-			else if (e->prev->is_bev) {
-				/* on-edge meet between e->prev and e */
-				offset_meet(e->prev, e, bv->v, e->fprev, false, co);
-				if (construct) {
-					v = add_new_bound_vert(mem_arena, vm, co);
-					v->efirst = e->prev;
-					v->elast = e;
-					e->leftv = v;
-					e->prev->rightv = v;
-				}
-				else {
-					adjust_bound_vert(e->leftv, co);
-				}
-			}
-			else {
-				/* None of e->prev, e, e->next are beveled.
-				 * could either leave alone or add slide points to make
-				 * one polygon around bv->v.  For now, we choose latter.
-				 * For vertex bevel, we use e->offset_l as slide distance.
-				 * Could slide to make an even bevel plane but for now will
-				 * just use last distance a meet point moved from bv->v. */
-				slide_dist(e, bv->v, bp->vertex_only ? e->offset_l : lastd, co);
-				if (con

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list