[Bf-blender-cvs] [b640fd829e3] master: Add miter pattern options.

Howard Trickey noreply at git.blender.org
Fri Jan 18 18:58:27 CET 2019


Commit: b640fd829e3a228561e4d9dba9c830ae22d3ebc7
Author: Howard Trickey
Date:   Fri Jan 18 12:54:10 2019 -0500
Branches: master
https://developer.blender.org/rBb640fd829e3a228561e4d9dba9c830ae22d3ebc7

Add miter pattern options.

Will document the new options in release notes, then in manual.
Still a bit of work to do on the bulging shape that appears
on cube corners if using arc inner miters, but will do that later.
Also need to do something smarter in clamp overlap.

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

M	release/scripts/addons
M	release/scripts/addons_contrib
M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/intern/bmesh_operator_api.h
M	source/blender/bmesh/intern/bmesh_operators.h
M	source/blender/bmesh/operators/bmo_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.h
M	source/blender/editors/mesh/editmesh_bevel.c
M	source/blender/makesdna/DNA_modifier_types.h
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/intern/MOD_bevel.c

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

diff --git a/release/scripts/addons b/release/scripts/addons
index 5f7fba0565a..ba97e19e5b3 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 5f7fba0565a7c9ae93eae31a08fc9bbbd16d333a
+Subproject commit ba97e19e5b3df449784a4cc4ed89ce7b511ec3e4
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index fecc0db5600..272b1a4ef07 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit fecc0db5600405a0c14c70120ae279222861ef80
+Subproject commit 272b1a4ef07717beb3d0bfcb7380c2164fd008a3
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index a6bab561e29..23bba83271b 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -166,6 +166,11 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.label(text="Set Face Strength Mode")
         layout.row().prop(md, "face_strength_mode", expand=True)
 
+        layout.label(text="Miter Patterns")
+        layout.row().prop(md, "miter_outer")
+        layout.row().prop(md, "miter_inner")
+        layout.row().prop(md, "spread")
+
     def BOOLEAN(self, layout, ob, md):
         split = layout.split()
 
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index db4985c62f6..dd913d95778 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1743,6 +1743,13 @@ static BMO_FlagSet bmo_enum_bevel_face_strength_type[] = {
 	{0, NULL},
 };
 
+static BMO_FlagSet bmo_enum_bevel_miter_type[] = {
+	{BEVEL_MITER_SHARP, "SHARP"},
+	{BEVEL_MITER_PATCH, "PATCH"},
+	{BEVEL_MITER_ARC, "ARC"},
+	{0, NULL},
+};
+
 /*
  * Bevel.
  *
@@ -1765,6 +1772,11 @@ static BMOpDefine bmo_bevel_def = {
 	 {"harden_normals", BMO_OP_SLOT_BOOL},  /* harden normals */
 	 {"face_strength_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
 	 	bmo_enum_bevel_face_strength_type}, /* whether to set face strength, and which faces to set if so */
+	 {"miter_outer", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
+	 	bmo_enum_bevel_miter_type},         /* outer miter kind */
+	 {"miter_inner", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM},
+		bmo_enum_bevel_miter_type},         /* outer miter kind */
+	 {"spread", BMO_OP_SLOT_FLT},           /* amount to offset beveled edge */
 	 {"smoothresh", BMO_OP_SLOT_FLT},       /* for passing mesh's smoothresh, used in hardening */
 	 {{'\0'}},
 	},
diff --git a/source/blender/bmesh/intern/bmesh_operator_api.h b/source/blender/bmesh/intern/bmesh_operator_api.h
index fd01bec9531..e609500ddc3 100644
--- a/source/blender/bmesh/intern/bmesh_operator_api.h
+++ b/source/blender/bmesh/intern/bmesh_operator_api.h
@@ -246,7 +246,7 @@ typedef struct BMOpSlot {
 	           ((slot >= (op)->slots_out) && (slot < &(op)->slots_out[BMO_OP_MAX_SLOTS])))
 
 /* way more than probably needed, compiler complains if limit hit */
