From d900f5be55d0812eb5c7dfd3ea47020c3edafd41 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Feb 2014 18:55:59 +1100 Subject: Code cleanup: use bools where possible --- source/blender/editors/mask/mask_add.c | 10 +++++----- source/blender/editors/mask/mask_draw.c | 22 +++++++++++----------- source/blender/editors/mask/mask_editaction.c | 2 +- source/blender/editors/mask/mask_intern.h | 2 +- source/blender/editors/mask/mask_ops.c | 7 ++++--- source/blender/editors/mask/mask_select.c | 4 ++-- 6 files changed, 24 insertions(+), 23 deletions(-) (limited to 'source/blender/editors/mask') diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index d2704923de1..7fa41c361bb 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -408,9 +408,9 @@ static int add_vertex_extrude(const bContext *C, Mask *mask, MaskLayer *masklay, int point_index; float tangent_point[2]; float tangent_co[2]; - int do_cyclic_correct = FALSE; - int do_recalc_src = FALSE; /* when extruding from endpoints only */ - int do_prev; /* use prev point rather then next?? */ + bool do_cyclic_correct = false; + bool do_recalc_src = false; /* when extruding from endpoints only */ + bool do_prev; /* use prev point rather then next?? */ if (!masklay) { return FALSE; @@ -584,8 +584,8 @@ static int add_vertex_exec(bContext *C, wmOperator *op) MaskSpline *spline = masklay->act_spline; MaskSplinePoint *point = masklay->act_point; - int is_sta = (point == spline->points); - int is_end = (point == &spline->points[spline->tot_point - 1]); + const bool is_sta = (point == spline->points); + const bool is_end = (point == &spline->points[spline->tot_point - 1]); /* then check are we overlapping the mouse */ if ((is_sta || is_end) && equals_v2v2(co, point->bezt.vec[1])) { diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 4cf4cd1ddba..24fcbd19fc1 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -56,7 +56,7 @@ #include "mask_intern.h" /* own include */ -static void mask_spline_color_get(MaskLayer *masklay, MaskSpline *spline, const int is_sel, +static void mask_spline_color_get(MaskLayer *masklay, MaskSpline *spline, const bool is_sel, unsigned char r_rgb[4]) { if (is_sel) { @@ -76,7 +76,7 @@ static void mask_spline_color_get(MaskLayer *masklay, MaskSpline *spline, const r_rgb[3] = 255; } -static void mask_spline_feather_color_get(MaskLayer *UNUSED(masklay), MaskSpline *UNUSED(spline), const int is_sel, +static void mask_spline_feather_color_get(MaskLayer *UNUSED(masklay), MaskSpline *UNUSED(spline), const bool is_sel, unsigned char r_rgb[4]) { if (is_sel) { @@ -136,7 +136,7 @@ static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float c static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline *spline, const char UNUSED(draw_flag), const char draw_type) { - const int is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; + const bool is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; unsigned char rgb_spline[4]; MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); SpaceClip *sc = CTX_wm_space_clip(C); @@ -212,7 +212,7 @@ static void draw_spline_points(const bContext *C, MaskLayer *masklay, MaskSpline float handle[2]; float vert[2]; - int has_handle = BKE_mask_point_has_handle(point); + const bool has_handle = BKE_mask_point_has_handle(point); copy_v2_v2(vert, bezt->vec[1]); BKE_mask_point_handle(point_deform, handle); @@ -295,7 +295,7 @@ static void mask_color_active_tint(unsigned char r_rgb[4], const unsigned char r } static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (*orig_points)[2], int tot_point, - const short is_feather, const short is_smooth, const short is_active, + const bool is_feather, const bool is_smooth, const bool is_active, const unsigned char rgb_spline[4], const char draw_type) { const int draw_method = (spline->flag & MASK_SPLINE_CYCLIC) ? GL_LINE_LOOP : GL_LINE_STRIP; @@ -407,7 +407,7 @@ static void mask_draw_curve_type(const bContext *C, MaskSpline *spline, float (* static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline *spline, const char draw_flag, const char draw_type, - const short is_active, + const bool is_active, int width, int height) { const unsigned int resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height), @@ -415,9 +415,9 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline unsigned char rgb_tmp[4]; - const short is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; - const short is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH); - const short is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0; + const bool is_spline_sel = (spline->flag & SELECT) && (masklay->restrictflag & MASK_RESTRICT_SELECT) == 0; + const bool is_smooth = (draw_flag & MASK_DRAWFLAG_SMOOTH) != 0; + const bool is_fill = (spline->flag & MASK_SPLINE_NOFILL) == 0; unsigned int tot_diff_point; float (*diff_points)[2]; @@ -489,7 +489,7 @@ static void draw_masklays(const bContext *C, Mask *mask, const char draw_flag, c for (masklay = mask->masklayers.first, i = 0; masklay; masklay = masklay->next, i++) { MaskSpline *spline; - const short is_active = (i == mask->masklay_act); + const bool is_active = (i == mask->masklay_act); if (masklay->restrictflag & MASK_RESTRICT_VIEW) { continue; @@ -623,7 +623,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, const char draw_flag, const char draw_type, const char overlay_mode, const int width_i, const int height_i, /* convert directly into aspect corrected vars */ const float aspx, const float aspy, - const short do_scale_applied, const short do_draw_cb, + const bool do_scale_applied, const bool do_draw_cb, float stabmat[4][4], /* optional - only used by clip */ const bContext *C /* optional - only used when do_post_draw is set or called from clip editor */ ) diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 20d49e89771..d4ac0338456 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -110,7 +110,7 @@ void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, short only /* Selection Tools */ /* check if one of the frames in this layer is selected */ -short ED_masklayer_frame_select_check(MaskLayer *masklay) +bool ED_masklayer_frame_select_check(MaskLayer *masklay) { MaskLayerShape *masklay_shape; diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index a666daaafde..62872e72cb4 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -73,7 +73,7 @@ bool ED_mask_feather_find_nearest( struct MaskSplinePoint *ED_mask_point_find_nearest( const struct bContext *C, struct Mask *mask, const float normal_co[2], const float threshold, - struct MaskLayer **masklay_r, struct MaskSpline **spline_r, int *is_handle_r, + struct MaskLayer **masklay_r, struct MaskSpline **spline_r, bool *is_handle_r, float *score); void MASK_OT_layer_move(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 13ae17c6efd..2f7ffd92f90 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -60,7 +60,7 @@ /******************** utility functions *********************/ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, Mask *mask, const float normal_co[2], const float threshold, - MaskLayer **masklay_r, MaskSpline **spline_r, int *is_handle_r, + MaskLayer **masklay_r, MaskSpline **spline_r, bool *is_handle_r, float *score) { ScrArea *sa = CTX_wm_area(C); @@ -471,8 +471,9 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent * MaskSpline *spline, *cv_spline, *feather_spline; MaskSplinePoint *point, *cv_point, *feather_point; MaskSplinePointUW *uw = NULL; - int is_handle = FALSE, width, height, action = SLIDE_ACTION_NONE; - int slide_feather = RNA_boolean_get(op->ptr, "slide_feather"); + int width, height, action = SLIDE_ACTION_NONE; + bool is_handle = false; + const bool slide_feather = RNA_boolean_get(op->ptr, "slide_feather"); float co[2], cv_score, feather_score; const float threshold = 19; diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 497aea27b26..16fd8414f22 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -256,7 +256,7 @@ static int select_exec(bContext *C, wmOperator *op) bool deselect = RNA_boolean_get(op->ptr, "deselect"); bool toggle = RNA_boolean_get(op->ptr, "toggle"); - int is_handle = 0; + bool is_handle = 0; const float threshold = 19; RNA_float_get_array(op->ptr, "location", co); @@ -703,7 +703,7 @@ static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, const wmE float co[2]; int do_select = !RNA_boolean_get(op->ptr, "deselect"); - int is_handle = 0; + bool is_handle = false; const float threshold = 19; bool changed = false; -- cgit v1.2.3