diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh_api.c | 10 |
3 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 45cc6c30e4e..53c23af73c0 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -212,6 +212,8 @@ int BKE_mesh_mselect_find(struct Mesh *me, int index, int type); int BKE_mesh_mselect_active_get(struct Mesh *me, int type); void BKE_mesh_mselect_active_set(struct Mesh *me, int index, int type); +void BKE_mesh_count_selected_items(const struct Mesh *mesh, int r_count[3]); + void BKE_mesh_apply_vert_coords(struct Mesh *mesh, float (*vertCoords)[3]); void BKE_mesh_apply_vert_normals(struct Mesh *mesh, short (*vertNormals)[3]); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index fcd0bfa9ceb..121aba43456 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1563,6 +1563,18 @@ void BKE_mesh_mselect_active_set(Mesh *me, int index, int type) (me->mselect[me->totselect - 1].type == type)); } +void BKE_mesh_count_selected_items(const Mesh *mesh, int r_count[3]) +{ + r_count[0] = r_count[1] = r_count[2] = 0; + if (mesh->edit_btmesh) { + BMesh *bm = mesh->edit_btmesh->bm; + r_count[0] = bm->totvertsel; + r_count[1] = bm->totedgesel; + r_count[2] = bm->totfacesel; + } + /* We could support faces in paint modes. */ + +} void BKE_mesh_apply_vert_coords(Mesh *mesh, float (*vertCoords)[3]) { diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index a08555794d8..5f198d2e22e 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -222,6 +222,11 @@ static void rna_Mesh_update_gpu_tag(Mesh *mesh) BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL); } +static void rna_Mesh_count_selected_items(Mesh *mesh, int r_count[3]) +{ + BKE_mesh_count_selected_items(mesh, r_count); +} + #else @@ -332,6 +337,11 @@ void RNA_api_mesh(StructRNA *srna) "invalid indices corrected (to default 0)"); parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "count_selected_items", "rna_Mesh_count_selected_items "); + RNA_def_function_ui_description(func, "Return the number of selected items (vert, edge, face)"); + parm = RNA_def_int_vector(func, "result", 3, NULL, 0, INT_MAX, "Result", NULL, 0, INT_MAX); + RNA_def_function_output(func, parm); } #endif |