Revision: 43551
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43551
Author:   trumanblending
Date:     2012-01-20 02:10:09 +0000 (Fri, 20 Jan 2012)
Log Message:
-----------
- 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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/ED_mesh.h
    trunk/blender/source/blender/editors/mesh/mesh_data.c
    trunk/blender/source/blender/makesrna/intern/rna_mesh.c

Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_mesh.h      2012-01-20 
02:03:37 UTC (rev 43550)
+++ trunk/blender/source/blender/editors/include/ED_mesh.h      2012-01-20 
02:10:09 UTC (rev 43551)
@@ -235,6 +235,10 @@
 void ED_mesh_edges_add(struct Mesh *mesh, struct ReportList *reports, int 
count);
 void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int 
count);
 
+void ED_mesh_faces_remove(struct Mesh *mesh, struct ReportList *reports, int 
count);
+void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int 
count);
+void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, 
int count);
+
 void ED_mesh_transform(struct Mesh *me, float *mat);
 void ED_mesh_calc_normals(struct Mesh *me);
 void ED_mesh_material_link(struct Mesh *me, struct Material *ma);

Modified: trunk/blender/source/blender/editors/mesh/mesh_data.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/mesh_data.c       2012-01-20 
02:03:37 UTC (rev 43550)
+++ trunk/blender/source/blender/editors/mesh/mesh_data.c       2012-01-20 
02:10:09 UTC (rev 43551)
@@ -695,6 +695,49 @@
        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 @@
        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);

Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c     2012-01-20 
02:03:37 UTC (rev 43550)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c     2012-01-20 
02:10:09 UTC (rev 43551)
@@ -1699,6 +1699,10 @@
        func= RNA_def_function(srna, "add", "ED_mesh_vertices_add");
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
        RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices 
to add", 0, INT_MAX);
+
+       func= RNA_def_function(srna, "remove", "ED_mesh_vertices_remove");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices 
to remove", 0, INT_MAX);
 }
 
 /* mesh.edges */
@@ -1717,7 +1721,11 @@
 
        func= RNA_def_function(srna, "add", "ED_mesh_edges_add");
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
-       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices 
to add", 0, INT_MAX);
+       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to 
add", 0, INT_MAX);
+
+       func= RNA_def_function(srna, "remove", "ED_mesh_edges_remove");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of edges to 
remove", 0, INT_MAX);
 }
 
 /* mesh.faces */
@@ -1746,7 +1754,11 @@
 
        func= RNA_def_function(srna, "add", "ED_mesh_faces_add");
        RNA_def_function_flag(func, FUNC_USE_REPORTS);
-       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices 
to add", 0, INT_MAX);
+       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to 
add", 0, INT_MAX);
+
+       func= RNA_def_function(srna, "remove", "ED_mesh_faces_remove");
+       RNA_def_function_flag(func, FUNC_USE_REPORTS);
+       RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of faces to 
remove", 0, INT_MAX);
 }
 
 /* mesh.vertex_colors */

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

Reply via email to