diff options
Diffstat (limited to 'source/blender/editors/mesh/mesh_data.c')
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 133 |
1 files changed, 84 insertions, 49 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index a0d424e083c..7007ff29401 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -1023,73 +1023,104 @@ static void mesh_add_polys(Mesh *mesh, int len) mesh->totpoly = totpoly; } -static void mesh_remove_verts(Mesh *mesh, int len) +/* -------------------------------------------------------------------- */ +/** \name Add Geometry + * \{ */ + +void ED_mesh_verts_add(Mesh *mesh, ReportList *reports, int count) { - int totvert; + if (mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode"); + return; + } + mesh_add_verts(mesh, count); +} - if (len == 0) { +void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) +{ + if (mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode"); return; } + mesh_add_edges(mesh, count); +} - totvert = mesh->totvert - len; - CustomData_free_elem(&mesh->vdata, totvert, len); +void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count) +{ + if (mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode"); + return; + } + mesh_add_loops(mesh, count); +} - /* set final vertex list size */ +void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) +{ + if (mesh->edit_mesh) { + BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode"); + return; + } + mesh_add_polys(mesh, count); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Remove Geometry + * \{ */ + +static void mesh_remove_verts(Mesh *mesh, int len) +{ + if (len == 0) { + return; + } + const int totvert = mesh->totvert - len; + CustomData_free_elem(&mesh->vdata, totvert, len); mesh->totvert = totvert; } static void mesh_remove_edges(Mesh *mesh, int len) { - int totedge; - if (len == 0) { return; } - - totedge = mesh->totedge - len; + const int totedge = mesh->totedge - len; CustomData_free_elem(&mesh->edata, totedge, len); - mesh->totedge = totedge; } -#if 0 -void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces) +static void mesh_remove_loops(Mesh *mesh, int len) { - if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot add geometry in edit mode"); + if (len == 0) { return; } - - if (verts) { - mesh_add_verts(mesh, verts); - } - if (edges) { - mesh_add_edges(mesh, edges); - } - if (faces) { - mesh_add_faces(mesh, faces); - } + const int totloop = mesh->totloop - len; + CustomData_free_elem(&mesh->ldata, totloop, len); + mesh->totloop = totloop; } -#endif -void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) +static void mesh_remove_polys(Mesh *mesh, int len) { - if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot add edges in edit mode"); + if (len == 0) { return; } - - mesh_add_edges(mesh, count); + const int totpoly = mesh->totpoly - len; + CustomData_free_elem(&mesh->pdata, totpoly, len); + mesh->totpoly = totpoly; } -void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count) +void ED_mesh_verts_remove(Mesh *mesh, ReportList *reports, int count) { if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot add vertices in edit mode"); + BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode"); + return; + } + else if (count > mesh->totvert) { + BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains"); return; } - mesh_add_verts(mesh, count); + mesh_remove_verts(mesh, count); } void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count) @@ -1106,40 +1137,44 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count) mesh_remove_edges(mesh, count); } -void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count) +void ED_mesh_loops_remove(Mesh *mesh, ReportList *reports, int count) { if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot remove vertices in edit mode"); + BKE_report(reports, RPT_ERROR, "Cannot remove loops in edit mode"); return; } - else if (count > mesh->totvert) { - BKE_report(reports, RPT_ERROR, "Cannot remove more vertices than the mesh contains"); + else if (count > mesh->totloop) { + BKE_report(reports, RPT_ERROR, "Cannot remove more loops than the mesh contains"); return; } - mesh_remove_verts(mesh, count); + mesh_remove_loops(mesh, count); } -void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count) +void ED_mesh_polys_remove(Mesh *mesh, ReportList *reports, int count) { if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot add loops in edit mode"); + BKE_report(reports, RPT_ERROR, "Cannot remove polys in edit mode"); + return; + } + else if (count > mesh->totpoly) { + BKE_report(reports, RPT_ERROR, "Cannot remove more polys than the mesh contains"); return; } - mesh_add_loops(mesh, count); + mesh_remove_polys(mesh, count); } -void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) +void ED_mesh_geometry_clear(Mesh *mesh) { - if (mesh->edit_mesh) { - BKE_report(reports, RPT_ERROR, "Cannot add polygons in edit mode"); - return; - } - - mesh_add_polys(mesh, count); + mesh_remove_verts(mesh, mesh->totvert); + mesh_remove_edges(mesh, mesh->totedge); + mesh_remove_loops(mesh, mesh->totloop); + mesh_remove_polys(mesh, mesh->totpoly); } +/** \} */ + void ED_mesh_report_mirror_ex(wmOperator *op, int totmirr, int totfail, char selectmode) { const char *elem_type; |