From f5e55c33378b96e614710006121860eb880e6820 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 2 Sep 2020 19:10:18 +0200 Subject: [PATCH] Cleanup: use bool instead of int in various places --- source/blender/blenkernel/BKE_DerivedMesh.h | 4 +- source/blender/blenkernel/BKE_colorband.h | 2 +- source/blender/blenkernel/BKE_colortools.h | 2 +- source/blender/blenkernel/BKE_fcurve.h | 2 +- source/blender/blenkernel/BKE_image.h | 8 +-- source/blender/blenkernel/BKE_object.h | 8 +-- .../blender/blenkernel/intern/DerivedMesh.c | 6 +- source/blender/blenkernel/intern/cloth.c | 48 +++++++------- source/blender/blenkernel/intern/colorband.c | 12 ++-- source/blender/blenkernel/intern/colortools.c | 30 +++++---- source/blender/blenkernel/intern/customdata.c | 24 ++++--- .../blenkernel/intern/customdata_file.c | 62 +++++++++---------- .../blender/blenkernel/intern/dynamicpaint.c | 48 +++++++------- source/blender/blenkernel/intern/effect.c | 4 +- source/blender/blenkernel/intern/fcurve.c | 10 +-- source/blender/blenkernel/intern/image.c | 22 +++---- source/blender/blenkernel/intern/object.c | 8 +-- source/blender/blenkernel/intern/softbody.c | 6 +- .../editors/gpencil/gpencil_primitive.c | 10 +-- source/blender/editors/include/ED_object.h | 2 +- .../interface_eyedropper_datablock.c | 4 +- .../interface/interface_eyedropper_depth.c | 6 +- .../interface/interface_eyedropper_driver.c | 4 +- .../editors/interface/interface_handlers.c | 4 +- .../blender/editors/interface/interface_ops.c | 8 +-- source/blender/editors/interface/view2d_ops.c | 22 +++---- .../editors/lattice/editlattice_tools.c | 2 +- source/blender/editors/mask/mask_editaction.c | 4 +- .../editors/object/object_gpencil_modifier.c | 8 +-- source/blender/editors/object/object_hook.c | 10 +-- .../blender/editors/object/object_modifier.c | 30 ++++----- source/blender/editors/sculpt_paint/sculpt.c | 4 +- .../blender/editors/sculpt_paint/sculpt_uv.c | 4 +- source/blender/editors/sound/sound_ops.c | 4 +- .../blender/editors/space_file/space_file.c | 4 +- .../editors/space_graph/graph_buttons.c | 16 ++--- .../editors/space_graph/graph_select.c | 6 +- .../blender/editors/space_image/image_ops.c | 10 +-- source/blender/editors/space_node/drawnode.c | 12 ++-- source/blender/editors/space_node/node_add.c | 4 +- source/blender/editors/space_node/node_draw.c | 14 ++--- source/blender/editors/space_node/node_edit.c | 16 ++--- .../blender/editors/space_node/node_intern.h | 2 +- .../editors/space_view3d/view3d_utils.c | 4 +- .../editors/space_view3d/view3d_view.c | 4 +- source/blender/makesrna/intern/rna_color.c | 2 +- .../modifiers/intern/MOD_weightvgproximity.c | 2 +- .../python/mathutils/mathutils_Matrix.c | 6 +- 48 files changed, 264 insertions(+), 270 deletions(-) diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index 76c610fb5bd..9752185bc40 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -281,9 +281,9 @@ void DM_from_template(DerivedMesh *dm, /** * Utility function to release a DerivedMesh's layers - * returns 1 if DerivedMesh has to be released by the backend, 0 otherwise. + * returns true if DerivedMesh has to be released by the backend, false otherwise. */ -int DM_release(DerivedMesh *dm); +bool DM_release(DerivedMesh *dm); void DM_set_only_copy(DerivedMesh *dm, const struct CustomData_MeshMasks *mask); diff --git a/source/blender/blenkernel/BKE_colorband.h b/source/blender/blenkernel/BKE_colorband.h index 6ac96a1ed36..0f46ced8b06 100644 --- a/source/blender/blenkernel/BKE_colorband.h +++ b/source/blender/blenkernel/BKE_colorband.h @@ -40,7 +40,7 @@ struct ColorBand *BKE_colorband_add(bool rangetype); bool BKE_colorband_evaluate(const struct ColorBand *coba, float in, float out[4]); void BKE_colorband_evaluate_table_rgba(const struct ColorBand *coba, float **array, int *size); struct CBData *BKE_colorband_element_add(struct ColorBand *coba, float position); -int BKE_colorband_element_remove(struct ColorBand *coba, int index); +bool BKE_colorband_element_remove(struct ColorBand *coba, int index); void BKE_colorband_update_sort(struct ColorBand *coba); #ifdef __cplusplus diff --git a/source/blender/blenkernel/BKE_colortools.h b/source/blender/blenkernel/BKE_colortools.h index 1ada83c0163..73fe50c0c4f 100644 --- a/source/blender/blenkernel/BKE_colortools.h +++ b/source/blender/blenkernel/BKE_colortools.h @@ -95,7 +95,7 @@ void BKE_curvemapping_evaluate_premulRGBF_ex(const struct CurveMapping *cumap, void BKE_curvemapping_evaluate_premulRGBF(const struct CurveMapping *cumap, float vecout[3], const float vecin[3]); -int BKE_curvemapping_RGBA_does_something(const struct CurveMapping *cumap); +bool BKE_curvemapping_RGBA_does_something(const struct CurveMapping *cumap); void BKE_curvemapping_table_RGBA(const struct CurveMapping *cumap, float **array, int *size); /* non-const, these modify the curve */ diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index b316fc28726..98702279706 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -273,7 +273,7 @@ void calchandles_fcurve(struct FCurve *fcu); void calchandles_fcurve_ex(struct FCurve *fcu, eBezTriple_Flag handle_sel_flag); void testhandles_fcurve(struct FCurve *fcu, eBezTriple_Flag sel_flag, const bool use_handle); void sort_time_fcurve(struct FCurve *fcu); -short test_time_fcurve(struct FCurve *fcu); +bool test_time_fcurve(struct FCurve *fcu); void correct_bezpart(const float v1[2], float v2[2], float v3[2], const float v4[2]); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index f052ba400fc..a04f6438170 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -121,10 +121,10 @@ char BKE_image_ftype_to_imtype(const int ftype, const struct ImbFormatOptions *o int BKE_image_imtype_to_ftype(const char imtype, struct ImbFormatOptions *r_options); bool BKE_imtype_is_movie(const char imtype); -int BKE_imtype_supports_zbuf(const char imtype); -int BKE_imtype_supports_compress(const char imtype); -int BKE_imtype_supports_quality(const char imtype); -int BKE_imtype_requires_linear_float(const char imtype); +bool BKE_imtype_supports_zbuf(const char imtype); +bool BKE_imtype_supports_compress(const char imtype); +bool BKE_imtype_supports_quality(const char imtype); +bool BKE_imtype_requires_linear_float(const char imtype); char BKE_imtype_valid_channels(const char imtype, bool write_file); char BKE_imtype_valid_depths(const char imtype); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 2029f4d38a1..020225d2794 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -311,10 +311,10 @@ void BKE_object_handle_update_ex(struct Depsgraph *depsgraph, void BKE_object_sculpt_data_create(struct Object *ob); -int BKE_object_obdata_texspace_get(struct Object *ob, - short **r_texflag, - float **r_loc, - float **r_size); +bool BKE_object_obdata_texspace_get(struct Object *ob, + short **r_texflag, + float **r_loc, + float **r_size); struct Mesh *BKE_object_get_evaluated_mesh(struct Object *object); struct Mesh *BKE_object_get_pre_modified_mesh(struct Object *object); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 263f63cb6da..681e46ed24e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -407,7 +407,7 @@ void DM_from_template(DerivedMesh *dm, &CD_MASK_DERIVEDMESH); } -int DM_release(DerivedMesh *dm) +bool DM_release(DerivedMesh *dm) { if (dm->needsFree) { CustomData_free(&dm->vertData, dm->numVertData); @@ -420,7 +420,7 @@ int DM_release(DerivedMesh *dm) dm->looptris.num = 0; dm->looptris.num_alloc = 0; - return 1; + return true; } CustomData_free_temporary(&dm->vertData, dm->numVertData); @@ -429,7 +429,7 @@ int DM_release(DerivedMesh *dm) CustomData_free_temporary(&dm->loopData, dm->numLoopData); CustomData_free_temporary(&dm->polyData, dm->numPolyData); - return 0; + return false; } void DM_DupPolys(DerivedMesh *source, DerivedMesh *target) diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 24b4b85d0d4..62e2294345d 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -56,12 +56,12 @@ */ static void cloth_to_object(Object *ob, ClothModifierData *clmd, float (*vertexCos)[3]); static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh); -static int cloth_from_object( +static bool cloth_from_object( Object *ob, ClothModifierData *clmd, Mesh *mesh, float framenr, int first); static void cloth_update_springs(ClothModifierData *clmd); static void cloth_update_verts(Object *ob, ClothModifierData *clmd, Mesh *mesh); static void cloth_update_spring_lengths(ClothModifierData *clmd, Mesh *mesh); -static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh); +static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh); static void cloth_apply_vgroup(ClothModifierData *clmd, Mesh *mesh); typedef struct BendSpringRef { @@ -324,7 +324,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr); } -static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) +static bool do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int framenr) { PointCache *cache; @@ -335,13 +335,13 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int if (!cloth_from_object(ob, clmd, result, framenr, 1)) { BKE_ptcache_invalidate(cache); BKE_modifier_set_error(&(clmd->modifier), "Can't initialize cloth"); - return 0; + return false; } if (clmd->clothObject == NULL) { BKE_ptcache_invalidate(cache); BKE_modifier_set_error(&(clmd->modifier), "Null cloth object"); - return 0; + return false; } SIM_cloth_solver_set_positions(clmd); @@ -356,7 +356,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame; } - return 1; + return true; } static int do_step_cloth( @@ -818,7 +818,7 @@ static float cloth_shrink_factor(ClothModifierData *clmd, ClothVertex *verts, in return sqrtf(k1 * k2); } -static int cloth_from_object( +static bool cloth_from_object( Object *ob, ClothModifierData *clmd, Mesh *mesh, float UNUSED(framenr), int first) { int i = 0; @@ -843,12 +843,12 @@ static int cloth_from_object( } else { BKE_modifier_set_error(&(clmd->modifier), "Out of memory on allocating clmd->clothObject"); - return 0; + return false; } // mesh input objects need Mesh if (!mesh) { - return 0; + return false; } cloth_from_mesh(clmd, mesh); @@ -915,7 +915,7 @@ static int cloth_from_object( if (!cloth_build_springs(clmd, mesh)) { cloth_free_modifier(clmd); BKE_modifier_set_error(&(clmd->modifier), "Cannot build springs"); - return 0; + return false; } // init our solver @@ -928,7 +928,7 @@ static int cloth_from_object( clmd->clothObject->bvhtree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->epsilon); clmd->clothObject->bvhselftree = bvhtree_build_from_cloth(clmd, clmd->coll_parms->selfepsilon); - return 1; + return true; } static void cloth_from_mesh(ClothModifierData *clmd, Mesh *mesh) @@ -1560,7 +1560,7 @@ static bool find_internal_spring_target_vertex(BVHTreeFromMesh *treedata, return false; } -static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) +static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) { Cloth *cloth = clmd->clothObject; ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL; @@ -1580,7 +1580,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) // error handling if (numedges == 0) { - return 0; + return false; } /* NOTE: handling ownership of springs and edgeset is quite sloppy @@ -1595,14 +1595,14 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) spring_ref = MEM_callocN(sizeof(*spring_ref) * numedges, "temp bend spring reference"); if (!spring_ref) { - return 0; + return false; } } else { edgelist = MEM_callocN(sizeof(*edgelist) * mvert_num, "cloth_edgelist_alloc"); if (!edgelist) { - return 0; + return false; } } @@ -1670,7 +1670,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (tmp_mesh) { BKE_mesh_free(tmp_mesh); } - return 0; + return false; } } } @@ -1736,7 +1736,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) } else { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } } @@ -1770,7 +1770,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) } else { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } } @@ -1784,7 +1784,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) } else { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } } } @@ -1816,7 +1816,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) !cloth_bend_set_poly_vert_array( &spring->pb, spring->lb, &mloop[mpoly[i].loopstart])) { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } spring->mn = ml->e; @@ -1874,7 +1874,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (!spring) { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } spring_verts_ordered_set(spring, tspring2->ij, index2); @@ -1912,7 +1912,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (!spring) { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } spring->ij = tspring2->ij; @@ -1952,7 +1952,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) if (!spring) { cloth_free_errorsprings(cloth, edgelist, spring_ref); - return 0; + return false; } spring->ij = tspring2->ij; @@ -2002,7 +2002,7 @@ static int cloth_build_springs(ClothModifierData *clmd, Mesh *mesh) } #endif - return 1; + return true; } /** \} */ diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c index 323a2f0cf53..cb30e4f1658 100644 --- a/source/blender/blenkernel/intern/colorband.c +++ b/source/blender/blenkernel/intern/colorband.c @@ -641,24 +641,22 @@ CBData *BKE_colorband_element_add(struct ColorBand *coba, float position) return coba->data + coba->cur; } -int BKE_colorband_element_remove(struct ColorBand *coba, int index) +bool BKE_colorband_element_remove(struct ColorBand *coba, int index) { - int a; - if (coba->tot < 2) { - return 0; + return false; } if (index < 0 || index >= coba->tot) { - return 0; + return false; } coba->tot--; - for (a = index; a < coba->tot; a++) { + for (int a = index; a < coba->tot; a++) { coba->data[a] = coba->data[a + 1]; } if (coba->cur) { coba->cur--; } - return 1; + return true; } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 116d8b1a82f..6fb2df04b3c 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1151,50 +1151,48 @@ void BKE_curvemapping_evaluate_premulRGB(const CurveMapping *cumap, vecout_byte[2] = unit_float_to_uchar_clamp(vecout[2]); } -int BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap) +bool BKE_curvemapping_RGBA_does_something(const CurveMapping *cumap) { - int a; - if (cumap->black[0] != 0.0f) { - return 1; + return true; } if (cumap->black[1] != 0.0f) { - return 1; + return true; } if (cumap->black[2] != 0.0f) { - return 1; + return true; } if (cumap->white[0] != 1.0f) { - return 1; + return true; } if (cumap->white[1] != 1.0f) { - return 1; + return true; } if (cumap->white[2] != 1.0f) { - return 1; + return true; } - for (a = 0; a < CM_TOT; a++) { + for (int a = 0; a < CM_TOT; a++) { if (cumap->cm[a].curve) { if (cumap->cm[a].totpoint != 2) { - return 1; + return true; } if (cumap->cm[a].curve[0].x != 0.0f) { - return 1; + return true; } if (cumap->cm[a].curve[0].y != 0.0f) { - return 1; + return true; } if (cumap->cm[a].curve[1].x != 1.0f) { - return 1; + return true; } if (cumap->cm[a].curve[1].y != 1.0f) { - return 1; + return true; } } } - return 0; + return false; } void BKE_curvemapping_init(CurveMapping *cumap) diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index b75efb6cdf1..909a4d42f0a 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -162,10 +162,10 @@ typedef struct LayerTypeInfo { void (*copyvalue)(const void *source, void *dest, const int mixmode, const float mixfactor); /** a function to read data from a cdf file */ - int (*read)(CDataFile *cdf, void *data, int count); + bool (*read)(CDataFile *cdf, void *data, int count); /** a function to write data to a cdf file */ - int (*write)(CDataFile *cdf, const void *data, int count); + bool (*write)(CDataFile *cdf, const void *data, int count); /** a function to determine file size */ size_t (*filesize)(CDataFile *cdf, const void *data, int count); @@ -659,12 +659,11 @@ static void layerFree_mdisps(void *data, int count, int UNUSED(size)) } } -static int layerRead_mdisps(CDataFile *cdf, void *data, int count) +static bool layerRead_mdisps(CDataFile *cdf, void *data, int count) { MDisps *d = data; - int i; - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { if (!d[i].disps) { d[i].disps = MEM_calloc_arrayN(d[i].totdisp, sizeof(float[3]), "mdisps read"); } @@ -675,22 +674,21 @@ static int layerRead_mdisps(CDataFile *cdf, void *data, int count) } } - return 1; + return true; } -static int layerWrite_mdisps(CDataFile *cdf, const void *data, int count) +static bool layerWrite_mdisps(CDataFile *cdf, const void *data, int count) { const MDisps *d = data; - int i; - for (i = 0; i < count; i++) { + for (int i = 0; i < count; i++) { if (!cdf_write_data(cdf, sizeof(float[3]) * d[i].totdisp, d[i].disps)) { CLOG_ERROR(&LOG, "failed to write multires displacement %d/%d %d", i, count, d[i].totdisp); return 0; } } - return 1; + return true; } static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), const void *data, int count) @@ -2594,12 +2592,12 @@ void CustomData_clear_layer_flag(struct CustomData *data, int type, int flag) } } -static int customData_resize(CustomData *data, int amount) +static bool customData_resize(CustomData *data, int amount) { CustomDataLayer *tmp = MEM_calloc_arrayN( (data->maxlayer + amount), sizeof(*tmp), "CustomData->layers"); if (!tmp) { - return 0; + return false; } data->maxlayer += amount; @@ -2609,7 +2607,7 @@ static int customData_resize(CustomData *data, int amount) } data->layers = tmp; - return 1; + return true; } static CustomDataLayer *customData_add_layer__internal(CustomData *data, diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 4fa232a368b..470c2f2d246 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -128,7 +128,7 @@ void cdf_free(CDataFile *cdf) /********************************* Read/Write ********************************/ -static int cdf_read_header(CDataFile *cdf) +static bool cdf_read_header(CDataFile *cdf) { CDataFileHeader *header; CDataFileImageHeader *image; @@ -141,14 +141,14 @@ static int cdf_read_header(CDataFile *cdf) header = &cdf->header; if (!fread(header, sizeof(CDataFileHeader), 1, cdf->readf)) { - return 0; + return false; } if (memcmp(header->ID, "BCDF", sizeof(header->ID)) != 0) { - return 0; + return false; } if (header->version > CDF_VERSION) { - return 0; + return false; } cdf->switchendian = header->endian != cdf_endian(); @@ -161,20 +161,20 @@ static int cdf_read_header(CDataFile *cdf) } if (!ELEM(header->type, CDF_TYPE_IMAGE, CDF_TYPE_MESH)) { - return 0; + return false; } offset += header->structbytes; header->structbytes = sizeof(CDataFileHeader); if (fseek(f, offset, SEEK_SET) != 0) { - return 0; + return false; } if (header->type == CDF_TYPE_IMAGE) { image = &cdf->btype.image; if (!fread(image, sizeof(CDataFileImageHeader), 1, f)) { - return 0; + return false; } if (cdf->switchendian) { @@ -190,7 +190,7 @@ static int cdf_read_header(CDataFile *cdf) else if (header->type == CDF_TYPE_MESH) { mesh = &cdf->btype.mesh; if (!fread(mesh, sizeof(CDataFileMeshHeader), 1, f)) { - return 0; + return false; } if (cdf->switchendian) { @@ -202,21 +202,21 @@ static int cdf_read_header(CDataFile *cdf) } if (fseek(f, offset, SEEK_SET) != 0) { - return 0; + return false; } cdf->layer = MEM_calloc_arrayN(header->totlayer, sizeof(CDataFileLayer), "CDataFileLayer"); cdf->totlayer = header->totlayer; if (!cdf->layer) { - return 0; + return false; } for (a = 0; a < header->totlayer; a++) { layer = &cdf->layer[a]; if (!fread(layer, sizeof(CDataFileLayer), 1, f)) { - return 0; + return false; } if (cdf->switchendian) { @@ -227,23 +227,23 @@ static int cdf_read_header(CDataFile *cdf) } if (layer->datatype != CDF_DATA_FLOAT) { - return 0; + return false; } offset += layer->structbytes; layer->structbytes = sizeof(CDataFileLayer); if (fseek(f, offset, SEEK_SET) != 0) { - return 0; + return false; } } cdf->dataoffset = offset; - return 1; + return true; } -static int cdf_write_header(CDataFile *cdf) +static bool cdf_write_header(CDataFile *cdf) { CDataFileHeader *header; CDataFileImageHeader *image; @@ -255,19 +255,19 @@ static int cdf_write_header(CDataFile *cdf) header = &cdf->header; if (!fwrite(header, sizeof(CDataFileHeader), 1, f)) { - return 0; + return false; } if (header->type == CDF_TYPE_IMAGE) { image = &cdf->btype.image; if (!fwrite(image, sizeof(CDataFileImageHeader), 1, f)) { - return 0; + return false; } } else if (header->type == CDF_TYPE_MESH) { mesh = &cdf->btype.mesh; if (!fwrite(mesh, sizeof(CDataFileMeshHeader), 1, f)) { - return 0; + return false; } } @@ -275,11 +275,11 @@ static int cdf_write_header(CDataFile *cdf) layer = &cdf->layer[a]; if (!fwrite(layer, sizeof(CDataFileLayer), 1, f)) { - return 0; + return false; } } - return 1; + return true; } bool cdf_read_open(CDataFile *cdf, const char *filename) @@ -288,22 +288,22 @@ bool cdf_read_open(CDataFile *cdf, const char *filename) f = BLI_fopen(filename, "rb"); if (!f) { - return 0; + return false; } cdf->readf = f; if (!cdf_read_header(cdf)) { cdf_read_close(cdf); - return 0; + return false; } if (cdf->header.type != cdf->type) { cdf_read_close(cdf); - return 0; + return false; } - return 1; + return true; } bool cdf_read_layer(CDataFile *cdf, CDataFileLayer *blay) @@ -328,7 +328,7 @@ bool cdf_read_data(CDataFile *cdf, unsigned int size, void *data) { /* read data */ if (!fread(data, size, 1, cdf->readf)) { - return 0; + return false; } /* switch endian if necessary */ @@ -336,7 +336,7 @@ bool cdf_read_data(CDataFile *cdf, unsigned int size, void *data) BLI_endian_switch_float_array(data, size / sizeof(float)); } - return 1; + return true; } void cdf_read_close(CDataFile *cdf) @@ -356,7 +356,7 @@ bool cdf_write_open(CDataFile *cdf, const char *filename) f = BLI_fopen(filename, "wb"); if (!f) { - return 0; + return false; } cdf->writef = f; @@ -390,22 +390,22 @@ bool cdf_write_open(CDataFile *cdf, const char *filename) cdf_write_header(cdf); - return 1; + return true; } bool cdf_write_layer(CDataFile *UNUSED(cdf), CDataFileLayer *UNUSED(blay)) { - return 1; + return true; } bool cdf_write_data(CDataFile *cdf, unsigned int size, void *data) { /* write data */ if (!fwrite(data, size, 1, cdf->writef)) { - return 0; + return false; } - return 1; + return true; } void cdf_write_close(CDataFile *cdf) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 1c61afe5e5a..dff7dca4d76 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -4276,12 +4276,12 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( } } -static int dynamicPaint_paintMesh(Depsgraph *depsgraph, - DynamicPaintSurface *surface, - DynamicPaintBrushSettings *brush, - Object *brushOb, - Scene *scene, - float timescale) +static bool dynamicPaint_paintMesh(Depsgraph *depsgraph, + DynamicPaintSurface *surface, + DynamicPaintBrushSettings *brush, + Object *brushOb, + Scene *scene, + float timescale) { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; @@ -4298,7 +4298,7 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph, Mesh *brush_mesh = dynamicPaint_brush_mesh_get(brush); if (brush_mesh == NULL) { - return 0; + return false; } { @@ -4395,7 +4395,7 @@ static int dynamicPaint_paintMesh(Depsgraph *depsgraph, MEM_freeN(brushVelocity); } - return 1; + return true; } /* @@ -4576,10 +4576,10 @@ static void dynamic_paint_paint_particle_cell_point_cb_ex( } } -static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, - ParticleSystem *psys, - DynamicPaintBrushSettings *brush, - float timescale) +static bool dynamicPaint_paintParticles(DynamicPaintSurface *surface, + ParticleSystem *psys, + DynamicPaintBrushSettings *brush, + float timescale) { ParticleSettings *part = psys->part; PaintSurfaceData *sData = surface->data; @@ -4601,7 +4601,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, Bounds3D part_bb = {{0}}; if (psys->totpart < 1) { - return 1; + return true; } /* @@ -4644,7 +4644,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, /* If no suitable particles were found, exit */ if (particlesAdded < 1) { BLI_kdtree_3d_free(tree); - return 1; + return true; } /* only continue if particle bb is close enough to canvas bb */ @@ -4684,7 +4684,7 @@ static int dynamicPaint_paintParticles(DynamicPaintSurface *surface, } BLI_kdtree_3d_free(tree); - return 1; + return true; } /* paint a single point of defined proximity radius to the surface */ @@ -4780,7 +4780,7 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata, } } -static int dynamicPaint_paintSinglePoint( +static bool dynamicPaint_paintSinglePoint( Depsgraph *depsgraph, DynamicPaintSurface *surface, /* Cannot be const, because it is assigned to non-const variable. @@ -4822,7 +4822,7 @@ static int dynamicPaint_paintSinglePoint( BLI_task_parallel_range( 0, sData->total_points, &data, dynamic_paint_paint_single_point_cb_ex, &settings); - return 1; + return true; } /***************************** Dynamic Paint Step / Baking ******************************/ @@ -6057,9 +6057,9 @@ static void dynamic_paint_generate_bake_data_cb(void *__restrict userdata, } } -static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, - Depsgraph *depsgraph, - Object *ob) +static bool dynamicPaint_generateBakeData(DynamicPaintSurface *surface, + Depsgraph *depsgraph, + Object *ob) { PaintSurfaceData *sData = surface->data; PaintBakeData *bData = sData->bData; @@ -6090,14 +6090,14 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, /* if previous data exists and mesh hasn't moved, no need to recalc */ if (!surface_moved) { - return 1; + return true; } } canvas_verts = (struct Vec3f *)MEM_mallocN(canvasNumOfVerts * sizeof(struct Vec3f), "Dynamic Paint transformed canvas verts"); if (!canvas_verts) { - return 0; + return false; } /* allocate memory if required */ @@ -6108,7 +6108,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, if (canvas_verts) { MEM_freeN(canvas_verts); } - return 0; + return false; } /* Init bdata */ @@ -6200,7 +6200,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, bData->clear = 0; - return 1; + return true; } /* diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 97f9cebf58b..1c5c74379f8 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1207,9 +1207,9 @@ static bool debug_element_compare(const void *a, const void *b) const SimDebugElement *elem2 = b; if (elem1->hash == elem2->hash) { - return 0; + return false; } - return 1; + return true; } static void debug_element_free(void *val) diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 294e6f8c8a0..5d227ec2f9b 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1267,13 +1267,13 @@ void sort_time_fcurve(FCurve *fcu) } /* This function tests if any BezTriples are out of order, thus requiring a sort */ -short test_time_fcurve(FCurve *fcu) +bool test_time_fcurve(FCurve *fcu) { unsigned int a; /* sanity checks */ if (fcu == NULL) { - return 0; + return false; } /* currently, only need to test beztriples */ @@ -1283,7 +1283,7 @@ short test_time_fcurve(FCurve *fcu) /* loop through all BezTriples, stopping when one exceeds the one after it */ for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) { if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) { - return 1; + return true; } } } @@ -1293,13 +1293,13 @@ short test_time_fcurve(FCurve *fcu) /* loop through all FPoints, stopping when one exceeds the one after it */ for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) { if (fpt->vec[0] > (fpt + 1)->vec[0]) { - return 1; + return true; } } } /* none need any swapping */ - return 0; + return false; } /** \} */ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0f694a26b45..aeb2634b4da 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1327,37 +1327,37 @@ bool BKE_imtype_is_movie(const char imtype) return false; } -int BKE_imtype_supports_zbuf(const char imtype) +bool BKE_imtype_supports_zbuf(const char imtype) { switch (imtype) { case R_IMF_IMTYPE_IRIZ: case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ - return 1; + return true; } - return 0; + return false; } -int BKE_imtype_supports_compress(const char imtype) +bool BKE_imtype_supports_compress(const char imtype) { switch (imtype) { case R_IMF_IMTYPE_PNG: - return 1; + return true; } - return 0; + return false; } -int BKE_imtype_supports_quality(const char imtype) +bool BKE_imtype_supports_quality(const char imtype) { switch (imtype) { case R_IMF_IMTYPE_JPEG90: case R_IMF_IMTYPE_JP2: case R_IMF_IMTYPE_AVIJPEG: - return 1; + return true; } - return 0; + return false; } -int BKE_imtype_requires_linear_float(const char imtype) +bool BKE_imtype_requires_linear_float(const char imtype) { switch (imtype) { case R_IMF_IMTYPE_CINEON: @@ -1367,7 +1367,7 @@ int BKE_imtype_requires_linear_float(const char imtype) case R_IMF_IMTYPE_MULTILAYER: return true; } - return 0; + return false; } char BKE_imtype_valid_channels(const char imtype, bool write_file) diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e2bed85399b..b7694afb55b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -3520,11 +3520,11 @@ void BKE_object_sculpt_data_create(Object *ob) ob->sculpt->mode_type = ob->mode; } -int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size) +bool BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size) { if (ob->data == NULL) { - return 0; + return false; } switch (GS(((ID *)ob->data)->name)) { @@ -3560,9 +3560,9 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, break; } default: - return 0; + return false; } - return 1; + return true; } /** Get evaluated mesh for given object. */ diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4d3e8b55404..1ebbc1e2d77 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3209,16 +3209,16 @@ void sbObjectToSoftbody(Object *ob) free_softbody_intern(ob->soft); } -static int object_has_edges(Object *ob) +static bool object_has_edges(Object *ob) { if (ob->type == OB_MESH) { return ((Mesh *)ob->data)->totedge; } if (ob->type == OB_LATTICE) { - return 1; + return true; } - return 0; + return false; } /* SB global visible functions */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index a4c8fc770e2..04e440a1960 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -255,13 +255,13 @@ static bool gpencil_primitive_add_poll(bContext *C) /* only 3D view */ ScrArea *area = CTX_wm_area(C); if (area && area->spacetype != SPACE_VIEW3D) { - return 0; + return false; } /* need data to create primitive */ bGPdata *gpd = CTX_data_gpencil_data(C); if (gpd == NULL) { - return 0; + return false; } /* only in edit and paint modes @@ -271,7 +271,7 @@ static bool gpencil_primitive_add_poll(bContext *C) */ if ((gpd->flag & (GP_DATA_STROKE_PAINTMODE | GP_DATA_STROKE_EDITMODE)) == 0) { CTX_wm_operator_poll_msg_set(C, "Primitives can only be added in Draw or Edit modes"); - return 0; + return false; } /* don't allow operator to function if the active layer is locked/hidden @@ -281,10 +281,10 @@ static bool gpencil_primitive_add_poll(bContext *C) if ((gpl) && (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE))) { CTX_wm_operator_poll_msg_set(C, "Primitives cannot be added as active layer is locked or hidden"); - return 0; + return false; } - return 1; + return true; } /* Allocate memory to stroke, adds MAX_EDGES on every call */ diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index f1ddc10f1a8..dc674aefe2e 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -381,7 +381,7 @@ bool ED_object_modifier_move_to_index(struct ReportList *reports, struct ModifierData *md, const int index); -int ED_object_modifier_convert(struct ReportList *reports, +bool ED_object_modifier_convert(struct ReportList *reports, struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, diff --git a/source/blender/editors/interface/interface_eyedropper_datablock.c b/source/blender/editors/interface/interface_eyedropper_datablock.c index dd55d2c364b..6a12f550d7c 100644 --- a/source/blender/editors/interface/interface_eyedropper_datablock.c +++ b/source/blender/editors/interface/interface_eyedropper_datablock.c @@ -355,12 +355,12 @@ static bool datadropper_poll(bContext *C) StructRNA *type = RNA_property_pointer_type(&ptr, prop); const short idcode = RNA_type_to_ID_code(type); if ((idcode == ID_OB) || OB_DATA_SUPPORT_ID(idcode)) { - return 1; + return true; } } } - return 0; + return false; } void UI_OT_eyedropper_id(wmOperatorType *ot) diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index ac142fe7217..fbc0ed1fc1f 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -351,7 +351,7 @@ static bool depthdropper_poll(bContext *C) if ((RNA_property_type(prop) == PROP_FLOAT) && (RNA_property_subtype(prop) & PROP_UNIT_LENGTH) && (RNA_property_array_check(prop) == false)) { - return 1; + return true; } } else { @@ -359,12 +359,12 @@ static bool depthdropper_poll(bContext *C) if (rv3d && rv3d->persp == RV3D_CAMOB) { View3D *v3d = CTX_wm_view3d(C); if (v3d->camera && v3d->camera->data && !ID_IS_LINKED(v3d->camera->data)) { - return 1; + return true; } } } - return 0; + return false; } void UI_OT_eyedropper_depth(wmOperatorType *ot) diff --git a/source/blender/editors/interface/interface_eyedropper_driver.c b/source/blender/editors/interface/interface_eyedropper_driver.c index d13e47624ee..29c0368219b 100644 --- a/source/blender/editors/interface/interface_eyedropper_driver.c +++ b/source/blender/editors/interface/interface_eyedropper_driver.c @@ -207,9 +207,9 @@ static int driverdropper_exec(bContext *C, wmOperator *op) static bool driverdropper_poll(bContext *C) { if (!CTX_wm_window(C)) { - return 0; + return false; } - return 1; + return true; } void UI_OT_eyedropper_driver(wmOperatorType *ot) diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index bf88b3c0318..143ca6a0ef1 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -10988,11 +10988,11 @@ bool UI_but_active_drop_name(bContext *C) if (but) { if (ELEM(but->type, UI_BTYPE_TEXT, UI_BTYPE_SEARCH_MENU)) { - return 1; + return true; } } - return 0; + return false; } bool UI_but_active_drop_color(bContext *C) diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index d6919fb4de7..c9f21c7fc2e 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -91,11 +91,11 @@ static bool copy_data_path_button_poll(bContext *C) if (path) { MEM_freeN(path); - return 1; + return true; } } - return 0; + return false; } static int copy_data_path_button_exec(bContext *C, wmOperator *op) @@ -182,11 +182,11 @@ static bool copy_as_driver_button_poll(bContext *C) if (path) { MEM_freeN(path); - return 1; + return true; } } - return 0; + return false; } static int copy_as_driver_button_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 7234e279da8..c6b29f79137 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -107,7 +107,7 @@ typedef struct v2dViewPanData { } v2dViewPanData; /* initialize panning customdata */ -static int view_pan_init(bContext *C, wmOperator *op) +static bool view_pan_init(bContext *C, wmOperator *op) { ARegion *region = CTX_wm_region(C); v2dViewPanData *vpd; @@ -116,13 +116,13 @@ static int view_pan_init(bContext *C, wmOperator *op) /* regions now have v2d-data by default, so check for region */ if (region == NULL) { - return 0; + return false; } /* check if panning is allowed at all */ v2d = ®ion->v2d; if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) { - return 0; + return false; } /* set custom-data for operator */ @@ -141,7 +141,7 @@ static int view_pan_init(bContext *C, wmOperator *op) vpd->facx = (BLI_rctf_size_x(&v2d->cur)) / winx; vpd->facy = (BLI_rctf_size_y(&v2d->cur)) / winy; - return 1; + return true; } #ifdef WITH_INPUT_NDOF @@ -152,17 +152,17 @@ static bool view_pan_poll(bContext *C) /* check if there's a region in context to work with */ if (region == NULL) { - return 0; + return false; } v2d = ®ion->v2d; /* check that 2d-view can pan */ if ((v2d->keepofs & V2D_LOCKOFS_X) && (v2d->keepofs & V2D_LOCKOFS_Y)) { - return 0; + return false; } /* view can pan */ - return 1; + return true; } #endif @@ -808,7 +808,7 @@ static void view_zoom_axis_lock_defaults(bContext *C, bool r_do_zoom_xy[2]) } /* initialize panning customdata */ -static int view_zoomdrag_init(bContext *C, wmOperator *op) +static bool view_zoomdrag_init(bContext *C, wmOperator *op) { ARegion *region = CTX_wm_region(C); v2dViewZoomData *vzd; @@ -816,13 +816,13 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op) /* regions now have v2d-data by default, so check for region */ if (region == NULL) { - return 0; + return false; } v2d = ®ion->v2d; /* check that 2d-view is zoomable */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) && (v2d->keepzoom & V2D_LOCKZOOM_Y)) { - return 0; + return false; } /* set custom-data for operator */ @@ -833,7 +833,7 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op) vzd->v2d = v2d; vzd->region = region; - return 1; + return true; } /* check if step-zoom can be applied */ diff --git a/source/blender/editors/lattice/editlattice_tools.c b/source/blender/editors/lattice/editlattice_tools.c index 0cfe59ef06c..d503cbc87b8 100644 --- a/source/blender/editors/lattice/editlattice_tools.c +++ b/source/blender/editors/lattice/editlattice_tools.c @@ -58,7 +58,7 @@ static bool make_regular_poll(bContext *C) Object *ob; if (ED_operator_editlattice(C)) { - return 1; + return true; } ob = CTX_data_active_object(C); diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 31fc403b157..af99df4c5d8 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -122,12 +122,12 @@ bool ED_masklayer_frame_select_check(MaskLayer *mask_layer) for (mask_layer_shape = mask_layer->splines_shapes.first; mask_layer_shape; mask_layer_shape = mask_layer_shape->next) { if (mask_layer_shape->flag & MASK_SHAPE_SELECT) { - return 1; + return true; } } /* not found */ - return 0; + return false; } /* helper function - select mask-frame based on SELECT_* mode */ diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index cfa55c68a56..575ef38476c 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -117,7 +117,7 @@ static bool gpencil_object_modifier_remove(Main *bmain, * get called twice on same modifier, so make * sure it is in list. */ if (BLI_findindex(&ob->greasepencil_modifiers, md) == -1) { - return 0; + return false; } DEG_relations_tag_update(bmain); @@ -126,7 +126,7 @@ static bool gpencil_object_modifier_remove(Main *bmain, BKE_gpencil_modifier_free(md); BKE_object_free_derived_caches(ob); - return 1; + return true; } bool ED_object_gpencil_modifier_remove(ReportList *reports, @@ -141,13 +141,13 @@ bool ED_object_gpencil_modifier_remove(ReportList *reports, if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name); - return 0; + return false; } DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); DEG_relations_tag_update(bmain); - return 1; + return true; } void ED_object_gpencil_modifier_clear(Main *bmain, Object *ob) diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 6bb03e62191..aaf76ff649e 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -482,18 +482,18 @@ static bool hook_op_edit_poll(bContext *C) if (obedit) { if (ED_operator_editmesh(C)) { - return 1; + return true; } if (ED_operator_editsurfcurve(C)) { - return 1; + return true; } if (ED_operator_editlattice(C)) { - return 1; + return true; } - // if (ED_operator_editmball(C)) return 1; + // if (ED_operator_editmball(C)) return true; } - return 0; + return false; } static Object *add_hook_object_new( diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 14882ab8ffc..692a445fe9c 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -397,13 +397,13 @@ bool ED_object_modifier_remove( if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name); - return 0; + return false; } DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); DEG_relations_tag_update(bmain); - return 1; + return true; } void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) @@ -513,13 +513,13 @@ bool ED_object_modifier_move_to_index(ReportList *reports, return true; } -int ED_object_modifier_convert(ReportList *UNUSED(reports), - Main *bmain, - Depsgraph *depsgraph, - Scene *scene, - ViewLayer *view_layer, - Object *ob, - ModifierData *md) +bool ED_object_modifier_convert(ReportList *UNUSED(reports), + Main *bmain, + Depsgraph *depsgraph, + Scene *scene, + ViewLayer *view_layer, + Object *ob, + ModifierData *md) { Object *obn; ParticleSystem *psys_orig, *psys_eval; @@ -533,21 +533,21 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), int totpart = 0, totchild = 0; if (md->type != eModifierType_ParticleSystem) { - return 0; + return false; } if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { - return 0; + return false; } psys_orig = ((ParticleSystemModifierData *)md)->psys; part = psys_orig->part; if (part->ren_as != PART_DRAW_PATH) { - return 0; + return false; } psys_eval = psys_eval_get(depsgraph, ob, psys_orig); if (psys_eval->pathcache == NULL) { - return 0; + return false; } totpart = psys_eval->totcached; @@ -579,7 +579,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), } if (totvert == 0) { - return 0; + return false; } /* add new mesh */ @@ -637,7 +637,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), DEG_relations_tag_update(bmain); - return 1; + return true; } /* Gets mesh for the modifier which corresponds to an evaluated state. */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7a066f35f23..7cb4f74282b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1771,10 +1771,10 @@ static bool sculpt_brush_test_cyl(SculptBrushTest *test, test->dist = dist; - return 1; + return true; } - return 0; + return false; } #endif diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index be509f4aed6..5be72ec87e7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -472,9 +472,9 @@ static bool uv_edge_compare(const void *a, const void *b) const UvEdge *edge2 = b; if ((edge1->uv1 == edge2->uv1) && (edge1->uv2 == edge2->uv2)) { - return 0; + return false; } - return 1; + return true; } static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index d4f5f066d48..87b84c475fd 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -749,10 +749,10 @@ static bool sound_poll(bContext *C) Editing *ed = CTX_data_scene(C)->ed; if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_TYPE_SOUND_RAM) { - return 0; + return false; } - return 1; + return true; } /********************* pack operator *********************/ diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 61d6d8bf678..edc1e83e882 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -662,10 +662,10 @@ static bool filepath_drop_poll(bContext *C, if (drag->type == WM_DRAG_PATH) { SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - return 1; + return true; } } - return 0; + return false; } static void filepath_drop_copy(wmDrag *drag, wmDropBox *drop) diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 0158e12c79c..6dbf6226de8 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -72,7 +72,7 @@ /* -------------- */ -static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu) +static bool graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu) { bAnimContext ac; bAnimListElem *elem = NULL; @@ -83,13 +83,13 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** * There's no point showing empty panels? */ if (ANIM_animdata_get_context(C, &ac) == 0) { - return 0; + return false; } /* try to find 'active' F-Curve */ elem = get_active_fcurve_channel(&ac); if (elem == NULL) { - return 0; + return false; } if (fcu) { @@ -102,7 +102,7 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** MEM_freeN(elem); } - return 1; + return true; } static bool graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) @@ -235,7 +235,7 @@ static void graph_panel_properties(const bContext *C, Panel *panel) /* ******************* active Keyframe ************** */ /* get 'active' keyframe for panel editing */ -static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezTriple **prevbezt) +static bool get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezTriple **prevbezt) { BezTriple *b; int i; @@ -245,7 +245,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT /* sanity checks */ if ((fcu->bezt == NULL) || (fcu->totvert == 0)) { - return 0; + return false; } /* find first selected keyframe for now, and call it the active one @@ -261,12 +261,12 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT *prevbezt = (i > 0) ? b - 1 : b; *bezt = b; - return 1; + return true; } } /* not found */ - return 0; + return false; } /* update callback for active keyframe properties - base updates stuff */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 160b731629c..0c05942ec4b 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -95,12 +95,12 @@ typedef enum eGraphVertIndex { static bool fcurve_handle_sel_check(SpaceGraph *sipo, BezTriple *bezt) { if (sipo->flag & SIPO_NOHANDLES) { - return 0; + return false; } if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZT_ISSEL_ANY(bezt) == 0) { - return 0; + return false; } - return 1; + return true; } /* check if the given vertex is within bounds or not */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index f312981d0e1..0a8bcd91f34 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -270,10 +270,10 @@ static bool space_image_main_area_not_uv_brush_poll(bContext *C) ToolSettings *toolsettings = scene->toolsettings; if (sima && !toolsettings->uvsculpt && (CTX_data_edit_object(C) == NULL)) { - return 1; + return true; } - return 0; + return false; } /** \} */ @@ -2897,16 +2897,16 @@ static bool image_pack_test(bContext *C, wmOperator *op) Image *ima = image_from_context(C); if (!ima) { - return 0; + return false; } if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE, IMA_SRC_TILED)) { BKE_report( op->reports, RPT_ERROR, "Packing movies, image sequences or tiled images not supported"); - return 0; + return false; } - return 1; + return true; } static int image_pack_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 5866b5cc12f..82f3b71eb32 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -3766,7 +3766,7 @@ static bool node_link_bezier_handles(View2D *v2d, } else { if (snode == NULL) { - return 0; + return false; } copy_v2_v2(vec[0], cursor); fromreroute = 0; @@ -3778,7 +3778,7 @@ static bool node_link_bezier_handles(View2D *v2d, } else { if (snode == NULL) { - return 0; + return false; } copy_v2_v2(vec[3], cursor); toreroute = 0; @@ -3791,7 +3791,7 @@ static bool node_link_bezier_handles(View2D *v2d, /* Straight line: align all points. */ mid_v2_v2v2(vec[1], vec[0], vec[3]); mid_v2_v2v2(vec[2], vec[1], vec[3]); - return 1; + return true; } dist = curving * 0.10f * fabsf(vec[0][0] - vec[3][0]); @@ -3828,13 +3828,13 @@ static bool node_link_bezier_handles(View2D *v2d, } if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) { - return 0; /* clipped */ + return false; /* clipped */ } if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) { - return 0; /* clipped */ + return false; /* clipped */ } - return 1; + return true; } /* if v2d not NULL, it clips and returns 0 if not visible */ diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 037fe575973..68f4bd0ff38 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -109,12 +109,12 @@ static bool add_reroute_intersect_check(bNodeLink *link, if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f; result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f; - return 1; + return true; } } } } - return 0; + return false; } typedef struct bNodeSocketLink { diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 56e53e79a8d..ba6b164704f 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -188,7 +188,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) for (parent = a->parent; parent; parent = parent->parent) { /* if b is an ancestor, it is always behind a */ if (parent == b) { - return 1; + return true; } /* any selected ancestor moves the node forward */ if (parent->flag & NODE_ACTIVE) { @@ -201,7 +201,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) for (parent = b->parent; parent; parent = parent->parent) { /* if a is an ancestor, it is always behind b */ if (parent == a) { - return 0; + return false; } /* any selected ancestor moves the node forward */ if (parent->flag & NODE_ACTIVE) { @@ -214,21 +214,21 @@ static bool compare_nodes(const bNode *a, const bNode *b) /* if one of the nodes is in the background and the other not */ if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) { - return 0; + return false; } if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) { - return 1; + return true; } /* if one has a higher selection state (active > selected > nothing) */ if (!b_active && a_active) { - return 1; + return true; } if (!b_select && (a_active || a_select)) { - return 1; + return true; } - return 0; + return false; } /* Sorts nodes by selection: unselected nodes first, then selected, diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index ef931dd9bb8..eae8bd05a93 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -358,10 +358,10 @@ bool composite_node_active(bContext *C) if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); if (ED_node_is_compositor(snode)) { - return 1; + return true; } } - return 0; + return false; } /* operator poll callback */ @@ -370,10 +370,10 @@ bool composite_node_editable(bContext *C) if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); if (ED_node_is_compositor(snode)) { - return 1; + return true; } } - return 0; + return false; } void snode_dag_update(bContext *C, SpaceNode *snode) @@ -1089,21 +1089,21 @@ void NODE_OT_resize(wmOperatorType *ot) /* ********************** hidden sockets ******************** */ -int node_has_hidden_sockets(bNode *node) +bool node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; for (sock = node->inputs.first; sock; sock = sock->next) { if (sock->flag & SOCK_HIDDEN) { - return 1; + return true; } } for (sock = node->outputs.first; sock; sock = sock->next) { if (sock->flag & SOCK_HIDDEN) { - return 1; + return true; } } - return 0; + return false; } void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 9461892360e..7e62170bce5 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -212,7 +212,7 @@ void snode_update(struct SpaceNode *snode, struct bNode *node); bool composite_node_active(struct bContext *C); bool composite_node_editable(struct bContext *C); -int node_has_hidden_sockets(struct bNode *node); +bool node_has_hidden_sockets(struct bNode *node); void node_set_hidden_sockets(struct SpaceNode *snode, bNode *node, int set); int node_render_changed_exec(bContext *, struct wmOperator *); int node_find_indicated_socket(struct SpaceNode *snode, diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index a264e1560c6..ffd5c4e182a 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1077,9 +1077,9 @@ static bool depth_segment_cb(int x, int y, void *userData) if (depth != FLT_MAX) { data->depth = depth; - return 0; + return false; } - return 1; + return true; } bool ED_view3d_autodist_depth_seg( diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d015b5dcc89..7000a4d89cd 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -496,13 +496,13 @@ static bool view3d_camera_to_view_poll(bContext *C) if (v3d && v3d->camera && !ID_IS_LINKED(v3d->camera)) { if (rv3d && (RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ANY_TRANSFORM) == 0) { if (rv3d->persp != RV3D_CAMOB) { - return 1; + return true; } } } } - return 0; + return false; } void VIEW3D_OT_camera_to_view(wmOperatorType *ot) diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ab4d936ae34..79f2ab70651 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -366,7 +366,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, { CBData *element = element_ptr->data; int index = (int)(element - coba->data); - if (BKE_colorband_element_remove(coba, index) == false) { + if (!BKE_colorband_element_remove(coba, index)) { BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element"); return; } diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index b23eb997f61..71c56255e3c 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -415,7 +415,7 @@ static bool isDisabled(const struct Scene *UNUSED(scene), WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md; /* If no vertex group, bypass. */ if (wmd->defgrp_name[0] == '\0') { - return 1; + return true; } /* If no target object, bypass. */ return (wmd->proximity_ob_target == NULL); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 0a524cbf24c..c158ec1da15 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -3301,13 +3301,13 @@ static bool Matrix_ParseCheck(MatrixObject *pymat) if (!MatrixObject_Check(pymat)) { PyErr_Format( PyExc_TypeError, "expected a mathutils.Matrix, not a %.200s", Py_TYPE(pymat)->tp_name); - return 0; + return false; } /* sets error */ if (BaseMath_ReadCallback(pymat) == -1) { - return 0; + return false; } - return 1; + return true; } int Matrix_ParseAny(PyObject *o, void *p)