RNA: Add Mesh.count_selected_items()
Needed for context menu checks.
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
||||
@@ -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])
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user