-#define BMO_OP_MAX_SLOTS 16
+#define BMO_OP_MAX_SLOTS 20
 
 /* BMOpDefine->type_flag */
 typedef enum {
diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h
index 365b5eb4681..dd9c57d6b6d 100644
--- a/source/blender/bmesh/intern/bmesh_operators.h
+++ b/source/blender/bmesh/intern/bmesh_operators.h
@@ -125,6 +125,13 @@ enum {
 	BEVEL_FACE_STRENGTH_ALL,
 };
 
+/* Bevel miter slot values */
+enum {
+	BEVEL_MITER_SHARP,
+	BEVEL_MITER_PATCH,
+	BEVEL_MITER_ARC,
+};
+
 extern const BMOpDefine *bmo_opdefines[];
 extern const int         bmo_opdefines_total;
 
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 3277824b890..853d11aade6 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -43,10 +43,13 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 	const bool  clamp_overlap = BMO_slot_bool_get(op->slots_in,  "clamp_overlap");
 	const int   material      = BMO_slot_int_get(op->slots_in,   "material");
 	const bool  loop_slide    = BMO_slot_bool_get(op->slots_in,  "loop_slide");
-	const bool	mark_seam	  = BMO_slot_bool_get(op->slots_in, "mark_seam");
-	const bool	mark_sharp	  = BMO_slot_bool_get(op->slots_in, "mark_sharp");
+	const bool	mark_seam	  = BMO_slot_bool_get(op->slots_in,  "mark_seam");
+	const bool	mark_sharp	  = BMO_slot_bool_get(op->slots_in,  "mark_sharp");
 	const bool  harden_normals = BMO_slot_bool_get(op->slots_in, "harden_normals");
 	const int   face_strength_mode = BMO_slot_int_get(op->slots_in, "face_strength_mode");
+	const int   miter_outer   = BMO_slot_int_get(op->slots_in,   "miter_outer");
+	const int   miter_inner   = BMO_slot_int_get(op->slots_in,   "miter_inner");
+	const float spread        = BMO_slot_float_get(op->slots_in, "spread");
 	const float smoothresh    = BMO_slot_float_get(op->slots_in, "smoothresh");
 
 	if (offset > 0) {
@@ -73,7 +76,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op)
 
 		BM_mesh_bevel(
 		        bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material,
-		        loop_slide, mark_seam, mark_sharp, harden_normals, face_strength_mode, smoothresh);
+		        loop_slide, mark_seam, mark_sharp, harden_normals, face_strength_mode,
+				miter_outer, miter_inner, spread, smoothresh);
 
 		BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
 		BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c
index 452dfa22993..043a40a9568 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -154,6 +154,8 @@ typedef struct BoundVert {
 	Profile profile;    /* edge profile between this and next BoundVert */
 	bool any_seam;      /* are any of the edges attached here seams? */
 	bool visited;       /* used during delta adjust pass */
+	bool is_arc_start;	/* this boundvert begins an arc profile */
+	bool is_patch_start; /* this boundvert begins a patch profile */
 	int seam_len;		/* length of seam starting from current boundvert to next boundvert with ccw ordering */
 	int sharp_len;		/* Same as seam_len but defines length of sharp edges */
 //	int _pad;
@@ -222,6 +224,9 @@ typedef struct BevelParams {
 	int vertex_group;       /* vertex group index, maybe set if vertex_only */
 	int mat_nr;             /* if >= 0, material number for bevel; else material comes from adjacent faces */
 	int face_strength_mode; /* setting face strength if > 0 */
+	int miter_outer;        /* what kind of miter pattern to use on reflex angles */
+	int miter_inner;		/* what kind of miter pattern to use on non-reflex angles */
+	float spread;			/* amount to spread when doing inside miter */
 	float smoothresh;		/* mesh's smoothresh, used if hardening */
 } BevelParams;
 
@@ -306,6 +311,9 @@ static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float
 	ans->adjchain = NULL;
 	ans->sinratio = 1.0f;
 	ans->visited = false;
+	ans->any_seam = false;
+	ans->is_arc_start = false;
+	ans->is_patch_start = false;
 	vm->count++;
 	return ans;
 }
