Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-10 11:54:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-10 11:56:02 +0300
commit3756f920f4894c9ec748c0ece5f63e1bc9c616df (patch)
tree9c75009e8998407a72b51e03328aa59f6c30a81a
parent7efac2b0b09d9e76d9fc573ec7936a1c6440c067 (diff)
BMesh: backport minor changes from 2.8
-rw-r--r--source/blender/bmesh/bmesh.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_marking.c4
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c11
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.h7
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh_conv.c2
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.c45
-rw-r--r--source/blender/bmesh/intern/bmesh_polygon.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_query.c34
-rw-r--r--source/blender/bmesh/intern/bmesh_query.h2
-rw-r--r--source/blender/bmesh/operators/bmo_bevel.c4
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c1
-rw-r--r--source/blender/bmesh/tools/bmesh_wireframe.c1
12 files changed, 101 insertions, 14 deletions
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
@@ -240,6 +240,28 @@ float BM_face_calc_area(const BMFace *f)
}
/**
+ * 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
*/
float BM_face_calc_perimeter(const BMFace *f)
@@ -256,6 +278,27 @@ float BM_face_calc_perimeter(const BMFace *f)
}
/**
+ * 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.
*
* \return The first edge index, where the second vertex is ``(index + 1) % 3``.
@@ -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
@@ -1678,6 +1678,40 @@ float BM_edge_calc_face_angle(const BMEdge *e)
}
/**
+* \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
*
* Calculates the angle between two faces.
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 BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
float BM_edge_calc_face_angle_signed_ex(const BMEdge *e, const float fallback) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float BM_edge_calc_face_angle_with_imat3_ex(const BMEdge *e, float imat3[3][3], const float fallback) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
+float BM_edge_calc_face_angle_with_imat3(const BMEdge *e, float imat3[3][3]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
float BM_edge_calc_face_angle_signed(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void BM_edge_calc_face_tangent(const BMEdge *e, const BMLoop *e_loop, float r_tangent[3]) ATTR_NONNULL();
diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c
index 2ae87b64286..9247c64d3fb 100644
--- a/source/blender/bmesh/operators/bmo_bevel.c
+++ b/source/blender/bmesh/operators/bmo_bevel.c
@@ -63,7 +63,9 @@ 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);
+ BM_mesh_bevel(
+ bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material,
+ loop_slide);
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 754db541548..e55e11e0bdb 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -32,7 +32,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_array.h"
diff --git a/source/blender/bmesh/tools/bmesh_wireframe.c b/source/blender/bmesh/tools/bmesh_wireframe.c
index c45e617dd39..57e0e0b44ca 100644
--- a/source/blender/bmesh/tools/bmesh_wireframe.c
+++ b/source/blender/bmesh/tools/bmesh_wireframe.c
@@ -28,7 +28,6 @@
#include "MEM_guardedalloc.h"
-#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_math.h"