From a4667fbb3d9715aff1df54faba2c145d815ee810 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Aug 2024 13:16:26 +1000 Subject: [PATCH] Cleanup: use bool instead of int for a boolean array --- source/blender/editors/armature/armature_skinning.cc | 12 ++++++------ source/blender/editors/armature/meshlaplacian.cc | 4 ++-- source/blender/editors/armature/meshlaplacian.h | 2 +- .../editors/gpencil_legacy/gpencil_armature.cc | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/blender/editors/armature/armature_skinning.cc b/source/blender/editors/armature/armature_skinning.cc index fd1dfade162..bebce422724 100644 --- a/source/blender/editors/armature/armature_skinning.cc +++ b/source/blender/editors/armature/armature_skinning.cc @@ -197,7 +197,7 @@ static void envelope_bone_weighting(Object *ob, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - const int *selected, + const bool *selected, float scale) { using namespace blender; @@ -226,7 +226,7 @@ static void envelope_bone_weighting(Object *ob, /* for each skinnable bone */ for (int j = 0; j < numbones; j++) { - if (!selected[j]) { + if (selected[j] == false) { continue; } @@ -290,7 +290,7 @@ static void add_verts_to_dgroups(ReportList *reports, Mesh *mesh; Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = nullptr; float(*root)[3], (*tip)[3], (*verts)[3]; - int *selected; + bool *selected; int numbones, vertsfilled = 0, segments = 0; const bool wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { @@ -338,7 +338,7 @@ static void add_verts_to_dgroups(ReportList *reports, * global coords */ root = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "root")); tip = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "tip")); - selected = static_cast(MEM_callocN(sizeof(int) * numbones, "selected")); + selected = static_cast(MEM_callocN(sizeof(bool) * numbones, "selected")); for (int j = 0; j < numbones; j++) { bone = bonelist[j]; @@ -383,11 +383,11 @@ static void add_verts_to_dgroups(ReportList *reports, /* set selected */ if (wpmode) { if (ANIM_bone_in_visible_collection(arm, bone) && (bone->flag & BONE_SELECTED)) { - selected[j] = 1; + selected[j] = true; } } else { - selected[j] = 1; + selected[j] = true; } /* find flipped group */ diff --git a/source/blender/editors/armature/meshlaplacian.cc b/source/blender/editors/armature/meshlaplacian.cc index 7b47fe0c088..93d0e8b353d 100644 --- a/source/blender/editors/armature/meshlaplacian.cc +++ b/source/blender/editors/armature/meshlaplacian.cc @@ -635,7 +635,7 @@ void heat_bone_weighting(Object *ob, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - const int *selected, + const bool *selected, const char **r_error_str) { using namespace blender; @@ -722,7 +722,7 @@ void heat_bone_weighting(Object *ob, /* compute weights per bone */ for (j = 0; j < numbones; j++) { - if (!selected[j]) { + if (selected[j] == false) { continue; } diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 7bc4a311fa0..65ee82fbe36 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -46,7 +46,7 @@ void heat_bone_weighting(struct Object *ob, struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - const int *selected, + const bool *selected, const char **r_error_str); #ifdef RIGID_DEFORM diff --git a/source/blender/editors/gpencil_legacy/gpencil_armature.cc b/source/blender/editors/gpencil_legacy/gpencil_armature.cc index 0b059c4f242..ec7768fed03 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_armature.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_armature.cc @@ -259,7 +259,7 @@ static void gpencil_add_verts_to_dgroups( Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = nullptr; float(*root)[3], (*tip)[3], (*verts)[3]; float *radsqr; - int *selected; + bool *selected; float weight; int numbones, i, j, segments = 0; struct { @@ -301,7 +301,7 @@ static void gpencil_add_verts_to_dgroups( * global coords */ root = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "root")); tip = static_cast(MEM_callocN(sizeof(float[3]) * numbones, "tip")); - selected = static_cast(MEM_callocN(sizeof(int) * numbones, "selected")); + selected = static_cast(MEM_callocN(sizeof(bool) * numbones, "selected")); radsqr = static_cast(MEM_callocN(sizeof(float) * numbones, "radsqr")); for (j = 0; j < numbones; j++) { @@ -341,7 +341,7 @@ static void gpencil_add_verts_to_dgroups( mul_m4_v3(ob_arm->object_to_world().ptr(), root[j]); mul_m4_v3(ob_arm->object_to_world().ptr(), tip[j]); - selected[j] = 1; + selected[j] = true; /* calculate radius squared */ radsqr[j] = len_squared_v3v3(root[j], tip[j]) * ratio;