[Bf-blender-cvs] [6d12bc9e918] master: Cleanup: use boolean arguments and return values

Campbell Barton noreply at git.blender.org
Tue Apr 26 06:27:06 CEST 2022


Commit: 6d12bc9e918d47f39135750f9d99f901f88efc44
Author: Campbell Barton
Date:   Tue Apr 26 14:25:58 2022 +1000
Branches: master
https://developer.blender.org/rB6d12bc9e918d47f39135750f9d99f901f88efc44

Cleanup: use boolean arguments and return values

===================================================================

M	source/blender/blenkernel/BKE_particle.h
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/editors/sculpt_paint/paint_vertex.cc
M	source/blender/geometry/intern/uv_parametrizer.c
M	source/blender/imbuf/intern/rectop.c
M	source/blender/imbuf/intern/scaling.c
M	source/blender/python/BPY_extern.h
M	source/blender/python/intern/bpy_app_handlers.c
M	source/blender/render/intern/pipeline.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index b622d7ba85c..123fdbb8bac 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -391,12 +391,12 @@ void psys_cache_child_paths(struct ParticleSimulationData *sim,
                             float cfra,
                             bool editupdate,
                             bool use_render_params);
-int do_guides(struct Depsgraph *depsgraph,
-              struct ParticleSettings *part,
-              struct ListBase *effectors,
-              ParticleKey *state,
-              int index,
-              float time);
+bool do_guides(struct Depsgraph *depsgraph,
+               struct ParticleSettings *part,
+               struct ListBase *effectors,
+               ParticleKey *state,
+               int index,
+               float time);
 void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
 float psys_get_timestep(struct ParticleSimulationData *sim);
 float psys_get_child_time(struct ParticleSystem *psys,
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index cc4738b1faa..bbb08155bfc 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2390,12 +2390,12 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors)
   }
 }
 
-int do_guides(Depsgraph *depsgraph,
-              ParticleSettings *part,
-              ListBase *effectors,
-              ParticleKey *state,
-              int index,
-              float time)
+bool do_guides(Depsgraph *depsgraph,
+               ParticleSettings *part,
+               ListBase *effectors,
+               ParticleKey *state,
+               int index,
+               float time)
 {
   CurveMapping *clumpcurve = (part->child_flag & PART_CHILD_USE_CLUMP_CURVE) ? part->clumpcurve :
                                                                                NULL;
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index d5d304343df..34720bf7d6b 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -1399,7 +1399,8 @@ static size_t ptcache_filename_ext_append(PTCacheID *pid,
   return len;
 }
 
-static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext)
+static int ptcache_filename(
+    PTCacheID *pid, char *filename, int cfra, const bool do_path, const bool do_ext)
 {
   int len = 0;
   char *idname;
@@ -1464,7 +1465,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra)
     }
   }
 
-  ptcache_filename(pid, filename, cfra, 1, 1);
+  ptcache_filename(pid, filename, cfra, true, true);
 
   if (mode == PTCACHE_FILE_READ) {
     fp = BLI_fopen(filename, "rb");
@@ -2630,7 +2631,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
           return;
         }
 
-        len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */
+        len = ptcache_filename(pid, filename, cfra, false, false); /* no path */
         /* append underscore terminator to ensure we don't match similar names
          * from objects whose names start with the same prefix
          */
@@ -2712,7 +2713,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
     case PTCACHE_CLEAR_FRAME:
       if (pid->cache->flag & PTCACHE_DISK_CACHE) {
         if (BKE_ptcache_id_exist(pid, cfra)) {
-          ptcache_filename(pid, filename, cfra, 1, 1); /* no path */
+          ptcache_filename(pid, filename, cfra, true, true); /* no path */
           BLI_delete(filename, false, false);
         }
       }
@@ -2753,7 +2754,7 @@ bool BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
   if (pid->cache->flag & PTCACHE_DISK_CACHE) {
     char filename[MAX_PTCACHE_FILE];
 
-    ptcache_filename(pid, filename, cfra, 1, 1);
+    ptcache_filename(pid, filename, cfra, true, true);
 
     return BLI_exists(filename);
   }
@@ -3500,7 +3501,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
   /* get "from" filename */
   BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name));
 
-  len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */
+  len = ptcache_filename(pid, old_filename, 0, false, false); /* no path */
 
   ptcache_path(pid, path);
   dir = opendir(path);
@@ -3522,7 +3523,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
 
         if (frame != -1) {
           BLI_join_dirfile(old_path_full, sizeof(old_path_full), path, de->d_name);
-          ptcache_filename(pid, new_path_full, frame, 1, 1);
+          ptcache_filename(pid, new_path_full, frame, true, true);
           BLI_rename(old_path_full, new_path_full);
         }
       }
@@ -3555,7 +3556,7 @@ void BKE_ptcache_load_external(PTCacheID *pid)
 
   ptcache_path(pid, path);
 
