From 27e86ed8324c5cc72e58f61231018b6c77689f03 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Mar 2014 22:56:28 +1100 Subject: Code cleanup: use bools --- source/blender/modifiers/intern/MOD_array.c | 4 +- source/blender/modifiers/intern/MOD_mask.c | 12 ++-- .../modifiers/intern/MOD_particleinstance.c | 8 +-- source/blender/modifiers/intern/MOD_skin.c | 77 +++++++++++----------- source/blender/modifiers/intern/MOD_solidify.c | 2 +- source/blender/modifiers/intern/MOD_weightvgmix.c | 2 +- .../modifiers/intern/MOD_weightvgproximity.c | 6 +- 7 files changed, 57 insertions(+), 54 deletions(-) (limited to 'source/blender/modifiers') diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 1f233cc5492..694b66b5076 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -385,7 +385,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if (cu) { #ifdef CYCLIC_DEPENDENCY_WORKAROUND if (amd->curve_ob->curve_cache == NULL) { - BKE_displist_make_curveTypes(scene, amd->curve_ob, FALSE); + BKE_displist_make_curveTypes(scene, amd->curve_ob, false); } #endif @@ -528,7 +528,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /* start capping */ if (start_cap || end_cap) { - BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, false); if (start_cap) { float startoffset[4][4]; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index f3672287d70..0a1ca6e52c4 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -150,7 +150,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, Object *oba = mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; - char *bone_select_array; + bool *bone_select_array; int bone_select_tot = 0; const int defbase_tot = BLI_countlist(&ob->defbase); @@ -167,11 +167,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { pchan = BKE_pose_channel_find_name(oba->pose, def->name); if (pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED)) { - bone_select_array[i] = TRUE; + bone_select_array[i] = true; bone_select_tot++; } else { - bone_select_array[i] = FALSE; + bone_select_array[i] = false; } } @@ -194,7 +194,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (dw->def_nr < defbase_tot) { if (bone_select_array[dw->def_nr]) { if (dw->weight != 0.0f) { - found = TRUE; + found = true; break; } } @@ -263,12 +263,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, for (i = 0; i < maxPolys; i++) { MPoly *mp = &mpoly[i]; MLoop *ml = mloop + mp->loopstart; - int ok = TRUE; + bool ok = true; int j; for (j = 0; j < mp->totloop; j++, ml++) { if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(ml->v))) { - ok = FALSE; + ok = false; break; } } diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 3928687c006..7aa81d6a003 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -80,11 +80,11 @@ static bool isDisabled(ModifierData *md, int useRenderParams) ModifierData *ob_md; if (!pimd->ob) - return TRUE; + return true; psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); if (psys == NULL) - return TRUE; + return true; /* If the psys modifier is disabled we cannot use its data. * First look up the psys modifier from the object, then check if it is enabled. @@ -99,14 +99,14 @@ static bool isDisabled(ModifierData *md, int useRenderParams) else required_mode = eModifierMode_Realtime; if (!modifier_isEnabled(md->scene, ob_md, required_mode)) - return TRUE; + return true; break; } } } - return FALSE; + return false; } diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 07be90b9ce1..8afcc5a9c9e 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -111,9 +111,9 @@ typedef struct Frame { } merge[4]; /* For hull frames, whether each vertex is detached or not */ - int inside_hull[4]; + bool inside_hull[4]; /* Whether any part of the frame (corner or edge) is detached */ - int detached; + bool detached; } Frame; #define MAX_SKIN_NODE_FRAMES 2 @@ -174,34 +174,35 @@ static bool is_quad_symmetric(BMVert *quad[4], } /* Returns true if the quad crosses the plane of symmetry, false otherwise */ -static int quad_crosses_symmetry_plane(BMVert *quad[4], - const SkinModifierData *smd) +static bool quad_crosses_symmetry_plane(BMVert *quad[4], + const SkinModifierData *smd) { int axis; for (axis = 0; axis < 3; axis++) { if (smd->symmetry_axes & (1 << axis)) { - int i, left = FALSE, right = FALSE; + bool left = false, right = false; + int i; for (i = 0; i < 4; i++) { if (quad[i]->co[axis] < 0.0f) - left = TRUE; + left = true; else if (quad[i]->co[axis] > 0.0f) - right = TRUE; + right = true; if (left && right) - return TRUE; + return true; } } } - return FALSE; + return false; } /* Returns true if the frame is filled by precisely two faces (and * outputs those faces to fill_faces), otherwise returns false. */ -static int skin_frame_find_contained_faces(const Frame *frame, - BMFace *fill_faces[2]) +static bool skin_frame_find_contained_faces(const Frame *frame, + BMFace *fill_faces[2]) { BMEdge *diag; @@ -213,11 +214,11 @@ static int skin_frame_find_contained_faces(const Frame *frame, if (diag) return BM_edge_face_pair(diag, &fill_faces[0], &fill_faces[1]); else - return FALSE; + return false; } -/* Returns TRUE if hull is successfully built, FALSE otherwise */ -static int build_hull(SkinOutput *so, Frame **frames, int totframe) +/* Returns true if hull is successfully built, FALSE otherwise */ +static bool build_hull(SkinOutput *so, Frame **frames, int totframe) { BMesh *bm = so->bm; BMOperator op; @@ -228,7 +229,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) BMEdge *e; int i, j; - BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); for (i = 0; i < totframe; i++) { for (j = 0; j < 4; j++) { @@ -246,7 +247,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) if (BMO_error_occurred(bm)) { BMO_op_finish(bm, &op); - return FALSE; + return false; } /* Apply face attributes to hull output */ @@ -264,8 +265,8 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) if (!frame->detached) { for (j = 0; j < 4; j++) { if (frame->verts[j] == v) { - frame->inside_hull[j] = TRUE; - frame->detached = TRUE; + frame->inside_hull[j] = true; + frame->detached = true; break; } } @@ -283,7 +284,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) !BM_edge_exists(frame->verts[2], frame->verts[3]) || !BM_edge_exists(frame->verts[3], frame->verts[0]))) { - frame->detached = TRUE; + frame->detached = true; } } @@ -304,7 +305,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) BM_elem_flag_enable(fill_faces[1], BM_ELEM_TAG); } else - frame->detached = TRUE; + frame->detached = true; } } @@ -326,7 +327,7 @@ static int build_hull(SkinOutput *so, Frame **frames, int totframe) BM_mesh_delete_hflag_tagged(bm, BM_ELEM_TAG, BM_EDGE | BM_FACE); - return TRUE; + return true; } /* Returns the average frame side length (frames are rectangular, so @@ -660,7 +661,7 @@ static void build_emats_stack(BLI_Stack *stack, int *visited_e, EMat *emat, return; /* Mark edge as visited */ - visited_e[e] = TRUE; + visited_e[e] = true; /* Process edge */ @@ -1036,7 +1037,7 @@ static int isect_ray_poly(const float ray_start[3], BMVert *v, *v_first = NULL, *v_prev = NULL; BMIter iter; float best_dist = FLT_MAX; - int hit = 0; + bool hit = false; BM_ITER_ELEM (v, &iter, f, BM_VERTS_OF_FACE) { if (!v_first) @@ -1049,7 +1050,7 @@ static int isect_ray_poly(const float ray_start[3], v_first->co, v_prev->co, v->co, &dist, NULL); if (curhit && dist < best_dist) { - hit = TRUE; + hit = true; best_dist = dist; } } @@ -1104,15 +1105,16 @@ static BMFace *collapse_face_corners(BMesh *bm, BMFace *f, int n, /* Find the new face */ f = NULL; BM_ITER_ELEM (vf, &iter, v_safe, BM_FACES_OF_VERT) { - int wrong_face = FALSE; + bool wrong_face = false; for (i = 0; i < orig_len; i++) { - if (orig_verts[i] == v_merge) + if (orig_verts[i] == v_merge) { orig_verts[i] = NULL; + } else if (orig_verts[i] && !BM_vert_in_face(vf, orig_verts[i])) { - wrong_face = TRUE; + wrong_face = true; break; } } @@ -1228,7 +1230,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f BLI_assert(split_face->len >= 3); /* Extrude the split face */ - BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_FACE, BM_ELEM_TAG, false); BM_elem_flag_enable(split_face, BM_ELEM_TAG); BMO_op_initf(bm, &op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "extrude_discrete_faces faces=%hf", BM_ELEM_TAG); @@ -1251,7 +1253,7 @@ static void skin_fix_hole_no_good_verts(BMesh *bm, Frame *frame, BMFace *split_f * face is a triangle */ longest_edge = BM_face_find_longest_loop(split_face)->e; - BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_EDGE, BM_ELEM_TAG, false); BM_elem_flag_enable(longest_edge, BM_ELEM_TAG); BMO_op_callf(bm, BMO_FLAG_DEFAULTS, @@ -1378,7 +1380,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) heap = BLI_heap_new(); - BM_mesh_elem_hflag_disable_all(so->bm, BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(so->bm, BM_FACE, BM_ELEM_TAG, false); /* Build heap */ BM_ITER_MESH (e, &iter, so->bm, BM_EDGES_OF_MESH) { @@ -1612,7 +1614,7 @@ static void skin_smooth_hulls(BMesh *bm, SkinNode *skin_nodes, return; /* Mark all frame vertices */ - BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm, BM_VERT, BM_ELEM_TAG, false); for (i = 0; i < totvert; i++) { for (j = 0; j < skin_nodes[i].totframe; j++) { Frame *frame = &skin_nodes[i].frames[j]; @@ -1662,12 +1664,13 @@ static void skin_smooth_hulls(BMesh *bm, SkinNode *skin_nodes, BM_data_layer_free_n(bm, &bm->vdata, CD_SHAPEKEY, skey); } -/* Returns TRUE if all hulls are successfully built, FALSE otherwise */ -static int skin_output_branch_hulls(SkinOutput *so, SkinNode *skin_nodes, - int totvert, const MeshElemMap *emap, - const MEdge *medge) +/* Returns TRUE if all hulls are successfully built, false otherwise */ +static bool skin_output_branch_hulls(SkinOutput *so, SkinNode *skin_nodes, + int totvert, const MeshElemMap *emap, + const MEdge *medge) { - int result = TRUE, v; + bool result = true; + int v; for (v = 0; v < totvert; v++) { SkinNode *sn = &skin_nodes[v]; @@ -1681,7 +1684,7 @@ static int skin_output_branch_hulls(SkinOutput *so, SkinNode *skin_nodes, emap, medge, &tothullframe); if (!build_hull(so, hull_frames, tothullframe)) - result = FALSE; + result = false; MEM_freeN(hull_frames); } diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 83b53e208c0..721a77df29c 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -720,7 +720,7 @@ static DerivedMesh *applyModifier( CustomData_copy_data(&dm->loopData, &result->loopData, k1, (int)(numLoops * 2 + j + 2), 1); CustomData_copy_data(&dm->loopData, &result->loopData, k2, (int)(numLoops * 2 + j + 3), 1); - if (flip == FALSE) { + if (flip == false) { ml[j].v = ed->v1; ml[j++].e = eidx; diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index b4be0f75f81..cc930213cb5 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -380,7 +380,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Update (add to) vgroup. * XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup. */ - weightvg_update_vg(dvert, defgrp_index, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f); + weightvg_update_vg(dvert, defgrp_index, dw1, numIdx, indices, org_w, true, -FLT_MAX, false, 0.0f); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 8115cdaa640..b2ba495d043 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -465,7 +465,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (use_trgt_verts || use_trgt_edges || use_trgt_faces) { DerivedMesh *target_dm = obr->derivedFinal; - short free_target_dm = FALSE; + bool free_target_dm = false; if (!target_dm) { if (ELEM3(obr->type, OB_CURVE, OB_SURF, OB_FONT)) target_dm = CDDM_from_curve(obr); @@ -476,7 +476,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der else target_dm = CDDM_from_mesh(me); } - free_target_dm = TRUE; + free_target_dm = true; } /* We must check that we do have a valid target_dm! */ @@ -521,7 +521,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ - weightvg_update_vg(dvert, defgrp_index, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); + weightvg_update_vg(dvert, defgrp_index, dw, numIdx, indices, org_w, false, 0.0f, false, 0.0f); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ -- cgit v1.2.3