Commit: 901ccfab52ada8e46a61c1dce56fa43c291fb935
Author: Campbell Barton
Date:   Wed Oct 24 11:37:44 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB901ccfab52ada8e46a61c1dce56fa43c291fb935

Fix T57366: Mesh.from_pydata invalid loose-edge state

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

M       release/scripts/modules/bpy_types.py
M       source/blender/blenkernel/BKE_mesh.h
M       source/blender/blenkernel/intern/mesh_validate.c
M       source/blender/editors/include/ED_mesh.h
M       source/blender/editors/mesh/mesh_data.c
M       source/blender/makesrna/intern/rna_mesh_api.c

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

diff --git a/release/scripts/modules/bpy_types.py 
b/release/scripts/modules/bpy_types.py
index 9fe45d223f5..84262e618d8 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -454,6 +454,8 @@ class Mesh(bpy_types.ID):
         # if no edges - calculate them
         if faces and (not edges):
             self.update(calc_edges=True)
+        elif edges:
+            self.update(calc_edges_loose=True)
 
     @property
     def edge_keys(self):
diff --git a/source/blender/blenkernel/BKE_mesh.h 
b/source/blender/blenkernel/BKE_mesh.h
index 9cc2bd8c152..56241a19221 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -497,6 +497,7 @@ void BKE_mesh_strip_loose_polysloops(struct Mesh *me);
 void BKE_mesh_strip_loose_edges(struct Mesh *me);
 
 void BKE_mesh_calc_edges_legacy(struct Mesh *me, const bool use_old);
+void BKE_mesh_calc_edges_loose(struct Mesh *mesh);
 void BKE_mesh_calc_edges(struct Mesh *mesh, bool update, const bool select);
 void BKE_mesh_calc_edges_tessface(struct Mesh *mesh);
 
diff --git a/source/blender/blenkernel/intern/mesh_validate.c 
b/source/blender/blenkernel/intern/mesh_validate.c
index dd9d6fa448a..af4d1265cfd 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -1445,6 +1445,18 @@ void BKE_mesh_calc_edges(Mesh *mesh, bool update, const 
bool select)
        BLI_edgehash_free(eh, NULL);
 }
 
+void BKE_mesh_calc_edges_loose(Mesh *mesh)
+{
+       MEdge *med = mesh->medge;
+       for (int i = 0; i < mesh->totedge; i++, med++) {
+               med->flag |= ME_LOOSEEDGE;
+       }
+       MLoop *ml = mesh->mloop;
+       for (int i = 0; i < mesh->totloop; i++, ml++) {
+               mesh->medge[ml->e].flag &= ~ME_LOOSEEDGE;
+       }
+}
+
 /**
  * Calculate/create edges from tessface data
  *
diff --git a/source/blender/editors/include/ED_mesh.h 
b/source/blender/editors/include/ED_mesh.h
index da6fd1a6b53..a6db1870106 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -319,7 +319,7 @@ void ED_mesh_edges_remove(struct Mesh *mesh, struct 
ReportList *reports, int cou
 void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, 
int count);
 
 void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly);
-void ED_mesh_update(struct Mesh *mesh, struct bContext *C, bool calc_edges, 
bool calc_tessface);
+void ED_mesh_update(struct Mesh *mesh, struct bContext *C, bool calc_edges, 
bool calc_edges_loose, bool calc_tessface);
 
 void ED_mesh_uv_texture_ensure(struct Mesh *me, const char *name);
 int  ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool 
active_set);
diff --git a/source/blender/editors/mesh/mesh_data.c 
b/source/blender/editors/mesh/mesh_data.c
index 438cbb8da91..2a918560ba8 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -877,7 +877,7 @@ void 
MESH_OT_customdata_custom_splitnormals_clear(wmOperatorType *ot)
 
 /************************** Add Geometry Layers *************************/
 
-void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool 
calc_tessface)
+void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool 
calc_edges_loose, bool calc_tessface)
 {
        bool tessface_input = false;
 
@@ -888,6 +888,10 @@ void ED_mesh_update(Mesh *mesh, bContext *C, bool 
calc_edges, bool calc_tessface
                tessface_input = true;
        }
 
+       if (calc_edges_loose && mesh->totedge) {
+               BKE_mesh_calc_edges_loose(mesh);
+       }
+
        if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 
0))
                BKE_mesh_calc_edges(mesh, calc_edges, true);
 
diff --git a/source/blender/makesrna/intern/rna_mesh_api.c 
b/source/blender/makesrna/intern/rna_mesh_api.c
index b1556edd4b7..a08555794d8 100644
--- a/source/blender/makesrna/intern/rna_mesh_api.c
+++ b/source/blender/makesrna/intern/rna_mesh_api.c
@@ -306,6 +306,7 @@ void RNA_api_mesh(StructRNA *srna)
 
        func = RNA_def_function(srna, "update", "ED_mesh_update");
        RNA_def_boolean(func, "calc_edges", 0, "Calculate Edges", "Force 
recalculation of edges");
+       RNA_def_boolean(func, "calc_edges_loose", 0, "Calculate Loose Edges", 
"Calculate the loose state of each edge");
        RNA_def_boolean(func, "calc_loop_triangles", 0, "Calculate Triangules", 
"Force recalculation of triangle tessellation");
        RNA_def_function_flag(func, FUNC_USE_CONTEXT);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to