Fix T57366: Mesh.from_pydata invalid loose-edge state
This commit is contained in:
parent
134db5618a
commit
901ccfab52
Notes:
blender-bot
2023-02-14 19:25:31 +01:00
Referenced by issue blender/blender-addons#57366, Python mesh.from_pydata() without faces won't show mesh until in/out edit mode
|
@ -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):
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue