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:
authorAndrew Hale <TrumanBlending@gmail.com>2012-01-20 06:10:09 +0400
committerAndrew Hale <TrumanBlending@gmail.com>2012-01-20 06:10:09 +0400
commit62ac943e3108ad5f70cd5349cd5f1cef98138313 (patch)
tree7f2b0631fd0caa67ece4b37aac78c1536c996df6 /source/blender/editors/mesh
parent181a4b74c17e1f007b5a9b5aa7a01eb051c1e48c (diff)
- Added functions to remove mesh vertices, edges and faces. These functions remove a specified number of elements from the end of their respective arrays. For example, removing two vertices removes the last two vertices of the mesh.
- Minor fixes to descriptions of add edge and add face functions.
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/mesh_data.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index e40c806fd17..7f599fb3458 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -695,6 +695,49 @@ static void mesh_add_faces(Mesh *mesh, int len)
mesh->totface= totface;
}
+static void mesh_remove_verts(Mesh *mesh, int len)
+{
+ CustomData vdata;
+ int totvert;
+
+ if(len == 0)
+ return;
+
+ totvert= mesh->totvert - len;
+ CustomData_free_elem(&mesh->vdata, totvert, len);
+
+ /* set final vertex list size */
+ mesh->totvert= totvert;
+}
+
+static void mesh_remove_edges(Mesh *mesh, int len)
+{
+ CustomData edata;
+ int totedge;
+
+ if(len == 0)
+ return;
+
+ totedge= mesh->totedge - len;
+ CustomData_free_elem(&mesh->edata, totedge, len);
+
+ mesh->totedge= totedge;
+}
+
+static void mesh_remove_faces(Mesh *mesh, int len)
+{
+ CustomData fdata;
+ int totface;
+
+ if(len == 0)
+ return;
+
+ totface= mesh->totface - len; /* new face count */
+ CustomData_free_elem(&mesh->fdata, totface, len);
+
+ mesh->totface= totface;
+}
+
/*
void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces)
{
@@ -742,6 +785,48 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count)
mesh_add_verts(mesh, count);
}
+void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode");
+ return;
+ }
+ else if(count > mesh->totface) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains");
+ return;
+ }
+
+ mesh_remove_faces(mesh, count);
+}
+
+void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode");
+ return;
+ }
+ else if(count > mesh->totedge) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains");
+ return;
+ }
+
+ mesh_remove_edges(mesh, count);
+}
+
+void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count)
+{
+ if(mesh->edit_mesh) {
+ BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode");
+ return;
+ }
+ else if(count > mesh->totvert) {
+ BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains");
+ return;
+ }
+
+ mesh_remove_verts(mesh, count);
+}
+
void ED_mesh_calc_normals(Mesh *me)
{
mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);