Cleanup: rename 'count' to 'len'
Reserve the term count for values that require calculation (typically linked lists).
This commit is contained in:
parent
432bfbf7a3
commit
3382b07ad6
|
@ -221,21 +221,21 @@ void *BMO_iter_as_arrayN(BMOpSlot slot_args[BMO_OP_MAX_SLOTS],
|
|||
{
|
||||
BMOIter iter;
|
||||
BMElem *ele;
|
||||
int count = BMO_slot_buffer_count(slot_args, slot_name);
|
||||
const int slot_len = BMO_slot_buffer_len(slot_args, slot_name);
|
||||
|
||||
BLI_assert(stack_array_size == 0 || (stack_array_size && stack_array));
|
||||
|
||||
if ((ele = BMO_iter_new(&iter, slot_args, slot_name, restrictmask)) && count > 0) {
|
||||
BMElem **array = count > stack_array_size ? MEM_mallocN(sizeof(ele) * count, __func__) :
|
||||
stack_array;
|
||||
if ((ele = BMO_iter_new(&iter, slot_args, slot_name, restrictmask)) && slot_len > 0) {
|
||||
BMElem **array = slot_len > stack_array_size ? MEM_mallocN(sizeof(ele) * slot_len, __func__) :
|
||||
stack_array;
|
||||
int i = 0;
|
||||
|
||||
do {
|
||||
array[i++] = ele;
|
||||
} while ((ele = BMO_iter_step(&iter)));
|
||||
BLI_assert(i <= count);
|
||||
BLI_assert(i <= slot_len);
|
||||
|
||||
if (i != count) {
|
||||
if (i != slot_len) {
|
||||
if ((void **)array != stack_array) {
|
||||
array = MEM_reallocN(array, sizeof(ele) * i);
|
||||
}
|
||||
|
|
|
@ -565,8 +565,8 @@ void BMO_slot_buffer_from_single(BMOperator *op, BMOpSlot *slot, BMHeader *ele);
|
|||
void *BMO_slot_buffer_get_single(BMOpSlot *slot);
|
||||
|
||||
/* counts number of elements inside a slot array. */
|
||||
int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
|
||||
int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
|
||||
int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
|
||||
int BMO_slot_map_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name);
|
||||
|
||||
void BMO_slot_map_insert(BMOperator *op, BMOpSlot *slot, const void *element, const void *data);
|
||||
|
||||
|
|
|
@ -678,7 +678,7 @@ void BMO_mesh_selected_remap(BMesh *bm,
|
|||
}
|
||||
}
|
||||
|
||||
int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
|
||||
int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
|
||||
{
|
||||
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
|
||||
BLI_assert(slot->slot_type == BMO_OP_SLOT_ELEMENT_BUF);
|
||||
|
@ -691,7 +691,7 @@ int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot
|
|||
return slot->len;
|
||||
}
|
||||
|
||||
int BMO_slot_map_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
|
||||
int BMO_slot_map_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
|
||||
{
|
||||
BMOpSlot *slot = BMO_slot_get(slot_args, slot_name);
|
||||
BLI_assert(slot->slot_type == BMO_OP_SLOT_MAPPING);
|
||||
|
|
|
@ -59,7 +59,7 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
|
|||
|
||||
/* will over alloc if some edges can't be rotated */
|
||||
edge_array = MEM_mallocN(
|
||||
sizeof(*edge_array) * (size_t)BMO_slot_buffer_count(op->slots_in, "edges"), __func__);
|
||||
sizeof(*edge_array) * (size_t)BMO_slot_buffer_len(op->slots_in, "edges"), __func__);
|
||||
|
||||
BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ void bmo_bisect_plane_exec(BMesh *bm, BMOperator *op)
|
|||
/* Use an array of vertices because 'geom' contains both verts and edges that may use them.
|
||||
* Removing a vert may remove and edge which is later checked by #BMO_ITER.
|
||||
* over-allocate the total possible vert count. */
|
||||
const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_count(op->slots_in, "geom"));
|
||||
const int vert_arr_max = min_ii(bm->totvert, BMO_slot_buffer_len(op->slots_in, "geom"));
|
||||
BMVert **vert_arr = MEM_mallocN(sizeof(*vert_arr) * (size_t)vert_arr_max, __func__);
|
||||
BMOIter siter;
|
||||
BMVert *v;
|
||||
|
|
|
@ -172,7 +172,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_op_exec(bm, &op_sub);
|
||||
|
||||
/* return if edge net create did something */
|
||||
if (BMO_slot_buffer_count(op_sub.slots_out, "faces.out")) {
|
||||
if (BMO_slot_buffer_len(op_sub.slots_out, "faces.out")) {
|
||||
BMO_slot_copy(&op_sub, slots_out, "faces.out", op, slots_out, "faces.out");
|
||||
BMO_op_finish(bm, &op_sub);
|
||||
return;
|
||||
|
@ -191,7 +191,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_op_exec(bm, &op_sub);
|
||||
|
||||
/* if we dissolved anything, then return */
|
||||
if (BMO_slot_buffer_count(op_sub.slots_out, "region.out")) {
|
||||
if (BMO_slot_buffer_len(op_sub.slots_out, "region.out")) {
|
||||
BMO_slot_copy(&op_sub, slots_out, "region.out", op, slots_out, "faces.out");
|
||||
BMO_op_finish(bm, &op_sub);
|
||||
return;
|
||||
|
@ -211,7 +211,7 @@ void bmo_contextual_create_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_op_exec(bm, &op_sub);
|
||||
|
||||
/* return if edge loop fill did something */
|
||||
if (BMO_slot_buffer_count(op_sub.slots_out, "faces.out")) {
|
||||
if (BMO_slot_buffer_len(op_sub.slots_out, "faces.out")) {
|
||||
BMO_slot_copy(&op_sub, slots_out, "faces.out", op, slots_out, "faces.out");
|
||||
BMO_op_finish(bm, &op_sub);
|
||||
return;
|
||||
|
|
|
@ -79,7 +79,7 @@ void bmo_edgenet_fill_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_op_exec(bm, &op_attr);
|
||||
|
||||
/* check if some faces couldn't be touched */
|
||||
if (BMO_slot_buffer_count(op_attr.slots_out, "faces_fail.out")) {
|
||||
if (BMO_slot_buffer_len(op_attr.slots_out, "faces_fail.out")) {
|
||||
BMO_op_callf(bm, op->flag, "recalc_face_normals faces=%S", &op_attr, "faces_fail.out");
|
||||
}
|
||||
BMO_op_finish(bm, &op_attr);
|
||||
|
|
|
@ -459,7 +459,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
|
|||
}
|
||||
|
||||
/* Allocate array to store possible vertices that will be dissolved. */
|
||||
int boundary_edges_len = BMO_slot_map_count(dupeop.slots_out, "boundary_map.out");
|
||||
int boundary_edges_len = BMO_slot_map_len(dupeop.slots_out, "boundary_map.out");
|
||||
/* We do not know the real number of boundary vertices. */
|
||||
int boundary_verts_len_maybe = 2 * boundary_edges_len;
|
||||
dissolve_verts = MEM_mallocN(boundary_verts_len_maybe * sizeof(*dissolve_verts), __func__);
|
||||
|
|
|
@ -161,7 +161,7 @@ void bmo_face_attribute_fill_exec(BMesh *bm, BMOperator *op)
|
|||
/* now we can copy adjacent data */
|
||||
face_tot = bmesh_face_attribute_fill(bm, use_normals, use_data);
|
||||
|
||||
if (face_tot != BMO_slot_buffer_count(op->slots_in, "faces")) {
|
||||
if (face_tot != BMO_slot_buffer_len(op->slots_in, "faces")) {
|
||||
/* any remaining tags will be skipped */
|
||||
BMO_slot_buffer_from_enabled_hflag(
|
||||
bm, op, op->slots_out, "faces_fail.out", BM_FACE, BM_ELEM_TAG);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
void bmo_edgeloop_fill_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
/* first collect an array of unique from the edges */
|
||||
const int tote = BMO_slot_buffer_count(op->slots_in, "edges");
|
||||
const int tote = BMO_slot_buffer_len(op->slots_in, "edges");
|
||||
const int totv = tote; /* these should be the same */
|
||||
BMVert **verts = MEM_mallocN(sizeof(*verts) * totv, __func__);
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void bmo_holes_fill_exec(BMesh *bm, BMOperator *op)
|
|||
BMO_op_exec(bm, &op_attr);
|
||||
|
||||
/* check if some faces couldn't be touched */
|
||||
if (BMO_slot_buffer_count(op_attr.slots_out, "faces_fail.out")) {
|
||||
if (BMO_slot_buffer_len(op_attr.slots_out, "faces_fail.out")) {
|
||||
BMOIter siter;
|
||||
BMFace *f;
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ static BMFace *bm_face_split_walk_back(BMesh *bm, BMLoop *l_src, BMLoop **r_l)
|
|||
|
||||
void bmo_offset_edgeloops_exec(BMesh *bm, BMOperator *op)
|
||||
{
|
||||
const int edges_num = BMO_slot_buffer_count(op->slots_in, "edges");
|
||||
const int edges_num = BMO_slot_buffer_len(op->slots_in, "edges");
|
||||
BMVert **verts;
|
||||
STACK_DECLARE(verts);
|
||||
int i;
|
||||
|
|
|
@ -41,7 +41,7 @@ void bmo_planar_faces_exec(BMesh *bm, BMOperator *op)
|
|||
{
|
||||
const float fac = BMO_slot_float_get(op->slots_in, "factor");
|
||||
const int iterations = BMO_slot_int_get(op->slots_in, "iterations");
|
||||
const int faces_num = BMO_slot_buffer_count(op->slots_in, "faces");
|
||||
const int faces_num = BMO_slot_buffer_len(op->slots_in, "faces");
|
||||
|
||||
const float eps = 0.00001f;
|
||||
const float eps_sq = square_f(eps);
|
||||
|
|
|
@ -234,7 +234,7 @@ void bmo_rotate_edges_exec(BMesh *bm, BMOperator *op)
|
|||
{
|
||||
BMOIter siter;
|
||||
BMEdge *e;
|
||||
const int edges_len = BMO_slot_buffer_count(op->slots_in, "edges");
|
||||
const int edges_len = BMO_slot_buffer_len(op->slots_in, "edges");
|
||||
const bool use_ccw = BMO_slot_bool_get(op->slots_in, "use_ccw");
|
||||
const bool is_single = (edges_len == 1);
|
||||
short check_flag = is_single ? BM_EDGEROT_CHECK_EXISTS :
|
||||
|
|
|
@ -74,7 +74,7 @@ void bmo_triangle_fill_exec(BMesh *bm, BMOperator *op)
|
|||
uint nors_tot;
|
||||
bool calc_winding = false;
|
||||
|
||||
sf_vert_map = BLI_ghash_ptr_new_ex(__func__, BMO_slot_buffer_count(op->slots_in, "edges"));
|
||||
sf_vert_map = BLI_ghash_ptr_new_ex(__func__, BMO_slot_buffer_len(op->slots_in, "edges"));
|
||||
|
||||
BMO_slot_vec_get(op->slots_in, "normal", normal);
|
||||
|
||||
|
|
|
@ -393,7 +393,7 @@ void bmo_smooth_vert_exec(BMesh *UNUSED(bm), BMOperator *op)
|
|||
BMIter iter;
|
||||
BMVert *v;
|
||||
BMEdge *e;
|
||||
float(*cos)[3] = MEM_mallocN(sizeof(*cos) * BMO_slot_buffer_count(op->slots_in, "verts"),
|
||||
float(*cos)[3] = MEM_mallocN(sizeof(*cos) * BMO_slot_buffer_len(op->slots_in, "verts"),
|
||||
__func__);
|
||||
float *co, *co2, clip_dist = BMO_slot_float_get(op->slots_in, "clip_dist");
|
||||
const float fac = BMO_slot_float_get(op->slots_in, "factor");
|
||||
|
|
|
@ -973,7 +973,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
|
|||
#ifdef USE_FACE_CREATE_SEL_EXTEND
|
||||
/* normally we would want to leave the new geometry selected,
|
||||
* but being able to press F many times to add geometry is too useful! */
|
||||
if (ele_desel && (BMO_slot_buffer_count(bmop.slots_out, "faces.out") == 1) &&
|
||||
if (ele_desel && (BMO_slot_buffer_len(bmop.slots_out, "faces.out") == 1) &&
|
||||
(ele_desel_face = BMO_slot_buffer_get_first(bmop.slots_out, "faces.out"))) {
|
||||
edbm_add_edge_face_exec__tricky_finalize_sel(em->bm, ele_desel, ele_desel_face);
|
||||
}
|
||||
|
@ -2344,7 +2344,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
|
|||
BMO_slot_buffer_hflag_enable(
|
||||
em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true);
|
||||
|
||||
const int tot_rotate = BMO_slot_buffer_count(bmop.slots_out, "edges.out");
|
||||
const int tot_rotate = BMO_slot_buffer_len(bmop.slots_out, "edges.out");
|
||||
const int tot_failed = tot - tot_rotate;
|
||||
|
||||
tot_rotate_all += tot_rotate;
|
||||
|
|
Loading…
Reference in New Issue