From ff6098345a6e0fca508d0e104976d54ca199f273 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 22 Apr 2022 12:41:25 -0500 Subject: Cleanup: Clang tidy, unused variable warnings Also remove unnecessary uses of `struct` and add const in one place. --- source/blender/bmesh/tools/bmesh_bevel.c | 6 +- source/blender/draw/intern/draw_volume.cc | 24 +-- .../blender/editors/sculpt_paint/paint_vertex.cc | 223 ++++++++++----------- 3 files changed, 125 insertions(+), 128 deletions(-) diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index fa93faf1606..e5006c2672c 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -922,6 +922,7 @@ static void math_layer_info_init(BevelParams *bp, BMesh *bm) } } BLI_assert(top_face != NULL && bot_face != NULL); + UNUSED_VARS_NDEBUG(top_face, bot_face); swap_face_components(face_component, totface, face_component[0], top_face_component); if (bot_face_component != top_face_component) { if (bot_face_component == 0) { @@ -4910,8 +4911,7 @@ static float projected_boundary_area(BevVert *bv, BMFace *f) */ static bool is_bad_uv_poly(BevVert *bv, BMFace *frep) { - VMesh *vm = bv->vmesh; - BLI_assert(vm != NULL); + BLI_assert(bv->vmesh != NULL); float area = projected_boundary_area(bv, frep); return area < BEVEL_EPSILON_BIG; } @@ -5326,7 +5326,7 @@ static BMEdge *snap_edge_for_center_vmesh_vert(int i, if (frep_beats_next[previ] && bndv_rep_faces[previ] == center_frep) { return eprev; } - else if (!frep_beats_next[i] && bndv_rep_faces[nexti] == center_frep) { + if (!frep_beats_next[i] && bndv_rep_faces[nexti] == center_frep) { return enext; } /* If n_bndv > 3 then we won't snap in the boundvert regions diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc index e268e28fa27..8d9a6f486e2 100644 --- a/source/blender/draw/intern/draw_volume.cc +++ b/source/blender/draw/intern/draw_volume.cc @@ -67,7 +67,7 @@ void DRW_volume_ubos_pool_free(void *pool) delete reinterpret_cast(pool); } -static void drw_volume_globals_init(void) +static void drw_volume_globals_init() { const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f}; @@ -132,17 +132,17 @@ static DRWShadingGroup *drw_volume_object_grids_init(Object *ob, int grid_id = 0; LISTBASE_FOREACH (GPUMaterialAttribute *, attr, attrs) { const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, attr->name); - DRWVolumeGrid *drw_grid = (volume_grid) ? - DRW_volume_batch_cache_get_grid(volume, volume_grid) : - NULL; + const DRWVolumeGrid *drw_grid = (volume_grid) ? + DRW_volume_batch_cache_get_grid(volume, volume_grid) : + nullptr; /* Handle 3 cases here: * - Grid exists and texture was loaded -> use texture. * - Grid exists but has zero size or failed to load -> use zero. * - Grid does not exist -> use default value. */ - GPUTexture *grid_tex = (drw_grid) ? drw_grid->texture : - (volume_grid) ? g_data.dummy_zero : - grid_default_texture(attr->default_value); + const GPUTexture *grid_tex = (drw_grid) ? drw_grid->texture : + (volume_grid) ? g_data.dummy_zero : + grid_default_texture(attr->default_value); DRW_shgroup_uniform_texture(grp, attr->input_name, grid_tex); copy_m4_m4(volume_infos.grids_xform[grid_id++].ptr(), drw_grid->object_to_texture); @@ -163,7 +163,7 @@ static DRWShadingGroup *drw_volume_object_mesh_init(Scene *scene, VolumeUniformBufPool *pool = (VolumeUniformBufPool *)DST.vmempool->volume_grids_ubos; VolumeInfosBuf &volume_infos = *pool->alloc(); - ModifierData *md = NULL; + ModifierData *md = nullptr; volume_infos.density_scale = 1.0f; volume_infos.color_mul = float4(1.0f); @@ -173,7 +173,7 @@ static DRWShadingGroup *drw_volume_object_mesh_init(Scene *scene, /* Smoke Simulation */ if ((md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) && (BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) && - ((FluidModifierData *)md)->domain != NULL) { + ((FluidModifierData *)md)->domain != nullptr) { FluidModifierData *fmd = (FluidModifierData *)md; FluidDomainSettings *fds = fmd->domain; @@ -256,10 +256,8 @@ DRWShadingGroup *DRW_shgroup_volume_create_sub(Scene *scene, if (ob == nullptr) { return drw_volume_world_grids_init(&attrs, shgrp); } - else if (ob->type == OB_VOLUME) { + if (ob->type == OB_VOLUME) { return drw_volume_object_grids_init(ob, &attrs, shgrp); } - else { - return drw_volume_object_mesh_init(scene, ob, &attrs, shgrp); - } + return drw_volume_object_mesh_init(scene, ob, &attrs, shgrp); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index be0598919c7..8b62dd33961 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -156,7 +156,7 @@ static int get_vcol_elements(Mesh *me, size_t *r_elem_size) } } -static void view_angle_limits_init(struct NormalAnglePrecalc *a, float angle, bool do_mask_normal) +static void view_angle_limits_init(NormalAnglePrecalc *a, float angle, bool do_mask_normal) { angle = RAD2DEGF(angle); a->do_mask_normal = do_mask_normal; @@ -180,7 +180,7 @@ static void view_angle_limits_init(struct NormalAnglePrecalc *a, float angle, bo a->angle_inner__cos = cosf(a->angle_inner); } -static float view_angle_limits_apply_falloff(const struct NormalAnglePrecalc *a, +static float view_angle_limits_apply_falloff(const NormalAnglePrecalc *a, float angle_cos, float *mask_p) { @@ -232,7 +232,7 @@ static bool vertex_paint_use_fast_update_check(Object *ob) { const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob); - if (me_eval != NULL) { + if (me_eval != nullptr) { Mesh *me = BKE_mesh_from_object(ob); if (me && me->mloopcol) { return (me->mloopcol == CustomData_get_layer(&me_eval->ldata, CD_PROP_BYTE_COLOR)); @@ -301,8 +301,8 @@ static bool weight_paint_poll_ex(bContext *C, bool check_tool) Object *ob = CTX_data_active_object(C); ScrArea *area; - if ((ob != NULL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && - (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && + if ((ob != nullptr) && (ob->mode & OB_MODE_WEIGHT_PAINT) && + (BKE_paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != nullptr) && (area = CTX_wm_area(C)) && (area->spacetype == SPACE_VIEW3D)) { ARegion *region = CTX_wm_region(C); if (ELEM(region->regiontype, RGN_TYPE_WINDOW, RGN_TYPE_HUD)) { @@ -450,9 +450,9 @@ static void paint_and_tex_color_alpha_intern(VPaint *vp, float r_rgba[4]) { const Brush *brush = BKE_paint_brush(&vp->paint); - BLI_assert(brush->mtex.tex != NULL); + BLI_assert(brush->mtex.tex != nullptr); if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_3D) { - BKE_brush_sample_tex_3d(vc->scene, brush, co, r_rgba, 0, NULL); + BKE_brush_sample_tex_3d(vc->scene, brush, co, r_rgba, 0, nullptr); } else { float co_ss[2]; /* screenspace */ @@ -462,7 +462,7 @@ static void paint_and_tex_color_alpha_intern(VPaint *vp, co_ss, (eV3DProjTest)(V3D_PROJ_TEST_CLIP_BB | V3D_PROJ_TEST_CLIP_NEAR)) == V3D_PROJ_RET_OK) { const float co_ss_3d[3] = {co_ss[0], co_ss[1], 0.0f}; /* we need a 3rd empty value */ - BKE_brush_sample_tex_3d(vc->scene, brush, co_ss_3d, r_rgba, 0, NULL); + BKE_brush_sample_tex_3d(vc->scene, brush, co_ss_3d, r_rgba, 0, nullptr); } else { zero_v4(r_rgba); @@ -568,7 +568,7 @@ static bool do_weight_paint_normalize_all_locked(MDeformVert *dvert, uint i, tot = 0; MDeformWeight *dw; - if (lock_flags == NULL) { + if (lock_flags == nullptr) { do_weight_paint_normalize_all(dvert, defbase_tot, vgroup_validmap); return true; } @@ -783,7 +783,7 @@ struct WeightPaintGroupData { * this _could_ be made a part of the operators 'WPaintData' struct, or at * least a member, but for now keep its own struct, initialized on every * paint stroke update - campbell */ -typedef struct WeightPaintInfo { +struct WeightPaintInfo { int defbase_tot; @@ -791,7 +791,7 @@ typedef struct WeightPaintInfo { int defbase_tot_sel; int defbase_tot_unsel; - struct WeightPaintGroupData active, mirror; + WeightPaintGroupData active, mirror; /* boolean array for locked bones, * length of defbase_tot */ @@ -814,7 +814,7 @@ typedef struct WeightPaintInfo { bool is_normalized; float brush_alpha_value; /* result of BKE_brush_alpha_get() */ -} WeightPaintInfo; +}; static void do_weight_paint_vertex_single( /* vars which remain the same for every vert */ @@ -843,7 +843,7 @@ static void do_weight_paint_vertex_single( /* Check if we should mirror vertex groups (X-axis). */ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) { - index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology); + index_mirr = mesh_get_x_mirror_vert(ob, nullptr, index, topology); vgroup_mirr = wpi->mirror.index; /* another possible error - mirror group _and_ active group are the same (which is fine), @@ -881,7 +881,7 @@ static void do_weight_paint_vertex_single( dw = BKE_defvert_ensure_index(dv, wpi->active.index); } - if (dw == NULL) { + if (dw == nullptr) { return; } @@ -891,9 +891,9 @@ static void do_weight_paint_vertex_single( if (wp->flag & VP_FLAG_VGROUP_RESTRICT) { dw_mirr = BKE_defvert_find_index(dv_mirr, vgroup_mirr); - if (dw_mirr == NULL) { + if (dw_mirr == nullptr) { index_mirr = vgroup_mirr = -1; - dv_mirr = NULL; + dv_mirr = nullptr; } } else { @@ -914,8 +914,8 @@ static void do_weight_paint_vertex_single( } } else { - dv_mirr = NULL; - dw_mirr = NULL; + dv_mirr = nullptr; + dw_mirr = nullptr; } weight_cur = dw->weight; @@ -1045,7 +1045,7 @@ static void do_weight_paint_vertex_multi( /* mirror vars */ int index_mirr = -1; - MDeformVert *dv_mirr = NULL; + MDeformVert *dv_mirr = nullptr; /* weights */ float curw, curw_real, oldw, neww, change, curw_mirr, change_mirr; @@ -1053,7 +1053,7 @@ static void do_weight_paint_vertex_multi( /* Check if we should mirror vertex groups (X-axis). */ if (ME_USING_MIRROR_X_VERTEX_GROUPS(me)) { - index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology); + index_mirr = mesh_get_x_mirror_vert(ob, nullptr, index, topology); if (!ELEM(index_mirr, -1, index)) { dv_mirr = &me->dvert[index_mirr]; @@ -1113,13 +1113,13 @@ static void do_weight_paint_vertex_multi( /* verify for all groups that 0 < result <= 1 */ multipaint_clamp_change(dv, wpi->defbase_tot, wpi->defbase_sel, &change); - if (dv_mirr != NULL) { + if (dv_mirr != nullptr) { curw_mirr = BKE_defvert_multipaint_collective_weight( dv_mirr, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->is_normalized); if (curw_mirr == 0.0f) { /* can't mirror into a zero weight vertex */ - dv_mirr = NULL; + dv_mirr = nullptr; } else { /* mirror is changed to achieve the same collective weight value */ @@ -1142,7 +1142,7 @@ static void do_weight_paint_vertex_multi( /* apply validated change to vertex and mirror */ multipaint_apply_change(dv, wpi->defbase_tot, change, wpi->defbase_sel); - if (dv_mirr != NULL) { + if (dv_mirr != nullptr) { multipaint_apply_change(dv_mirr, wpi->defbase_tot, change_mirr, wpi->defbase_sel); } @@ -1151,7 +1151,7 @@ static void do_weight_paint_vertex_multi( do_weight_paint_normalize_all_locked_try_active( dv, wpi->defbase_tot, wpi->vgroup_validmap, wpi->lock_flags, wpi->active.lock); - if (dv_mirr != NULL) { + if (dv_mirr != nullptr) { do_weight_paint_normalize_all_locked_try_active( dv_mirr, wpi->defbase_tot, wpi->vgroup_validmap, wpi->lock_flags, wpi->active.lock); } @@ -1185,7 +1185,7 @@ static void vertex_paint_init_session(Depsgraph *depsgraph, /* Create persistent sculpt mode data */ BKE_sculpt_toolsettings_data_ensure(scene); - BLI_assert(ob->sculpt == NULL); + BLI_assert(ob->sculpt == nullptr); ob->sculpt = (SculptSession *)MEM_callocN(sizeof(SculptSession), "sculpt session"); ob->sculpt->mode_type = object_mode; BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false); @@ -1224,7 +1224,7 @@ static void vertex_paint_init_stroke(Scene *scene, Depsgraph *depsgraph, Object static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) { /* Create maps */ - struct SculptVertexPaintGeomMap *gmap = NULL; + SculptVertexPaintGeomMap *gmap = nullptr; if (ob->mode == OB_MODE_VERTEX_PAINT) { gmap = &ob->sculpt->mode.vpaint.gmap; BLI_assert(ob->sculpt->mode_type == OB_MODE_VERTEX_PAINT); @@ -1241,11 +1241,11 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) Mesh *me = (Mesh *)ob->data; - if (gmap->vert_to_loop == NULL) { - gmap->vert_map_mem = NULL; - gmap->vert_to_loop = NULL; - gmap->poly_map_mem = NULL; - gmap->vert_to_poly = NULL; + if (gmap->vert_to_loop == nullptr) { + gmap->vert_map_mem = nullptr; + gmap->vert_to_loop = nullptr; + gmap->poly_map_mem = nullptr; + gmap->vert_to_poly = nullptr; BKE_mesh_vert_loop_map_create(&gmap->vert_to_loop, &gmap->vert_map_mem, me->mpoly, @@ -1265,11 +1265,11 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) /* Create average brush arrays */ if (ob->mode == OB_MODE_WEIGHT_PAINT) { if (!brush_use_accumulate(ts->wpaint)) { - if (ob->sculpt->mode.wpaint.alpha_weight == NULL) { + if (ob->sculpt->mode.wpaint.alpha_weight == nullptr) { ob->sculpt->mode.wpaint.alpha_weight = (float *)MEM_callocN(me->totvert * sizeof(float), __func__); } - if (ob->sculpt->mode.wpaint.dvert_prev == NULL) { + if (ob->sculpt->mode.wpaint.dvert_prev == nullptr) { ob->sculpt->mode.wpaint.dvert_prev = (MDeformVert *)MEM_callocN( me->totvert * sizeof(MDeformVert), __func__); MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev; @@ -1281,10 +1281,10 @@ static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob) } else { MEM_SAFE_FREE(ob->sculpt->mode.wpaint.alpha_weight); - if (ob->sculpt->mode.wpaint.dvert_prev != NULL) { + if (ob->sculpt->mode.wpaint.dvert_prev != nullptr) { BKE_defvert_array_free_elems(ob->sculpt->mode.wpaint.dvert_prev, me->totvert); MEM_freeN(ob->sculpt->mode.wpaint.dvert_prev); - ob->sculpt->mode.wpaint.dvert_prev = NULL; + ob->sculpt->mode.wpaint.dvert_prev = nullptr; } } } @@ -1309,7 +1309,7 @@ static void ed_vwpaintmode_enter_generic( if (mode_flag == OB_MODE_VERTEX_PAINT) { const ePaintMode paint_mode = PAINT_MODE_VERTEX; - ED_mesh_color_ensure(me, NULL); + ED_mesh_color_ensure(me, nullptr); BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->vpaint); Paint *paint = BKE_paint_get_active_from_paintmode(scene, paint_mode); @@ -1336,7 +1336,7 @@ static void ed_vwpaintmode_enter_generic( if (ob->sculpt) { if (ob->sculpt->cache) { SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } BKE_sculptsession_free(ob); } @@ -1351,7 +1351,7 @@ void ED_object_vpaintmode_enter_ex(Main *bmain, Depsgraph *depsgraph, Scene *sce { ed_vwpaintmode_enter_generic(bmain, depsgraph, scene, ob, OB_MODE_VERTEX_PAINT); } -void ED_object_vpaintmode_enter(struct bContext *C, Depsgraph *depsgraph) +void ED_object_vpaintmode_enter(bContext *C, Depsgraph *depsgraph) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -1363,7 +1363,7 @@ void ED_object_wpaintmode_enter_ex(Main *bmain, Depsgraph *depsgraph, Scene *sce { ed_vwpaintmode_enter_generic(bmain, depsgraph, scene, ob, OB_MODE_WEIGHT_PAINT); } -void ED_object_wpaintmode_enter(struct bContext *C, Depsgraph *depsgraph) +void ED_object_wpaintmode_enter(bContext *C, Depsgraph *depsgraph) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); @@ -1405,7 +1405,7 @@ static void ed_vwpaintmode_exit_generic(Object *ob, const eObjectMode mode_flag) /* If the cache is not released by a cancel or a done, free it now. */ if (ob->sculpt && ob->sculpt->cache) { SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } BKE_sculptsession_free(ob); @@ -1428,7 +1428,7 @@ void ED_object_vpaintmode_exit_ex(Object *ob) { ed_vwpaintmode_exit_generic(ob, OB_MODE_VERTEX_PAINT); } -void ED_object_vpaintmode_exit(struct bContext *C) +void ED_object_vpaintmode_exit(bContext *C) { Object *ob = CTX_data_active_object(C); ED_object_vpaintmode_exit_ex(ob); @@ -1438,7 +1438,7 @@ void ED_object_wpaintmode_exit_ex(Object *ob) { ed_vwpaintmode_exit_generic(ob, OB_MODE_WEIGHT_PAINT); } -void ED_object_wpaintmode_exit(struct bContext *C) +void ED_object_wpaintmode_exit(bContext *C) { Object *ob = CTX_data_active_object(C); ED_object_wpaintmode_exit_ex(ob); @@ -1505,7 +1505,7 @@ static int wpaint_mode_toggle_exec(bContext *C, wmOperator *op) static bool paint_mode_toggle_poll_test(bContext *C) { Object *ob = CTX_data_active_object(C); - if (ob == NULL || ob->type != OB_MESH) { + if (ob == nullptr || ob->type != OB_MESH) { return false; } if (!ob->data || ID_IS_LINKED(ob->data)) { @@ -1538,9 +1538,9 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) struct WPaintData { ViewContext vc; - struct NormalAnglePrecalc normal_angle_precalc; + NormalAnglePrecalc normal_angle_precalc; - struct WeightPaintGroupData active, mirror; + WeightPaintGroupData active, mirror; /* variables for auto normalize */ const bool *vgroup_validmap; /* stores if vgroups tie to deforming bones or not */ @@ -1647,7 +1647,7 @@ static void vwpaint_update_cache_invariants( /* Truly temporary data that isn't stored in properties */ cache->vc = vc; cache->brush = brush; - cache->first_time = 1; + cache->first_time = true; /* cache projection matrix */ ED_view3d_ob_project_mat_get(cache->vc->rv3d, ob, cache->projection_mat); @@ -1714,12 +1714,12 @@ static void vwpaint_update_cache_variants(bContext *C, VPaint *vp, Object *ob, P static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2]) { Scene *scene = CTX_data_scene(C); - struct PaintStroke *stroke = (PaintStroke *)op->customdata; + PaintStroke *stroke = (PaintStroke *)op->customdata; ToolSettings *ts = scene->toolsettings; Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); - struct WPaintData *wpd; - struct WPaintVGroupIndex vgroup_index; + WPaintData *wpd; + WPaintVGroupIndex vgroup_index; int defbase_tot, defbase_tot_sel; bool *defbase_sel; SculptSession *ss = ob->sculpt; @@ -1775,7 +1775,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo /* ALLOCATIONS! no return after this line */ /* make mode data storage */ - wpd = (WPaintData *)MEM_callocN(sizeof(struct WPaintData), "WPaintData"); + wpd = (WPaintData *)MEM_callocN(sizeof(WPaintData), "WPaintData"); paint_stroke_set_mode_data(stroke, wpd); ED_view3d_viewcontext_init(C, &wpd->vc, depsgraph); view_angle_limits_init(&wpd->normal_angle_precalc, @@ -1854,7 +1854,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo wpd->precomputed_weight = (float *)MEM_mallocN(sizeof(float) * me->totvert, __func__); } - if (ob->sculpt->mode.wpaint.dvert_prev != NULL) { + if (ob->sculpt->mode.wpaint.dvert_prev != nullptr) { MDeformVert *dv = ob->sculpt->mode.wpaint.dvert_prev; for (int i = 0; i < me->totvert; i++, dv++) { /* Use to show this isn't initialized, never apply to the mesh data. */ @@ -1910,7 +1910,7 @@ static void do_wpaint_precompute_weight_cb_ex(void *__restrict userdata, } static void precompute_weight_values( - bContext *C, Object *ob, Brush *brush, struct WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me) + bContext *C, Object *ob, Brush *brush, WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me) { if (wpd->precomputed_weight_ready && !brush_use_accumulate_ex(brush, ob->mode)) { return; @@ -1939,7 +1939,7 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata, SculptSession *ss = data->ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap; const Brush *brush = data->brush; const StrokeCache *cache = ss->cache; @@ -2030,7 +2030,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata, SculptSession *ss = data->ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.wpaint.gmap; const Brush *brush = data->brush; const Scene *scene = CTX_data_scene(data->C); @@ -2217,7 +2217,7 @@ static void do_wpaint_brush_calc_average_weight_cb_ex( const bool use_face_sel = (data->me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (data->me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; - struct WPaintAverageAccum *accum = (struct WPaintAverageAccum *)data->custom_data + n; + WPaintAverageAccum *accum = (WPaintAverageAccum *)data->custom_data + n; accum->len = 0; accum->value = 0.0; @@ -2256,8 +2256,8 @@ static void calculate_average_weight(SculptThreadedTaskData *data, PBVHNode **UNUSED(nodes), int totnode) { - struct WPaintAverageAccum *accum = (WPaintAverageAccum *)MEM_mallocN(sizeof(*accum) * totnode, - __func__); + WPaintAverageAccum *accum = (WPaintAverageAccum *)MEM_mallocN(sizeof(*accum) * totnode, + __func__); data->custom_data = accum; TaskParallelSettings settings; @@ -2282,7 +2282,7 @@ static void wpaint_paint_leaves(bContext *C, Object *ob, Sculpt *sd, VPaint *vp, - struct WPaintData *wpd, + WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me, PBVHNode **nodes, @@ -2292,7 +2292,7 @@ static void wpaint_paint_leaves(bContext *C, const Brush *brush = ob->sculpt->cache->brush; /* threaded loop over nodes */ - SculptThreadedTaskData data = {0}; + SculptThreadedTaskData data = {nullptr}; data.C = C; data.sd = sd; data.ob = ob; @@ -2333,11 +2333,11 @@ static PBVHNode **vwpaint_pbvh_gather_generic( { SculptSession *ss = ob->sculpt; const bool use_normal = vwpaint_use_normal(wp); - PBVHNode **nodes = NULL; + PBVHNode **nodes = nullptr; /* Build a list of all nodes that are potentially within the brush's area of influence */ if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_SPHERE) { - SculptSearchSphereData data = {0}; + SculptSearchSphereData data = {nullptr}; data.ss = ss; data.sd = sd; data.radius_squared = ss->cache->radius_squared; @@ -2353,10 +2353,10 @@ static PBVHNode **vwpaint_pbvh_gather_generic( } } else { - struct DistRayAABB_Precalc dist_ray_to_aabb_precalc; + DistRayAABB_Precalc dist_ray_to_aabb_precalc; dist_squared_ray_to_aabb_v3_precalc( &dist_ray_to_aabb_precalc, ss->cache->location, ss->cache->view_normal); - SculptSearchCircleData data = {0}; + SculptSearchCircleData data = {nullptr}; data.ss = ss; data.sd = sd; data.radius_squared = ss->cache->radius_squared; @@ -2378,7 +2378,7 @@ static void wpaint_do_paint(bContext *C, Object *ob, VPaint *wp, Sculpt *sd, - struct WPaintData *wpd, + WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me, Brush *brush, @@ -2405,7 +2405,7 @@ static void wpaint_do_radial_symmetry(bContext *C, Object *ob, VPaint *wp, Sculpt *sd, - struct WPaintData *wpd, + WPaintData *wpd, WeightPaintInfo *wpi, Mesh *me, Brush *brush, @@ -2421,7 +2421,7 @@ static void wpaint_do_radial_symmetry(bContext *C, /* near duplicate of: sculpt.c's, * 'do_symmetrical_brush_actions' and 'vpaint_do_symmetrical_brush_actions'. */ static void wpaint_do_symmetrical_brush_actions( - bContext *C, Object *ob, VPaint *wp, Sculpt *sd, struct WPaintData *wpd, WeightPaintInfo *wpi) + bContext *C, Object *ob, VPaint *wp, Sculpt *sd, WPaintData *wpd, WeightPaintInfo *wpi) { Brush *brush = BKE_paint_brush(&wp->paint); Mesh *me = (Mesh *)ob->data; @@ -2474,14 +2474,14 @@ static void wpaint_do_symmetrical_brush_actions( static void wpaint_stroke_update_step(bContext *C, wmOperator *UNUSED(op), - struct PaintStroke *stroke, + PaintStroke *stroke, PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); VPaint *wp = ts->wpaint; Brush *brush = BKE_paint_brush(&wp->paint); - struct WPaintData *wpd = (WPaintData *)paint_stroke_mode_data(stroke); + WPaintData *wpd = (WPaintData *)paint_stroke_mode_data(stroke); ViewContext *vc; Object *ob = CTX_data_active_object(C); @@ -2494,11 +2494,11 @@ static void wpaint_stroke_update_step(bContext *C, const float brush_alpha_value = BKE_brush_alpha_get(scene, brush); - /* intentionally don't initialize as NULL, make sure we initialize all members below */ + /* intentionally don't initialize as nullptr, make sure we initialize all members below */ WeightPaintInfo wpi; /* cannot paint if there is no stroke data */ - if (wpd == NULL) { + if (wpd == nullptr) { /* XXX: force a redraw here, since even though we can't paint, * at least view won't freeze until stroke ends */ ED_region_tag_redraw(CTX_wm_region(C)); @@ -2528,7 +2528,7 @@ static void wpaint_stroke_update_step(bContext *C, wpi.vgroup_unlocked = wpd->vgroup_unlocked; wpi.do_flip = RNA_boolean_get(itemptr, "pen_flip") || ss->cache->invert; wpi.do_multipaint = wpd->do_multipaint; - wpi.do_auto_normalize = ((ts->auto_normalize != 0) && (wpi.vgroup_validmap != NULL) && + wpi.do_auto_normalize = ((ts->auto_normalize != 0) && (wpi.vgroup_validmap != nullptr) && (wpi.do_multipaint || wpi.vgroup_validmap[wpi.active.index])); wpi.do_lock_relative = wpd->do_lock_relative; wpi.is_normalized = wpi.do_auto_normalize || wpi.do_lock_relative; @@ -2577,10 +2577,10 @@ static void wpaint_stroke_update_step(bContext *C, ED_region_tag_redraw_partial(vc->region, &r, true); } -static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) +static void wpaint_stroke_done(const bContext *C, PaintStroke *stroke) { Object *ob = CTX_data_active_object(C); - struct WPaintData *wpd = (WPaintData *)paint_stroke_mode_data(stroke); + WPaintData *wpd = (WPaintData *)paint_stroke_mode_data(stroke); if (wpd) { if (wpd->defbase_sel) { @@ -2639,7 +2639,7 @@ static void wpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -2651,7 +2651,7 @@ static int wpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) SCULPT_stroke_get_location, wpaint_stroke_test_start, wpaint_stroke_update_step, - NULL, + nullptr, wpaint_stroke_done, event->type); @@ -2675,7 +2675,7 @@ static int wpaint_exec(bContext *C, wmOperator *op) SCULPT_stroke_get_location, wpaint_stroke_test_start, wpaint_stroke_update_step, - NULL, + nullptr, wpaint_stroke_done, 0); @@ -2690,7 +2690,7 @@ static void wpaint_cancel(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (ob->sculpt->cache) { SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } paint_stroke_cancel(C, op, (PaintStroke *)op->customdata); @@ -2698,7 +2698,7 @@ static void wpaint_cancel(bContext *C, wmOperator *op) static int wpaint_modal(bContext *C, wmOperator *op, const wmEvent *event) { - return paint_stroke_modal(C, op, event, (struct PaintStroke **)&op->customdata); + return paint_stroke_modal(C, op, event, (PaintStroke **)&op->customdata); } void PAINT_OT_weight_paint(wmOperatorType *ot) @@ -2821,12 +2821,12 @@ struct VPaintDataBase { template struct VPaintData : public VPaintDataBase { - struct NormalAnglePrecalc normal_angle_precalc; + NormalAnglePrecalc normal_angle_precalc; Color paintcol; struct VertProjHandle *vp_handle; - struct CoNo *vertexcosnos; + CoNo *vertexcosnos; /** * Modify #Mesh.mloopcol directly, since the derived mesh is drawing from this @@ -2849,7 +2849,7 @@ struct VPaintData : public VPaintDataBase { template static void *vpaint_init_vpaint(bContext *C, - struct wmOperator *op, + wmOperator *op, Scene *scene, Depsgraph *depsgraph, VPaint *vp, @@ -2916,11 +2916,11 @@ static void *vpaint_init_vpaint(bContext *C, return static_cast(vpd); } -static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const float mouse[2]) +static bool vpaint_stroke_test_start(bContext *C, wmOperator *op, const float mouse[2]) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; - struct PaintStroke *stroke = (PaintStroke *)op->customdata; + PaintStroke *stroke = (PaintStroke *)op->customdata; VPaint *vp = ts->vpaint; Brush *brush = BKE_paint_brush(&vp->paint); Object *ob = CTX_data_active_object(C); @@ -2930,11 +2930,11 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f /* context checks could be a poll() */ me = BKE_mesh_from_object(ob); - if (me == NULL || me->totpoly == 0) { + if (me == nullptr || me->totpoly == 0) { return false; } - ED_mesh_color_ensure(me, NULL); + ED_mesh_color_ensure(me, nullptr); CustomDataLayer *layer = BKE_id_attributes_active_color_get(&me->id); if (!layer) { @@ -3002,7 +3002,7 @@ static void do_vpaint_brush_blur_loops(bContext *C, const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; const StrokeCache *cache = ss->cache; float brush_size_pressure, brush_alpha_value, brush_alpha_pressure; get_brush_alpha_data( @@ -3088,9 +3088,9 @@ static void do_vpaint_brush_blur_loops(bContext *C, BLI_assert(me->mloop[l_index].v == v_index); const MPoly *mp = &me->mpoly[p_index]; if (!use_face_sel || mp->flag & ME_FACE_SEL) { - Color color_orig(0, 0, 0, 0); /* unused when array is NULL */ + Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */ - if (previous_color != NULL) { + if (previous_color != nullptr) { /* Get the previous loop color */ if (isZero(previous_color[l_index])) { previous_color[l_index] = lcol[l_index]; @@ -3144,7 +3144,7 @@ static void do_vpaint_brush_blur_verts(bContext *C, const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; const StrokeCache *cache = ss->cache; float brush_size_pressure, brush_alpha_value, brush_alpha_pressure; get_brush_alpha_data( @@ -3233,9 +3233,9 @@ static void do_vpaint_brush_blur_verts(bContext *C, const MPoly *mp = &me->mpoly[p_index]; if (!use_face_sel || mp->flag & ME_FACE_SEL) { - Color color_orig(0, 0, 0, 0); /* unused when array is NULL */ + Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */ - if (previous_color != NULL) { + if (previous_color != nullptr) { /* Get the previous loop color */ if (isZero(previous_color[v_index])) { previous_color[v_index] = lcol[v_index]; @@ -3277,7 +3277,7 @@ static void do_vpaint_brush_smear(bContext *C, { SculptSession *ss = ob->sculpt; - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; const StrokeCache *cache = ss->cache; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); @@ -3411,9 +3411,9 @@ static void do_vpaint_brush_smear(bContext *C, const MPoly *mp = &me->mpoly[p_index]; if (!use_face_sel || mp->flag & ME_FACE_SEL) { /* Get the previous element color */ - Color color_orig(0, 0, 0, 0); /* unused when array is NULL */ + Color color_orig(0, 0, 0, 0); /* unused when array is nullptr */ - if (color_prev != NULL) { + if (color_prev != nullptr) { /* Get the previous element color */ if (isZero(color_prev[elem_index])) { color_prev[elem_index] = lcol[elem_index]; @@ -3455,20 +3455,20 @@ static void calculate_average_color(VPaintData *vpd, { using Blend = typename Traits::BlendType; - struct VPaintAverageAccum *accum = (VPaintAverageAccum *)MEM_mallocN( + VPaintAverageAccum *accum = (VPaintAverageAccum *)MEM_mallocN( sizeof(*accum) * totnode, __func__); blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) { for (int n : range) { SculptSession *ss = ob->sculpt; const PBVHType pbvh_type = BKE_pbvh_type(ss->pbvh); const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; StrokeCache *cache = ss->cache; const bool use_vert_sel = (me->editflag & (ME_EDIT_PAINT_FACE_SEL | ME_EDIT_PAINT_VERT_SEL)) != 0; - struct VPaintAverageAccum *accum2 = accum + n; + VPaintAverageAccum *accum2 = accum + n; accum2->len = 0; memset(accum2->value, 0, sizeof(accum2->value)); @@ -3574,7 +3574,7 @@ static void vpaint_do_draw(bContext *C, blender::threading::parallel_for(IndexRange(totnode), 1LL, [&](IndexRange range) { for (int n : range) { const bool has_grids = (pbvh_type == PBVH_GRIDS); - const struct SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; + const SculptVertexPaintGeomMap *gmap = &ss->mode.vpaint.gmap; const StrokeCache *cache = ss->cache; float brush_size_pressure, brush_alpha_value, brush_alpha_pressure; @@ -3636,7 +3636,7 @@ static void vpaint_do_draw(bContext *C, if constexpr (domain == ATTR_DOMAIN_POINT) { int v_index = vd.index; - if (previous_color != NULL) { + if (previous_color != nullptr) { /* Get the previous loop color */ if (isZero(previous_color[v_index])) { previous_color[v_index] = lcol[v_index]; @@ -3661,9 +3661,9 @@ static void vpaint_do_draw(bContext *C, BLI_assert(me->mloop[l_index].v == v_index); const MPoly *mp = &me->mpoly[p_index]; if (!use_face_sel || mp->flag & ME_FACE_SEL) { - Color color_orig = Color(0, 0, 0, 0); /* unused when array is NULL */ + Color color_orig = Color(0, 0, 0, 0); /* unused when array is nullptr */ - if (previous_color != NULL) { + if (previous_color != nullptr) { /* Get the previous loop color */ if (isZero(previous_color[l_index])) { previous_color[l_index] = lcol[l_index]; @@ -3845,9 +3845,7 @@ static void vpaint_do_symmetrical_brush_actions( } template -static void vpaint_stroke_update_step_intern(bContext *C, - struct PaintStroke *stroke, - PointerRNA *itemptr) +static void vpaint_stroke_update_step_intern(bContext *C, PaintStroke *stroke, PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); @@ -3907,7 +3905,7 @@ static void vpaint_stroke_update_step_intern(bContext *C, static void vpaint_stroke_update_step(bContext *C, wmOperator *UNUSED(op), - struct PaintStroke *stroke, + PaintStroke *stroke, PointerRNA *itemptr) { VPaintDataBase *vpd = static_cast(paint_stroke_mode_data(stroke)); @@ -3956,7 +3954,7 @@ static void vpaint_free_vpaintdata(Object *UNUSED(ob), void *_vpd) MEM_delete>(vpd); } -static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) +static void vpaint_stroke_done(const bContext *C, PaintStroke *stroke) { void *vpd_ptr = paint_stroke_mode_data(stroke); VPaintDataBase *vpd = static_cast(vpd_ptr); @@ -3994,7 +3992,7 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) SCULPT_undo_push_end(ob); SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -4006,7 +4004,7 @@ static int vpaint_invoke(bContext *C, wmOperator *op, const wmEvent *event) SCULPT_stroke_get_location, vpaint_stroke_test_start, vpaint_stroke_update_step, - NULL, + nullptr, vpaint_stroke_done, event->type); @@ -4039,7 +4037,7 @@ static int vpaint_exec(bContext *C, wmOperator *op) SCULPT_stroke_get_location, vpaint_stroke_test_start, vpaint_stroke_update_step, - NULL, + nullptr, vpaint_stroke_done, 0); @@ -4054,7 +4052,7 @@ static void vpaint_cancel(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (ob->sculpt->cache) { SCULPT_cache_free(ob->sculpt->cache); - ob->sculpt->cache = NULL; + ob->sculpt->cache = nullptr; } paint_stroke_cancel(C, op, (PaintStroke *)op->customdata); @@ -4062,7 +4060,7 @@ static void vpaint_cancel(bContext *C, wmOperator *op) static int vpaint_modal(bContext *C, wmOperator *op, const wmEvent *event) { - return paint_stroke_modal(C, op, event, (struct PaintStroke **)&op->customdata); + return paint_stroke_modal(C, op, event, (PaintStroke **)&op->customdata); } void PAINT_OT_vertex_paint(wmOperatorType *ot) @@ -4093,7 +4091,8 @@ template static bool vertex_color_set(Object *ob, ColorPaint4f paintcol_in, Color *color_layer) { Mesh *me; - if (((me = BKE_mesh_from_object(ob)) == NULL) || (ED_mesh_color_ensure(me, NULL) == false)) { + if (((me = BKE_mesh_from_object(ob)) == nullptr) || + (ED_mesh_color_ensure(me, nullptr) == false)) { return false; } -- cgit v1.2.3