-  len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */
+  len = ptcache_filename(pid, filename, 1, false, false); /* no path */
 
   dir = opendir(path);
   if (dir == NULL) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index 1ae9f7a8afb..5aeacb15e00 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -412,7 +412,7 @@ static float wpaint_blend(const VPaint *wp,
                           const float alpha,
                           float paintval,
                           const float UNUSED(brush_alpha_value),
-                          const short do_flip)
+                          const bool do_flip)
 {
   const Brush *brush = wp->paint.brush;
   IMB_BlendMode blend = (IMB_BlendMode)brush->blend;
diff --git a/source/blender/geometry/intern/uv_parametrizer.c b/source/blender/geometry/intern/uv_parametrizer.c
index dd97a996b18..e25fff0d6b8 100644
--- a/source/blender/geometry/intern/uv_parametrizer.c
+++ b/source/blender/geometry/intern/uv_parametrizer.c
@@ -203,7 +203,7 @@ typedef struct PHandle {
 
   RNG *rng;
   float blend;
-  char do_aspect;
+  bool do_aspect;
 } PHandle;
 
 /* PHash
diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c
index cb1c5ea2e8d..2f864534d61 100644
--- a/source/blender/imbuf/intern/rectop.c
+++ b/source/blender/imbuf/intern/rectop.c
@@ -515,7 +515,7 @@ void IMB_rectblend(ImBuf *dbuf,
   const unsigned short *cmaskrect = curvemask, *cmr;
   unsigned short *dmaskrect = dmask, *dmr;
   const unsigned short *texmaskrect = texmask, *tmr;
-  int do_float, do_char, srcskip, destskip, origskip, x;
+  int srcskip, destskip, origskip, x;
   IMB_blend_func func = NULL;
   IMB_blend_func_float func_float = NULL;
 
@@ -535,8 +535,8 @@ void IMB_rectblend(ImBuf *dbuf,
     return;
   }
 
-  do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect);
-  do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float);
+  const bool do_char = (sbuf && sbuf->rect && dbuf->rect && obuf->rect);
+  const bool do_float = (sbuf && sbuf->rect_float && dbuf->rect_float && obuf->rect_float);
 
   if (do_char) {
     drect = dbuf->rect + ((size_t)desty) * dbuf->x + destx;
diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c
index afb0845c23b..f4abc668402 100644
--- a/source/blender/imbuf/intern/scaling.c
+++ b/source/blender/imbuf/intern/scaling.c
@@ -171,14 +171,13 @@ static void imb_half_y_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
   uchar *p1, *p2, *_p1, *dest;
   short a, r, g, b;
   int x, y;
-  int do_rect, do_float;
   float af, rf, gf, bf, *p1f, *p2f, *_p1f, *destf;
 
   p1 = p2 = NULL;
   p1f = p2f = NULL;
 
-  do_rect = (ibuf1->rect != NULL);
-  do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL);
+  const bool do_rect = (ibuf1->rect != NULL);
+  const bool do_float = (ibuf1->rect_float != NULL && ibuf2->rect_float != NULL);
 
   _p1 = (uchar *)ibuf1->rect;
   dest = (uchar *)ibuf2->rect;
@@ -264,7 +263,6 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
   int *p1, *dest1, *dest2;
   float *p1f, *dest1f, *dest2f;
   int x, y;
-  int do_rect, do_float;
 
   if (ibuf1 == NULL) {
     return NULL;
@@ -273,8 +271,8 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1)
     return NULL;
   }
 
-  do_rect = (ibuf1->rect != NULL);
-  do_float = (ibuf1->rect_float != NULL);
+  const bool do_rect = (ibuf1->rect != NULL);
+  const bool do_float = (ibuf1->rect_float != NULL);
 
   ibuf2 = IMB_allocImBuf(ibuf1->x, 2 * ibuf1->y, ibuf1->planes, ibuf1->flags);
   if (ibuf2 == NULL) {
@@ -358,8 +356,8 @@ MINLINE void premul_ushort_to_straight_uchar(unsigned char *result, const unsign
 void imb_onehalf_no_alloc(struct ImBuf *ibuf2, struct ImBuf *ibuf1)
 {
   int x, y;
-  const short do_rect = (ibuf1->rect != NULL);
-  const short do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL);
+  const bool do_rect = (ibuf1->rect != NULL);
+  const bool do_float = (ibuf1->rect_float != NULL) && (ibuf2->rect_float != NULL);
 
   if (do_rect && (ibuf2->rect == NULL)) {
     imb_addrectImBuf(ibuf2);
@@ -892,8 +890,8 @@ static bool q_scale_linear_interpolation(struct ImBuf *ibuf, int newx, int newy)
 
 static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
 {
-  const int do_rect = (ibuf->rect != NULL);
-  const int do_float = (ibuf->rect_float != NULL);
+  const bool do_rect = (ibuf->rect != NULL);
+  const bool do_float = (ibuf->rect_float != NULL);
   const size_t rect_size = IMB_get_rect_len(ibuf) * 4;
 
   uchar *rect, *_newrect, *newrect;
@@ -1033,8 +1031,8 @@ static ImBuf *scaledownx(struct ImBuf *ibuf, int newx)
 
 static ImBuf *scaledowny(struct ImBuf *ibuf, int newy)
 {
-  const int do_rect = (ibuf->rect != NULL);
-  const int do_float = (ibuf->rect_float != NULL);
+  const bool do_rect = (ibuf->rect != NULL);
+  const bool do_float = (ibuf->rect_float != NULL);
   const size_t rect_size = IMB_get_rect_len(ibuf) * 4;
 
   uchar *rect, *_newrect, *newrect;
diff --git a/source/blender/python/BPY_extern.h b/sour

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list