Cleanup: remove/comment unused code, simplify casts

Remove simple counters where they aren't used, comment in some cases.
Also add missing include.
This commit is contained in:
Campbell Barton 2023-01-19 17:07:29 +11:00
parent bc502f3b19
commit 66595e29e2
26 changed files with 28 additions and 58 deletions

View File

@ -760,6 +760,7 @@ static void create_samples(CurveProfile *profile,
}
BLI_assert(n_added == n_segments); /* n_added is just used for this assert, could remove it. */
UNUSED_VARS_NDEBUG(n_added);
/* Sample the points and add them to the locations table. */
for (int i_sample = 0, i = 0; i < totedges; i++) {

View File

@ -5284,7 +5284,6 @@ const blender::CPPType *custom_data_type_to_cpp_type(const eCustomDataType type)
default:
return nullptr;
}
return nullptr;
}
eCustomDataType cpp_type_to_custom_data_type(const blender::CPPType &type)

View File

@ -1566,7 +1566,6 @@ bGPDlayer *BKE_gpencil_layer_active_get(bGPdata *gpd)
bGPDlayer *BKE_gpencil_layer_get_by_name(bGPdata *gpd, char *name, int first_if_not_found)
{
bGPDlayer *gpl;
int i = 0;
/* error checking */
if (ELEM(NULL, gpd, gpd->layers.first)) {
@ -1578,7 +1577,6 @@ bGPDlayer *BKE_gpencil_layer_get_by_name(bGPdata *gpd, char *name, int first_if_
if (STREQ(name, gpl->info)) {
return gpl;
}
i++;
}
/* no such layer */

View File

@ -971,7 +971,7 @@ static float *gpencil_stroke_points_from_editcurve_adaptive_resolu(
MEM_freeN(segment_point_lengths);
*r_points_len = points_len;
return (float(*))r_points;
return (float *)r_points;
}
/**
@ -1012,7 +1012,7 @@ static float *gpencil_stroke_points_from_editcurve_fixed_resolu(bGPDcurve_point
}
*r_points_len = points_len;
return (float(*))r_points;
return (float *)r_points;
}
void BKE_gpencil_stroke_update_geometry_from_editcurve(bGPDstroke *gps,

View File

@ -636,8 +636,6 @@ static bool layer_collection_hidden(ViewLayer *view_layer, LayerCollection *lc)
}
return false;
return false;
}
LayerCollection *BKE_layer_collection_from_index(ViewLayer *view_layer, const int index)
@ -1210,6 +1208,7 @@ static void layer_collection_sync(ViewLayer *view_layer,
layer_resync->layer->layer_collections = new_lb_layer;
BLI_assert(BLI_listbase_count(&layer_resync->collection->children) - skipped_children ==
BLI_listbase_count(&new_lb_layer));
UNUSED_VARS_NDEBUG(skipped_children);
/* Update bases etc. for objects. */
layer_collection_objects_sync(view_layer,

View File

@ -2629,8 +2629,6 @@ bool BKE_sculpt_attribute_exists(Object *ob,
CustomData *cdata = sculpt_get_cdata(ob, domain);
return CustomData_get_named_layer_index(cdata, proptype, name) != -1;
return false;
}
static SculptAttribute *sculpt_alloc_attr(SculptSession *ss)

View File

@ -361,7 +361,6 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
{
const uint poly_num = (uint)sf_ctx->poly_nr + 1;
uint eed_index = 0;
int totvert_new = 0;
bool changed = false;
PolyInfo *poly_info;
@ -453,7 +452,6 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
if (eve->user_flag != 1) {
BLI_remlink(&sf_ctx->fillvertbase, eve);
BLI_addtail(remvertbase, eve);
totvert_new--;
}
else {
eve->user_flag = 0;

View File

@ -196,11 +196,9 @@ TEST(task, MempoolIterTLS)
int i;
/* Add numbers negative `1..ITEMS_NUM` inclusive. */
int items_num = 0;
for (i = 0; i < ITEMS_NUM; i++) {
data[i] = (int *)BLI_mempool_alloc(mempool);
*data[i] = -(i + 1);
items_num++;
}
TaskParallelSettings settings;

View File

@ -149,14 +149,12 @@ void BM_face_interp_from_face_ex(BMesh *bm,
float *w = BLI_array_alloca(w, f_src->len);
float co[2];
int i;
if (f_src != f_dst) {
BM_elem_attrs_copy(bm, bm, f_src, f_dst);
}
/* interpolate */
i = 0;
l_iter = l_first = BM_FACE_FIRST_LOOP(f_dst);
do {
mul_v2_m3v3(co, axis_mat, l_iter->v->co);
@ -165,7 +163,7 @@ void BM_face_interp_from_face_ex(BMesh *bm,
if (do_vertex) {
CustomData_bmesh_interp(&bm->vdata, blocks_v, w, NULL, f_src->len, l_iter->v->head.data);
}
} while ((void)i++, (l_iter = l_iter->next) != l_first);
} while ((l_iter = l_iter->next) != l_first);
}
void BM_face_interp_from_face(BMesh *bm, BMFace *f_dst, const BMFace *f_src, const bool do_vertex)

View File

@ -1342,10 +1342,9 @@ bool BM_mesh_intersect(BMesh *bm,
GHASH_ITER (gh_iter, s.face_edges) {
struct LinkBase *e_ls_base = BLI_ghashIterator_getValue(&gh_iter);
LinkNode **node_prev_p;
uint i;
node_prev_p = &e_ls_base->list;
for (i = 0, node = e_ls_base->list; node; i++, node = node->next) {
for (node = e_ls_base->list; node; node = node->next) {
BMEdge *e = node->link;
if (BM_elem_flag_test(e, BM_ELEM_TAG)) {
/* allocated by arena, don't free */

View File

@ -29,6 +29,8 @@
#include "GPU_texture.h"
#include "compositor_engine.h" /* Own include. */
namespace blender::draw::compositor {
class TexturePool : public realtime_compositor::TexturePool {

View File

@ -67,7 +67,6 @@ static const char *workbench_lighting_mode_to_str(int light)
return "_matcap";
case V3D_LIGHTING_FLAT:
return "_flat";
return "";
}
}

View File

@ -887,8 +887,7 @@ void ANIM_fmodifier_panels(const bContext *C,
if (!panels_match) {
UI_panels_free_instanced(C, region);
FModifier *fcm = fmodifiers->first;
for (int i = 0; fcm; i++, fcm = fcm->next) {
for (FModifier *fcm = fmodifiers->first; fcm; fcm = fcm->next) {
char panel_idname[MAX_NAME];
panel_id_fn(fcm, panel_idname);

View File

@ -4197,11 +4197,9 @@ static void ui_litem_layout_column_flow(uiLayout *litem)
/* compute max needed width and total height */
int toth = 0;
int totitem = 0;
LISTBASE_FOREACH (uiItem *, item, &litem->items) {
ui_item_size(item, &itemw, &itemh);
toth += itemh;
totitem++;
}
/* compute sizes */

View File

@ -2291,8 +2291,7 @@ void uiTemplateModifiers(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
ModifierData *md = static_cast<ModifierData *>(modifiers->first);
for (int i = 0; md; i++, md = md->next) {
for (ModifierData *md = static_cast<ModifierData *>(modifiers->first); md; md = md->next) {
const ModifierTypeInfo *mti = BKE_modifier_get_info(ModifierType(md->type));
if (mti->panelRegister == nullptr) {
continue;
@ -2451,9 +2450,10 @@ void uiTemplateConstraints(uiLayout * /*layout*/, bContext *C, bool use_bone_con
if (!panels_match) {
UI_panels_free_instanced(C, region);
bConstraint *con = (constraints == nullptr) ? nullptr :
static_cast<bConstraint *>(constraints->first);
for (int i = 0; con; i++, con = con->next) {
for (bConstraint *con =
(constraints == nullptr) ? nullptr : static_cast<bConstraint *>(constraints->first);
con;
con = con->next) {
/* Don't show invalid/legacy constraints. */
if (con->type == CONSTRAINT_TYPE_NULL) {
continue;
@ -2543,8 +2543,8 @@ void uiTemplateGpencilModifiers(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
GpencilModifierData *md = static_cast<GpencilModifierData *>(modifiers->first);
for (int i = 0; md; i++, md = md->next) {
for (GpencilModifierData *md = static_cast<GpencilModifierData *>(modifiers->first); md;
md = md->next) {
const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info(
GpencilModifierType(md->type));
if (mti->panelRegister == nullptr) {
@ -2617,8 +2617,7 @@ void uiTemplateShaderFx(uiLayout * /*layout*/, bContext *C)
if (!panels_match) {
UI_panels_free_instanced(C, region);
ShaderFxData *fx = static_cast<ShaderFxData *>(shaderfx->first);
for (int i = 0; fx; i++, fx = fx->next) {
for (ShaderFxData *fx = static_cast<ShaderFxData *>(shaderfx->first); fx; fx = fx->next) {
char panel_idname[MAX_NAME];
shaderfx_panel_id(fx, panel_idname);

View File

@ -291,6 +291,7 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm)
BM_edge_loop_pair(e_last, &lp->l_a, &lp->l_b);
BLI_assert(tot == uid_end - uid_start);
UNUSED_VARS_NDEBUG(tot);
#if 0
printf("%s: found contiguous edge loop of (%d)\n", __func__, uid_end - uid_start);

View File

@ -983,13 +983,6 @@ static void region_azone_tab_plus(ScrArea *area, AZone *az, ARegion *region)
const float tab_size_x = 0.7f * U.widget_unit;
const float tab_size_y = 0.4f * U.widget_unit;
int tot = 0;
LISTBASE_FOREACH (AZone *, azt, &area->actionzones) {
if (azt->edge == az->edge) {
tot++;
}
}
switch (az->edge) {
case AE_TOP_TO_BOTTOMRIGHT: {
int add = (region->winrct.ymax == area->totrct.ymin) ? 1 : 0;

View File

@ -347,7 +347,7 @@ static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const
return a->locx < b->locx;
});
int numlinks = 0;
// int numlinks = 0; /* UNUSED */
for (const int i : sorted_nodes.as_mutable_span().drop_back(1).index_range()) {
bool has_selected_inputs = false;
@ -374,7 +374,7 @@ static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const
}
if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
numlinks++;
// numlinks++;
}
}
}
@ -398,7 +398,7 @@ static void snode_autoconnect(SpaceNode &snode, const bool allow_multiple, const
}
if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) {
numlinks++;
// numlinks++;
break;
}
}

View File

@ -377,7 +377,7 @@ int bm_mesh_calc_uv_islands(const Scene *scene,
}
}
struct SharedUVLoopData user_data = {0};
struct SharedUVLoopData user_data = {{0}};
user_data.offsets = uv_offsets;
user_data.use_seams = use_seams;

View File

@ -875,13 +875,13 @@ static int __recursiveSplit(Chain *_curve,
++it;
// real mean = 0.0f;
// soc unused - real variance = 0.0f;
uint count = 0;
// uint count = 0;
CurveInternal::CurvePointIterator next = it;
++next;
bool bsplit = false;
for (; ((it != end) && (next != end)); ++it, ++next) {
++count;
// ++count;
it0d = it.castToInterface0DIterator();
if (pred0d(it0d) < 0) {
return -1;

View File

@ -1168,7 +1168,6 @@ static float p_edge_boundary_angle(PEdge *e)
PEdge *we;
PVert *v, *v1, *v2;
float angle;
int n = 0;
v = e->vert;
@ -1182,7 +1181,6 @@ static float p_edge_boundary_angle(PEdge *e)
angle -= angle_v3v3v3(v1->co, v->co, v2->co);
we = we->next->next->pair;
n++;
} while (we && (we != v->edge));
return angle;

View File

@ -4506,7 +4506,7 @@ LineartBoundingArea *MOD_lineart_get_bounding_area(LineartData *ld, double x, do
static void lineart_add_triangles_worker(TaskPool *__restrict /*pool*/, LineartIsecThread *th)
{
LineartData *ld = th->ld;
int _dir_control = 0;
// int _dir_control = 0; /* UNUSED */
while (lineart_schedule_new_triangle_task(th)) {
for (LineartElementLinkNode *eln = th->pending_from; eln != th->pending_to->next;
eln = eln->next) {
@ -4522,7 +4522,7 @@ static void lineart_add_triangles_worker(TaskPool *__restrict /*pool*/, LineartI
continue;
}
if (lineart_get_triangle_bounding_areas(ld, tri, &y1, &y2, &x1, &x2)) {
_dir_control++;
// _dir_control++;
for (co = x1; co <= x2; co++) {
for (r = y1; r <= y2; r++) {
lineart_bounding_area_link_triangle(ld,

View File

@ -757,7 +757,6 @@ static char *rna_idp_path_create(IDP_Chain *child_link)
char *path;
bool is_first = true;
int tot = 0;
IDP_Chain *link = child_link;
/* reverse the list */
@ -768,7 +767,6 @@ static char *rna_idp_path_create(IDP_Chain *child_link)
link->up = link_prev;
link_prev = link;
link = link_next;
tot++;
}
for (link = link_prev; link; link = link->up) {

View File

@ -1401,8 +1401,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
gs_ptr = orig_vert_groups_arr;
for (uint i = 0; i < verts_num; i++, gs_ptr++) {
if (*gs_ptr) {
EdgeGroup *g = *gs_ptr;
for (uint j = 0; g->valid; j++, g++) {
for (EdgeGroup *g = *gs_ptr; g->valid; g++) {
if (!g->is_singularity) {
float *nor = g->no;
/* During vertex position calculation, the algorithm decides if it wants to disable the
@ -2003,8 +2002,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
for (uint i = 0; i < verts_num; i++, gs_ptr++) {
EdgeGroup *gs = *gs_ptr;
if (gs) {
EdgeGroup *g = gs;
for (uint j = 0; g->valid; j++, g++) {
for (EdgeGroup *g = gs; g->valid; g++) {
if (g->new_vert != MOD_SOLIDIFY_EMPTY_TAG) {
CustomData_copy_data(&mesh->vdata, &result->vdata, (int)i, (int)g->new_vert, 1);
copy_v3_v3(vert_positions[g->new_vert], g->co);

View File

@ -2520,7 +2520,6 @@ bool RE_layers_have_name(struct RenderResult *result)
default:
return true;
}
return false;
}
bool RE_passes_have_name(struct RenderLayer *rl)

View File

@ -767,7 +767,6 @@ void render_result_single_layer_end(Render *re)
BLI_remlink(&re->result->layers, rl);
/* reconstruct render result layers */
int nr = 0;
LISTBASE_FOREACH (ViewLayer *, view_layer, &re->scene->view_layers) {
if (STREQ(view_layer->name, re->single_view_layer)) {
BLI_addtail(&re->result->layers, rl);
@ -779,7 +778,6 @@ void render_result_single_layer_end(Render *re)
BLI_addtail(&re->result->layers, rlpush);
}
}
nr++;
}
}