Cleanup: rename list count_ex -> count_at_most
This commit is contained in:
parent
06a62d4e06
commit
bfdb88f3f4
@ -2739,7 +2739,7 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal)
|
||||
if (BKE_image_has_packedfile(ima)) {
|
||||
const int totfiles = image_num_files(ima);
|
||||
|
||||
if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) {
|
||||
if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) {
|
||||
/* in case there are new available files to be loaded */
|
||||
image_free_packedfiles(ima);
|
||||
BKE_image_packfiles(NULL, ima, ID_BLEND_PATH(G.main, &ima->id));
|
||||
@ -2894,7 +2894,7 @@ void BKE_image_multiview_index(Image *ima, ImageUser *iuser)
|
||||
iuser->multi_index = iuser->multiview_eye;
|
||||
}
|
||||
else {
|
||||
if ((iuser->view < 0) || (iuser->view >= BLI_listbase_count_ex(&ima->views, iuser->view + 1))) {
|
||||
if ((iuser->view < 0) || (iuser->view >= BLI_listbase_count_at_most(&ima->views, iuser->view + 1))) {
|
||||
iuser->multi_index = iuser->view = 0;
|
||||
}
|
||||
else {
|
||||
@ -3361,7 +3361,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame)
|
||||
const int totfiles = image_num_files(ima);
|
||||
int i;
|
||||
|
||||
if (totfiles != BLI_listbase_count_ex(&ima->anims, totfiles + 1)) {
|
||||
if (totfiles != BLI_listbase_count_at_most(&ima->anims, totfiles + 1)) {
|
||||
image_free_anims(ima);
|
||||
|
||||
for (i = 0; i < totfiles; i++) {
|
||||
@ -3517,7 +3517,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra)
|
||||
|
||||
/* this should never happen, but just playing safe */
|
||||
if (has_packed) {
|
||||
if (totfiles != BLI_listbase_count_ex(&ima->packedfiles, totfiles + 1)) {
|
||||
if (totfiles != BLI_listbase_count_at_most(&ima->packedfiles, totfiles + 1)) {
|
||||
image_free_packedfiles(ima);
|
||||
has_packed = false;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ void BKE_paint_curve_clamp_endpoint_add_index(PaintCurve *pc, const int add_inde
|
||||
/* remove colour from palette. Must be certain color is inside the palette! */
|
||||
void BKE_palette_color_remove(Palette *palette, PaletteColor *color)
|
||||
{
|
||||
if (BLI_listbase_count_ex(&palette->colors, palette->active_color) == palette->active_color) {
|
||||
if (BLI_listbase_count_at_most(&palette->colors, palette->active_color) == palette->active_color) {
|
||||
palette->active_color--;
|
||||
}
|
||||
|
||||
|
@ -3165,7 +3165,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
|
||||
|
||||
psys->part = BKE_particlesettings_add(NULL, DATA_("ParticleSettings"));
|
||||
|
||||
if (BLI_listbase_count_ex(&ob->particlesystem, 2) > 1)
|
||||
if (BLI_listbase_count_at_most(&ob->particlesystem, 2) > 1)
|
||||
BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_listbase_count(&ob->particlesystem));
|
||||
else
|
||||
BLI_strncpy(psys->name, DATA_("ParticleSystem"), sizeof(psys->name));
|
||||
|
@ -2955,7 +2955,7 @@ static ImBuf *seq_render_movie_strip(const SeqRenderData *context, Sequence *seq
|
||||
int totviews;
|
||||
int i;
|
||||
|
||||
if (totfiles != BLI_listbase_count_ex(&seq->anims, totfiles + 1))
|
||||
if (totfiles != BLI_listbase_count_at_most(&seq->anims, totfiles + 1))
|
||||
goto monoview_movie;
|
||||
|
||||
totviews = BKE_scene_multiview_num_views_get(&context->scene->r);
|
||||
|
@ -74,7 +74,7 @@ void BLI_listbase_sort(struct ListBase *listbase, int (*cmp)(const void *, const
|
||||
void BLI_listbase_sort_r(ListBase *listbase, int (*cmp)(void *, const void *, const void *), void *thunk) ATTR_NONNULL(1, 2);
|
||||
bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL();
|
||||
void BLI_freelist(struct ListBase *listbase) ATTR_NONNULL(1);
|
||||
int BLI_listbase_count_ex(const struct ListBase *listbase, const int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
|
||||
int BLI_listbase_count_at_most(const struct ListBase *listbase, const int count_max) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
|
||||
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
|
||||
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1);
|
||||
|
||||
|
@ -484,7 +484,7 @@ void BLI_freelistN(ListBase *listbase)
|
||||
*
|
||||
* \note Use to avoid redundant looping.
|
||||
*/
|
||||
int BLI_listbase_count_ex(const ListBase *listbase, const int count_max)
|
||||
int BLI_listbase_count_at_most(const ListBase *listbase, const int count_max)
|
||||
{
|
||||
Link *link;
|
||||
int count = 0;
|
||||
|
@ -105,7 +105,7 @@ void ImageNode::convertToOperations(NodeConverter &converter, const CompositorCo
|
||||
}
|
||||
|
||||
/* returns the image view to use for the current active view */
|
||||
if (BLI_listbase_count_ex(&image->rr->views, 2) > 1) {
|
||||
if (BLI_listbase_count_at_most(&image->rr->views, 2) > 1) {
|
||||
const int view_image = imageuser->view;
|
||||
const bool is_allview = (view_image == 0); /* if view selected == All (0) */
|
||||
|
||||
|
@ -525,7 +525,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op)
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
/* Make sure data from this file is usable for pose paste. */
|
||||
if (BLI_listbase_count_ex(&tmp_bmain->object, 2) != 1) {
|
||||
if (BLI_listbase_count_at_most(&tmp_bmain->object, 2) != 1) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Copy buffer is not from pose mode");
|
||||
BKE_main_free(tmp_bmain);
|
||||
return OPERATOR_CANCELLED;
|
||||
|
@ -1062,7 +1062,7 @@ static int gp_brush_remove_exec(bContext *C, wmOperator *op)
|
||||
if (ELEM(NULL, ts, brush))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (BLI_listbase_count_ex(&ts->gp_brushes, 2) < 2) {
|
||||
if (BLI_listbase_count_at_most(&ts->gp_brushes, 2) < 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a brush, unable to delete the last one");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
@ -1420,7 +1420,7 @@ static int gp_palette_remove_exec(bContext *C, wmOperator *op)
|
||||
if (ELEM(NULL, gpd, palette))
|
||||
return OPERATOR_CANCELLED;
|
||||
|
||||
if (BLI_listbase_count_ex(&gpd->palettes, 2) < 2) {
|
||||
if (BLI_listbase_count_at_most(&gpd->palettes, 2) < 2) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Grease Pencil needs a palette, unable to delete the last one");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
@ -857,7 +857,7 @@ static void knife_cut_face(KnifeTool_OpData *kcd, BMFace *f, ListBase *hits)
|
||||
{
|
||||
Ref *r;
|
||||
|
||||
if (BLI_listbase_count_ex(hits, 2) != 2)
|
||||
if (BLI_listbase_count_at_most(hits, 2) != 2)
|
||||
return;
|
||||
|
||||
for (r = hits->first; r->next; r = r->next) {
|
||||
|
@ -1119,7 +1119,7 @@ static bool bm_vert_connect_select_history(BMesh *bm)
|
||||
* - Otherwise connect faces.
|
||||
* - If all edges have been created already, closed the loop.
|
||||
*/
|
||||
if (BLI_listbase_count_ex(&bm->selected, 2) == 2 && (bm->totvertsel > 2)) {
|
||||
if (BLI_listbase_count_at_most(&bm->selected, 2) == 2 && (bm->totvertsel > 2)) {
|
||||
BMEditSelection *ese;
|
||||
int tot = 0;
|
||||
bool changed = false;
|
||||
|
@ -470,7 +470,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts)
|
||||
}
|
||||
else {
|
||||
/* set one user as active based on active index */
|
||||
if (ct->index >= BLI_listbase_count_ex(&ct->users, ct->index + 1))
|
||||
if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1))
|
||||
ct->index = 0;
|
||||
|
||||
ct->user = BLI_findlink(&ct->users, ct->index);
|
||||
|
@ -762,7 +762,7 @@ static void uiblock_layer_pass_buttons(
|
||||
}
|
||||
|
||||
/* view */
|
||||
if (BLI_listbase_count_ex(&rr->views, 2) > 1 &&
|
||||
if (BLI_listbase_count_at_most(&rr->views, 2) > 1 &&
|
||||
((!show_stereo) || (!RE_RenderResult_is_stereo(rr))))
|
||||
{
|
||||
rview = BLI_findlink(&rr->views, iuser->view);
|
||||
|
@ -1851,7 +1851,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
|
||||
/* we need renderresult for exr and rendered multiview */
|
||||
scene = CTX_data_scene(C);
|
||||
rr = BKE_image_acquire_renderresult(scene, ima);
|
||||
bool is_mono = rr ? BLI_listbase_count_ex(&rr->views, 2) < 2 : BLI_listbase_count_ex(&ima->views, 2) < 2;
|
||||
bool is_mono = rr ? BLI_listbase_count_at_most(&rr->views, 2) < 2 : BLI_listbase_count_at_most(&ima->views, 2) < 2;
|
||||
bool is_exr_rr = rr && ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) && RE_HasFloatPixels(rr);
|
||||
|
||||
/* error handling */
|
||||
|
@ -1501,7 +1501,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op)
|
||||
NlaStrip *mstrip = (NlaStrip *)nlt->strips.first;
|
||||
|
||||
if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) &&
|
||||
(BLI_listbase_count_ex(&mstrip->strips, 3) == 2))
|
||||
(BLI_listbase_count_at_most(&mstrip->strips, 3) == 2))
|
||||
{
|
||||
/* remove this temp meta, so that we can see the strips inside */
|
||||
BKE_nlastrips_clear_metas(&nlt->strips, 0, 1);
|
||||
|
@ -2701,7 +2701,7 @@ static int rna_Node_image_has_views_get(PointerRNA *ptr)
|
||||
|
||||
if (!ima || !(ima->rr)) return 0;
|
||||
|
||||
return BLI_listbase_count_ex(&ima->rr->views, 2) > 1;
|
||||
return BLI_listbase_count_at_most(&ima->rr->views, 2) > 1;
|
||||
}
|
||||
|
||||
static const EnumPropertyItem *renderresult_views_add_enum(RenderView *rv)
|
||||
|
@ -3349,7 +3349,7 @@ bool RE_WriteRenderViewsImage(ReportList *reports, RenderResult *rr, Scene *scen
|
||||
if (!rr)
|
||||
return false;
|
||||
|
||||
bool is_mono = BLI_listbase_count_ex(&rr->views, 2) < 2;
|
||||
bool is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
|
||||
bool is_exr_rr = ELEM(rd->im_format.imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER) &&
|
||||
RE_HasFloatPixels(rr);
|
||||
|
||||
@ -3466,7 +3466,7 @@ bool RE_WriteRenderViewsMovie(
|
||||
if (!rr)
|
||||
return false;
|
||||
|
||||
is_mono = BLI_listbase_count_ex(&rr->views, 2) < 2;
|
||||
is_mono = BLI_listbase_count_at_most(&rr->views, 2) < 2;
|
||||
|
||||
if (is_mono || (scene->r.im_format.views_format == R_IMF_VIEWS_INDIVIDUAL)) {
|
||||
int view_id;
|
||||
@ -4067,7 +4067,7 @@ bool RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env,
|
||||
/* Used in the interface to decide whether to show layers or passes. */
|
||||
bool RE_layers_have_name(struct RenderResult *rr)
|
||||
{
|
||||
switch (BLI_listbase_count_ex(&rr->layers, 2)) {
|
||||
switch (BLI_listbase_count_at_most(&rr->layers, 2)) {
|
||||
case 0:
|
||||
return false;
|
||||
case 1:
|
||||
|
@ -753,7 +753,7 @@ void render_result_views_new(RenderResult *rr, RenderData *rd)
|
||||
}
|
||||
|
||||
/* we always need at least one view */
|
||||
if (BLI_listbase_count_ex(&rr->views, 1) == 0) {
|
||||
if (BLI_listbase_count_at_most(&rr->views, 1) == 0) {
|
||||
render_result_view_new(rr, "");
|
||||
}
|
||||
}
|
||||
|
@ -1540,7 +1540,7 @@ static KX_GameObject *gameobject_from_blenderobject(
|
||||
gameobj->AddMesh(meshobj);
|
||||
|
||||
// gather levels of detail
|
||||
if (BLI_listbase_count_ex(&ob->lodlevels, 2) > 1) {
|
||||
if (BLI_listbase_count_at_most(&ob->lodlevels, 2) > 1) {
|
||||
LodLevel *lod = ((LodLevel*)ob->lodlevels.first)->next;
|
||||
Mesh* lodmesh = mesh;
|
||||
Object* lodmatob = ob;
|
||||
|
Loading…
Reference in New Issue
Block a user