[Bf-blender-cvs] [3756f920f48] master: BMesh: backport minor changes from 2.8

Campbell Barton noreply at git.blender.org
Sat Nov 10 09:59:06 CET 2018


Commit: 3756f920f4894c9ec748c0ece5f63e1bc9c616df
Author: Campbell Barton
Date:   Sat Nov 10 19:54:49 2018 +1100
Branches: master
https://developer.blender.org/rB3756f920f4894c9ec748c0ece5f63e1bc9c616df

BMesh: backport minor changes from 2.8

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

M	source/blender/bmesh/bmesh.h
M	source/blender/bmesh/intern/bmesh_marking.c
M	source/blender/bmesh/intern/bmesh_mesh.c
M	source/blender/bmesh/intern/bmesh_mesh.h
M	source/blender/bmesh/intern/bmesh_mesh_conv.c
M	source/blender/bmesh/intern/bmesh_polygon.c
M	source/blender/bmesh/intern/bmesh_polygon.h
M	source/blender/bmesh/intern/bmesh_query.c
M	source/blender/bmesh/intern/bmesh_query.h
M	source/blender/bmesh/operators/bmo_bevel.c
M	source/blender/bmesh/tools/bmesh_bevel.c
M	source/blender/bmesh/tools/bmesh_wireframe.c

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

diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h
index 8b0b8a282f5..266b31aaeb3 100644
--- a/source/blender/bmesh/bmesh.h
+++ b/source/blender/bmesh/bmesh.h
@@ -84,7 +84,7 @@
  * Edges and Vertices in BMesh are primitive structures.
  *
  * \note There can be more than one edge between two vertices in BMesh,
- * though the rest of Blender (e.g. DerivedMesh, CDDM, CCGSubSurf, etc) does not support this.
+ * though the rest of Blender (i.e. DerivedMesh, CDDM, CCGSubSurf, etc) does not support this.
  * So it should only occur temporarily during editing operations.
  *
  *
diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c
index 10a03050d4b..1e53180396e 100644
--- a/source/blender/bmesh/intern/bmesh_marking.c
+++ b/source/blender/bmesh/intern/bmesh_marking.c
@@ -863,7 +863,7 @@ void BM_editselection_normal(BMEditSelection *ese, float r_normal[3])
 
 /* Calculate a plane that is rightangles to the edge/vert/faces normal
  * also make the plane run along an axis that is related to the geometry,
- * because this is used for the manipulators Y axis. */
+ * because this is used for the gizmos Y axis. */
 void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
 {
 	if (ese->htype == BM_VERT) {
@@ -895,7 +895,7 @@ void BM_editselection_plane(BMEditSelection *ese, float r_plane[3])
 		else {
 			/* the plane is simple, it runs along the edge
 			 * however selecting different edges can swap the direction of the y axis.
-			 * this makes it less likely for the y axis of the manipulator
+			 * this makes it less likely for the y axis of the gizmo
 			 * (running along the edge).. to flip less often.
 			 * at least its more predictable */
 			if (eed->v2->co[1] > eed->v1->co[1]) {  /* check which to do first */
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 4568c3b7965..6dc6fee3a18 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -894,7 +894,10 @@ static void bm_mesh_loops_calc_normals(
 								clnors_avg[0] /= clnors_nbr;
 								clnors_avg[1] /= clnors_nbr;
 								/* Fix/update all clnors of this fan with computed average value. */
-								printf("Invalid clnors in this fan!\n");
+
+								/* Prints continuously when merge custom normals, so commenting. */
+								/* printf("Invalid clnors in this fan!\n"); */
+
 								while ((clnor = BLI_SMALLSTACK_POP(clnors))) {
 									//print_v2("org clnor", clnor);
 									clnor[0] = (short)clnors_avg[0];
@@ -1009,7 +1012,8 @@ void BM_mesh_loop_normals_update(
 void BM_loops_calc_normal_vcos(
         BMesh *bm, const float (*vcos)[3], const float (*vnos)[3], const float (*fnos)[3],
         const bool use_split_normals, const float split_angle, float (*r_lnos)[3],
-        MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2], const int cd_loop_clnors_offset)
+        MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2],
+        const int cd_loop_clnors_offset)
 {
 	const bool has_clnors = clnors_data || (cd_loop_clnors_offset != -1);
 
@@ -1019,7 +1023,8 @@ void BM_loops_calc_normal_vcos(
 		bm_mesh_edges_sharp_tag(bm, vnos, fnos, r_lnos, has_clnors ? (float)M_PI : split_angle, false);
 
 		/* Finish computing lnos by accumulating face normals in each fan of faces defined by sharp edges. */
-		bm_mesh_loops_calc_normals(bm, vcos, fnos, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
+		bm_mesh_loops_calc_normals(
+		        bm, vcos, fnos, r_lnos, r_lnors_spacearr, clnors_data, cd_loop_clnors_offset);
 	}
 	else {
 		BLI_assert(!r_lnors_spacearr);
diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h
index 9d7866c280a..cc056e1fa19 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.h
+++ b/source/blender/bmesh/intern/bmesh_mesh.h
@@ -48,9 +48,10 @@ void   BM_mesh_clear(BMesh *bm);
 void BM_mesh_normals_update(BMesh *bm);
 void BM_verts_calc_normal_vcos(BMesh *bm, const float (*fnos)[3], const float (*vcos)[3], float (*vnos)[3]);
 void BM_loops_calc_normal_vcos(
-        BMesh *bm, const float (*vcos)[3], const float (*vnos)[3], const float (*pnos)[3],
-        const bool use_split_normals, const float split_angle, float (*r_lnos)[3],
-        struct MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2], const int cd_loop_clnors_offset);
+        BMesh *bm, const float(*vcos)[3], const float(*vnos)[3], const float(*pnos)[3],
+        const bool use_split_normals, const float split_angle, float(*r_lnos)[3],
+        struct MLoopNorSpaceArray *r_lnors_spacearr, short (*clnors_data)[2],
+        const int cd_loop_clnors_offset);
 
 bool BM_loop_check_cyclic_smooth_fan(BMLoop *l_curr);
 
diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c
index 340b0b70772..2259a7dfe09 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@ -592,7 +592,7 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
 
 /**
  *
- * \param bmain May be NULL in case \a calc_object_remap parameter option is set.
+ * \param bmain May be NULL in case \a calc_object_remap parameter option is not set.
  */
 void BM_mesh_bm_to_me(
         Main *bmain, BMesh *bm, Mesh *me,
diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 3137725d6e7..5e3f5958a32 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -239,6 +239,28 @@ float BM_face_calc_area(const BMFace *f)
 	return len_v3(n) * 0.5f;
 }
 
+/**
+ * Get the area of the face in world space.
+ */
+float BM_face_calc_area_with_mat3(const BMFace *f, float mat3[3][3])
+{
+	/* inline 'area_poly_v3' logic, avoid creating a temp array */
+	const BMLoop *l_iter, *l_first;
+	float co[3];
+	float n[3];
+
+	zero_v3(n);
+	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+	mul_v3_m3v3(co, mat3, l_iter->v->co);
+	do {
+		float co_next[3];
+		mul_v3_m3v3(co_next, mat3, l_iter->next->v->co);
+		add_newell_cross_v3_v3v3(n, co, co_next);
+		copy_v3_v3(co, co_next);
+	} while ((l_iter = l_iter->next) != l_first);
+	return len_v3(n) * 0.5f;
+}
+
 /**
  * compute the perimeter of an ngon
  */
@@ -255,6 +277,27 @@ float BM_face_calc_perimeter(const BMFace *f)
 	return perimeter;
 }
 
+/**
+ * Calculate the perimeter of a ngon in world space.
+ */
+float BM_face_calc_perimeter_with_mat3(const BMFace *f, float mat3[3][3])
+{
+	const BMLoop *l_iter, *l_first;
+	float co[3];
+	float perimeter = 0.0f;
+
+	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+	mul_v3_m3v3(co, mat3, l_iter->v->co);
+	do {
+		float co_next[3];
+		mul_v3_m3v3(co_next, mat3, l_iter->next->v->co);
+		perimeter += len_v3v3(co, co_next);
+		copy_v3_v3(co, co_next);
+	} while ((l_iter = l_iter->next) != l_first);
+
+	return perimeter;
+}
+
 /**
  * Utility function to calculate the edge which is most different from the other two.
  *
@@ -487,7 +530,7 @@ void  BM_face_calc_tangent_vert_diagonal(const BMFace *f, float r_tangent[3])
 }
 
 /**
- * Compute a meaningful direction along the face (use for manipulator axis).
+ * Compute a meaningful direction along the face (use for gizmo axis).
  *
  * \note Callers shouldn't depend on the *exact* method used here.
  */
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h
index a40da2bfbfa..1d5fb2cc620 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -44,7 +44,9 @@ float BM_face_calc_normal_vcos(
         float const (*vertexCos)[3]) ATTR_NONNULL();
 float BM_face_calc_normal_subset(const BMLoop *l_first, const BMLoop *l_last, float r_no[3]) ATTR_NONNULL();
 float BM_face_calc_area(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float BM_face_calc_area_with_mat3(const BMFace *f, float mat3[3][3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 float BM_face_calc_perimeter(const BMFace *f) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float BM_face_calc_perimeter_with_mat3(const BMFace *f, float mat3[3][3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 void  BM_face_calc_tangent_edge(const BMFace *f, float r_plane[3]) ATTR_NONNULL();
 void  BM_face_calc_tangent_edge_pair(const BMFace *f, float r_plane[3]) ATTR_NONNULL();
 void  BM_face_calc_tangent_edge_diagonal(const BMFace *f, float r_plane[3]) ATTR_NONNULL();
diff --git a/source/blender/bmesh/intern/bmesh_query.c b/source/blender/bmesh/intern/bmesh_query.c
index 540888ac0b9..6e69ba48baf 100644
--- a/source/blender/bmesh/intern/bmesh_query.c
+++ b/source/blender/bmesh/intern/bmesh_query.c
@@ -1677,6 +1677,40 @@ float BM_edge_calc_face_angle(const BMEdge *e)
 	return BM_edge_calc_face_angle_ex(e, DEG2RADF(90.0f));
 }
 
+/**
+* \brief BMESH EDGE/FACE ANGLE
+*
+* Calculates the angle between two faces in world space.
+* Assumes the face normals are correct.
+*
+* \return angle in radians
+*/
+float BM_edge_calc_face_angle_with_imat3_ex(const BMEdge *e, float imat3[3][3], const float fallback)
+{
+	if (BM_edge_is_manifold(e)) {
+		const BMLoop *l1 = e->l;
+		const BMLoop *l2 = e->l->radial_next;
+		float no1[3], no2[3];
+		copy_v3_v3(no1, l1->f->no);
+		copy_v3_v3(no2, l2->f->no);
+
+		mul_transposed_m3_v3(imat3, no1);
+		mul_transposed_m3_v3(imat3, no2);
+
+		normalize_v3(no1);
+		normalize_v3(no2);
+
+		return angle_normalized_v3v3(no1, no2);
+	}
+	else {
+		return fallback;
+	}
+}
+float BM_edge_calc_face_angle_with_imat3(const BMEdge *e, float imat3[3][3])
+{
+	return BM_edge_calc_face_angle_with_imat3_ex(e, imat3, DEG2RADF(90.0f));
+}
+
 /**
  * \brief BMESH EDGE/FACE ANGLE
  *
diff --git a/source/blender/bmesh/intern/bmesh_query.h b/source/blender/bmesh/intern/bmesh_query.h
index 51956761d8f..fb625c9acc8 100644
--- a/source/blender/bmesh/intern/bmesh_query.h
+++ b/source/blender/bmesh/intern/bmesh_query.h
@@ -123,6 +123,8 @@ void    BM_loop_calc_face_tangent(const BMLoop *l, float r_tangent[3]);
 float   BM_edge_calc_face_angle_ex(const BMEdge *e, const float fallback) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 float   BM_edge_calc_face_angle(const BMEd

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list