@@ -450,7 +458,7 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
 		if (v->efirst->fprev != frep)
 			frep2 = v->efirst->fprev;
 	}
-	else {
+	else if (v->efirst) {
 		frep = v->efirst->fprev;
 		if (frep) {
 			if (v->elast->fnext != frep)
@@ -469,6 +477,18 @@ static BMFace *boundvert_rep_face(BoundVert *v, BMFace **r_fother)
 			frep = v->elast->fprev;
 		}
 	}
+	else if (v->prev->elast) {
+		frep = v->prev->elast->fnext;
+		if (v->next->efirst) {
+			if (frep)
+				frep2 = v->next->efirst->fprev;
+			else
+				frep = v->next->efirst->fprev;
+		}
+	}
+	else {
+		frep = NULL;
+	}
 	if (r_fother)
 		*r_fother = frep2;
 	return frep;
@@ -737,6 +757,33 @@ static bool is_outside_edge(EdgeHalf *e, const float co[3], BMVert **ret_closer_
 	}
 }
 
+/* Return -1, 0, or 1 as angle from e1 to e2 is <. =, or > 180 degrees */
+static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v)
+{
+	BMVert *v1, *v2;
+	float dir1[3], dir2[3], cross[3], *no, dot;
+
+	v1 = BM_edge_other_vert(e1->e, v);
+	v2 = BM_edge_other_vert(e2->e, v);
+	sub_v3_v3v3(dir1, v->co, v1->co);
+	sub_v3_v3v3(dir2, v->co, v2->co);
+	/* angles are in [0,pi]. need to compare cross product with normal to see if they are reflex */
+	cross_v3_v3v3(cross, dir1, dir2);
+	if (e1->fnext)
+		no = e1->fnext->no;
+	else if (e2->fprev)
+		no = e2->fprev->no;
+	else
+		no = v->no;
+	dot = dot_v3v3(cross, no);
+	if (fabsf(dot) < BEVEL_EPSILON_BIG)
+		return 0;
+	else if (dot < 0.0f)
+		return 1;
+	else
+		return -1;
+}
+
 /* co should be approximately on the plane between e1 and e2, which share common vert v
  * and common face f (which cannot be NULL).
  * Is it between those edges, sweeping CCW? */
@@ -1181,6 +1228,16 @@ static void set_profile_params(BevelParams *bp, BevVert *bv, BoundVert *bndv)
 		}
 		copy_v3_v3(pro->plane_co, co1);
 	}
+	else if (bndv->is_arc_start) {
+		/* assume pro->midco was alredy set */
+		copy_v3_v3(pro->coa, co1);
+		copy_v3_v3(pro->cob, co2);
+		pro->super_r = PRO_CIRCLE_R;
+		zero_v3(pro->plane_co);
+		zero_v3(pro->plane_no);
+		zero_v3(pro->proj_dir);
+		do_linear_interp = false;
+	}
 	if (do_linear_interp) {
 		pro->super_r = PRO_LINE_R;
 		copy_v3_v3(pro->coa, co1);
@@ -2129,6 +2186,87 @@ static void build_boundary_terminal_edge(BevelParams *bp, BevVert *bv, EdgeHalf
 	}
 }
 
+/* Helper for build_boundary to handle special miters */
+static void adjust_miter_coords(BevelParams *bp, BevVert *bv, EdgeHalf *emiter)
+{
+	float co1[3], co2[3], co3[3], edge_dir[3], line_p[3];
+	BoundVert *v1, *v2, *v3, *v1prev, *v3next;
+	BMVert *vother;
+	EdgeHalf *emiter_other;
+	int miter_outer = bp->miter_outer;
+
+	v1 = emiter->rightv;
+	if (miter_outer == BEVEL_MITER_PATCH) {
+		v2 = v1->next;
+		v3 = v2->next;
+	}
+	else {
+		BLI_assert(miter_outer == BEVEL_MITER_ARC);
+		v2 = NULL;
+		v3 = v1->next;
+	}
+	v1p

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list