diff options
Diffstat (limited to 'source/blender/editors')
119 files changed, 2657 insertions, 2002 deletions
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 7a3fc3a8d9b..205f67cf96a 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -1037,7 +1037,7 @@ static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned } } -static int ed_marker_select(bContext *C, const wmEvent *event, int extend, int camera) +static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool camera) { ListBase *markers = ED_context_get_markers(C); ARegion *ar = CTX_wm_region(C); @@ -1106,8 +1106,8 @@ static int ed_marker_select(bContext *C, const wmEvent *event, int extend, int c static int ed_marker_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - short extend = RNA_boolean_get(op->ptr, "extend"); - short camera = 0; + bool extend = RNA_boolean_get(op->ptr, "extend"); + bool camera = false; #ifdef DURIAN_CAMERA_SWITCH camera = RNA_boolean_get(op->ptr, "camera"); #endif diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 7ff318bb6b6..bbdc0df41a7 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -454,7 +454,7 @@ static int ebone_select_flag(EditBone *ebone) } /* context: editmode armature in view3d */ -int mouse_armature(bContext *C, const int mval[2], int extend, int deselect, int toggle) +bool mouse_armature(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; @@ -550,10 +550,10 @@ int mouse_armature(bContext *C, const int mval[2], int extend, int deselect, int } WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); - return 1; + return true; } - return 0; + return false; } diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 4fa1389426d..c599e978e58 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -67,7 +67,7 @@ /* called from editview.c, for mode-less pose selection */ /* assumes scene obact and basact is still on old situation */ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, - short extend, short deselect, short toggle) + bool extend, bool deselect, bool toggle) { Object *ob = base->object; Bone *nearBone; @@ -575,7 +575,7 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) /* -------------------------------------- */ -static short pose_select_same_group(bContext *C, Object *ob, short extend) +static short pose_select_same_group(bContext *C, Object *ob, bool extend) { bArmature *arm = (ob) ? ob->data : NULL; bPose *pose = (ob) ? ob->pose : NULL; @@ -607,7 +607,7 @@ static short pose_select_same_group(bContext *C, Object *ob, short extend) } /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) + if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -634,7 +634,7 @@ static short pose_select_same_group(bContext *C, Object *ob, short extend) return changed; } -static short pose_select_same_layer(bContext *C, Object *ob, short extend) +static short pose_select_same_layer(bContext *C, Object *ob, bool extend) { bPose *pose = (ob) ? ob->pose : NULL; bArmature *arm = (ob) ? ob->data : NULL; @@ -652,7 +652,7 @@ static short pose_select_same_layer(bContext *C, Object *ob, short extend) layers |= pchan->bone->layer; /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) + if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -673,7 +673,7 @@ static short pose_select_same_layer(bContext *C, Object *ob, short extend) return changed; } -static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) +static int pose_select_same_keyingset(bContext *C, Object *ob, bool extend) { KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); KS_Path *ksp; @@ -690,7 +690,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) return 0; /* if not extending selection, deselect all selected first */ - if (extend == 0) { + if (extend == false) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 2525641e58c..c530faedd68 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -459,7 +459,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) int selOnly = RNA_boolean_get(op->ptr, "selected_mask"); /* get KeyingSet to use */ - KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOC_ROT_SCALE_ID); + KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); /* sanity checks */ if (ELEM(NULL, ob, ob->pose)) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index e134507600e..f95fbd1eacb 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -3387,156 +3387,14 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt /***************** set spline type operator *******************/ -static int convertspline(short type, Nurb *nu) -{ - BezTriple *bezt; - BPoint *bp; - int a, c, nr; - - if (nu->type == CU_POLY) { - if (type == CU_BEZIER) { /* to Bezier with vecthandles */ - nr = nu->pntsu; - bezt = (BezTriple *)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt = bezt; - a = nr; - bp = nu->bp; - while (a--) { - copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f1 = bezt->f2 = bezt->f3 = bp->f1; - bezt->h1 = bezt->h2 = HD_VECT; - bezt->weight = bp->weight; - bezt->radius = bp->radius; - bp++; - bezt++; - } - MEM_freeN(nu->bp); - nu->bp = NULL; - nu->pntsu = nr; - nu->type = CU_BEZIER; - BKE_nurb_handles_calc(nu); - } - else if (type == CU_NURBS) { - nu->type = CU_NURBS; - nu->orderu = 4; - nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ - BKE_nurb_knot_calc_u(nu); - a = nu->pntsu * nu->pntsv; - bp = nu->bp; - while (a--) { - bp->vec[3] = 1.0; - bp++; - } - } - } - else if (nu->type == CU_BEZIER) { /* Bezier */ - if (type == CU_POLY || type == CU_NURBS) { - nr = 3 * nu->pntsu; - nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype"); - a = nu->pntsu; - bezt = nu->bezt; - bp = nu->bp; - while (a--) { - if (type == CU_POLY && bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) { - /* vector handle becomes 1 poly vertice */ - copy_v3_v3(bp->vec, bezt->vec[1]); - bp->vec[3] = 1.0; - bp->f1 = bezt->f2; - nr -= 2; - bp->radius = bezt->radius; - bp->weight = bezt->weight; - bp++; - } - else { - for (c = 0; c < 3; c++) { - copy_v3_v3(bp->vec, bezt->vec[c]); - bp->vec[3] = 1.0; - if (c == 0) bp->f1 = bezt->f1; - else if (c == 1) bp->f1 = bezt->f2; - else bp->f1 = bezt->f3; - bp->radius = bezt->radius; - bp->weight = bezt->weight; - bp++; - } - } - bezt++; - } - MEM_freeN(nu->bezt); - nu->bezt = NULL; - nu->pntsu = nr; - nu->pntsv = 1; - nu->orderu = 4; - nu->orderv = 1; - nu->type = type; - -#if 0 /* UNUSED */ - if (nu->flagu & CU_NURB_CYCLIC) c = nu->orderu - 1; - else c = 0; -#endif - - if (type == CU_NURBS) { - nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ - nu->flagu |= CU_NURB_BEZIER; - BKE_nurb_knot_calc_u(nu); - } - } - } - else if (nu->type == CU_NURBS) { - if (type == CU_POLY) { - nu->type = CU_POLY; - if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ - nu->knotsu = NULL; - if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv = NULL; - } - else if (type == CU_BEZIER) { /* to Bezier */ - nr = nu->pntsu / 3; - - if (nr < 2) { - return 1; /* conversion impossible */ - } - else { - bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt = bezt; - a = nr; - bp = nu->bp; - while (a--) { - copy_v3_v3(bezt->vec[0], bp->vec); - bezt->f1 = bp->f1; - bp++; - copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f2 = bp->f1; - bp++; - copy_v3_v3(bezt->vec[2], bp->vec); - bezt->f3 = bp->f1; - bezt->radius = bp->radius; - bezt->weight = bp->weight; - bp++; - bezt++; - } - MEM_freeN(nu->bp); - nu->bp = NULL; - MEM_freeN(nu->knotsu); - nu->knotsu = NULL; - nu->pntsu = nr; - nu->type = CU_BEZIER; - } - } - } - - return 0; -} - -void ED_nurb_set_spline_type(Nurb *nu, int type) -{ - convertspline(type, nu); -} - static int set_spline_type_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int changed = 0, type = RNA_enum_get(op->ptr, "type"); + bool change = false; + const bool use_handles = RNA_boolean_get(op->ptr, "use_handles"); + const int type = RNA_enum_get(op->ptr, "type"); if (type == CU_CARDINAL || type == CU_BSPLINE) { BKE_report(op->reports, RPT_ERROR, "Not yet implemented"); @@ -3545,14 +3403,14 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { - if (convertspline(type, nu)) + if (BKE_nurb_type_convert(nu, type, use_handles) == false) BKE_report(op->reports, RPT_ERROR, "No conversion possible"); else - changed = 1; + change = true; } } - if (changed) { + if (change) { if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); @@ -3592,6 +3450,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); + RNA_def_boolean(ot->srna, "use_handles", 0, "Handles", "Use handles when converting bezier curves into polygons"); } /***************** set handle type operator *******************/ @@ -4201,7 +4060,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /***************** pick select from 3d view **********************/ -int mouse_nurb(bContext *C, const int mval[2], int extend, int deselect, int toggle) +bool mouse_nurb(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { Object *obedit = CTX_data_edit_object(C); Curve *cu = obedit->data; @@ -4314,10 +4173,10 @@ int mouse_nurb(bContext *C, const int mval[2], int extend, int deselect, int tog WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - return 1; + return true; } - return 0; + return false; } /******************** spin operator ***********************/ @@ -6275,8 +6134,8 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); // because we removed object(s), call before editmode! - ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); + ED_object_editmode_enter(C, EM_WAITCURSOR); + ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -6291,20 +6150,20 @@ static const char *get_curve_defname(int type) if ((type & CU_TYPE) == CU_BEZIER) { switch (stype) { - case CU_PRIM_CURVE: return "BezierCurve"; - case CU_PRIM_CIRCLE: return "BezierCircle"; - case CU_PRIM_PATH: return "CurvePath"; + case CU_PRIM_CURVE: return DATA_("BezierCurve"); + case CU_PRIM_CIRCLE: return DATA_("BezierCircle"); + case CU_PRIM_PATH: return DATA_("CurvePath"); default: - return "Curve"; + return DATA_("Curve"); } } else { switch (stype) { - case CU_PRIM_CURVE: return "NurbsCurve"; - case CU_PRIM_CIRCLE: return "NurbsCircle"; - case CU_PRIM_PATH: return "NurbsPath"; + case CU_PRIM_CURVE: return DATA_("NurbsCurve"); + case CU_PRIM_CIRCLE: return DATA_("NurbsCircle"); + case CU_PRIM_PATH: return DATA_("NurbsPath"); default: - return "Curve"; + return DATA_("Curve"); } } } @@ -6314,13 +6173,13 @@ static const char *get_surf_defname(int type) int stype = type & CU_PRIMITIVE; switch (stype) { - case CU_PRIM_CURVE: return "SurfCurve"; - case CU_PRIM_CIRCLE: return "SurfCircle"; - case CU_PRIM_PATCH: return "SurfPatch"; - case CU_PRIM_SPHERE: return "SurfSphere"; - case CU_PRIM_DONUT: return "SurfTorus"; + case CU_PRIM_CURVE: return DATA_("SurfCurve"); + case CU_PRIM_CIRCLE: return DATA_("SurfCircle"); + case CU_PRIM_PATCH: return DATA_("SurfPatch"); + case CU_PRIM_SPHERE: return DATA_("SurfSphere"); + case CU_PRIM_DONUT: return DATA_("SurfTorus"); default: - return "Surface"; + return DATA_("Surface"); } } @@ -6744,7 +6603,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) /* userdef */ if (newob && !enter_editmode) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 09a7890a539..59850aff72f 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -757,7 +757,7 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d) /* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly * Note: this gets called twice - first time with only3d=1 to draw 3d-strokes, * second time with only3d=0 for screen-aligned strokes */ -void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) +void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d) { bGPdata *gpd; int dflag = 0; diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 19c1bc34f5c..e7033ef0147 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -198,6 +198,8 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons uiItemR(sub, &ptr, "info", 0, "", ICON_NONE); /* move up/down */ + uiBlockBeginAlign(block); + if (gpl->prev) { but = uiDefIconBut(block, BUT, 0, ICON_TRIA_UP, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Move layer up")); @@ -209,6 +211,8 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons uiButSetFunc(but, gp_ui_layer_down_cb, gpd, gpl); } + uiBlockEndAlign(block); + /* delete 'button' */ uiBlockSetEmboss(block, UI_EMBOSSN); /* right-align ............................... */ diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 671adfb8d1e..e4c7a1edbcb 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -63,6 +63,7 @@ #include "BKE_library.h" #include "BKE_object.h" #include "BKE_report.h" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "UI_interface.h" @@ -393,6 +394,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) enum { GP_STROKECONVERT_PATH = 1, GP_STROKECONVERT_CURVE, + GP_STROKECONVERT_POLY, }; /* Defines for possible timing modes */ @@ -407,6 +409,7 @@ enum { static EnumPropertyItem prop_gpencil_convertmodes[] = { {GP_STROKECONVERT_PATH, "PATH", 0, "Path", ""}, {GP_STROKECONVERT_CURVE, "CURVE", 0, "Bezier Curve", ""}, + {GP_STROKECONVERT_POLY, "POLY", 0, "Polygon Curve", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1278,13 +1281,14 @@ static void gp_stroke_norm_curve_weights(Curve *cu, float minmax_weights[2]) static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bGPDlayer *gpl, int mode, int norm_weights, float rad_fac, int link_strokes, tGpTimingData *gtd) { + struct Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); bGPDstroke *gps, *prev_gps = NULL; Object *ob; Curve *cu; Nurb *nu = NULL; - Base *base = BASACT, *newbase = NULL; + Base *base_orig = BASACT, *base_new = NULL; float minmax_weights[2] = {1.0f, 0.0f}; /* camera framing */ @@ -1306,16 +1310,12 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ - ob = BKE_object_add(scene, OB_CURVE); - zero_v3(ob->loc); - zero_v3(ob->rot); - cu = ob->data; + ob = BKE_object_add_only_object(bmain, OB_CURVE, gpl->info); + cu = ob->data = BKE_curve_add(bmain, gpl->info, OB_CURVE); + base_new = BKE_scene_base_add(scene, ob); + cu->flag |= CU_3D; - /* rename object and curve to layer name */ - rename_id((ID *)ob, gpl->info); - rename_id((ID *)cu, gpl->info); - gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime; /* add points to curve */ @@ -1344,6 +1344,7 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, gtd); break; case GP_STROKECONVERT_CURVE: + case GP_STROKECONVERT_POLY: /* convert after */ gp_stroke_to_bezier(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, gtd); break; default: @@ -1364,19 +1365,15 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG /* Create the path animation, if needed */ gp_stroke_path_animation(C, reports, cu, gtd); - /* Reset original object as active, else we can't edit operator's settings!!! */ - /* set layers OK */ - newbase = BASACT; - if (base) { - newbase->lay = base->lay; - ob->lay = newbase->lay; - } - - /* restore, BKE_object_add sets active */ - BASACT = base; - if (base) { - base->flag |= SELECT; + if (mode == GP_STROKECONVERT_POLY) { + for (nu = cu->nurb.first; nu; nu = nu->next) { + BKE_nurb_type_convert(nu, CU_POLY, false); + } } + + /* set the layer and select */ + base_new->lay = ob->lay = base_orig ? base_orig->lay : scene->lay; + base_new->flag = ob->flag = base_new->flag | SELECT; } /* --- */ @@ -1526,7 +1523,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } -static int gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); int link_strokes = RNA_boolean_get(ptr, "use_link_strokes"); @@ -1542,7 +1539,7 @@ static int gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) strcmp(prop_id, "radius_multiplier") == 0 || strcmp(prop_id, "use_link_strokes") == 0) { - return TRUE; + return true; } /* Never show this prop */ @@ -1550,44 +1547,44 @@ static int gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) return FALSE; if (link_strokes) { - /* Only show when link_stroke is TRUE */ + /* Only show when link_stroke is true */ if (strcmp(prop_id, "timing_mode") == 0) - return TRUE; + return true; if (timing_mode != GP_STROKECONVERT_TIMING_NONE) { - /* Only show when link_stroke is TRUE and stroke timing is enabled */ + /* Only show when link_stroke is true and stroke timing is enabled */ if (strcmp(prop_id, "frame_range") == 0 || strcmp(prop_id, "start_frame") == 0) { - return TRUE; + return true; } /* Only show if we have valid timing data! */ if (valid_timing && strcmp(prop_id, "use_realtime") == 0) - return TRUE; + return true; /* Only show if realtime or valid_timing is FALSE! */ if ((!realtime || !valid_timing) && strcmp(prop_id, "end_frame") == 0) - return TRUE; + return true; if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { /* Only show for custom gaps! */ if (strcmp(prop_id, "gap_duration") == 0) - return TRUE; + return true; /* Only show randomness for non-null custom gaps! */ if (strcmp(prop_id, "gap_randomness") == 0 && (gap_duration > 0.0f)) - return TRUE; + return true; /* Only show seed for randomize action! */ if (strcmp(prop_id, "seed") == 0 && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) - return TRUE; + return true; } } } /* Else, hidden! */ - return FALSE; + return false; } static void gp_convert_ui(bContext *C, wmOperator *op) diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 1c2ec27a061..b8ad40b2bd9 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -474,7 +474,7 @@ void ANIM_timecode_string_from_frame(char *str, struct Scene *scene, int power, /* ---------- Current Frame Drawing ---------------- */ /* flags for Current Frame Drawing */ -enum { +enum eAnimEditDraw_CurrentFrame { /* plain time indicator with no special indicators */ DRAWCFRA_PLAIN = 0, /* draw box indicating current frame number */ @@ -483,7 +483,7 @@ enum { DRAWCFRA_UNIT_SECONDS = (1 << 1), /* draw indicator extra wide (for timeline) */ DRAWCFRA_WIDE = (1 << 2) -} eAnimEditDraw_CurrentFrame; +}; /* main call to draw current-frame indicator in an Animation Editor */ void ANIM_draw_cfra(const struct bContext *C, struct View2D *v2d, short flag); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 310b60f13e8..3367dcb9c4c 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -123,8 +123,8 @@ void ED_armature_deselect_all(struct Object *obedit, int toggle); void ED_armature_deselect_all_visible(struct Object *obedit); int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, - short hits, short extend, short deselect, short toggle); -int mouse_armature(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); + short hits, bool extend, bool deselect, bool toggle); +bool mouse_armature(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone(struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 66c1798f507..1d26204095c 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -63,12 +63,11 @@ void load_editNurb(struct Object *obedit); void make_editNurb(struct Object *obedit); void free_editNurb(struct Object *obedit); -int mouse_nurb(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); +bool mouse_nurb(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); struct Nurb *add_nurbs_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], int type, int newob); int isNurbsel(struct Nurb *nu); -void ED_nurb_set_spline_type(struct Nurb *nu, int type); int join_curve_exec(struct bContext *C, struct wmOperator *op); diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 29d4097521d..cb4a81be8b8 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -79,7 +79,7 @@ void ED_operatortypes_gpencil(void); void draw_gpencil_2dimage(const struct bContext *C); void draw_gpencil_view2d(const struct bContext *C, short onlyv2d); -void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, short only3d); +void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, bool only3d); void gpencil_panel_standard_header(const struct bContext *C, struct Panel *pa); void gpencil_panel_standard(const struct bContext *C, struct Panel *pa); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 4655188a3dd..da96aba011e 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -41,7 +41,7 @@ void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, struct Object *obedit, float mat[4][4], float dia, int type, int newname); -int mouse_mball(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); +bool mouse_mball(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); void free_editMball(struct Object *obedit); void make_editMball(struct Object *obedit); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index e704b8f0bf3..f84281a4f08 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -74,7 +74,7 @@ struct rcti; /* editmesh_utils.c */ -void EDBM_verts_mirror_cache_begin(struct BMEditMesh *em, const short use_select); /* note, replaces EM_cache_x_mirror_vert in trunk */ +void EDBM_verts_mirror_cache_begin(struct BMEditMesh *em, const bool use_select); /* note, replaces EM_cache_x_mirror_vert in trunk */ void EDBM_verts_mirror_apply(struct BMEditMesh *em, const int sel_from, const int sel_to); struct BMVert *EDBM_verts_mirror_get(struct BMEditMesh *em, struct BMVert *v); void EDBM_verts_mirror_cache_clear(struct BMEditMesh *em, struct BMVert *v); @@ -93,7 +93,7 @@ void EDBM_index_arrays_ensure(struct BMEditMesh *em, const char htype) void EDBM_index_arrays_init(struct BMEditMesh *em, const char htype); void EDBM_index_arrays_free(struct BMEditMesh *em); #ifndef NDEBUG -int EDBM_index_arrays_check(struct BMEditMesh *em); +bool EDBM_index_arrays_check(struct BMEditMesh *em); #endif struct BMVert *EDBM_vert_at_index(struct BMEditMesh *em, int index); struct BMEdge *EDBM_edge_at_index(struct BMEditMesh *em, int index); @@ -137,30 +137,33 @@ void EDBM_flag_disable_all(struct BMEditMesh *em, const char hflag); /* editmesh_select.c */ -void EDBM_select_mirrored(struct Object *obedit, struct BMEditMesh *em, int extend); +void EDBM_select_mirrored(struct Object *obedit, struct BMEditMesh *em, bool extend); void EDBM_automerge(struct Scene *scene, struct Object *ob, int update); -int EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); +bool EDBM_backbuf_border_init(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); int EDBM_backbuf_check(unsigned int index); void EDBM_backbuf_free(void); -int EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot, +bool EDBM_backbuf_border_mask_init(struct ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); -int EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads); +bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads); -struct BMVert *EDBM_vert_find_nearest(struct ViewContext *vc, float *r_dist, const short sel, const short strict); +struct BMVert *EDBM_vert_find_nearest(struct ViewContext *vc, float *r_dist, const bool sel, const bool strict); struct BMEdge *EDBM_edge_find_nearest(struct ViewContext *vc, float *r_dist); struct BMFace *EDBM_face_find_nearest(struct ViewContext *vc, float *r_dist); -int EDBM_select_pick(struct bContext *C, const int mval[2], short extend, short deselect, short toggle); +bool EDBM_select_pick(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); void EDBM_selectmode_set(struct BMEditMesh *em); void EDBM_selectmode_convert(struct BMEditMesh *em, const short selectmode_old, const short selectmode_new); /* user access this */ -int EDBM_selectmode_toggle(struct bContext *C, const short selectmode_new, - const int action, const int use_extend, const int use_expand); +bool EDBM_selectmode_toggle(struct bContext *C, const short selectmode_new, + const int action, const bool use_extend, const bool use_expand); +bool EDBM_selectmode_disable(struct Scene *scene, struct BMEditMesh *em, + const short selectmode_disable, + const short selectmode_fallback); void EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const short select); @@ -183,17 +186,17 @@ void EMBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEd /* editface.c */ void paintface_flush_flags(struct Object *ob); -int paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], int extend, int deselect, int toggle); -int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend); -void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags); +bool paintface_mouse_select(struct bContext *C, struct Object *ob, const int mval[2], bool extend, bool deselect, bool toggle); +int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, bool select, bool extend); +void paintface_deselect_all_visible(struct Object *ob, int action, bool flush_flags); void paintface_select_linked(struct bContext *C, struct Object *ob, const int mval[2], int mode); -int paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]); +bool paintface_minmax(struct Object *ob, float r_min[3], float r_max[3]); void paintface_hide(struct Object *ob, const int unselected); void paintface_reveal(struct Object *ob); -void paintvert_deselect_all_visible(struct Object *ob, int action, short flush_flags); -void paintvert_select_ungrouped(struct Object *ob, short extend, short flush_flags); +void paintvert_deselect_all_visible(struct Object *ob, int action, bool flush_flags); +void paintvert_select_ungrouped(struct Object *ob, bool extend, bool flush_flags); void paintvert_flush_flags(struct Object *ob); /* mirrtopo */ @@ -204,9 +207,9 @@ typedef struct MirrTopoStore_t { int prev_ob_mode; } MirrTopoStore_t; -int ED_mesh_mirrtopo_recalc_check(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store); +bool ED_mesh_mirrtopo_recalc_check(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store); void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store, - const short skip_em_vert_array_init); + const bool skip_em_vert_array_init); void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); @@ -251,13 +254,16 @@ void ED_mesh_calc_tessface(struct Mesh *mesh); void ED_mesh_material_link(struct Mesh *me, struct Material *ma); void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface); -int ED_mesh_uv_texture_add(struct bContext *C, struct Mesh *me, const char *name, int active_set); -int ED_mesh_uv_texture_remove(struct bContext *C, struct Object *ob, struct Mesh *me); +int ED_mesh_uv_texture_add(struct Mesh *me, const char *name, const bool active_set); +bool ED_mesh_uv_texture_remove_index(struct Mesh *me, const int n); +bool ED_mesh_uv_texture_remove_active(struct Mesh *me); +bool ED_mesh_uv_texture_remove_named(struct Mesh *me, const char *name); int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me); int ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum); -int ED_mesh_color_add(struct bContext *C, struct Scene *scene, struct Object *ob, struct Mesh *me, const char *name, int active_set); -int ED_mesh_color_remove(struct bContext *C, struct Object *ob, struct Mesh *me); -int ED_mesh_color_remove_named(struct bContext *C, struct Object *ob, struct Mesh *me, const char *name); +int ED_mesh_color_add(struct Mesh *me, const char *name, const bool active_set); +bool ED_mesh_color_remove_index(struct Mesh *me, const int n); +bool ED_mesh_color_remove_active(struct Mesh *me); +bool ED_mesh_color_remove_named(struct Mesh *me, const char *name); /* mesh backup */ typedef struct BMBackup { @@ -286,9 +292,9 @@ int mesh_get_x_mirror_vert(struct Object *ob, int index); struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, const float co[3], int index); int *mesh_get_x_mirror_faces(struct Object *ob, struct BMEditMesh *em); -int ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size, int use_zbuf); -int ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size); -int ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size); +bool ED_mesh_pick_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf); +bool ED_mesh_pick_face(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size); +bool ED_mesh_pick_face_vert(struct bContext *C, struct Object *ob, const int mval[2], unsigned int *index, int size); #define ED_MESH_PICK_DEFAULT_VERT_SIZE 50 #define ED_MESH_PICK_DEFAULT_FACE_SIZE 3 diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index 2c43f6e4f25..e23465f15a8 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -128,8 +128,9 @@ void ED_object_toggle_modes(struct bContext *C, int mode); #define EM_WAITCURSOR 4 #define EM_DO_UNDO 8 #define EM_IGNORE_LAYER 16 -void ED_object_exit_editmode(struct bContext *C, int flag); -void ED_object_enter_editmode(struct bContext *C, int flag); +void ED_object_editmode_exit(struct bContext *C, int flag); +void ED_object_editmode_enter(struct bContext *C, int flag); +bool ED_object_editmode_load(struct Object *obedit); void ED_object_location_from_view(struct bContext *C, float loc[3]); void ED_object_rotation_from_view(struct bContext *C, float rot[3]); @@ -164,7 +165,7 @@ void ED_object_constraint_update(struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Object *ob); /* object_lattice.c */ -int mouse_lattice(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); +bool mouse_lattice(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); void undo_push_lattice(struct bContext *C, const char *name); /* object_lattice.c */ @@ -190,7 +191,7 @@ int ED_object_modifier_apply(struct ReportList *reports, struct Scene *scene, struct Object *ob, struct ModifierData *md, int mode); int ED_object_modifier_copy(struct ReportList *reports, struct Object *ob, struct ModifierData *md); -int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, int include_orig, +int ED_object_iter_other(struct Main *bmain, struct Object *orig_ob, const bool include_orig, int (*callback)(struct Object *ob, void *callback_data), void *callback_data); diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index dee97c7882a..f9516f255cf 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -58,10 +58,10 @@ void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); /* selection tools */ -int PE_mouse_particles(struct bContext *C, const int mval[2], int extend, int deselect, int toggle); -int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend); +int PE_mouse_particles(struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle); +int PE_border_select(struct bContext *C, struct rcti *rect, bool select, bool extend); int PE_circle_select(struct bContext *C, int selecting, const int mval[2], float rad); -int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, short extend, short select); +int PE_lasso_select(struct bContext *C, const int mcords[][2], const short moves, bool extend, bool select); void PE_deselect_all_visible(struct PTCacheEdit *edit); /* undo */ diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 6101d03b946..d43582fa8d1 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -52,7 +52,7 @@ void transform_operatortypes(void); /* ******************** Macros & Prototypes *********************** */ /* MODE AND NUMINPUT FLAGS */ -enum { +enum TfmMode { TFM_INIT = -1, TFM_DUMMY, TFM_TRANSLATION, @@ -85,7 +85,7 @@ enum { TFM_EDGE_SLIDE, TFM_VERT_SLIDE, TFM_SEQ_SLIDE -} TfmMode; +}; /* TRANSFORM CONTEXTS */ #define CTX_NONE 0 @@ -125,7 +125,7 @@ void BIF_createTransformOrientation(struct bContext *C, struct ReportList *repor void BIF_selectTransformOrientation(struct bContext *C, struct TransformOrientation *ts); void BIF_selectTransformOrientationValue(struct bContext *C, int orientation); -void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], int activeOnly); +void ED_getTransformOrientationMatrix(const struct bContext *C, float orientation_mat[3][3], const bool activeOnly); struct EnumPropertyItem *BIF_enumTransformOrientation(struct bContext *C); const char *BIF_menustringTransformOrientation(const struct bContext *C, const char *title); /* the returned value was allocated and needs to be freed after use */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 12afeb2d343..81f49b4e1f8 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -79,7 +79,7 @@ typedef struct ViewDepths { float *depths; double depth_range[2]; - char damaged; + bool damaged; } ViewDepths; float *give_cursor(struct Scene *scene, struct View3D *v3d); @@ -201,8 +201,10 @@ void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coo void ED_view3d_win_to_3d(const struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); void ED_view3d_win_to_delta(const struct ARegion *ar, const float mval[2], float out[3], const float zfac); void ED_view3d_win_to_vector(const struct ARegion *ar, const float mval[2], float out[3]); -void ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); -int ED_view3d_win_to_segment_clip(const struct ARegion *ar, struct View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]); +void ED_view3d_win_to_segment(const struct ARegion *ar, struct View3D *v3d, const float mval[2], + float ray_start[3], float ray_end[3]); +bool ED_view3d_win_to_segment_clip(const struct ARegion *ar, struct View3D *v3d, const float mval[2], + float ray_start[3], float ray_end[3]); void ED_view3d_ob_project_mat_get(const struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); void ED_view3d_unproject(struct bglMats *mats, float out[3], const float x, const float y, const float z); @@ -223,7 +225,7 @@ void ED_view3d_calc_camera_border_size(struct Scene *scene, struct ARegion *ar, void ED_view3d_clipping_calc(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, const struct rcti *rect); void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[4][4]); -int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float co[3], const bool is_local); +bool ED_view3d_clipping_test(struct RegionView3D *rv3d, const float co[3], const bool is_local); void ED_view3d_clipping_set(struct RegionView3D *rv3d); void ED_view3d_clipping_enable(void); void ED_view3d_clipping_disable(void); @@ -244,13 +246,13 @@ unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const int mval[2 unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* draws and does a 4x4 sample */ -int ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride); +bool ED_view3d_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride); /* only draw so ED_view3d_autodist_simple can be called many times after */ -int ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode); -int ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth); -int ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth); -int ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth); +void ED_view3d_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode); +bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth); +bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth); +bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth); /* select */ #define MAXPICKBUF 10000 @@ -264,11 +266,11 @@ void view3d_opengl_read_pixels(struct ARegion *ar, int x, int y, int w, int h, i void view3d_get_transformation(const struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); /* XXX should move to BLI_math */ -int edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2]); +bool edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2]); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); -int ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_ar); +bool ED_view3d_context_user_region(struct bContext *C, struct View3D **r_v3d, struct ARegion **r_ar); int ED_operator_rv3d_user_region_poll(struct bContext *C); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); @@ -276,19 +278,19 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d); int ED_view3d_scene_layer_set(int lay, const int *values, int *active); -int ED_view3d_context_activate(struct bContext *C); +bool ED_view3d_context_activate(struct bContext *C); void ED_view3d_draw_offscreen_init(struct Scene *scene, struct View3D *v3d); void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, - int winx, int winy, float viewmat[4][4], float winmat[4][4], int do_bgpic); + int winx, int winy, float viewmat[4][4], float winmat[4][4], bool do_bgpic); struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, - int draw_background, int alpha_mode, char err_out[256]); + bool draw_background, int alpha_mode, char err_out[256]); struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(struct Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, - int use_solid_tex, int draw_background, int alpha_mode, char err_out[256]); + bool use_solid_tex, bool draw_background, int alpha_mode, char err_out[256]); void ED_view3d_offscreen_sky_color_get(struct Scene *scene, float sky_color[3]); struct Base *ED_view3d_give_base_under_cursor(struct bContext *C, const int mval[2]); -void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); +void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, bool do_clip); void ED_view3d_update_viewmat(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, float viewmat[4][4], float winmat[4][4]); bool ED_view3d_lock(struct RegionView3D *rv3d); @@ -297,11 +299,11 @@ uint64_t ED_view3d_screen_datamask(struct bScreen *screen); uint64_t ED_view3d_object_datamask(struct Scene *scene); /* camera lock functions */ -int ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); +bool ED_view3d_camera_lock_check(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the camera to the view before starting a view transformation */ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ -int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); +bool ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); void ED_view3D_lock_clear(struct View3D *v3d); diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 0560cbd69cc..2e2842210c2 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -748,10 +748,8 @@ DEF_ICON(PASTEFLIPDOWN) DEF_ICON(BLANK230) #endif DEF_ICON(SNAP_SURFACE) -#ifndef DEF_ICON_BLANK_SKIP - DEF_ICON(BLANK232) - DEF_ICON(BLANK233) -#endif +DEF_ICON(AUTOMERGE_ON) +DEF_ICON(AUTOMERGE_OFF) DEF_ICON(RETOPO) DEF_ICON(UV_VERTEXSEL) DEF_ICON(UV_EDGESEL) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index f805b199280..3b4415703d5 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -223,7 +223,7 @@ typedef enum { NUMSLI = (14 << 9), COLOR = (15 << 9), IDPOIN = (16 << 9), - HSVSLI = (17 << 9), /* UNUSED, but code still references */ + /* HSVSLI = (17 << 9), */ /* UNUSED */ SCROLL = (18 << 9), BLOCK = (19 << 9), BUTM = (20 << 9), @@ -608,7 +608,7 @@ uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, const char *str, int x, in uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, int x, int y, short width, short height, float a1, float a2, const char *tip); uiBut *uiDefAutoButR(uiBlock *block, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, const char *name, int icon, int x1, int y1, int x2, int y2); -int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); +int uiDefAutoButsRNA(uiLayout *layout, struct PointerRNA *ptr, bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align); /* Links * @@ -762,7 +762,7 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct Pointe void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context); const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, - int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), + bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag); struct MenuType *uiButGetMenuType(uiBut *but); @@ -922,5 +922,4 @@ void UI_template_fix_linking(void); int UI_editsource_enable_check(void); void UI_editsource_active_but_test(uiBut *but); -#endif /* __UI_INTERFACE_H__ */ - +#endif /* __UI_INTERFACE_H__ */ diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 308ca8c9355..050e9c81f2a 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -310,4 +310,4 @@ const unsigned char *UI_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, i void UI_make_axis_color(const unsigned char *src_col, unsigned char *dst_col, const char axis); -#endif /* UI_ICONS_H */ +#endif /* UI_RESOURCES_H */ diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index 3743539a9bd..100e72e18ed 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -47,7 +47,7 @@ * and settings for a View2D region, and that set of settings is used in more * than one specific place */ -enum { +enum eView2D_CommonViewTypes { /* custom view type (region has defined all necessary flags already) */ V2D_COMMONVIEW_CUSTOM = -1, /* standard (only use this when setting up a new view, as a sensible base for most settings) */ @@ -60,7 +60,7 @@ enum { V2D_COMMONVIEW_HEADER, /* ui region containing panels */ V2D_COMMONVIEW_PANELS_UI -} eView2D_CommonViewTypes; +}; /* ---- Defines for Scroller/Grid Arguments ----- */ @@ -68,7 +68,7 @@ enum { #define V2D_ARG_DUMMY -1 /* Grid units */ -enum { +enum eView2D_Units { /* for drawing time */ V2D_UNIT_SECONDS = 0, V2D_UNIT_FRAMES, @@ -79,16 +79,16 @@ enum { V2D_UNIT_DEGREES, V2D_UNIT_TIME, V2D_UNIT_SECONDSSEQ -} eView2D_Units; +}; /* clamping of grid values to whole numbers */ -enum { +enum eView2D_Clamp { V2D_GRID_NOCLAMP = 0, V2D_GRID_CLAMP -} eView2D_Clamp; +}; /* flags for grid-lines to draw */ -enum { +enum eView2D_Gridlines { V2D_HORIZONTAL_LINES = (1 << 0), V2D_VERTICAL_LINES = (1 << 1), V2D_HORIZONTAL_AXIS = (1 << 2), @@ -97,7 +97,7 @@ enum { V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES | V2D_HORIZONTAL_AXIS), V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES), -} eView2D_Gridlines; +}; /* ------ Defines for Scrollers ----- */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 4f0d788d733..16598511921 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1492,18 +1492,6 @@ double ui_get_but_val(uiBut *but) break; } } - else if (but->type == HSVSLI) { - float *fp, hsv[3]; - - fp = (but->editvec) ? but->editvec : (float *)but->poin; - rgb_to_hsv_v(fp, hsv); - - switch (but->str[0]) { - case 'H': value = hsv[0]; break; - case 'S': value = hsv[1]; break; - case 'V': value = hsv[2]; break; - } - } else if (but->pointype == UI_BUT_POIN_CHAR) { value = *(char *)but->poin; } @@ -1570,21 +1558,6 @@ void ui_set_but_val(uiBut *but, double value) else if (but->pointype == 0) { /* pass */ } - else if (but->type == HSVSLI) { - float *fp, hsv[3]; - - fp = (but->editvec) ? but->editvec : (float *)but->poin; - rgb_to_hsv_v(fp, hsv); - - switch (but->str[0]) { - case 'H': hsv[0] = value; break; - case 'S': hsv[1] = value; break; - case 'V': hsv[2] = value; break; - } - - hsv_to_rgb_v(hsv, fp); - - } else { /* first do rounding */ if (but->pointype == UI_BUT_POIN_CHAR) { @@ -2300,7 +2273,6 @@ void ui_check_but(uiBut *but) case SLI: case SCROLL: case NUMSLI: - case HSVSLI: UI_GET_BUT_VALUE_INIT(but, value); if (value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); else if (value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); @@ -2360,7 +2332,6 @@ void ui_check_but(uiBut *but) case NUM: case NUMSLI: - case HSVSLI: case NUMABS: UI_GET_BUT_VALUE_INIT(but, value); @@ -2786,7 +2757,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->pos = -1; /* cursor invisible */ - if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { /* add a space to name */ + if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* add a space to name */ /* slen remains unchanged from previous assignment, ensure this stays true */ if (slen > 0 && slen < UI_MAX_NAME_STR - 2) { if (but->str[slen - 1] != ' ') { @@ -3963,7 +3934,7 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...) } } else if (type == BUT_GET_RNA_LABEL_CONTEXT) { - const char *_tmp = NULL; + const char *_tmp = BLF_I18NCONTEXT_DEFAULT; if (but->rnaprop) _tmp = RNA_property_translation_context(but->rnaprop); else if (but->optype) @@ -3973,8 +3944,8 @@ void uiButGetStrInfo(bContext *C, uiBut *but, ...) if (mt) _tmp = RNA_struct_translation_context(mt->ext.srna); } - if (!_tmp) { /* _tmp == BLF_I18NCONTEXT_DEFAULT */ - _tmp = BLF_I18NCONTEXT_DEFAULT_BPY; + if (BLF_is_default_context(_tmp)) { + _tmp = BLF_I18NCONTEXT_DEFAULT_BPYRNA; } tmp = BLI_strdup(_tmp); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 54a173af603..b34f4c9653f 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1270,8 +1270,6 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut case NUMSLI: ui_apply_but_NUM(C, but, data); break; - case HSVSLI: - break; case TOG3: ui_apply_but_TOG3(C, but, data); break; @@ -1393,7 +1391,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } /* numeric value */ - if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { + if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { if (but->poin == NULL && but->rnapoin.data == NULL) { /* pass */ @@ -2053,7 +2051,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa return; for (but = actbut->next; but; but = but->next) { - if (ELEM8(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2062,7 +2060,7 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } } for (but = block->buttons.first; but != actbut; but = but->next) { - if (ELEM8(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2081,7 +2079,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa return; for (but = actbut->prev; but; but = but->prev) { - if (ELEM8(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -2090,7 +2088,7 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa } } for (but = block->buttons.last; but != actbut; but = but->prev) { - if (ELEM8(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, IDPOIN, SEARCH_MENU, SEARCH_MENU_UNLINK)) { if (!(but->flag & UI_BUT_DISABLED)) { data->postbut = but; data->posttype = BUTTON_ACTIVATE_TEXT_EDITING; @@ -3121,10 +3119,6 @@ static bool ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, offs = (BLI_rctf_size_y(&but->rect) / 2.0f) * but->aspect; deler = BLI_rctf_size_x(&but->rect) - offs; } - else if (but->type == HSVSLI) { - offs = (BLI_rctf_size_y(&but->rect) / 2.0f) * but->aspect; - deler = (BLI_rctf_size_x(&but->rect) / 2.0f) - offs; - } else if (but->type == SCROLL) { const float size = (is_horizontal) ? BLI_rctf_size_x(&but->rect) : -BLI_rctf_size_y(&but->rect); deler = size * (but->softmax - but->softmin) / (but->softmax - but->softmin + but->a1); @@ -5423,7 +5417,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * break; case SLI: case NUMSLI: - case HSVSLI: retval = ui_do_but_SLI(C, block, but, data, event); break; case ROUNDBOX: diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 19b863dd6fa..9f836ed789f 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -208,12 +208,6 @@ struct uiBut { struct bContextStore *context; - /* not used yet, was used in 2.4x for ui_draw_pulldown_round & friends */ -#if 0 - void (*embossfunc)(int, int, float, float, float, float, float, int); - void (*sliderfunc)(int, float, float, float, float, float, float, int); -#endif - uiButCompleteFunc autocomplete_func; void *autofunc_arg; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 2ca26ae5317..53887163778 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1599,6 +1599,14 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) else but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); + /* to compensate for string size padding in ui_text_icon_width, + * make text aligned right if the layout is aligned right. + */ + if (uiLayoutGetAlignment(layout) == UI_LAYOUT_ALIGN_RIGHT) { + but->flag &= ~UI_TEXT_LEFT; /* default, needs to be unset */ + but->flag |= UI_TEXT_RIGHT; + } + return but; } @@ -2914,7 +2922,7 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, /* this function does not initialize the layout, functions can be called on the layout before and after */ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, - int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), + bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag) { if (!op->properties) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index a741ea432a5..ca26044f662 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1378,19 +1378,5 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat } ED_region_tag_redraw(ar); - - /* XXX exception handling, 3d window preview panel */ -#if 0 - if (block->drawextra == BIF_view3d_previewdraw) - BIF_view3d_previewrender_clear(curarea); -#endif - - /* XXX exception handling, 3d window preview panel */ -#if 0 - if (block->drawextra == BIF_view3d_previewdraw) - BIF_view3d_previewrender_signal(curarea, PR_DISPRECT); - else if (strcmp(block->name, "image_panel_preview") == 0) - image_preview_event(2); -#endif } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 7c84784c46b..3bf1a1a7701 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -137,7 +137,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind * in cases where PROP_HIDDEN flag can't be used for a property. */ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, - int (*check_prop)(PointerRNA *, PropertyRNA *), + bool (*check_prop)(PointerRNA *, PropertyRNA *), const char label_align) { uiLayout *split, *col; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f2e553bd140..96c8ded46da 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1147,6 +1147,8 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b if (but->editstr || (but->flag & UI_TEXT_LEFT)) fstyle->align = UI_STYLE_TEXT_LEFT; + else if (but->flag & UI_TEXT_RIGHT) + fstyle->align = UI_STYLE_TEXT_RIGHT; else fstyle->align = UI_STYLE_TEXT_CENTER; @@ -1333,10 +1335,16 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB if (but->editstr || (but->flag & UI_TEXT_LEFT)) { rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } + else if ((but->flag & UI_TEXT_RIGHT)) { + rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; + } } else if ((but->flag & UI_TEXT_LEFT)) { rect->xmin += (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } + else if ((but->flag & UI_TEXT_RIGHT)) { + rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; + } /* unlink icon for this button type */ if (but->type == SEARCH_MENU_UNLINK && but->drawstr[0]) { @@ -3216,7 +3224,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; case NUMSLI: - case HSVSLI: wt = widget_type(UI_WTYPE_SLIDER); break; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 013b6d3c606..a66169d54ae 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2086,13 +2086,8 @@ void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y) } void UI_view2d_setcenter(struct View2D *v2d, float x, float y) { - /* get delta from current center */ - float dx = x - BLI_rctf_cent_x(&v2d->cur); - float dy = y - BLI_rctf_cent_y(&v2d->cur); + BLI_rctf_recenter(&v2d->cur, x, y); - /* add to cur */ - BLI_rctf_translate(&v2d->cur, dx, dy); - /* make sure that 'cur' rect is in a valid state as a result of these changes */ UI_view2d_curRect_validate(v2d); } diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index c673e0fb2b0..a1bb7a8ae88 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -127,7 +127,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) second_life = RNA_boolean_get(op->ptr, "second_life"); /* get editmode results */ - ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + ED_object_editmode_load(CTX_data_edit_object(C)); if (collada_export(CTX_data_scene(C), filepath, diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index f2a0532932d..a33340cc39a 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -31,6 +31,8 @@ #include "io_collada.h" +#include "BLI_utildefines.h" + #include "WM_types.h" #include "WM_api.h" diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index ccc2fad5f52..7de6f66f2ef 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -252,9 +252,9 @@ static int select_exec(bContext *C, wmOperator *op) MaskSpline *spline; MaskSplinePoint *point = NULL; float co[2]; - short extend = RNA_boolean_get(op->ptr, "extend"); - short deselect = RNA_boolean_get(op->ptr, "deselect"); - short toggle = RNA_boolean_get(op->ptr, "toggle"); + bool extend = RNA_boolean_get(op->ptr, "extend"); + bool deselect = RNA_boolean_get(op->ptr, "deselect"); + bool toggle = RNA_boolean_get(op->ptr, "toggle"); int is_handle = 0; const float threshold = 19; @@ -263,7 +263,7 @@ static int select_exec(bContext *C, wmOperator *op) point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL); - if (extend == 0 && deselect == 0 && toggle == 0) + if (extend == false && deselect == false && toggle == false) ED_mask_select_toggle_all(mask, SEL_DESELECT); if (point) { diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 260d01d726a..d6ae2497cbb 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -203,7 +203,8 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind MLoop *ml; MEdge *med; char *linkflag; - int a, b, do_it = TRUE, mark = 0; + int a, b, mark = 0; + bool do_it = true; ehash = BLI_edgehash_new(); seamhash = BLI_edgehash_new(); @@ -234,7 +235,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind } while (do_it) { - do_it = FALSE; + do_it = false; /* expand selection */ mp = me->mpoly; @@ -257,7 +258,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind if (mark) { linkflag[a] = 1; hash_add_face(ehash, mp, me->mloop + mp->loopstart); - do_it = TRUE; + do_it = true; } } } @@ -315,7 +316,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, const int UNUSED(m paintface_flush_flags(ob); } -void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) +void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags) { Mesh *me; MPoly *mpoly; @@ -374,14 +375,15 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) } } -int paintface_minmax(Object *ob, float r_min[3], float r_max[3]) +bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) { Mesh *me; MPoly *mp; MTexPoly *tf; MLoop *ml; MVert *mvert; - int a, b, ok = FALSE; + int a, b; + bool ok = false; float vec[3], bmat[3][3]; me = BKE_mesh_from_object(ob); @@ -404,7 +406,7 @@ int paintface_minmax(Object *ob, float r_min[3], float r_max[3]) minmax_v3v3_v3(r_min, r_max, vec); } - ok = TRUE; + ok = true; } return ok; @@ -483,7 +485,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) } #endif -int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], int extend, int deselect, int toggle) +bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], bool extend, bool deselect, bool toggle) { Mesh *me; MPoly *mpoly, *mpoly_sel; @@ -493,13 +495,13 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in me = BKE_mesh_from_object(ob); if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) - return 0; + return false; if (index >= me->totpoly) - return 0; + return false; mpoly_sel = me->mpoly + index; - if (mpoly_sel->flag & ME_HIDE) return 0; + if (mpoly_sel->flag & ME_HIDE) return false; /* clear flags */ mpoly = me->mpoly; @@ -534,10 +536,10 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in paintface_flush_flags(ob); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views - return 1; + return true; } -int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) +int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { Object *ob = vc->obact; Mesh *me; @@ -556,8 +558,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) selar = MEM_callocN(me->totpoly + 1, "selar"); - if (extend == 0 && select) { - paintface_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE); + if (extend == false && select) { + paintface_deselect_all_visible(vc->obact, SEL_DESELECT, false); mpoly = me->mpoly; for (a = 1; a <= me->totpoly; a++, mpoly++) { @@ -652,8 +654,8 @@ void paintvert_flush_flags(Object *ob) } } } -/* note: if the caller passes FALSE to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */ -void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) +/* note: if the caller passes false to flush_flags, then they will need to run paintvert_flush_flags(ob) themselves */ +void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags) { Mesh *me; MVert *mvert; @@ -712,7 +714,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) } } -void paintvert_select_ungrouped(Object *ob, short extend, short flush_flags) +void paintvert_select_ungrouped(Object *ob, bool extend, bool flush_flags) { Mesh *me = BKE_mesh_from_object(ob); MVert *mv; @@ -724,7 +726,7 @@ void paintvert_select_ungrouped(Object *ob, short extend, short flush_flags) } if (!extend) { - paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); + paintvert_deselect_all_visible(ob, SEL_DESELECT, false); } dv = me->dvert; @@ -769,7 +771,7 @@ static int mirrtopo_vert_sort(const void *v1, const void *v2) return 0; } -int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store) +bool ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store) { int totvert; int totedge; @@ -788,16 +790,16 @@ int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t * (totvert != mesh_topo_store->prev_vert_tot) || (totedge != mesh_topo_store->prev_edge_tot)) { - return TRUE; + return true; } else { - return FALSE; + return false; } } void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store, - const short skip_em_vert_array_init) + const bool skip_em_vert_array_init) { MEdge *medge; BMEditMesh *em = me->edit_btmesh; @@ -900,7 +902,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to index_lookup = MEM_mallocN(totvert * sizeof(*index_lookup), "mesh_topo_lookup"); if (em) { - if (skip_em_vert_array_init == FALSE) { + if (skip_em_vert_array_init == false) { EDBM_index_arrays_ensure(em, BM_VERT); } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 174715495f6..1daf39d3319 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -34,6 +34,8 @@ #include "BLI_math.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_library.h" #include "BKE_tessmesh.h" @@ -62,17 +64,17 @@ static Object *make_prim_init(bContext *C, const char *idname, *state = 0; if (obedit == NULL || obedit->type != OB_MESH) { - obedit = ED_object_add_type(C, OB_MESH, loc, rot, FALSE, layer); + obedit = ED_object_add_type(C, OB_MESH, loc, rot, false, layer); rename_id((ID *)obedit, idname); rename_id((ID *)obedit->data, idname); /* create editmode */ - ED_object_enter_editmode(C, EM_DO_UNDO | EM_IGNORE_LAYER); /* rare cases the active layer is messed up */ + ED_object_editmode_enter(C, EM_DO_UNDO | EM_IGNORE_LAYER); /* rare cases the active layer is messed up */ *state = 1; } - *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, FALSE); + *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, false); return obedit; } @@ -87,11 +89,11 @@ static void make_prim_finish(bContext *C, Object *obedit, int *state, int enter_ EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); /* only recalc editmode tessface if we are staying in editmode */ - EDBM_update_generic(em, !exit_editmode, TRUE); + EDBM_update_generic(em, !exit_editmode, true); /* userdef */ if (exit_editmode) { - ED_object_exit_editmode(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */ + ED_object_editmode_exit(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */ } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); } @@ -106,7 +108,7 @@ static int add_primitive_plane_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Plane", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Plane"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "verts.out", @@ -134,7 +136,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_cube_exec(bContext *C, wmOperator *op) @@ -147,7 +149,7 @@ static int add_primitive_cube_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Cube", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Cube"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "verts.out", "create_cube matrix=%m4 size=%f", mat, dia * 2.0f)) { @@ -174,7 +176,7 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static const EnumPropertyItem fill_type_items[] = { @@ -196,7 +198,7 @@ static int add_primitive_circle_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Circle", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Circle"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "verts.out", @@ -235,7 +237,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot) RNA_def_property_subtype(prop, PROP_DISTANCE); RNA_def_enum(ot->srna, "fill_type", fill_type_items, 0, "Fill Type", ""); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) @@ -251,7 +253,7 @@ static int add_primitive_cylinder_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Cylinder", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Cylinder"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -296,7 +298,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot) RNA_def_property_subtype(prop, PROP_DISTANCE); RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Cap Fill Type", ""); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_cone_exec(bContext *C, wmOperator *op) @@ -312,7 +314,7 @@ static int add_primitive_cone_exec(bContext *C, wmOperator *op) cap_tri = (cap_end == 2); ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Cone", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Cone"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -356,7 +358,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot) RNA_def_property_subtype(prop, PROP_DISTANCE); RNA_def_enum(ot->srna, "end_fill_type", fill_type_items, 1, "Base Fill Type", ""); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_grid_exec(bContext *C, wmOperator *op) @@ -369,7 +371,7 @@ static int add_primitive_grid_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Grid", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Grid"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "verts.out", @@ -409,7 +411,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, FLT_MAX); RNA_def_property_subtype(prop, PROP_DISTANCE); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_monkey_exec(bContext *C, wmOperator *op) @@ -425,7 +427,7 @@ static int add_primitive_monkey_exec(bContext *C, wmOperator *op) if (!view_aligned) rot[0] += (float)M_PI / 2.0f; - obedit = make_prim_init(C, "Suzanne", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Suzanne"), &dia, mat, &state, loc, rot, layer); mat[0][0] *= dia; mat[1][1] *= dia; mat[2][2] *= dia; @@ -455,7 +457,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) @@ -468,7 +470,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Sphere", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Sphere"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf(em, op, "verts.out", @@ -507,7 +509,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0, FLT_MAX, "Size", "", 0.001, 100.00); RNA_def_property_subtype(prop, PROP_DISTANCE); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) @@ -520,7 +522,7 @@ static int add_primitive_icosphere_exec(bContext *C, wmOperator *op) unsigned int layer; ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL); - obedit = make_prim_init(C, "Icosphere", &dia, mat, &state, loc, rot, layer); + obedit = make_prim_init(C, DATA_("Icosphere"), &dia, mat, &state, loc, rot, layer); em = BMEdit_FromObject(obedit); if (!EDBM_op_call_and_selectf( @@ -559,5 +561,5 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "size", 1.0f, 0.0f, FLT_MAX, "Size", "", 0.001f, 100.00); RNA_def_property_subtype(prop, PROP_DISTANCE); - ED_object_add_generic_props(ot, TRUE); + ED_object_add_generic_props(ot, true); } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index b5b6a92cbf5..57d3f7406ca 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1200,7 +1200,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, for (i = 0; i < tot; i++, result++) { BMLoop *l1; - BMFace *hitf; + BMFace *f_hit; ListBase *lst; Ref *ref; @@ -1233,7 +1233,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, continue; } if ((kcd->vc.rv3d->rflag & RV3D_CLIPPING) && - ED_view3d_clipping_test(kcd->vc.rv3d, p, TRUE)) + ED_view3d_clipping_test(kcd->vc.rv3d, p, true)) { continue; } @@ -1243,7 +1243,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, mul_m4_v3(kcd->ob->imat, view); if (kcd->cut_through) { - hitf = FALSE; + f_hit = NULL; } else { /* check if this point is visible in the viewport */ @@ -1267,11 +1267,11 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, add_v3_v3(p1, no); /* ray cast */ - hitf = BMBVH_RayCast(bmtree, p1, no, NULL, NULL); + f_hit = BMBVH_RayCast(bmtree, p1, no, NULL, NULL); } /* ok, if visible add the new point */ - if (!hitf && !BLI_smallhash_haskey(ehash, (intptr_t)kfe)) { + if (!f_hit && !BLI_smallhash_haskey(ehash, (intptr_t)kfe)) { BMEdgeHit hit; if (len_squared_v3v3(p, kcd->curr.co) < depsilon_sq || @@ -1555,7 +1555,7 @@ static int knife_sample_screen_density(KnifeTool_OpData *kcd, const float radius dis_sq = len_squared_v2v2(kfv->sco, sco); if (dis_sq < radius_sq) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { c++; } } @@ -1634,7 +1634,7 @@ static KnifeEdge *knife_find_closest_edge(KnifeTool_OpData *kcd, float p[3], flo interp_v3_v3v3(vec, kfe->v1->cageco, kfe->v2->cageco, lambda); - if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, true) == 0) { cure = kfe; curdis = dis; } @@ -1725,7 +1725,7 @@ static KnifeVert *knife_find_closest_vert(KnifeTool_OpData *kcd, float p[3], flo dis_sq = len_squared_v2v2(kfv->sco, sco); if (dis_sq < curdis_sq && dis_sq < maxdist_sq) { if (kcd->vc.rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, TRUE) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, kfv->cageco, true) == 0) { curv = kfv; curdis_sq = dis_sq; } @@ -1933,7 +1933,7 @@ static void remerge_faces(KnifeTool_OpData *kcd) if (BLI_array_count(faces) > 0) { idx = BM_elem_index_get(faces[0]); - f2 = BM_faces_join(bm, faces, BLI_array_count(faces), TRUE); + f2 = BM_faces_join(bm, faces, BLI_array_count(faces), true); if (f2) { BMO_elem_flag_enable(bm, f2, FACE_NEW); BM_elem_index_set(f2, idx); /* set_dirty! *//* BMESH_TODO, check if this is valid or not */ @@ -2144,7 +2144,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) f2 = BM_face_create_quad_tri(bm, v1, v2, v3, NULL, - NULL, FALSE); + NULL, false); BMO_elem_flag_enable(bm, f2, FACE_NEW); @@ -2184,7 +2184,7 @@ static void knifenet_fill_faces(KnifeTool_OpData *kcd) BM_elem_attrs_copy(bm, bm, f2, f); BM_ITER_ELEM (l1, &liter1, f, BM_LOOPS_OF_FACE) { - BM_loop_interp_from_face(bm, l1, f2, TRUE, TRUE); + BM_loop_interp_from_face(bm, l1, f2, true, true); } } @@ -2434,11 +2434,11 @@ static ListBase *find_hole(KnifeTool_OpData *kcd, ListBase *fedges) } /* Try to find "nice" diagonals - short, and far apart from each other. - * If found, return TRUE and make a 'main chain' going across f which uses + * If found, return true and make a 'main chain' going across f which uses * the two diagonals and one part of the hole, and a 'side chain' that * completes the hole. */ -static int find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, ListBase **mainchain, - ListBase **sidechain) +static bool find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, ListBase **mainchain, + ListBase **sidechain) { float **fco, **hco; BMVert **fv; @@ -2450,14 +2450,14 @@ static int find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, Li ListBase *chain; BMVert *v; BMIter iter; - int nh, nf, i, j, k, m, ax, ay, ok, sep = 0 /* Quite warnings */, bestsep; + int nh, nf, i, j, k, m, ax, ay, sep = 0 /* Quite warnings */, bestsep; int besti[2], bestj[2]; float d, bestd; nh = BLI_countlist(hole); nf = f->len; if (nh < 2 || nf < 3) - return 0; + return false; /* Gather 2d projections of hole and face vertex coordinates. * Use best-axis projection - not completely accurate, maybe revisit */ @@ -2518,18 +2518,20 @@ static int find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, Li bestd = FLT_MAX; } for (j = 0; j < nf; j++) { + bool ok; + if (m == 1 && j == bestj[0]) continue; d = len_squared_v2v2(hco[i], fco[j]); if (d > bestd) continue; - ok = TRUE; + ok = true; for (k = 0; k < nh && ok; k++) { if (k == i || (k + 1) % nh == i) continue; if (isect_line_line_v2(hco[i], fco[j], hco[k], hco[(k + 1) % nh])) - ok = FALSE; + ok = false; } if (!ok) continue; @@ -2537,7 +2539,7 @@ static int find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, Li if (k == j || (k + 1) % nf == j) continue; if (isect_line_line_v2(hco[i], fco[j], fco[k], fco[(k + 1) % nf])) - ok = FALSE; + ok = false; } if (ok) { besti[m] = i; @@ -2572,14 +2574,14 @@ static int find_hole_chains(KnifeTool_OpData *kcd, ListBase *hole, BMFace *f, Li } *sidechain = chain; - return TRUE; + return true; } else { - return FALSE; + return false; } } -static int knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMFace *f) +static bool knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMFace *f) { /* BMesh *bm = kcd->em->bm; */ /* UNUSED */ BMVert *v1, *v2; @@ -2589,7 +2591,7 @@ static int knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMF int v1inside, v2inside; if (!f) - return FALSE; + return false; v1 = kfe->v1->v; v2 = kfe->v2->v; @@ -2608,7 +2610,7 @@ static int knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMF v1inside = l1 ? 0 : BM_face_point_inside_test(f, kfe->v1->co); v2inside = l2 ? 0 : BM_face_point_inside_test(f, kfe->v2->co); if ((l1 && v2inside) || (l2 && v1inside) || (v1inside && v2inside)) - return TRUE; + return true; if (l1 && l2) { /* Can have case where v1 and v2 are on shared chain between two faces. * BM_face_legal_splits does visibility and self-intersection tests, @@ -2617,7 +2619,7 @@ static int knife_edge_in_face(KnifeTool_OpData *UNUSED(kcd), KnifeEdge *kfe, BMF mid_v3_v3v3(mid, kfe->v1->co, kfe->v2->co); return BM_face_point_inside_test(f, mid); } - return FALSE; + return false; } /* Split face f with KnifeEdges on chain. f remains as one side, the face formed is put in *newface. @@ -2658,7 +2660,7 @@ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *cha *newface = NULL; } else { - *newface = BM_face_split(bm, f, v1, v2, &lnew, NULL, TRUE); + *newface = BM_face_split(bm, f, v1, v2, &lnew, NULL, true); } } else { @@ -2670,7 +2672,7 @@ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *cha for (l_iter = lnew->next, i = 0; i < nco; l_iter = l_iter->next, i++) { BLI_assert(equals_v3v3(cos[i], l_iter->v->co)); if (kcd->select_result) { - BM_edge_select_set(bm, l_iter->e, TRUE); + BM_edge_select_set(bm, l_iter->e, true); } kverts[i]->v = l_iter->v; } @@ -2680,7 +2682,7 @@ static void knife_make_chain_cut(KnifeTool_OpData *kcd, BMFace *f, ListBase *cha /* the select chain above doesnt account for the first loop */ if (kcd->select_result) { if (lnew) { - BM_edge_select_set(bm, lnew->e, TRUE); + BM_edge_select_set(bm, lnew->e, true); } } } @@ -2717,7 +2719,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe if (fnew_kfedges->first) knife_make_face_cuts(kcd, fnew, fnew_kfedges); - /* find_chain should always remove edges if it returns TRUE, + /* find_chain should always remove edges if it returns true, * but guard against infinite loop anyway */ count = BLI_countlist(kfedges); if (count >= oldcount) { @@ -2740,10 +2742,16 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe kfe = ((Ref *)sidechain->first)->ref; if (knife_edge_in_face(kcd, kfe, f)) { knife_make_chain_cut(kcd, f, sidechain, &fnew2); + if (fnew2 == NULL) { + return; + } fhole = f; } else if (knife_edge_in_face(kcd, kfe, fnew)) { knife_make_chain_cut(kcd, fnew, sidechain, &fnew2); + if (fnew2 == NULL) { + return; + } fhole = fnew2; } else { @@ -2777,7 +2785,7 @@ static void knife_make_face_cuts(KnifeTool_OpData *kcd, BMFace *f, ListBase *kfe knife_make_face_cuts(kcd, fnew2, fnew2_kfedges); if (f == fhole) break; - /* find_hole should always remove edges if it returns TRUE, + /* find_hole should always remove edges if it returns true, * but guard against infinite loop anyway */ count = BLI_countlist(kfedges); if (count >= oldcount) { @@ -2881,7 +2889,7 @@ static void knifetool_finish_ex(KnifeTool_OpData *kcd) #endif EDBM_mesh_normals_update(kcd->em); - EDBM_update_generic(kcd->em, TRUE, TRUE); + EDBM_update_generic(kcd->em, true, true); } static void knifetool_finish(wmOperator *op) { @@ -3185,7 +3193,7 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODAL_MIDPOINT_OFF: kcd->snap_midpoints = false; @@ -3194,29 +3202,29 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event) knife_update_active(kcd); knife_update_header(C, kcd); ED_region_tag_redraw(kcd->ar); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODEL_IGNORE_SNAP_ON: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = true; knife_update_header(C, kcd); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODEL_IGNORE_SNAP_OFF: ED_region_tag_redraw(kcd->ar); kcd->ignore_vert_snapping = kcd->ignore_edge_snapping = false; knife_update_header(C, kcd); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODAL_ANGLE_SNAP_TOGGLE: kcd->angle_snapping = !kcd->angle_snapping; knife_update_header(C, kcd); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODAL_CUT_THROUGH_TOGGLE: kcd->cut_through = !kcd->cut_through; knife_update_header(C, kcd); - do_refresh = TRUE; + do_refresh = true; break; case KNF_MODAL_NEW_CUT: ED_region_tag_redraw(kcd->ar); @@ -3295,8 +3303,8 @@ void MESH_OT_knife_tool(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - RNA_def_boolean(ot->srna, "use_occlude_geometry", TRUE, "Occlude Geometry", "Only cut the front most geometry"); - RNA_def_boolean(ot->srna, "only_selected", FALSE, "Only Selected", "Only cut selected geometry"); + RNA_def_boolean(ot->srna, "use_occlude_geometry", true, "Occlude Geometry", "Only cut the front most geometry"); + RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only cut selected geometry"); } diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index c581ce5a2e8..c8256914884 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -51,6 +51,7 @@ #include "WM_types.h" +#include "ED_mesh.h" #include "ED_screen.h" #include "ED_view3d.h" @@ -137,6 +138,12 @@ static int knifeproject_exec(bContext *C, wmOperator *op) /* select only tagged faces */ BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); + + /* not essential, but switch out of vertex mode since the + * selected regions wont be nicely isolated after flushing. + * note: call after de-select to avoid selection flushing */ + EDBM_selectmode_disable(scene, em, SCE_SELECT_VERTEX, SCE_SELECT_EDGE); + BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_TAG); BM_mesh_select_mode_flush(em->bm); @@ -165,4 +172,3 @@ void MESH_OT_knife_project(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; } - diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 5b9864ca239..ee1c274b154 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -77,8 +77,8 @@ typedef struct RingSelOpData { BMEdge *eed; NumInput num; - int extend; - int do_cut; + bool extend; + bool do_cut; } RingSelOpData; /* modal loop selection drawing callback */ @@ -186,7 +186,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select) BMW_NIL_LAY); for (eed = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, true); } BMW_end(&walker); @@ -276,9 +276,9 @@ static void ringsel_finish(bContext *C, wmOperator *op) const int cuts = RNA_int_get(op->ptr, "number_cuts"); const float smoothness = 0.292f * RNA_float_get(op->ptr, "smoothness"); #ifdef BMW_EDGERING_NGON - const int use_only_quads = FALSE; + const bool use_only_quads = false; #else - const int use_only_quads = TRUE; + const bool use_only_quads = false; #endif if (lcd->eed) { @@ -293,24 +293,18 @@ static void ringsel_finish(bContext *C, wmOperator *op) BM_mesh_esubdivide(em->bm, BM_ELEM_SELECT, smoothness, 0.0f, 0.0f, cuts, - SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, TRUE, + SUBDIV_SELECT_LOOPCUT, SUBD_PATH, 0, true, use_only_quads, 0); /* tessface is already re-recalculated */ - EDBM_update_generic(em, FALSE, TRUE); + EDBM_update_generic(em, false, true); /* force edge slide to edge select mode in in face select mode */ - if (em->selectmode & SCE_SELECT_FACE) { - if (em->selectmode == SCE_SELECT_FACE) - em->selectmode = SCE_SELECT_EDGE; - else - em->selectmode &= ~SCE_SELECT_FACE; - CTX_data_tool_settings(C)->selectmode = em->selectmode; - EDBM_selectmode_set(em); - - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, CTX_data_scene(C)); + if (EDBM_selectmode_disable(lcd->vc.scene, em, SCE_SELECT_FACE, SCE_SELECT_EDGE)) { + /* pass, the change will flush selection */ } else { + /* else flush explicitly */ EDBM_selectmode_flush(lcd->em); } } @@ -349,7 +343,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) /* called when modal loop selection gets set up... */ -static int ringsel_init(bContext *C, wmOperator *op, int do_cut) +static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) { RingSelOpData *lcd; @@ -423,7 +417,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) float smoothness = RNA_float_get(op->ptr, "smoothness"); int cuts = RNA_int_get(op->ptr, "number_cuts"); RingSelOpData *lcd = op->customdata; - int show_cuts = 0; + bool show_cuts = false; view3d_operator_needs_opengl(C); @@ -471,12 +465,12 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) cuts++; RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); - show_cuts = TRUE; + show_cuts = true; } else { smoothness = min_ff(smoothness + 0.05f, 4.0f); RNA_float_set(op->ptr, "smoothness", smoothness); - show_cuts = TRUE; + show_cuts = true; } ED_region_tag_redraw(lcd->ar); @@ -491,12 +485,12 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) cuts = max_ii(cuts - 1, 0); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); - show_cuts = TRUE; + show_cuts = true; } else { smoothness = max_ff(smoothness - 0.05f, 0.0f); RNA_float_set(op->ptr, "smoothness", smoothness); - show_cuts = TRUE; + show_cuts = true; } ED_region_tag_redraw(lcd->ar); @@ -534,7 +528,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); - show_cuts = TRUE; + show_cuts = true; ED_region_tag_redraw(lcd->ar); } diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 8198e088e5a..0ea02f371f0 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -207,7 +207,7 @@ static BMEdge *edbm_ripsel_edge_mark_step(BMVert *v, const int uid) BM_edge_loop_pair(e, &l_a, &l_b); /* no need to check, we know this will be true */ - /* so (IS_VISIT_DONE == TRUE) */ + /* so (IS_VISIT_DONE == true) */ BM_elem_index_set(l_a, uid); BM_elem_index_set(l_b, uid); @@ -246,7 +246,7 @@ static EdgeLoopPair *edbm_ripsel_looptag_helper(BMesh *bm) } /* set contiguous loops ordered 'uid' values for walking after split */ - while (TRUE) { + while (true) { int tot = 0; BMIter eiter; BMEdge *e_step; @@ -373,7 +373,7 @@ static void edbm_ripsel_deselect_helper(BMesh *bm, EdgeLoopPair *eloop_pairs, e = (score_a > score_b) ? lp->l_a->e : lp->l_b->e; v_prev = edbm_ripsel_edloop_pair_start_vert(e); for (; e; e = edbm_ripsel_edge_uid_step(e, &v_prev)) { - BM_edge_select_set(bm, e, FALSE); + BM_edge_select_set(bm, e, false); } } } @@ -486,9 +486,9 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u } /* face should never exist */ - BLI_assert(BM_face_exists(f_verts, f_verts[3] ? 4 : 3, &f) == FALSE); + BLI_assert(BM_face_exists(f_verts, f_verts[3] ? 4 : 3, &f) == false); - f = BM_face_create_quad_tri_v(bm, f_verts, f_verts[3] ? 4 : 3, f_example, FALSE); + f = BM_face_create_quad_tri_v(bm, f_verts, f_verts[3] ? 4 : 3, f_example, false); l_iter = BM_FACE_FIRST_LOOP(f); @@ -511,21 +511,21 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u /* --- end 'face-fill' code --- */ -static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) +static bool edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) { BMOperator bmop; if (!EDBM_op_init(em, &bmop, op, "split_edges edges=%he verts=%hv use_verts=%b", - BM_ELEM_TAG, BM_ELEM_SELECT, TRUE)) + BM_ELEM_TAG, BM_ELEM_SELECT, true)) { - return FALSE; + return false; } BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { - return FALSE; + if (!EDBM_op_finish(em, &bmop, op, true)) { + return false; } - return TRUE; + return true; } /** @@ -533,7 +533,7 @@ static int edbm_rip_call_edgesplit(BMEditMesh *em, wmOperator *op) */ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *event) { - const int do_fill = RNA_boolean_get(op->ptr, "use_fill"); + const bool do_fill = RNA_boolean_get(op->ptr, "use_fill"); UnorderedLoopPair *fill_uloop_pairs = NULL; Object *obedit = CTX_data_edit_object(C); ARegion *ar = CTX_wm_region(C); @@ -549,7 +549,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]}; float dist = FLT_MAX; float d; - int is_wire; + bool is_wire; BMEditSelection ese; int totboundary_edge = 0; @@ -585,7 +585,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve * otherwise we can't a face away from a wire edge */ totboundary_edge += (is_boundary != 0 || BM_edge_is_wire(e)); if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN)) { - if (is_boundary == FALSE && BM_edge_is_manifold(e)) { + if (is_boundary == false && BM_edge_is_manifold(e)) { d = edbm_rip_edgedist(ar, projectMat, e->v1->co, e->v2->co, fmval, INSET_DEFAULT); if (d < dist) { dist = d; @@ -640,22 +640,22 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve * - the boundary edge total is greater then 2, * in this case edge split _can_ work but we get far nicer results if we use this special case. * - there are only 2 edges but we are a wire vert. */ - if ((is_wire == FALSE && totboundary_edge > 2) || - (is_wire == TRUE && totboundary_edge > 1)) + if ((is_wire == false && totboundary_edge > 2) || + (is_wire == true && totboundary_edge > 1)) { BMVert **vout; int vout_len; - BM_vert_select_set(bm, v, FALSE); + BM_vert_select_set(bm, v, false); - if (bmesh_vert_separate(bm, v, &vout, &vout_len) == FALSE) { + if (bmesh_vert_separate(bm, v, &vout, &vout_len) == false) { BKE_report(op->reports, RPT_ERROR, "Error ripping vertex from faces"); return OPERATOR_CANCELLED; } else if (vout_len < 2) { MEM_freeN(vout); /* set selection back to avoid active-unselected vertex */ - BM_vert_select_set(bm, v, TRUE); + BM_vert_select_set(bm, v, true); /* should never happen */ BKE_report(op->reports, RPT_ERROR, "Error ripping vertex from faces"); return OPERATOR_CANCELLED; @@ -673,7 +673,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve * either by its face corner, or connected edge (when no faces are attached) */ for (i = 0; i < vout_len; i++) { - if (BM_vert_is_wire(vout[i]) == FALSE) { + if (BM_vert_is_wire(vout[i]) == false) { /* find the best face corner */ BM_ITER_ELEM (l, &iter, vout[i], BM_LOOPS_OF_VERT) { if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) { @@ -709,7 +709,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve /* select the vert from the best region */ v = vout[vi_best]; - BM_vert_select_set(bm, v, TRUE); + BM_vert_select_set(bm, v, true); if (ese.ele) { BM_select_history_store(bm, v); @@ -804,7 +804,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_SELECT)) { /* disable by default, re-enable winner at end */ - BM_vert_select_set(bm, v, FALSE); + BM_vert_select_set(bm, v, false); BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { /* calculate a point in the face, rather then calculate the middle, @@ -829,7 +829,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve } if (v_best) { - BM_vert_select_set(bm, v_best, TRUE); + BM_vert_select_set(bm, v_best, true); if (ese.ele) { BM_select_history_store(bm, v_best); } @@ -855,7 +855,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve */ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *event) { - const int do_fill = RNA_boolean_get(op->ptr, "use_fill"); + const bool do_fill = RNA_boolean_get(op->ptr, "use_fill"); UnorderedLoopPair *fill_uloop_pairs = NULL; Object *obedit = CTX_data_edit_object(C); ARegion *ar = CTX_wm_region(C); @@ -878,14 +878,14 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve /* expand edge selection */ BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - int all_manifold; + bool all_manifold; int totedge_manifold; /* manifold, visible edges */ int i; e2 = NULL; i = 0; totedge_manifold = 0; - all_manifold = TRUE; + all_manifold = true; BM_ITER_ELEM (e, &eiter, v, BM_EDGES_OF_VERT) { if (!BM_edge_is_wire(e) && @@ -901,8 +901,8 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve } /** #BM_vert_other_disk_edge has no hidden checks so don't check hidden here */ - if ((all_manifold == TRUE) && (BM_edge_is_manifold(e) == FALSE)) { - all_manifold = FALSE; + if ((all_manifold == true) && (BM_edge_is_manifold(e) == false)) { + all_manifold = false; } } @@ -911,7 +911,7 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve /* note: if the case of 3 edges has one change in loop stepping, * if this becomes more involved we may be better off splitting * the 3 edge case into its own else-if branch */ - if ((totedge_manifold == 4 || totedge_manifold == 3) || (all_manifold == FALSE)) { + if ((totedge_manifold == 4 || totedge_manifold == 3) || (all_manifold == false)) { BMLoop *l_a = e2->l; BMLoop *l_b = l_a->radial_next; @@ -1034,7 +1034,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1056,6 +1056,6 @@ void MESH_OT_rip(wmOperatorType *ot) /* to give to transform */ Transform_Properties(ot, P_PROPORTIONAL); - RNA_def_boolean(ot->srna, "mirror", FALSE, "Mirror Editing", ""); - RNA_def_boolean(ot->srna, "use_fill", FALSE, "Fill", "Fill the ripped region"); + RNA_def_boolean(ot->srna, "mirror", false, "Mirror Editing", ""); + RNA_def_boolean(ot->srna, "use_fill", false, "Fill", "Fill the ripped region"); } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index a1c302c6a63..9474c051cee 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -74,7 +74,7 @@ /* ****************************** MIRROR **************** */ -void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, int extend) +void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, bool extend) { BMVert *v1, *v2; BMIter iter; @@ -88,7 +88,7 @@ void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, int extend) } } - EDBM_verts_mirror_cache_begin(em, TRUE); + EDBM_verts_mirror_cache_begin(em, true); if (!extend) EDBM_flag_disable_all(em, BM_ELEM_SELECT); @@ -99,7 +99,7 @@ void EDBM_select_mirrored(Object *UNUSED(obedit), BMEditMesh *em, int extend) v2 = EDBM_verts_mirror_get(em, v1); if (v2 && !BM_elem_flag_test(v2, BM_ELEM_HIDDEN)) { - BM_vert_select_set(em->bm, v2, TRUE); + BM_vert_select_set(em->bm, v2, true); } } @@ -124,7 +124,7 @@ void EDBM_automerge(Scene *scene, Object *obedit, int update) BM_ELEM_SELECT, scene->toolsettings->doublimit); if (LIKELY(ok) && update) { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); } } } @@ -184,19 +184,19 @@ static void draw_triangulated(const int mcords[][2], const short tot) /* reads rect, and builds selection array for quick lookup */ /* returns if all is OK */ -int EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax, short ymax) +bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax, short ymax) { struct ImBuf *buf; unsigned int *dr; int a; if (vc->obedit == NULL || vc->v3d->drawtype < OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT) == 0) { - return 0; + return false; } buf = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if (buf == NULL) return 0; - if (bm_vertoffs == 0) return 0; + if (buf == NULL) return false; + if (bm_vertoffs == 0) return false; dr = buf->rect; @@ -210,7 +210,7 @@ int EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax dr++; } IMB_freeImBuf(buf); - return 1; + return true; } int EDBM_backbuf_check(unsigned int index) @@ -233,7 +233,7 @@ void EDBM_backbuf_free(void) * - grab again and compare * returns 'OK' */ -int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) +bool EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax) { unsigned int *dr, *drm; struct ImBuf *buf, *bufmask; @@ -242,16 +242,16 @@ int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short /* method in use for face selecting too */ if (vc->obedit == NULL) { if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) { - return 0; + return false; } } else if (vc->v3d->drawtype < OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT) == 0) { - return 0; + return false; } buf = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if (buf == NULL) return 0; - if (bm_vertoffs == 0) return 0; + if (buf == NULL) return false; + if (bm_vertoffs == 0) return false; dr = buf->rect; @@ -282,7 +282,7 @@ int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short bufmask = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); if (bufmask == NULL) { - return 0; /* only when mem alloc fails, go crash somewhere else! */ + return false; /* only when mem alloc fails, go crash somewhere else! */ } else { drm = bufmask->rect; @@ -299,11 +299,11 @@ int EDBM_backbuf_border_mask_init(ViewContext *vc, const int mcords[][2], short IMB_freeImBuf(buf); IMB_freeImBuf(bufmask); - return 1; + return true; } /* circle shaped sample area */ -int EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) +bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) { struct ImBuf *buf; unsigned int *dr; @@ -313,18 +313,18 @@ int EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) /* method in use for face selecting too */ if (vc->obedit == NULL) { if (!(paint_facesel_test(vc->obact) || paint_vertsel_test(vc->obact))) { - return 0; + return false; } } else if (vc->v3d->drawtype < OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT) == 0) { - return 0; + return false; } xmin = xs - rads; xmax = xs + rads; ymin = ys - rads; ymax = ys + rads; buf = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax); - if (bm_vertoffs == 0) return 0; - if (buf == NULL) return 0; + if (bm_vertoffs == 0) return false; + if (buf == NULL) return false; dr = buf->rect; @@ -340,7 +340,7 @@ int EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads) } IMB_freeImBuf(buf); - return 1; + return true; } @@ -396,7 +396,7 @@ static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int * if 0, unselected vertice are given the bias * strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased */ -BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const short sel, const short strict) +BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const bool sel, const bool strict) { if (vc->v3d->drawtype > OB_WIRE && (vc->v3d->flag & V3D_ZBUF_SELECT)) { float distance; @@ -436,7 +436,7 @@ BMVert *EDBM_vert_find_nearest(ViewContext *vc, float *r_dist, const short sel, data.lastIndex = lastSelectedIndex; data.mval_fl[0] = vc->mval[0]; data.mval_fl[1] = vc->mval[1]; - data.select = sel; + data.select = sel ? BM_ELEM_SELECT : 0; data.dist = *r_dist; data.strict = strict; data.closest = NULL; @@ -482,7 +482,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, const float vec[1] = eed->v1->co[1] + lambda * (eed->v2->co[1] - eed->v1->co[1]); vec[2] = eed->v1->co[2] + lambda * (eed->v2->co[2] - eed->v1->co[2]); - if (ED_view3d_clipping_test(data->vc.rv3d, vec, TRUE) == 0) { + if (ED_view3d_clipping_test(data->vc.rv3d, vec, true) == 0) { data->dist = distance; data->closest = eed; } @@ -735,14 +735,14 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -776,15 +776,15 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true); EDBM_selectmode_flush(em); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -805,7 +805,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the type from RNA */ const int type = RNA_enum_get(op->ptr, "type"); - float thresh = RNA_float_get(op->ptr, "threshold"); + const float thresh = RNA_float_get(op->ptr, "threshold"); const int compare = RNA_enum_get(op->ptr, "compare"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ @@ -820,16 +820,16 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } EDBM_selectmode_flush(em); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -929,10 +929,10 @@ void MESH_OT_select_similar(wmOperatorType *ot) static int edbm_select_mode_exec(bContext *C, wmOperator *op) { - const int type = RNA_enum_get(op->ptr, "type"); - const int action = RNA_enum_get(op->ptr, "action"); - const int use_extend = RNA_boolean_get(op->ptr, "use_extend"); - const int use_expand = RNA_boolean_get(op->ptr, "use_expand"); + const int type = RNA_enum_get(op->ptr, "type"); + const int action = RNA_enum_get(op->ptr, "action"); + const bool use_extend = RNA_boolean_get(op->ptr, "use_extend"); + const bool use_expand = RNA_boolean_get(op->ptr, "use_expand"); if (EDBM_selectmode_toggle(C, type, action, use_extend, use_expand)) { return OPERATOR_FINISHED; @@ -986,9 +986,9 @@ void MESH_OT_select_mode(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_boolean(ot->srna, "use_extend", FALSE, "Extend", ""); + prop = RNA_def_boolean(ot->srna, "use_extend", false, "Extend", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - prop = RNA_def_boolean(ot->srna, "use_expand", FALSE, "Expand", ""); + prop = RNA_def_boolean(ot->srna, "use_expand", false, "Expand", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); ot->prop = prop = RNA_def_enum(ot->srna, "type", elem_items, 0, "Type", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1000,7 +1000,7 @@ void MESH_OT_select_mode(wmOperatorType *ot) /* **************** LOOP SELECTS *************** */ -static void walker_select(BMEditMesh *em, int walkercode, void *start, int select) +static void walker_select(BMEditMesh *em, int walkercode, void *start, const bool select) { BMesh *bm = em->bm; BMElem *ele; @@ -1027,7 +1027,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) BMEdge *eed; BMEdge **edarray; int edindex; - int looptype = RNA_boolean_get(op->ptr, "ring"); + const bool is_ring = RNA_boolean_get(op->ptr, "ring"); BMIter iter; int totedgesel = 0; @@ -1048,17 +1048,17 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) } } - if (looptype) { + if (is_ring) { for (edindex = 0; edindex < totedgesel; edindex += 1) { eed = edarray[edindex]; - walker_select(em, BMW_EDGERING, eed, TRUE); + walker_select(em, BMW_EDGERING, eed, true); } EDBM_selectmode_flush(em); } else { for (edindex = 0; edindex < totedgesel; edindex += 1) { eed = edarray[edindex]; - walker_select(em, BMW_LOOP, eed, TRUE); + walker_select(em, BMW_LOOP, eed, true); } EDBM_selectmode_flush(em); } @@ -1094,12 +1094,12 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** loop select (non modal) ************** */ -static void mouse_mesh_loop(bContext *C, const int mval[2], short extend, short deselect, short toggle, short ring) +static void mouse_mesh_loop(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool ring) { ViewContext vc; BMEditMesh *em; BMEdge *eed; - int select = TRUE; + bool select = true; float dist = 50.0f; float mvalf[2]; @@ -1113,21 +1113,21 @@ static void mouse_mesh_loop(bContext *C, const int mval[2], short extend, short eed = EDBM_edge_find_nearest(&vc, &dist); if (eed) { - if (extend == 0 && deselect == 0 && toggle == 0) { + if (extend == false && deselect == false && toggle == false) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); } if (extend) { - select = TRUE; + select = true; } else if (deselect) { - select = FALSE; + select = false; } else if (BM_elem_flag_test(eed, BM_ELEM_SELECT) == 0) { - select = TRUE; + select = true; } else if (toggle) { - select = FALSE; + select = false; } if (em->selectmode & SCE_SELECT_FACE) { @@ -1218,7 +1218,8 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, const wmEvent *e view3d_operator_needs_opengl(C); - mouse_mesh_loop(C, event->mval, RNA_boolean_get(op->ptr, "extend"), + mouse_mesh_loop(C, event->mval, + RNA_boolean_get(op->ptr, "extend"), RNA_boolean_get(op->ptr, "deselect"), RNA_boolean_get(op->ptr, "toggle"), RNA_boolean_get(op->ptr, "ring")); @@ -1368,15 +1369,15 @@ static int edgetag_context_check(Scene *scene, BMesh *bm, BMEdge *e) { switch (scene->toolsettings->edge_mode) { case EDGE_MODE_SELECT: - return BM_elem_flag_test(e, BM_ELEM_SELECT) ? TRUE : FALSE; + return BM_elem_flag_test(e, BM_ELEM_SELECT) ? true : false; case EDGE_MODE_TAG_SEAM: return BM_elem_flag_test(e, BM_ELEM_SEAM); case EDGE_MODE_TAG_SHARP: return !BM_elem_flag_test(e, BM_ELEM_SMOOTH); case EDGE_MODE_TAG_CREASE: - return BM_elem_float_data_get(&bm->edata, e, CD_CREASE) ? TRUE : FALSE; + return BM_elem_float_data_get(&bm->edata, e, CD_CREASE) ? true : false; case EDGE_MODE_TAG_BEVEL: - return BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT) ? TRUE : FALSE; + return BM_elem_float_data_get(&bm->edata, e, CD_BWEIGHT) ? true : false; #ifdef WITH_FREESTYLE case EDGE_MODE_TAG_FREESTYLE: { @@ -1421,7 +1422,7 @@ static int edgetag_shortest_path(Scene *scene, BMesh *bm, BMEdge *e_src, BMEdge edgetag_ensure_cd_flag(scene, OBACT->data); BM_ITER_MESH_INDEX (e, &eiter, bm, BM_EDGES_OF_MESH, i) { - if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == FALSE) { + if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false) { BM_elem_flag_disable(e, BM_ELEM_TAG); } else { @@ -1470,14 +1471,14 @@ static int edgetag_shortest_path(Scene *scene, BMesh *bm, BMEdge *e_src, BMEdge } if (e == e_dst) { - short all_set = TRUE; + bool all_set = true; /* Check whether the path is already completely tagged. * if it is, the tags will be cleared instead of set. */ e = e_dst; do { if (!edgetag_context_check(scene, bm, e)) { - all_set = FALSE; + all_set = false; break; } } while ((e = edges_prev[BM_elem_index_get(e)])); @@ -1561,12 +1562,12 @@ static int mouse_mesh_shortest_path_edge(ViewContext *vc) #endif } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -1643,7 +1644,7 @@ static int facetag_shortest_path(Scene *scene, BMesh *bm, BMFace *f_src, BMFace // BM_mesh_elem_index_ensure(bm, BM_VERT /* | BM_EDGE */); // NOT NEEDED FOR FACETAG BM_ITER_MESH_INDEX (f, &fiter, bm, BM_FACES_OF_MESH, i) { - if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) == FALSE) { + if (BM_elem_flag_test(f, BM_ELEM_HIDDEN) == false) { BM_elem_flag_disable(f, BM_ELEM_TAG); } else { @@ -1692,14 +1693,14 @@ static int facetag_shortest_path(Scene *scene, BMesh *bm, BMFace *f_src, BMFace } if (f == f_dst) { - short all_set = TRUE; + bool all_set = true; /* Check whether the path is already completely tagged. * if it is, the tags will be cleared instead of set. */ f = f_dst; do { if (!facetag_context_check(scene, bm, f)) { - all_set = FALSE; + all_set = false; break; } } while ((f = faces_prev[BM_elem_index_get(f)])); @@ -1727,7 +1728,7 @@ static int mouse_mesh_shortest_path_face(ViewContext *vc) f_dst = EDBM_face_find_nearest(vc, &dist); if (f_dst) { int path = 0; - BMFace *f_act = BM_active_face_get(em->bm, FALSE, TRUE); + BMFace *f_act = BM_active_face_get(em->bm, false, true); if (f_act) { if (f_act != f_dst) { @@ -1752,12 +1753,12 @@ static int mouse_mesh_shortest_path_face(ViewContext *vc) BM_active_face_set(em->bm, f_dst); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -1827,7 +1828,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* ************************************************** */ /* here actual select happens */ /* gets called via generic mouse select operator */ -int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselect, short toggle) +bool EDBM_select_pick(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { ViewContext vc; BMVert *eve = NULL; @@ -1842,7 +1843,7 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec if (unified_findnearest(&vc, &eve, &eed, &efa)) { /* Deselect everything */ - if (extend == 0 && deselect == 0 && toggle == 0) + if (extend == false && deselect == false && toggle == false) EDBM_flag_disable_all(vc.em, BM_ELEM_SELECT); if (efa) { @@ -1853,13 +1854,13 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec /* Work-around: deselect first, so we can guarantee it will */ /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, efa); - BM_face_select_set(vc.em->bm, efa, FALSE); + BM_face_select_set(vc.em->bm, efa, false); BM_select_history_store(vc.em->bm, efa); - BM_face_select_set(vc.em->bm, efa, TRUE); + BM_face_select_set(vc.em->bm, efa, true); } else if (deselect) { BM_select_history_remove(vc.em->bm, efa); - BM_face_select_set(vc.em->bm, efa, FALSE); + BM_face_select_set(vc.em->bm, efa, false); } else { /* set the last selected face */ @@ -1867,11 +1868,11 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BM_select_history_store(vc.em->bm, efa); - BM_face_select_set(vc.em->bm, efa, TRUE); + BM_face_select_set(vc.em->bm, efa, true); } else if (toggle) { BM_select_history_remove(vc.em->bm, efa); - BM_face_select_set(vc.em->bm, efa, FALSE); + BM_face_select_set(vc.em->bm, efa, false); } } } @@ -1880,22 +1881,22 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec /* Work-around: deselect first, so we can guarantee it will */ /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eed); - BM_edge_select_set(vc.em->bm, eed, FALSE); + BM_edge_select_set(vc.em->bm, eed, false); BM_select_history_store(vc.em->bm, eed); - BM_edge_select_set(vc.em->bm, eed, TRUE); + BM_edge_select_set(vc.em->bm, eed, true); } else if (deselect) { BM_select_history_remove(vc.em->bm, eed); - BM_edge_select_set(vc.em->bm, eed, FALSE); + BM_edge_select_set(vc.em->bm, eed, false); } else { if (!BM_elem_flag_test(eed, BM_ELEM_SELECT)) { BM_select_history_store(vc.em->bm, eed); - BM_edge_select_set(vc.em->bm, eed, TRUE); + BM_edge_select_set(vc.em->bm, eed, true); } else if (toggle) { BM_select_history_remove(vc.em->bm, eed); - BM_edge_select_set(vc.em->bm, eed, FALSE); + BM_edge_select_set(vc.em->bm, eed, false); } } } @@ -1904,22 +1905,22 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec /* Work-around: deselect first, so we can guarantee it will */ /* be active even if it was already selected */ BM_select_history_remove(vc.em->bm, eve); - BM_vert_select_set(vc.em->bm, eve, FALSE); + BM_vert_select_set(vc.em->bm, eve, false); BM_select_history_store(vc.em->bm, eve); - BM_vert_select_set(vc.em->bm, eve, TRUE); + BM_vert_select_set(vc.em->bm, eve, true); } else if (deselect) { BM_select_history_remove(vc.em->bm, eve); - BM_vert_select_set(vc.em->bm, eve, FALSE); + BM_vert_select_set(vc.em->bm, eve, false); } else { if (!BM_elem_flag_test(eve, BM_ELEM_SELECT)) { BM_select_history_store(vc.em->bm, eve); - BM_vert_select_set(vc.em->bm, eve, TRUE); + BM_vert_select_set(vc.em->bm, eve, true); } else if (toggle) { BM_select_history_remove(vc.em->bm, eve); - BM_vert_select_set(vc.em->bm, eve, FALSE); + BM_vert_select_set(vc.em->bm, eve, false); } } } @@ -1936,10 +1937,10 @@ int EDBM_select_pick(bContext *C, const int mval[2], short extend, short deselec } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit); - return 1; + return true; } - return 0; + return false; } static void edbm_strip_selections(BMEditMesh *em) @@ -1985,38 +1986,57 @@ void EDBM_selectmode_set(BMEditMesh *em) edbm_strip_selections(em); /* strip BMEditSelections from em->selected that are not relevant to new mode */ + if (em->bm->totvertsel == 0 && + em->bm->totedgesel == 0 && + em->bm->totfacesel == 0) + { + return; + } + if (em->selectmode & SCE_SELECT_VERTEX) { - EDBM_select_flush(em); + if (em->bm->totvertsel) { + EDBM_select_flush(em); + } } else if (em->selectmode & SCE_SELECT_EDGE) { /* deselect vertices, and select again based on edge select */ - eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); - for (; eve; eve = BM_iter_step(&iter)) BM_vert_select_set(em->bm, eve, FALSE); - - eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for (; eed; eed = BM_iter_step(&iter)) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { + BM_vert_select_set(em->bm, eve, false); + } + + if (em->bm->totedgesel) { + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + BM_edge_select_set(em->bm, eed, true); + } } + + /* selects faces based on edge status */ + EDBM_selectmode_flush(em); } - - /* selects faces based on edge status */ - EDBM_selectmode_flush(em); } else if (em->selectmode & SCE_SELECT_FACE) { /* deselect eges, and select again based on face select */ - eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); - for (; eed; eed = BM_iter_step(&iter)) BM_edge_select_set(em->bm, eed, FALSE); - - efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - for (; efa; efa = BM_iter_step(&iter)) { - if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { - BM_face_select_set(em->bm, efa, TRUE); + BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { + BM_edge_select_set(em->bm, eed, false); + } + + if (em->bm->totfacesel) { + efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); + for (; efa; efa = BM_iter_step(&iter)) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + BM_face_select_set(em->bm, efa, true); + } } } } } +/** + * Flush the selection up: + * - vert -> edge + * - edge -> face + */ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const short selectmode_new) { BMEdge *eed; @@ -2027,7 +2047,10 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s /* have to find out what the selectionmode was previously */ if (selectmode_old == SCE_SELECT_VERTEX) { - if (selectmode_new == SCE_SELECT_EDGE) { + if (em->bm->totvertsel == 0) { + /* pass */ + } + else if (selectmode_new == SCE_SELECT_EDGE) { /* select all edges associated with every selected vert */ BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { BM_elem_flag_set(eed, BM_ELEM_TAG, BM_edge_is_any_vert_flag_test(eed, BM_ELEM_SELECT)); @@ -2035,7 +2058,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_TAG)) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, true); } } } @@ -2047,13 +2070,16 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - BM_face_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, true); } } } } else if (selectmode_old == SCE_SELECT_EDGE) { - if (selectmode_new == SCE_SELECT_FACE) { + if (em->bm->totedgesel == 0) { + /* pass */ + } + else if (selectmode_new == SCE_SELECT_FACE) { /* select all faces associated with every selected edge */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BM_elem_flag_set(efa, BM_ELEM_TAG, BM_face_is_any_edge_flag_test(efa, BM_ELEM_SELECT)); @@ -2061,7 +2087,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - BM_face_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, true); } } } @@ -2069,13 +2095,13 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s } /* user facing function, does notification and undo push */ -int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, - const int action, const int use_extend, const int use_expand) +bool EDBM_selectmode_toggle(bContext *C, const short selectmode_new, + const int action, const bool use_extend, const bool use_expand) { ToolSettings *ts = CTX_data_tool_settings(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = NULL; - int ret = FALSE; + bool ret = false; if (obedit && obedit->type == OB_MESH) { em = BMEdit_FromObject(obedit); @@ -2092,21 +2118,21 @@ int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, case 0: /* disable */ /* check we have something to do */ if ((em->selectmode & selectmode_new) == 0) { - return FALSE; + return false; } em->selectmode &= ~selectmode_new; break; case 1: /* enable */ /* check we have something to do */ if ((em->selectmode & selectmode_new) != 0) { - return FALSE; + return false; } em->selectmode |= selectmode_new; break; case 2: /* toggle */ /* can't disable this flag if its the only one set */ if (em->selectmode == selectmode_new) { - return FALSE; + return false; } em->selectmode ^= selectmode_new; break; @@ -2120,7 +2146,7 @@ int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, em->selectmode = SCE_SELECT_VERTEX; ts->selectmode = em->selectmode; EDBM_selectmode_set(em); - ret = TRUE; + ret = true; break; case SCE_SELECT_EDGE: if (use_extend == 0 || em->selectmode == 0) { @@ -2134,7 +2160,7 @@ int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, } ts->selectmode = em->selectmode; EDBM_selectmode_set(em); - ret = TRUE; + ret = true; break; case SCE_SELECT_FACE: if (use_extend == 0 || em->selectmode == 0) { @@ -2149,14 +2175,14 @@ int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, } ts->selectmode = em->selectmode; EDBM_selectmode_set(em); - ret = TRUE; + ret = true; break; default: BLI_assert(0); break; } - if (ret == TRUE) { + if (ret == true) { WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); } @@ -2164,6 +2190,37 @@ int EDBM_selectmode_toggle(bContext *C, const short selectmode_new, return ret; } +/** + * Use to disable a selectmode if its enabled, Using another mode as a fallback + * if the disabled mode is the only mode set. + * + * \return true if the mode is changed. + */ +bool EDBM_selectmode_disable(Scene *scene, BMEditMesh *em, + const short selectmode_disable, + const short selectmode_fallback) +{ + /* note essential, but switch out of vertex mode since the + * selected regions wont be nicely isolated after flushing */ + if (em->selectmode & selectmode_disable) { + if (em->selectmode == selectmode_disable) { + em->selectmode = selectmode_fallback; + } + else { + em->selectmode &= ~selectmode_disable; + } + scene->toolsettings->selectmode = em->selectmode; + EDBM_selectmode_set(em); + + WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, scene); + + return true; + } + else { + return false; + } +} + void EDBM_deselect_by_material(BMEditMesh *em, const short index, const short select) { BMIter iter; @@ -2225,25 +2282,25 @@ int EDBM_select_interior_faces(BMEditMesh *em) BMIter eiter; BMFace *efa; BMEdge *eed; - int ok; - int change = FALSE; + bool ok; + bool change = false; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) continue; - ok = TRUE; + ok = true; BM_ITER_ELEM (eed, &eiter, efa, BM_EDGES_OF_FACE) { if (BM_edge_face_count(eed) < 3) { - ok = FALSE; + ok = false; break; } } if (ok) { - BM_face_select_set(bm, efa, TRUE); - change = TRUE; + BM_face_select_set(bm, efa, true); + change = true; } } @@ -2256,9 +2313,9 @@ static void linked_limit_default(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); if (em->selectmode == SCE_SELECT_FACE) - RNA_boolean_set(op->ptr, "limit", TRUE); + RNA_boolean_set(op->ptr, "limit", true); else - RNA_boolean_set(op->ptr, "limit", FALSE); + RNA_boolean_set(op->ptr, "limit", false); } } @@ -2418,7 +2475,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) { - BM_face_select_set(bm, efa, TRUE); + BM_face_select_set(bm, efa, true); } } } @@ -2600,7 +2657,7 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h if (!BM_elem_flag_test(ele, BM_ELEM_TAG)) { /* Deselect elements that aren't at "nth" depth from active */ if ((offset + BMW_current_depth(&walker)) % nth) { - BM_elem_select_set(bm, ele, FALSE); + BM_elem_select_set(bm, ele, false); } BM_elem_flag_enable(ele, BM_ELEM_TAG); } @@ -2659,7 +2716,7 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **r_eve, BMEdge **r_eed, } } else if (em->selectmode & SCE_SELECT_FACE) { - f = BM_active_face_get(em->bm, TRUE, FALSE); + f = BM_active_face_get(em->bm, true, false); if (f) { *r_efa = f; return; @@ -2695,7 +2752,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int nth = RNA_int_get(op->ptr, "nth"); + const int nth = RNA_int_get(op->ptr, "nth"); int offset = RNA_int_get(op->ptr, "offset"); /* so input of offset zero ends up being (nth - 1) */ @@ -2706,7 +2763,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); return OPERATOR_FINISHED; } @@ -2763,14 +2820,14 @@ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op) const float sharp = RNA_float_get(op->ptr, "sharpness"); BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { - if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == FALSE && + if (BM_elem_flag_test(e, BM_ELEM_HIDDEN) == false && BM_edge_loop_pair(e, &l1, &l2)) { /* edge has exactly two neighboring faces, check angle */ const float angle = angle_normalized_v3v3(l1->f->no, l2->f->no); if (fabsf(angle) > sharp) { - BM_edge_select_set(em->bm, e, TRUE); + BM_edge_select_set(em->bm, e, true); } } } @@ -2810,7 +2867,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) BMFace *f, **stack = NULL; BLI_array_declare(stack); BMLoop *l, *l2; - float sharp = RNA_float_get(op->ptr, "sharpness"); + const float sharp = RNA_float_get(op->ptr, "sharpness"); int i; BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { @@ -2831,7 +2888,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op) f = stack[i - 1]; i--; - BM_face_select_set(em->bm, f, TRUE); + BM_face_select_set(em->bm, f, true); BM_elem_flag_enable(f, BM_ELEM_TAG); @@ -2907,13 +2964,13 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN) && !BM_vert_is_manifold(v)) { - BM_vert_select_set(em->bm, v, TRUE); + BM_vert_select_set(em->bm, v, true); } } BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(e, BM_ELEM_HIDDEN) && !BM_edge_is_manifold(e)) { - BM_edge_select_set(em->bm, e, TRUE); + BM_edge_select_set(em->bm, e, true); } } @@ -2948,7 +3005,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) BMEdge *eed; BMFace *efa; BMIter iter; - float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; + const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; BLI_srand(BLI_rand()); /* random seed */ @@ -2958,7 +3015,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_vert_select_set(em->bm, eve, TRUE); + BM_vert_select_set(em->bm, eve, true); } } EDBM_selectmode_flush(em); @@ -2966,7 +3023,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) else if (em->selectmode & SCE_SELECT_EDGE) { BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, true); } } EDBM_selectmode_flush(em); @@ -2974,7 +3031,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op) else { BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BLI_frand() < randfac) { - BM_face_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, true); } } EDBM_selectmode_flush(em); @@ -3012,7 +3069,7 @@ static int edbm_select_ungrouped_exec(bContext *C, wmOperator *op) BMVert *eve; BMIter iter; - if (!em->selectmode == SCE_SELECT_VERTEX) { + if ((em->selectmode & SCE_SELECT_VERTEX) == 0) { BKE_report(op->reports, RPT_ERROR, "Does not work out of vertex selection mode"); return OPERATOR_CANCELLED; } @@ -3077,14 +3134,14 @@ static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) { BM_elem_flag_enable(l->next->v, BM_ELEM_TAG); - BM_vert_select_set(em->bm, l->v, FALSE); + BM_vert_select_set(em->bm, l->v, false); } } } BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v, BM_ELEM_TAG)) { - BM_vert_select_set(em->bm, v, TRUE); + BM_vert_select_set(em->bm, v, true); } } @@ -3116,7 +3173,7 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op)) BMEdge *e; BMIter iter; - BM_mesh_elem_hflag_disable_all(em->bm, BM_EDGE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_EDGE, BM_ELEM_TAG, false); BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { BMLoop *l1, *l2; @@ -3139,7 +3196,7 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, BM_ELEM_TAG)) { - BM_edge_select_set(em->bm, e, TRUE); + BM_edge_select_set(em->bm, e, true); } } @@ -3315,22 +3372,22 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); BMIter iter; BMFace *f; - int selbigger = RNA_boolean_get(op->ptr, "select_bigger"); + const bool select_bigger = RNA_boolean_get(op->ptr, "select_bigger"); int a, b; /* find the set of regions with smallest number of total faces */ - a = loop_find_regions(em, selbigger); - b = loop_find_regions(em, !selbigger); + a = loop_find_regions(em, select_bigger); + b = loop_find_regions(em, !select_bigger); - if ((a <= b) ^ selbigger) { - loop_find_regions(em, selbigger); + if ((a <= b) ^ select_bigger) { + loop_find_regions(em, select_bigger); } EDBM_flag_disable_all(em, BM_ELEM_SELECT); BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(f, BM_ELEM_TAG) && !BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { - BM_face_select_set(em->bm, f, TRUE); + BM_face_select_set(em->bm, f, true); } } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 36a1d30c85e..13660a47248 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -97,10 +97,10 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int cuts = RNA_int_get(op->ptr, "number_cuts"); + const int cuts = RNA_int_get(op->ptr, "number_cuts"); float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness"); - float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; - float along_normal = RNA_float_get(op->ptr, "fractal_along_normal"); + const float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; + const float along_normal = RNA_float_get(op->ptr, "fractal_along_normal"); if (RNA_boolean_get(op->ptr, "quadtri") && RNA_enum_get(op->ptr, "quadcorner") == SUBD_STRAIGHT_CUT) @@ -112,10 +112,10 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op) smooth, fractal, along_normal, cuts, SUBDIV_SELECT_ORIG, RNA_enum_get(op->ptr, "quadcorner"), - RNA_boolean_get(op->ptr, "quadtri"), TRUE, FALSE, + RNA_boolean_get(op->ptr, "quadtri"), true, false, RNA_int_get(op->ptr, "seed")); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -168,14 +168,14 @@ static int edbm_unsubdivide_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - int iterations = RNA_int_get(op->ptr, "iterations"); + const int iterations = RNA_int_get(op->ptr, "iterations"); EDBM_op_init(em, &bmop, op, "unsubdivide verts=%hv iterations=%i", BM_ELEM_SELECT, iterations); BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return 0; } @@ -184,7 +184,7 @@ static int edbm_unsubdivide_exec(bContext *C, wmOperator *op) } EDBM_selectmode_flush(em); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -247,7 +247,7 @@ static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const c BMO_op_exec(em->bm, &bmop); BMO_ITER (f, &siter, bmop.slots_out, "faces.out", BM_FACE) { - BM_face_select_set(em->bm, f, TRUE); + BM_face_select_set(em->bm, f, true); /* set face vertex normals to face normal */ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { @@ -255,7 +255,7 @@ static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const c } } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return 0; } @@ -273,9 +273,9 @@ static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_flag_disable_all(em, BM_ELEM_SELECT); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_VERT | BM_EDGE, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return 0; } @@ -290,12 +290,12 @@ static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char EDBM_op_init(em, &bmop, op, "extrude_vert_indiv verts=%hv", hflag); /* deselect original verts */ - BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "verts", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "verts", BM_VERT, BM_ELEM_SELECT, true); BMO_op_exec(em->bm, &bmop); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return 0; } @@ -384,7 +384,7 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, zero_v3(nor); BMO_ITER (ele, &siter, extop.slots_out, "geom.out", BM_ALL) { - BM_elem_select_set(bm, ele, TRUE); + BM_elem_select_set(bm, ele, true); if (ele->head.htype == BM_FACE) { f = (BMFace *)ele; @@ -409,8 +409,8 @@ static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, hflag)) { if (hflag & BM_ELEM_SELECT) { - BM_vert_select_set(em->bm, eed->v1, TRUE); - BM_vert_select_set(em->bm, eed->v2, TRUE); + BM_vert_select_set(em->bm, eed->v1, true); + BM_vert_select_set(em->bm, eed->v2, true); } BM_elem_flag_enable(eed->v1, hflag & ~BM_ELEM_SELECT); @@ -419,7 +419,7 @@ static short edbm_extrude_vert(Object *obedit, BMEditMesh *em, const char hflag, else { if (BM_elem_flag_test(eed->v1, hflag) && BM_elem_flag_test(eed->v2, hflag)) { if (hflag & BM_ELEM_SELECT) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, true); } BM_elem_flag_enable(eed, hflag & ~BM_ELEM_SELECT); @@ -436,9 +436,9 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); RegionView3D *rv3d = CTX_wm_region_view3d(C); - int steps = RNA_int_get(op->ptr, "steps"); + const int steps = RNA_int_get(op->ptr, "steps"); - float offs = RNA_float_get(op->ptr, "offset"); + const float offs = RNA_float_get(op->ptr, "offset"); float dvec[3], tmat[3][3], bmat[3][3], nor[3] = {0.0, 0.0, 0.0}; short a; @@ -463,7 +463,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op) EDBM_mesh_normals_update(em); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -585,7 +585,7 @@ static int edbm_extrude_region_exec(bContext *C, wmOperator *op) * done.*/ EDBM_mesh_normals_update(em); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -616,7 +616,7 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op) edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -647,7 +647,7 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op) edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -678,7 +678,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT, nor); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -706,7 +706,7 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int action = RNA_enum_get(op->ptr, "action"); + const int action = RNA_enum_get(op->ptr, "action"); switch (action) { case SEL_TOGGLE: @@ -784,8 +784,8 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w BMVert *v1; BMIter iter; float min[3], max[3]; - int done = FALSE; - short use_proj; + bool done = false; + bool use_proj; em_setup_viewcontext(C, &vc); @@ -800,13 +800,13 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w BM_ITER_MESH (v1, &iter, vc.em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(v1, BM_ELEM_SELECT)) { minmax_v3v3_v3(min, max, v1->co); - done = TRUE; + done = true; } } /* call extrude? */ if (done) { - const short rot_src = RNA_boolean_get(op->ptr, "rotate_source"); + const bool rot_src = RNA_boolean_get(op->ptr, "rotate_source"); BMEdge *eed; float vec[3], cent[3], mat[3][3]; float nor[3] = {0.0, 0.0, 0.0}; @@ -816,7 +816,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w (float)event->mval[1]}; /* check for edges that are half selected, use for rotation */ - done = FALSE; + done = false; BM_ITER_MESH (eed, &iter, vc.em->bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { float co1[2], co2[2]; @@ -837,7 +837,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w nor[0] += (co2[1] - co1[1]); nor[1] += -(co2[0] - co1[0]); } - done = TRUE; + done = true; } } } @@ -920,10 +920,10 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w BMO_op_exec(vc.em->bm, &bmop); BMO_ITER (v1, &oiter, bmop.slots_out, "vert.out", BM_VERT) { - BM_vert_select_set(vc.em->bm, v1, TRUE); + BM_vert_select_set(vc.em->bm, v1, true); } - if (!EDBM_op_finish(vc.em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(vc.em, &bmop, op, true)) { return OPERATOR_CANCELLED; } } @@ -936,7 +936,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w * done. */ EDBM_mesh_normals_update(vc.em); - EDBM_update_generic(vc.em, TRUE, TRUE); + EDBM_update_generic(vc.em, true, true); return OPERATOR_FINISHED; } @@ -972,7 +972,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); if (type == 0) { if (!EDBM_op_callf(em, op, "delete geom=%hv context=%i", BM_ELEM_SELECT, DEL_VERTS)) /* Erase Vertices */ @@ -1001,7 +1001,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op) EDBM_flag_disable_all(em, BM_ELEM_SELECT); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1034,7 +1034,7 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "collapse edges=%he", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1062,7 +1062,7 @@ static int edbm_collapse_edge_loop_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "dissolve_edge_loop edges=%he", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1274,11 +1274,11 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op) BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true); } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1309,7 +1309,7 @@ static int edbm_mark_seam(bContext *C, wmOperator *op) BMesh *bm = em->bm; BMEdge *eed; BMIter iter; - int clear = RNA_boolean_get(op->ptr, "clear"); + const bool clear = RNA_boolean_get(op->ptr, "clear"); /* auto-enable seams drawing */ if (clear == 0) { @@ -1333,7 +1333,7 @@ static int edbm_mark_seam(bContext *C, wmOperator *op) } ED_uvedit_live_unwrap(scene, obedit); - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1363,7 +1363,7 @@ static int edbm_mark_sharp(bContext *C, wmOperator *op) BMesh *bm = em->bm; BMEdge *eed; BMIter iter; - int clear = RNA_boolean_get(op->ptr, "clear"); + const bool clear = RNA_boolean_get(op->ptr, "clear"); /* auto-enable sharp edge drawing */ if (clear == 0) { @@ -1387,7 +1387,7 @@ static int edbm_mark_sharp(bContext *C, wmOperator *op) } } - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1423,13 +1423,13 @@ static int edbm_vert_connect(bContext *C, wmOperator *op) } BMO_op_exec(bm, &bmop); len = BMO_slot_get(bmop.slots_out, "edges.out")->len; - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } else { EDBM_selectmode_flush(em); /* so newly created edges get the selection state from the vertex */ - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1463,11 +1463,11 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op) } BMO_op_exec(bm, &bmop); len = BMO_slot_get(bmop.slots_out, "edges.out")->len; - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1500,13 +1500,13 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1545,7 +1545,7 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1566,8 +1566,8 @@ void MESH_OT_flip_normals(wmOperatorType *ot) } static const EnumPropertyItem direction_items[] = { - {FALSE, "CW", 0, "Clockwise", ""}, - {TRUE, "CCW", 0, "Counter Clockwise", ""}, + {false, "CW", 0, "Clockwise", ""}, + {true, "CCW", 0, "Counter Clockwise", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1579,7 +1579,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) BMOperator bmop; BMEdge *eed; BMIter iter; - const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); + const bool use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); int tot = 0; if (em->bm->totedgesel == 0) { @@ -1614,19 +1614,19 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op) /* avoids leaving old verts selected which can be a problem running multiple times, * since this means the edges become selected around the face which then attempt to rotate */ - BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_in, "edges", BM_EDGE, BM_ELEM_SELECT, true); BMO_op_exec(em->bm, &bmop); /* edges may rotate into hidden vertices, if this does _not_ run we get an ilogical state */ - BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, TRUE); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_HIDDEN, true); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "edges.out", BM_EDGE, BM_ELEM_SELECT, true); EDBM_selectmode_flush(em); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -1646,7 +1646,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); + RNA_def_boolean(ot->srna, "use_ccw", false, "Counter Clockwise", ""); } @@ -1657,7 +1657,7 @@ static int edbm_hide_exec(bContext *C, wmOperator *op) EDBM_mesh_hide(em, RNA_boolean_get(op->ptr, "unselected")); - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1687,7 +1687,7 @@ static int edbm_reveal_exec(bContext *C, wmOperator *UNUSED(op)) EDBM_mesh_reveal(em); - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1714,13 +1714,13 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op) /* doflip has to do with bmesh_rationalize_normals, it's an internal * thing */ - if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf use_flip=%b", BM_ELEM_SELECT, TRUE)) + if (!EDBM_op_callf(em, op, "recalc_face_normals faces=%hf use_flip=%b", BM_ELEM_SELECT, true)) return OPERATOR_CANCELLED; if (RNA_boolean_get(op->ptr, "inside")) EDBM_op_callf(em, op, "reverse_faces faces=%hf", BM_ELEM_SELECT); - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1749,17 +1749,17 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); ModifierData *md; - int mirrx = FALSE, mirry = FALSE, mirrz = FALSE; + int mirrx = false, mirry = false, mirrz = false; int i, repeat; float clip_dist = 0.0f; - int xaxis = RNA_boolean_get(op->ptr, "xaxis"); - int yaxis = RNA_boolean_get(op->ptr, "yaxis"); - int zaxis = RNA_boolean_get(op->ptr, "zaxis"); + const bool xaxis = RNA_boolean_get(op->ptr, "xaxis"); + const bool yaxis = RNA_boolean_get(op->ptr, "yaxis"); + const bool zaxis = RNA_boolean_get(op->ptr, "zaxis"); /* mirror before smooth */ if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) { - EDBM_verts_mirror_cache_begin(em, TRUE); + EDBM_verts_mirror_cache_begin(em, true); } /* if there is a mirror modifier with clipping, flag the verts that @@ -1771,11 +1771,11 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) if (mmd->flag & MOD_MIR_CLIPPING) { if (mmd->flag & MOD_MIR_AXIS_X) - mirrx = TRUE; + mirrx = true; if (mmd->flag & MOD_MIR_AXIS_Y) - mirry = TRUE; + mirry = true; if (mmd->flag & MOD_MIR_AXIS_Z) - mirrz = TRUE; + mirrz = true; clip_dist = mmd->tolerance; } @@ -1802,7 +1802,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op) EDBM_verts_mirror_cache_end(em); } - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1831,7 +1831,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int usex = TRUE, usey = TRUE, usez = TRUE, preserve_volume = TRUE; + int usex = true, usey = true, usez = true, preserve_volume = true; int i, repeat; float lambda_factor; float lambda_border; @@ -1850,7 +1850,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) /* mirror before smooth */ if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) { - EDBM_verts_mirror_cache_begin(em, TRUE); + EDBM_verts_mirror_cache_begin(em, true); } repeat = RNA_int_get(op->ptr, "repeat"); @@ -1878,7 +1878,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) EDBM_verts_mirror_cache_end(em); } - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -1932,7 +1932,7 @@ static int edbm_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op)) mesh_set_smooth_faces(em, 1); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); return OPERATOR_FINISHED; } @@ -1959,7 +1959,7 @@ static int edbm_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op)) mesh_set_smooth_faces(em, 0); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); return OPERATOR_FINISHED; } @@ -1989,7 +1989,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the direction from RNA */ - const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); + const bool use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ EDBM_op_init(em, &bmop, op, "rotate_uvs faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw); @@ -1998,11 +1998,11 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -2021,11 +2021,11 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -2038,7 +2038,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) BMOperator bmop; /* get the direction from RNA */ - const int use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); + const bool use_ccw = RNA_boolean_get(op->ptr, "use_ccw"); /* initialize the bmop using EDBM api, which does various ui error reporting and other stuff */ EDBM_op_init(em, &bmop, op, "rotate_colors faces=%hf use_ccw=%b", BM_ELEM_SELECT, use_ccw); @@ -2047,12 +2047,12 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } /* dependencies graph and notification stuff */ - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -2072,11 +2072,11 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -2097,7 +2097,7 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); + RNA_def_boolean(ot->srna, "use_ccw", false, "Counter Clockwise", ""); } //void MESH_OT_uvs_mirror(wmOperatorType *ot) @@ -2134,7 +2134,7 @@ void MESH_OT_colors_rotate(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "use_ccw", FALSE, "Counter Clockwise", ""); + RNA_def_boolean(ot->srna, "use_ccw", false, "Counter Clockwise", ""); } void MESH_OT_colors_reverse(wmOperatorType *ot) @@ -2156,7 +2156,7 @@ void MESH_OT_colors_reverse(wmOperatorType *ot) } -static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *wmop) +static bool merge_firstlast(BMEditMesh *em, const bool use_first, const bool use_uvmerge, wmOperator *wmop) { BMVert *mergevert; BMEditSelection *ese; @@ -2166,44 +2166,44 @@ static int merge_firstlast(BMEditMesh *em, int first, int uvmerge, wmOperator *w */ /* do sanity check in mergemenu in edit.c ?*/ - if (first == 0) { + if (use_first == false) { if (!em->bm->selected.last || ((BMEditSelection *)em->bm->selected.last)->htype != BM_VERT) - return OPERATOR_CANCELLED; + return false; ese = em->bm->selected.last; mergevert = (BMVert *)ese->ele; } else { if (!em->bm->selected.first || ((BMEditSelection *)em->bm->selected.first)->htype != BM_VERT) - return OPERATOR_CANCELLED; + return false; ese = em->bm->selected.first; mergevert = (BMVert *)ese->ele; } if (!BM_elem_flag_test(mergevert, BM_ELEM_SELECT)) - return OPERATOR_CANCELLED; + return false; - if (uvmerge) { + if (use_uvmerge) { if (!EDBM_op_callf(em, wmop, "pointmerge_facedata verts=%hv vert_snap=%e", BM_ELEM_SELECT, mergevert)) - return OPERATOR_CANCELLED; + return false; } if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, mergevert->co)) - return OPERATOR_CANCELLED; + return false; - return OPERATOR_FINISHED; + return true; } -static int merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, - int target, int uvmerge, wmOperator *wmop) +static bool merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, + const bool use_cursor, const bool use_uvmerge, wmOperator *wmop) { BMIter iter; BMVert *v; float co[3], cent[3] = {0.0f, 0.0f, 0.0f}; const float *vco = NULL; - if (target) { + if (use_cursor) { vco = give_cursor(scene, v3d); copy_v3_v3(co, vco); mul_m4_v3(ob->imat, co); @@ -2219,7 +2219,7 @@ static int merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, } if (!i) - return OPERATOR_CANCELLED; + return false; fac = 1.0f / (float)i; mul_v3_fl(cent, fac); @@ -2228,17 +2228,17 @@ static int merge_target(BMEditMesh *em, Scene *scene, View3D *v3d, Object *ob, } if (!vco) - return OPERATOR_CANCELLED; + return false; - if (uvmerge) { + if (use_uvmerge) { if (!EDBM_op_callf(em, wmop, "average_vert_facedata verts=%hv", BM_ELEM_SELECT)) - return OPERATOR_CANCELLED; + return false; } if (!EDBM_op_callf(em, wmop, "pointmerge verts=%hv merge_co=%v", BM_ELEM_SELECT, co)) - return OPERATOR_CANCELLED; + return false; - return OPERATOR_FINISHED; + return true; } static int edbm_merge_exec(bContext *C, wmOperator *op) @@ -2247,32 +2247,37 @@ static int edbm_merge_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int status = 0, uvs = RNA_boolean_get(op->ptr, "uvs"); + const int type = RNA_enum_get(op->ptr, "type"); + const bool uvs = RNA_boolean_get(op->ptr, "uvs"); + bool ok = false; - switch (RNA_enum_get(op->ptr, "type")) { + switch (type) { case 3: - status = merge_target(em, scene, v3d, obedit, 0, uvs, op); + ok = merge_target(em, scene, v3d, obedit, false, uvs, op); break; case 4: - status = merge_target(em, scene, v3d, obedit, 1, uvs, op); + ok = merge_target(em, scene, v3d, obedit, true, uvs, op); break; case 1: - status = merge_firstlast(em, 0, uvs, op); + ok = merge_firstlast(em, false, uvs, op); break; case 6: - status = merge_firstlast(em, 1, uvs, op); + ok = merge_firstlast(em, true, uvs, op); break; case 5: - status = 1; + ok = true; if (!EDBM_op_callf(em, op, "collapse edges=%he", BM_ELEM_SELECT)) - status = 0; + ok = false; break; + default: + BLI_assert(0); } - if (!status) + if (!ok) { return OPERATOR_CANCELLED; + } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -2356,8 +2361,8 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; const float threshold = RNA_float_get(op->ptr, "threshold"); - int use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); - int totvert_orig = em->bm->totvert; + const bool use_unselected = RNA_boolean_get(op->ptr, "use_unselected"); + const int totvert_orig = em->bm->totvert; int count; if (use_unselected) { @@ -2366,7 +2371,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) BM_ELEM_SELECT, threshold); BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } } @@ -2381,7 +2386,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } } @@ -2389,7 +2394,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op) count = totvert_orig - em->bm->totvert; BKE_reportf(op->reports, RPT_INFO, "Removed %d vertices", count); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -2439,7 +2444,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) BMEditSelection *sv, *ev; /* get the type from RNA */ - int type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); /* first try to find vertices in edit selection */ sv = em->bm->selected.last; @@ -2491,16 +2496,16 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op) /* EDBM_flag_disable_all(em, BM_ELEM_SELECT); */ /* select the output */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "verts.out", BM_VERT, BM_ELEM_SELECT, true); /* finish the operator */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } EDBM_selectmode_flush(em); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); /* we succeeded */ return OPERATOR_FINISHED; @@ -2575,7 +2580,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op) shape_propagate(em, op); - EDBM_update_generic(em, FALSE, FALSE); + EDBM_update_generic(em, false, false); return OPERATOR_FINISHED; } @@ -2607,11 +2612,12 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) BMVert *eve; BMIter iter; float co[3], *sco; - float blend = RNA_float_get(op->ptr, "blend"); - int shape = RNA_enum_get(op->ptr, "shape"); - int add = RNA_boolean_get(op->ptr, "add"); int totshape; + const float blend = RNA_float_get(op->ptr, "blend"); + const int shape = RNA_enum_get(op->ptr, "shape"); + const bool use_add = RNA_boolean_get(op->ptr, "add"); + /* sanity check */ totshape = CustomData_number_of_layers(&em->bm->vdata, CD_SHAPEKEY); if (totshape == 0 || shape < 0 || shape >= totshape) @@ -2631,7 +2637,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) sco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, shape); copy_v3_v3(co, sco); - if (add) { + if (use_add) { /* in add mode, we add relative shape key offset */ if (kb) { float *rco = CustomData_bmesh_get_n(&em->bm->vdata, eve->head.data, CD_SHAPEKEY, kb->relative); @@ -2646,7 +2652,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op) } } - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -2730,8 +2736,8 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMEditSelection *ese = em->bm->selected.last; - int axis = RNA_enum_get(op->ptr, "axis"); - int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */ + const int axis = RNA_enum_get(op->ptr, "axis"); + const int mode = RNA_enum_get(op->ptr, "mode"); /* -1 == aligned, 0 == neg, 1 == pos */ if (ese == NULL || ese->htype != BM_VERT) { BKE_report(op->reports, RPT_WARNING, "This operator requires an active vertex (last selected)"); @@ -2753,15 +2759,15 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op) switch (mode) { case -1: /* aligned */ if (fabsf(ev->co[axis] - value) < limit) - BM_vert_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, true); break; case 0: /* neg */ if (ev->co[axis] > value) - BM_vert_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, true); break; case 1: /* pos */ if (ev->co[axis] < value) - BM_vert_select_set(em->bm, ev, TRUE); + BM_vert_select_set(em->bm, ev, true); break; } } @@ -2815,7 +2821,7 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op) BMesh *bm = em->bm; BMOperator bmop; - float thickness = RNA_float_get(op->ptr, "thickness"); + const float thickness = RNA_float_get(op->ptr, "thickness"); if (!EDBM_op_init(em, &bmop, op, "solidify geom=%hf thickness=%f", BM_ELEM_SELECT, thickness)) { return OPERATOR_CANCELLED; @@ -2824,19 +2830,19 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op) /* deselect only the faces in the region to be solidified (leave wire * edges and loose verts selected, as there will be no corresponding * geometry selected below) */ - BMO_slot_buffer_hflag_disable(bm, bmop.slots_in, "geom", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_disable(bm, bmop.slots_in, "geom", BM_FACE, BM_ELEM_SELECT, true); /* run the solidify operator */ BMO_op_exec(bm, &bmop); /* select the newly generated faces */ - BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(bm, bmop.slots_out, "geom.out", BM_FACE, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3061,7 +3067,8 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BMOperator bmop; float isect = 0.0f; int len = 0, isected, i; - short numcuts = 1, mode = RNA_int_get(op->ptr, "type"); + short numcuts = 1; + const short mode = RNA_int_get(op->ptr, "type"); BMOpSlot *slot_edge_percents; /* allocd vars */ @@ -3119,7 +3126,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) /* store percentage of edge cut for KNIFE_EXACT here.*/ slot_edge_percents = BMO_slot_get(bmop.slots_in, "edge_percents"); for (be = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); be; be = BM_iter_step(&iter)) { - int is_cut = FALSE; + bool is_cut = false; if (BM_elem_flag_test(be, BM_ELEM_SELECT)) { const float *sco_a = screen_vert_coords[BM_elem_index_get(be->v1)]; const float *sco_b = screen_vert_coords[BM_elem_index_get(be->v2)]; @@ -3151,17 +3158,17 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) BMO_slot_int_set(bmop.slots_in, "cuts", numcuts); BMO_slot_int_set(bmop.slots_in, "quad_corner_type", SUBD_STRAIGHT_CUT); - BMO_slot_bool_set(bmop.slots_in, "use_single_edge", FALSE); - BMO_slot_bool_set(bmop.slots_in, "use_grid_fill", FALSE); + BMO_slot_bool_set(bmop.slots_in, "use_single_edge", false); + BMO_slot_bool_set(bmop.slots_in, "use_grid_fill", false); BMO_slot_float_set(bmop.slots_in, "radius", 0); BMO_op_exec(bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3226,25 +3233,25 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh /* deselect loose data - this used to get deleted, * we could de-select edges and verts only, but this turns out to be less complicated * since de-selecting all skips selection flushing logic */ - BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); - BM_mesh_normals_update(bm_new, FALSE); + BM_mesh_normals_update(bm_new, false); - BM_mesh_bm_to_me(bm_new, base_new->object->data, FALSE); + BM_mesh_bm_to_me(bm_new, base_new->object->data, false); BM_mesh_free(bm_new); ((Mesh *)base_new->object->data)->edit_btmesh = NULL; - return TRUE; + return true; } -static int mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) +static bool mesh_separate_selected(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) { /* we may have tags from previous operators */ - BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, false); /* sel -> tag */ - BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, TRUE, BM_ELEM_SELECT); + BM_mesh_elem_hflag_enable_test(bm_old, BM_FACE | BM_EDGE | BM_VERT, BM_ELEM_TAG, true, BM_ELEM_SELECT); return mesh_separate_tagged(bmain, scene, base_old, bm_old); } @@ -3260,7 +3267,7 @@ static void bm_mesh_hflag_flush_vert(BMesh *bm, const char hflag) BMIter eiter; BMIter fiter; - int ok; + bool ok; BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e->v1, hflag) && @@ -3273,11 +3280,11 @@ static void bm_mesh_hflag_flush_vert(BMesh *bm, const char hflag) } } BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { - ok = TRUE; + ok = true; l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { if (!BM_elem_flag_test(l_iter->v, hflag)) { - ok = FALSE; + ok = false; break; } } while ((l_iter = l_iter->next) != l_first); @@ -3286,17 +3293,17 @@ static void bm_mesh_hflag_flush_vert(BMesh *bm, const char hflag) } } -static int mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) +static bool mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) { BMFace *f_cmp, *f; BMIter iter; - int result = FALSE; + bool result = false; while ((f_cmp = BM_iter_at_index(bm_old, BM_FACES_OF_MESH, NULL, 0))) { const short mat_nr = f_cmp->mat_nr; int tot = 0; - BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false); BM_ITER_MESH (f, &iter, bm_old, BM_FACES_OF_MESH) { if (f->mat_nr == mat_nr) { @@ -3326,17 +3333,17 @@ static int mesh_separate_material(Main *bmain, Scene *scene, Base *base_old, BMe return result; } -static int mesh_separate_loose(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) +static bool mesh_separate_loose(Main *bmain, Scene *scene, Base *base_old, BMesh *bm_old) { int i; BMEdge *e; BMVert *v_seed; BMWalker walker; - int result = FALSE; + bool result = false; int max_iter = bm_old->totvert; /* Clear all selected vertices */ - BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false); /* A "while (true)" loop should work here as each iteration should * select and remove at least one vertex and when all vertices @@ -3389,7 +3396,8 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - int retval = 0, type = RNA_enum_get(op->ptr, "type"); + const int type = RNA_enum_get(op->ptr, "type"); + int retval = 0; if (ED_operator_editmesh(C)) { Base *base = CTX_data_active_base(C); @@ -3412,7 +3420,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) else BLI_assert(0); if (retval) { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); } } else { @@ -3433,14 +3441,14 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) bm_old = BM_mesh_create(&bm_mesh_allocsize_default); - BM_mesh_bm_from_me(bm_old, me, FALSE, 0); + BM_mesh_bm_from_me(bm_old, me, false, 0); if (type == 1) retval_iter = mesh_separate_material(bmain, scene, base_iter, bm_old); else if (type == 2) retval_iter = mesh_separate_loose(bmain, scene, base_iter, bm_old); else BLI_assert(0); if (retval_iter) { - BM_mesh_bm_to_me(bm_old, me, FALSE); + BM_mesh_bm_to_me(bm_old, me, false); DAG_id_tag_update(&me->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -3497,7 +3505,7 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); + const bool use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); BMOperator bmop; if (!EDBM_op_init(em, &bmop, op, @@ -3510,13 +3518,13 @@ static int edbm_fill_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* select new geometry */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_FACE | BM_EDGE, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; @@ -3547,7 +3555,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "beautify_fill faces=%hf edges=ae", BM_ELEM_SELECT)) return OPERATOR_CANCELLED; - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3574,7 +3582,7 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - int use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); + const bool use_beauty = RNA_boolean_get(op->ptr, "use_beauty"); EDBM_op_init(em, &bmop, op, "triangulate faces=%hf use_beauty=%b", BM_ELEM_SELECT, use_beauty); BMO_op_exec(em->bm, &bmop); @@ -3586,11 +3594,11 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op) &bmop, "faces.out", &bmop, "edges.out"); } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3617,7 +3625,7 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); int dosharp, douvs, dovcols, domaterials; - float limit = RNA_float_get(op->ptr, "limit"); + const float limit = RNA_float_get(op->ptr, "limit"); dosharp = RNA_boolean_get(op->ptr, "sharp"); douvs = RNA_boolean_get(op->ptr, "uvs"); @@ -3631,7 +3639,7 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3672,7 +3680,7 @@ static int edbm_dissolve_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int use_verts = RNA_boolean_get(op->ptr, "use_verts"); + const bool use_verts = RNA_boolean_get(op->ptr, "use_verts"); if (em->selectmode & SCE_SELECT_FACE) { if (!EDBM_op_callf(em, op, "dissolve_faces faces=%hf use_verts=%b", BM_ELEM_SELECT, use_verts)) @@ -3687,7 +3695,7 @@ static int edbm_dissolve_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3717,7 +3725,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); BMesh *bm = em->bm; const float angle_limit = RNA_float_get(op->ptr, "angle_limit"); - const int use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries"); + const bool use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries"); char dissolve_flag; @@ -3759,7 +3767,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3793,18 +3801,18 @@ static int edbm_split_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(ob); BMOperator bmop; - EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, FALSE); + EDBM_op_init(em, &bmop, op, "split geom=%hvef use_only_faces=%b", BM_ELEM_SELECT, false); BMO_op_exec(em->bm, &bmop); - BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, TRUE); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } /* Geometry has changed, need to recalc normals and looptris */ EDBM_mesh_normals_update(em); - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3858,12 +3866,12 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, TRUE); - if (!EDBM_op_finish(em, &spinop, op, TRUE)) { + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + if (!EDBM_op_finish(em, &spinop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -3976,18 +3984,18 @@ static int edbm_screw_exec(bContext *C, wmOperator *op) if (!EDBM_op_init(em, &spinop, op, "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f use_duplicate=%b", - BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), FALSE)) + BM_ELEM_SELECT, cent, axis, dvec, turns * steps, DEG2RADF(360.0f * turns), false)) { return OPERATOR_CANCELLED; } BMO_op_exec(bm, &spinop); EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, TRUE); - if (!EDBM_op_finish(em, &spinop, op, TRUE)) { + BMO_slot_buffer_hflag_enable(bm, spinop.slots_out, "geom_last.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, true); + if (!EDBM_op_finish(em, &spinop, op, true)) { return OPERATOR_CANCELLED; } - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } @@ -4061,12 +4069,12 @@ static int edbm_select_face_by_sides_exec(bContext *C, wmOperator *op) break; default: BLI_assert(0); - select = FALSE; + select = false; break; } if (select) { - BM_face_select_set(em->bm, efa, TRUE); + BM_face_select_set(em->bm, efa, true); } } @@ -4101,7 +4109,7 @@ void MESH_OT_select_face_by_sides(wmOperatorType *ot) /* properties */ RNA_def_int(ot->srna, "number", 4, 3, INT_MAX, "Number of Vertices", "", 3, INT_MAX); RNA_def_enum(ot->srna, "type", type_items, 1, "Type", "Type of comparison to make"); - RNA_def_boolean(ot->srna, "extend", TRUE, "Extend", "Extend the selection"); + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend the selection"); } static int edbm_select_loose_verts_exec(bContext *C, wmOperator *op) @@ -4117,13 +4125,13 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *op) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (!eve->e) { - BM_vert_select_set(em->bm, eve, TRUE); + BM_vert_select_set(em->bm, eve, true); } } BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!eed->l) { - BM_edge_select_set(em->bm, eed, TRUE); + BM_edge_select_set(em->bm, eed, true); } } @@ -4155,7 +4163,7 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int extend = RNA_boolean_get(op->ptr, "extend"); + bool extend = RNA_boolean_get(op->ptr, "extend"); if (em->bm->totvert && em->bm->totvertsel) { EDBM_select_mirrored(obedit, em, extend); @@ -4259,12 +4267,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, float co[3]; mul_v3_m4v3(co, mat, ve->co); - pb[i] = FALSE; + pb[i] = false; sb[affected[0]].org_idx = i; sb[affected[0]++].srt = co[coidx] * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4279,12 +4287,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, mid_v3_v3v3(co, ed->v1->co, ed->v2->co); mul_m4_v3(mat, co); - pb[i] = FALSE; + pb[i] = false; sb[affected[1]].org_idx = i; sb[affected[1]++].srt = co[coidx] * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4299,12 +4307,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_face_calc_center_mean(fa, co); mul_m4_v3(mat, co); - pb[i] = FALSE; + pb[i] = false; sb[affected[2]].org_idx = i; sb[affected[2]++].srt = co[coidx] * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4328,12 +4336,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(ve, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[0]].org_idx = i; sb[affected[0]++].srt = len_squared_v3v3(cur, ve->co) * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4347,12 +4355,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, float co[3]; mid_v3_v3v3(co, ed->v1->co, ed->v2->co); - pb[i] = FALSE; + pb[i] = false; sb[affected[1]].org_idx = i; sb[affected[1]++].srt = len_squared_v3v3(cur, co) * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4366,12 +4374,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, float co[3]; BM_face_calc_center_mean(fa, co); - pb[i] = FALSE; + pb[i] = false; sb[affected[2]].org_idx = i; sb[affected[2]++].srt = len_squared_v3v3(cur, co) * fact; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4387,14 +4395,14 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, /* Reverse materials' order, not order of faces inside each mat! */ /* Note: cannot use totcol, as mat_nr may sometimes be greater... */ float srt = reverse ? (float)(MAXMAT - fa->mat_nr) : (float)fa->mat_nr; - pb[i] = FALSE; + pb[i] = false; sb[affected[2]].org_idx = i; /* Multiplying with totface and adding i ensures us we keep current order for all faces of same mat. */ sb[affected[2]++].srt = srt * ((float)totelem[2]) + ((float)i); /* printf("e: %d; srt: %f; final: %f\n", i, srt, srt * ((float)totface) + ((float)i));*/ } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4488,12 +4496,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(ve, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[0]].org_idx = i; sb[affected[0]++].srt = BLI_frand(); } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4505,12 +4513,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { if (BM_elem_flag_test(ed, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[1]].org_idx = i; sb[affected[1]++].srt = BLI_frand(); } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4522,12 +4530,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { if (BM_elem_flag_test(fa, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[2]].org_idx = i; sb[affected[2]++].srt = BLI_frand(); } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4540,12 +4548,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (BM_elem_flag_test(ve, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[0]].org_idx = i; sb[affected[0]++].srt = (float)-i; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4556,12 +4564,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { if (BM_elem_flag_test(ed, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[1]].org_idx = i; sb[affected[1]++].srt = (float)-i; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4572,12 +4580,12 @@ static void sort_bmelem_flag(Scene *scene, Object *ob, BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { if (BM_elem_flag_test(fa, flag)) { - pb[i] = FALSE; + pb[i] = false; sb[affected[2]].org_idx = i; sb[affected[2]++].srt = (float)-i; } else { - pb[i] = TRUE; + pb[i] = true; } } } @@ -4647,9 +4655,9 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); - int action = RNA_enum_get(op->ptr, "type"); + const int action = RNA_enum_get(op->ptr, "type"); PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements"); - int reverse = RNA_boolean_get(op->ptr, "reverse"); + const bool use_reverse = RNA_boolean_get(op->ptr, "reverse"); unsigned int seed = RNA_int_get(op->ptr, "seed"); int elem_types = 0; @@ -4676,32 +4684,32 @@ static int edbm_sort_elements_exec(bContext *C, wmOperator *op) } sort_bmelem_flag(scene, ob, v3d, rv3d, - elem_types, BM_ELEM_SELECT, action, reverse, seed); + elem_types, BM_ELEM_SELECT, action, use_reverse, seed); return OPERATOR_FINISHED; } -static int edbm_sort_elements_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +static bool edbm_sort_elements_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - int action = RNA_enum_get(ptr, "type"); + const int action = RNA_enum_get(ptr, "type"); /* Only show seed for randomize action! */ if (STREQ(prop_id, "seed")) { if (action == SRT_RANDOMIZE) - return TRUE; + return true; else - return FALSE; + return false; } /* Hide seed for reverse and randomize actions! */ if (STREQ(prop_id, "reverse")) { if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) - return FALSE; + return false; else - return TRUE; + return true; } - return TRUE; + return true; } static void edbm_sort_elements_ui(bContext *C, wmOperator *op) @@ -4760,7 +4768,7 @@ void MESH_OT_sort_elements(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Type of re-ordering operation to apply"); RNA_def_enum_flag(ot->srna, "elements", elem_items, 0, "Elements", "Which elements to affect (vertices, edges and/or faces)"); - RNA_def_boolean(ot->srna, "reverse", FALSE, "Reverse", "Reverse the sorting effect"); + RNA_def_boolean(ot->srna, "reverse", false, "Reverse", "Reverse the sorting effect"); RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for random-based operations", 0, 255); } @@ -4774,7 +4782,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op) Tex *tex; BMVert *eve; BMIter iter; - float fac = RNA_float_get(op->ptr, "factor"); + const float fac = RNA_float_get(op->ptr, "factor"); if (em == NULL) { return OPERATOR_FINISHED; @@ -4814,7 +4822,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op) EDBM_mesh_normals_update(em); - EDBM_update_generic(em, TRUE, FALSE); + EDBM_update_generic(em, true, false); return OPERATOR_FINISHED; } @@ -4899,13 +4907,13 @@ static int edbm_bevel_calc(wmOperator *op) BevelData *opdata = op->customdata; BMEditMesh *em = opdata->em; BMOperator bmop; - float offset = RNA_float_get(op->ptr, "offset"); - int segments = RNA_int_get(op->ptr, "segments"); - int vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); + const float offset = RNA_float_get(op->ptr, "offset"); + const int segments = RNA_int_get(op->ptr, "segments"); + const bool vertex_only = RNA_boolean_get(op->ptr, "vertex_only"); /* revert to original mesh */ if (opdata->is_modal) { - EDBM_redo_state_restore(opdata->mesh_backup, em, FALSE); + EDBM_redo_state_restore(opdata->mesh_backup, em, false); } if (!EDBM_op_init(em, &bmop, op, @@ -4921,16 +4929,16 @@ static int edbm_bevel_calc(wmOperator *op) /* not essential, but we may have some loose geometry that * won't get bevel'd and better not leave it selected */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); } /* no need to de-select existing geometry */ - if (!EDBM_op_finish(em, &bmop, op, TRUE)) + if (!EDBM_op_finish(em, &bmop, op, true)) return 0; EDBM_mesh_normals_update(opdata->em); - EDBM_update_generic(opdata->em, TRUE, TRUE); + EDBM_update_generic(opdata->em, true, true); return 1; } @@ -4946,7 +4954,7 @@ static void edbm_bevel_exit(bContext *C, wmOperator *op) } if (opdata->is_modal) { - EDBM_redo_state_free(&opdata->mesh_backup, NULL, FALSE); + EDBM_redo_state_free(&opdata->mesh_backup, NULL, false); } MEM_freeN(opdata); op->customdata = NULL; @@ -4956,8 +4964,8 @@ static int edbm_bevel_cancel(bContext *C, wmOperator *op) { BevelData *opdata = op->customdata; if (opdata->is_modal) { - EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, TRUE); - EDBM_update_generic(opdata->em, FALSE, TRUE); + EDBM_redo_state_free(&opdata->mesh_backup, opdata->em, true); + EDBM_update_generic(opdata->em, false, true); } edbm_bevel_exit(C, op); @@ -4970,7 +4978,7 @@ static int edbm_bevel_cancel(bContext *C, wmOperator *op) /* bevel! yay!!*/ static int edbm_bevel_exec(bContext *C, wmOperator *op) { - if (!edbm_bevel_init(C, op, FALSE)) { + if (!edbm_bevel_init(C, op, false)) { edbm_bevel_exit(C, op); return OPERATOR_CANCELLED; } @@ -4993,7 +5001,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) float mlen[2]; float center_3d[3]; - if (!edbm_bevel_init(C, op, TRUE)) { + if (!edbm_bevel_init(C, op, true)) { return OPERATOR_CANCELLED; } @@ -5025,7 +5033,7 @@ static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event) static float edbm_bevel_mval_factor(wmOperator *op, const wmEvent *event) { BevelData *opdata = op->customdata; - int use_dist = TRUE; + int use_dist = true; float mdiff[2]; float factor; @@ -5147,7 +5155,7 @@ void MESH_OT_bevel(wmOperatorType *ot) RNA_def_float(ot->srna, "offset", 0.0f, -FLT_MAX, FLT_MAX, "Offset", "", 0.0f, 1.0f); RNA_def_int(ot->srna, "segments", 1, 1, 50, "Segments", "Segments for curved edge", 1, 8); - RNA_def_boolean(ot->srna, "vertex_only", FALSE, "Vertex only", "Bevel only vertices"); + RNA_def_boolean(ot->srna, "vertex_only", false, "Vertex only", "Bevel only vertices"); } static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) @@ -5155,7 +5163,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) BMOperator bmop; Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - const int use_merge = RNA_boolean_get(op->ptr, "use_merge"); + const bool use_merge = RNA_boolean_get(op->ptr, "use_merge"); const float merge_factor = RNA_float_get(op->ptr, "merge_factor"); EDBM_op_init(em, &bmop, op, @@ -5165,17 +5173,17 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); /* when merge is used the edges are joined and remain selected */ - if (use_merge == FALSE) { + if (use_merge == false) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } else { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } } @@ -5196,7 +5204,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot) RNA_def_boolean(ot->srna, "inside", 0, "Inside", ""); - RNA_def_boolean(ot->srna, "use_merge", FALSE, "Merge", "Merge rather than creating faces"); + RNA_def_boolean(ot->srna, "use_merge", false, "Merge", "Merge rather than creating faces"); RNA_def_float(ot->srna, "merge_factor", 0.5f, 0.0f, 1.0f, "Merge Factor", "", 0.0f, 1.0f); } @@ -5256,8 +5264,8 @@ static int edbm_inset_init(bContext *C, wmOperator *op, int is_modal) opdata->old_thickness = 0.01; opdata->old_depth = 0.0; - opdata->modify_depth = FALSE; - opdata->shift = FALSE; + opdata->modify_depth = false; + opdata->shift = false; opdata->shift_amount = 0.0f; opdata->is_modal = is_modal; opdata->em = em; @@ -5279,7 +5287,7 @@ static void edbm_inset_exit(bContext *C, wmOperator *op) opdata = op->customdata; if (opdata->is_modal) - EDBM_redo_state_free(&opdata->backup, NULL, FALSE); + EDBM_redo_state_free(&opdata->backup, NULL, false); if (sa) { ED_area_headerprint(sa, NULL); @@ -5293,8 +5301,8 @@ static int edbm_inset_cancel(bContext *C, wmOperator *op) opdata = op->customdata; if (opdata->is_modal) { - EDBM_redo_state_free(&opdata->backup, opdata->em, TRUE); - EDBM_update_generic(opdata->em, FALSE, TRUE); + EDBM_redo_state_free(&opdata->backup, opdata->em, true); + EDBM_update_generic(opdata->em, false, true); } edbm_inset_exit(C, op); @@ -5310,19 +5318,19 @@ static int edbm_inset_calc(wmOperator *op) BMEditMesh *em; BMOperator bmop; - int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); - int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); - int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); - float thickness = RNA_float_get(op->ptr, "thickness"); - float depth = RNA_float_get(op->ptr, "depth"); - int use_outset = RNA_boolean_get(op->ptr, "use_outset"); - int use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */ + const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const bool use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); + const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); + const float thickness = RNA_float_get(op->ptr, "thickness"); + const float depth = RNA_float_get(op->ptr, "depth"); + const bool use_outset = RNA_boolean_get(op->ptr, "use_outset"); + const bool use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */ opdata = op->customdata; em = opdata->em; if (opdata->is_modal) { - EDBM_redo_state_restore(opdata->backup, em, FALSE); + EDBM_redo_state_restore(opdata->backup, em, false); } EDBM_op_init(em, &bmop, op, @@ -5336,27 +5344,27 @@ static int edbm_inset_calc(wmOperator *op) if (use_select_inset) { /* deselect original faces/verts */ EDBM_flag_disable_all(em, BM_ELEM_SELECT); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); } else { - BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, FALSE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE, BM_ELEM_SELECT, false); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, false); /* re-select faces so the verts and edges get selected too */ - BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, TRUE, BM_ELEM_SELECT); + BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, BM_ELEM_SELECT); } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return 0; } else { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return 1; } } static int edbm_inset_exec(bContext *C, wmOperator *op) { - edbm_inset_init(C, op, FALSE); + edbm_inset_init(C, op, false); if (!edbm_inset_calc(op)) { edbm_inset_exit(C, op); @@ -5374,7 +5382,7 @@ static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event) float mlen[2]; float center_3d[3]; - edbm_inset_init(C, op, TRUE); + edbm_inset_init(C, op, true); opdata = op->customdata; @@ -5476,11 +5484,11 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) opdata->shift_amount = RNA_float_get(op->ptr, "depth"); else opdata->shift_amount = RNA_float_get(op->ptr, "thickness"); - opdata->shift = TRUE; + opdata->shift = true; } else { opdata->shift_amount = 0.0f; - opdata->shift = FALSE; + opdata->shift = false; } break; @@ -5496,13 +5504,13 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) opdata->old_thickness = RNA_float_get(op->ptr, "thickness"); if (opdata->shift) opdata->shift_amount = opdata->old_thickness; - opdata->modify_depth = TRUE; + opdata->modify_depth = true; } else { opdata->old_depth = RNA_float_get(op->ptr, "depth"); if (opdata->shift) opdata->shift_amount = opdata->old_depth; - opdata->modify_depth = FALSE; + opdata->modify_depth = false; } opdata->initial_length = len_v2(mlen); @@ -5512,7 +5520,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) case OKEY: if (event->val == KM_PRESS) { - int use_outset = RNA_boolean_get(op->ptr, "use_outset"); + const bool use_outset = RNA_boolean_get(op->ptr, "use_outset"); RNA_boolean_set(op->ptr, "use_outset", !use_outset); if (edbm_inset_calc(op)) { edbm_inset_update_header(op, C); @@ -5525,7 +5533,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event) break; case BKEY: if (event->val == KM_PRESS) { - int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); RNA_boolean_set(op->ptr, "use_boundary", !use_boundary); if (edbm_inset_calc(op)) { edbm_inset_update_header(op, C); @@ -5562,9 +5570,9 @@ void MESH_OT_inset(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; /* properties */ - RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundaries"); - RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); - RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); + RNA_def_boolean(ot->srna, "use_boundary", true, "Boundary", "Inset face boundaries"); + RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness"); + RNA_def_boolean(ot->srna, "use_relative_offset", false, "Offset Relative", "Scale the offset by surrounding geometry"); prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f); /* use 1 rather then 10 for max else dragging the button moves too far */ @@ -5572,8 +5580,8 @@ void MESH_OT_inset(wmOperatorType *ot) prop = RNA_def_float(ot->srna, "depth", 0.0f, -FLT_MAX, FLT_MAX, "Depth", "", -10.0f, 10.0f); RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.01, 4); - RNA_def_boolean(ot->srna, "use_outset", FALSE, "Outset", "Outset rather than inset"); - RNA_def_boolean(ot->srna, "use_select_inset", TRUE, "Select Outer", "Select the new inset faces"); + RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset"); + RNA_def_boolean(ot->srna, "use_select_inset", true, "Select Outer", "Select the new inset faces"); } static int edbm_wireframe_exec(bContext *C, wmOperator *op) @@ -5581,12 +5589,12 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMOperator bmop; - const int use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); - const int use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); - const int use_replace = RNA_boolean_get(op->ptr, "use_replace"); - const int use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); - const int use_crease = RNA_boolean_get(op->ptr, "use_crease"); - const float thickness = RNA_float_get(op->ptr, "thickness"); + const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary"); + const bool use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset"); + const bool use_replace = RNA_boolean_get(op->ptr, "use_replace"); + const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset"); + const bool use_crease = RNA_boolean_get(op->ptr, "use_crease"); + const float thickness = RNA_float_get(op->ptr, "thickness"); EDBM_op_init(em, &bmop, op, "wireframe faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b use_crease=%b " @@ -5597,22 +5605,22 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op) BMO_op_exec(em->bm, &bmop); if (use_replace) { - BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_in, "faces", BM_FACE, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_in, "faces", BM_FACE, BM_ELEM_TAG, false); BMO_op_callf(em->bm, BMO_FLAG_DEFAULTS, "delete geom=%hvef context=%i", BM_ELEM_TAG, DEL_FACES); } - BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, TRUE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } else { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); return OPERATOR_FINISHED; } } @@ -5634,17 +5642,17 @@ void MESH_OT_wireframe(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundaries"); - RNA_def_boolean(ot->srna, "use_even_offset", TRUE, "Offset Even", "Scale the offset to give more even thickness"); - RNA_def_boolean(ot->srna, "use_relative_offset", FALSE, "Offset Relative", "Scale the offset by surrounding geometry"); - RNA_def_boolean(ot->srna, "use_crease", FALSE, "Crease", "Crease hub edges for improved subsurf"); + RNA_def_boolean(ot->srna, "use_boundary", true, "Boundary", "Inset face boundaries"); + RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness"); + RNA_def_boolean(ot->srna, "use_relative_offset", false, "Offset Relative", "Scale the offset by surrounding geometry"); + RNA_def_boolean(ot->srna, "use_crease", false, "Crease", "Crease hub edges for improved subsurf"); prop = RNA_def_float(ot->srna, "thickness", 0.01f, 0.0f, FLT_MAX, "Thickness", "", 0.0f, 10.0f); /* use 1 rather then 10 for max else dragging the button moves too far */ RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4); - RNA_def_boolean(ot->srna, "use_replace", TRUE, "Replace", "Remove original faces"); + RNA_def_boolean(ot->srna, "use_replace", true, "Replace", "Remove original faces"); } #ifdef WITH_BULLET @@ -5662,7 +5670,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) /* Hull fails if input is coplanar */ if (BMO_error_occurred(em->bm)) { - EDBM_op_finish(em, &bmop, op, TRUE); + EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; } @@ -5672,7 +5680,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", &bmop, "geom_unused.out", DEL_ONLYTAGGED)) { - EDBM_op_finish(em, &bmop, op, TRUE); + EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; } } @@ -5682,7 +5690,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) if (!EDBM_op_callf(em, op, "delete geom=%S context=%i", &bmop, "geom_holes.out", DEL_ONLYTAGGED)) { - EDBM_op_finish(em, &bmop, op, TRUE); + EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; } } @@ -5693,16 +5701,16 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op) &bmop, "geom.out", RNA_float_get(op->ptr, "limit"))) { - EDBM_op_finish(em, &bmop, op, TRUE); + EDBM_op_finish(em, &bmop, op, true); return OPERATOR_CANCELLED; } } - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } else { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); EDBM_selectmode_flush(em); return OPERATOR_FINISHED; } @@ -5723,19 +5731,19 @@ void MESH_OT_convex_hull(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "delete_unused", TRUE, + RNA_def_boolean(ot->srna, "delete_unused", true, "Delete Unused", "Delete selected elements that are not used by the hull"); - RNA_def_boolean(ot->srna, "use_existing_faces", TRUE, + RNA_def_boolean(ot->srna, "use_existing_faces", true, "Use Existing Faces", "Skip hull triangles that are covered by a pre-existing face"); - RNA_def_boolean(ot->srna, "make_holes", FALSE, + RNA_def_boolean(ot->srna, "make_holes", false, "Make Holes", "Delete selected faces that are used by the hull"); - RNA_def_boolean(ot->srna, "join_triangles", TRUE, + RNA_def_boolean(ot->srna, "join_triangles", true, "Join Triangles", "Merge adjacent triangles into quads"); @@ -5753,11 +5761,11 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op) BM_ELEM_SELECT, RNA_enum_get(op->ptr, "direction")); BMO_op_exec(em->bm, &bmop); - if (!EDBM_op_finish(em, &bmop, op, TRUE)) { + if (!EDBM_op_finish(em, &bmop, op, true)) { return OPERATOR_CANCELLED; } else { - EDBM_update_generic(em, TRUE, TRUE); + EDBM_update_generic(em, true, true); EDBM_selectmode_flush(em); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index fd90246f791..cb15fdef880 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -114,7 +114,7 @@ void EDBM_mesh_ensure_valid_dm_hack(Scene *scene, BMEditMesh *em) void EDBM_mesh_normals_update(BMEditMesh *em) { - BM_mesh_normals_update(em->bm, TRUE); + BM_mesh_normals_update(em->bm, true); } void EDBM_mesh_clear(BMEditMesh *em) @@ -169,7 +169,7 @@ void EDBM_stats_update(BMEditMesh *em) } } -int EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt, ...) +bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt, ...) { BMesh *bm = em->bm; va_list list; @@ -179,7 +179,7 @@ int EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *f if (!BMO_op_vinitf(bm, bmop, BMO_FLAG_DEFAULTS, fmt, list)) { BKE_reportf(op->reports, RPT_ERROR, "Parse error in %s", __func__); va_end(list); - return 0; + return false; } if (!em->emcopy) @@ -188,12 +188,12 @@ int EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *f va_end(list); - return 1; + return true; } /* returns 0 on error, 1 on success. executes and finishes a bmesh operator */ -int EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const int report) +bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool do_report) { const char *errmsg; @@ -202,7 +202,7 @@ int EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const int r if (BMO_error_get(em->bm, &errmsg, NULL)) { BMEditMesh *emcopy = em->emcopy; - if (report) { + if (do_report) { BKE_report(op->reports, RPT_ERROR, errmsg); } @@ -219,7 +219,7 @@ int EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const int r BMEdit_RecalcTessellation(em); } - return FALSE; + return false; } else { em->emcopyusers--; @@ -233,11 +233,11 @@ int EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const int r em->emcopy = NULL; } - return TRUE; + return true; } } -int EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) +bool EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) { BMesh *bm = em->bm; BMOperator bmop; @@ -248,7 +248,7 @@ int EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) if (!BMO_op_vinitf(bm, &bmop, BMO_FLAG_DEFAULTS, fmt, list)) { BKE_reportf(op->reports, RPT_ERROR, "Parse error in %s", __func__); va_end(list); - return 0; + return false; } if (!em->emcopy) @@ -258,10 +258,10 @@ int EDBM_op_callf(BMEditMesh *em, wmOperator *op, const char *fmt, ...) BMO_op_exec(bm, &bmop); va_end(list); - return EDBM_op_finish(em, &bmop, op, TRUE); + return EDBM_op_finish(em, &bmop, op, true); } -int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...) +bool EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_slot_out, const char *fmt, ...) { BMOpSlot *slot_select_out; BMesh *bm = em->bm; @@ -274,7 +274,7 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_ if (!BMO_op_vinitf(bm, &bmop, BMO_FLAG_DEFAULTS, fmt, list)) { BKE_reportf(op->reports, RPT_ERROR, "Parse error in %s", __func__); va_end(list); - return 0; + return false; } if (!em->emcopy) @@ -286,15 +286,15 @@ int EDBM_op_call_and_selectf(BMEditMesh *em, wmOperator *op, const char *select_ slot_select_out = BMO_slot_get(bmop.slots_out, select_slot_out); hflag = slot_select_out->slot_subtype.elem & BM_ALL_NOLOOP; - BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, FALSE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false); - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, hflag, BM_ELEM_SELECT, TRUE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, select_slot_out, hflag, BM_ELEM_SELECT, true); va_end(list); - return EDBM_op_finish(em, &bmop, op, TRUE); + return EDBM_op_finish(em, &bmop, op, true); } -int EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...) +bool EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...) { BMesh *bm = em->bm; BMOperator bmop; @@ -304,7 +304,7 @@ int EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...) if (!BMO_op_vinitf(bm, &bmop, BMO_FLAG_DEFAULTS, fmt, list)) { va_end(list); - return 0; + return false; } if (!em->emcopy) @@ -314,7 +314,7 @@ int EDBM_op_call_silentf(BMEditMesh *em, const char *fmt, ...) BMO_op_exec(bm, &bmop); va_end(list); - return EDBM_op_finish(em, &bmop, NULL, FALSE); + return EDBM_op_finish(em, &bmop, NULL, false); } void EDBM_selectmode_to_scene(bContext *C) @@ -352,9 +352,9 @@ void EDBM_mesh_make(ToolSettings *ts, Scene *UNUSED(scene), Object *ob) /* currently executing operators re-tessellates, so we can avoid doing here * but at some point it may need to be added back. */ #if 0 - me->edit_btmesh = BMEdit_Create(bm, TRUE); + me->edit_btmesh = BMEdit_Create(bm, true); #else - me->edit_btmesh = BMEdit_Create(bm, FALSE); + me->edit_btmesh = BMEdit_Create(bm, false); #endif me->edit_btmesh->selectmode = me->edit_btmesh->bm->selectmode = ts->selectmode; @@ -368,7 +368,7 @@ void EDBM_mesh_load(Object *ob) Mesh *me = ob->data; BMesh *bm = me->edit_btmesh->bm; - BM_mesh_bm_to_me(bm, me, FALSE); + BM_mesh_bm_to_me(bm, me, false); #ifdef USE_TESSFACE_DEFAULT BKE_mesh_tessface_calc(me); @@ -400,7 +400,7 @@ void EDBM_index_arrays_ensure(BMEditMesh *em, const char htype) BLI_assert((htype & ~BM_ALL_NOLOOP) == 0); /* in debug mode double check we didn't need to recalculate */ - BLI_assert(EDBM_index_arrays_check(em) == TRUE); + BLI_assert(EDBM_index_arrays_check(em) == true); if (htype_needed & BM_VERT) { em->vert_index = MEM_mallocN(sizeof(void **) * em->bm->totvert, "em->vert_index"); @@ -465,7 +465,7 @@ void EDBM_index_arrays_free(BMEditMesh *em) /* debug check only - no need to optimize */ #ifndef NDEBUG -int EDBM_index_arrays_check(BMEditMesh *em) +bool EDBM_index_arrays_check(BMEditMesh *em) { BMIter iter; BMElem *ele; @@ -474,7 +474,7 @@ int EDBM_index_arrays_check(BMEditMesh *em) if (em->vert_index) { BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_VERTS_OF_MESH, i) { if (ele != (BMElem *)em->vert_index[i]) { - return FALSE; + return false; } } } @@ -482,7 +482,7 @@ int EDBM_index_arrays_check(BMEditMesh *em) if (em->edge_index) { BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_EDGES_OF_MESH, i) { if (ele != (BMElem *)em->edge_index[i]) { - return FALSE; + return false; } } } @@ -490,12 +490,12 @@ int EDBM_index_arrays_check(BMEditMesh *em) if (em->face_index) { BM_ITER_MESH_INDEX (ele, &iter, em->bm, BM_FACES_OF_MESH, i) { if (ele != (BMElem *)em->face_index[i]) { - return FALSE; + return false; } } } - return TRUE; + return true; } #endif @@ -546,10 +546,10 @@ void EDBM_select_more(BMEditMesh *em) BMO_op_initf(em->bm, &bmop, BMO_FLAG_DEFAULTS, "region_extend geom=%hvef use_constrict=%b use_faces=%b", - BM_ELEM_SELECT, FALSE, use_faces); + BM_ELEM_SELECT, false, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ - BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); + BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? true : false); BMO_op_finish(em->bm, &bmop); EDBM_selectmode_flush(em); @@ -562,10 +562,10 @@ void EDBM_select_less(BMEditMesh *em) BMO_op_initf(em->bm, &bmop, BMO_FLAG_DEFAULTS, "region_extend geom=%hvef use_constrict=%b use_faces=%b", - BM_ELEM_SELECT, TRUE, use_faces); + BM_ELEM_SELECT, true, use_faces); BMO_op_exec(em->bm, &bmop); /* don't flush selection in edge/vertex mode */ - BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? TRUE : FALSE); + BMO_slot_buffer_hflag_disable(em->bm, bmop.slots_out, "geom.out", BM_ALL_NOLOOP, BM_ELEM_SELECT, use_faces ? true : false); BMO_op_finish(em->bm, &bmop); EDBM_selectmode_flush(em); @@ -573,12 +573,12 @@ void EDBM_select_less(BMEditMesh *em) void EDBM_flag_disable_all(BMEditMesh *em, const char hflag) { - BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, FALSE); + BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, false); } void EDBM_flag_enable_all(BMEditMesh *em, const char hflag) { - BM_mesh_elem_hflag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, TRUE); + BM_mesh_elem_hflag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag, true); } /**************-------------- Undo ------------*****************/ @@ -623,7 +623,7 @@ static void *editbtMesh_to_undoMesh(void *emv, void *obdata) /* BM_mesh_validate(em->bm); */ /* for troubleshooting */ - BM_mesh_bm_to_me(em->bm, &um->me, FALSE); + BM_mesh_bm_to_me(em->bm, &um->me, false); um->selectmode = em->selectmode; um->shapenr = em->bm->shapenr; @@ -644,12 +644,12 @@ static void undoMesh_to_editbtMesh(void *umv, void *em_v, void *UNUSED(obdata)) bm = BM_mesh_create(&bm_mesh_allocsize_default); - BM_mesh_bm_from_me(bm, &um->me, FALSE, ob->shapenr); + BM_mesh_bm_from_me(bm, &um->me, false, ob->shapenr); /* face normals need recalculation since we are not calling through an operator */ - BM_mesh_normals_update(bm, TRUE); + BM_mesh_normals_update(bm, true); - em_tmp = BMEdit_Create(bm, TRUE); + em_tmp = BMEdit_Create(bm, true); *em = *em_tmp; em->selectmode = um->selectmode; @@ -667,7 +667,7 @@ static void free_undo(void *me_v) MEM_freeN(me->key); } - BKE_mesh_free(me, FALSE); + BKE_mesh_free(me, false); MEM_freeN(me); } @@ -1133,7 +1133,7 @@ static BMVert *cache_mirr_intptr_as_bmvert(intptr_t *index_lookup, int index) * preference */ #define BM_SEARCH_MAXDIST_MIRR 0.00002f #define BM_CD_LAYER_ID "__mirror_index" -void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const short use_select) +void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const bool use_select) { Mesh *me = (Mesh *)em->ob->data; BMesh *bm = em->bm; @@ -1162,7 +1162,7 @@ void EDBM_verts_mirror_cache_begin(BMEditMesh *em, const short use_select) BM_mesh_elem_index_ensure(bm, BM_VERT); if (topo) { - ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, TRUE); + ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, true); } else { tree = BMBVH_NewBVH(em, 0, NULL, NULL); @@ -1283,7 +1283,7 @@ void EDBM_mesh_hide(BMEditMesh *em, int swap) BM_ITER_MESH (ele, &iter, em->bm, itermode) { if (BM_elem_flag_test(ele, BM_ELEM_SELECT) ^ swap) - BM_elem_hide_set(em->bm, ele, TRUE); + BM_elem_hide_set(em->bm, ele, true); } EDBM_selectmode_flush(em); @@ -1335,7 +1335,7 @@ void EDBM_mesh_reveal(BMEditMesh *em) BM_ITER_MESH (ele, &iter, em->bm, iter_types[i]) { if (BM_elem_flag_test(ele, BM_ELEM_TAG)) { - BM_elem_select_set(em->bm, ele, TRUE); + BM_elem_select_set(em->bm, ele, true); } } } @@ -1364,6 +1364,6 @@ void EDBM_update_generic(BMEditMesh *em, const bool do_tessface, const bool is_d } else { /* in debug mode double check we didn't need to recalculate */ - BLI_assert(EDBM_index_arrays_check(em) == TRUE); + BLI_assert(EDBM_index_arrays_check(em) == true); } } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 68e93fa22f7..20633aa0c87 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -123,9 +123,8 @@ static CustomData *mesh_customdata_get_type(Mesh *me, const char htype, int *r_t } #define GET_CD_DATA(me, data) (me->edit_btmesh ? &me->edit_btmesh->bm->data : &me->data) -static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *layer) +static void delete_customdata_layer(Mesh *me, CustomDataLayer *layer) { - Mesh *me = ob->data; CustomData *data; void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata = layer->data; int type = layer->type; @@ -162,9 +161,6 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la BKE_mesh_update_customdata_pointers(me, true); } - if (!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) - ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); - /* reconstruct active layer */ if (actlayerdata != layerdata) { /* find index */ @@ -344,12 +340,12 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) } /* note: keep in sync with ED_mesh_color_add */ -int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set) +int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) { BMEditMesh *em; int layernum_dst; - short is_init = FALSE; + bool is_init = false; if (me->edit_btmesh) { em = me->edit_btmesh; @@ -376,7 +372,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s const int layernum_src = CustomData_get_active_layer(&em->bm->ldata, CD_MLOOPUV); BM_data_layer_copy(em->bm, &em->bm->ldata, CD_MLOOPUV, layernum_src, layernum_dst); - is_init = TRUE; + is_init = true; } if (active_set || layernum_dst == 0) { CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum_dst); @@ -391,7 +387,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name); CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name); - is_init = TRUE; + is_init = true; } else { CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name); @@ -410,42 +406,73 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s } /* don't overwrite our copied coords */ - if (is_init == FALSE) { + if (is_init == false) { ED_mesh_uv_loop_reset_ex(me, layernum_dst); } DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + WM_main_add_notifier(NC_GEOM | ND_DATA, me); return layernum_dst; } -int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me) +bool ED_mesh_uv_texture_remove_index(Mesh *me, const int n) { CustomData *pdata = GET_CD_DATA(me, pdata), *ldata = GET_CD_DATA(me, ldata); CustomDataLayer *cdlp, *cdlu; int index; - index = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY); + index = CustomData_get_layer_index_n(pdata, CD_MTEXPOLY, n); cdlp = (index == -1) ? NULL : &pdata->layers[index]; - index = CustomData_get_active_layer_index(ldata, CD_MLOOPUV); + index = CustomData_get_layer_index_n(ldata, CD_MLOOPUV, n); cdlu = (index == -1) ? NULL : &ldata->layers[index]; - + if (!cdlp || !cdlu) - return 0; + return false; + + delete_customdata_layer(me, cdlp); + delete_customdata_layer(me, cdlu); - delete_customdata_layer(C, ob, cdlp); - delete_customdata_layer(C, ob, cdlu); - DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + WM_main_add_notifier(NC_GEOM | ND_DATA, me); - return 1; + return true; +} +bool ED_mesh_uv_texture_remove_active(Mesh *me) +{ + /* texpoly/uv are assumed to be in sync */ + CustomData *pdata = GET_CD_DATA(me, pdata); + const int n = CustomData_get_active_layer(pdata, CD_MTEXPOLY); + + /* double check active layers align! */ +#ifdef DEBUG + CustomData *ldata = GET_CD_DATA(me, ldata); + BLI_assert(CustomData_get_active_layer(ldata, CD_MLOOPUV) == n); +#endif + + if (n != -1) { + return ED_mesh_uv_texture_remove_index(me, n); + } + else { + return false; + } +} +bool ED_mesh_uv_texture_remove_named(Mesh *me, const char *name) +{ + /* texpoly/uv are assumed to be in sync */ + CustomData *pdata = GET_CD_DATA(me, pdata); + const int n = CustomData_get_named_layer(pdata, CD_MTEXPOLY, name); + if (n != -1) { + return ED_mesh_uv_texture_remove_index(me, n); + } + else { + return false; + } } /* note: keep in sync with ED_mesh_uv_texture_add */ -int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mesh *me, const char *name, int active_set) +int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set) { BMEditMesh *em; int layernum; @@ -493,47 +520,50 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes } DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + WM_main_add_notifier(NC_GEOM | ND_DATA, me); return layernum; } -int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me) +bool ED_mesh_color_remove_index(Mesh *me, const int n) { CustomData *ldata = GET_CD_DATA(me, ldata); CustomDataLayer *cdl; int index; - index = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL); + index = CustomData_get_layer_index_n(ldata, CD_MLOOPCOL, n); cdl = (index == -1) ? NULL : &ldata->layers[index]; if (!cdl) - return 0; + return false; - delete_customdata_layer(C, ob, cdl); + delete_customdata_layer(me, cdl); DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); + WM_main_add_notifier(NC_GEOM | ND_DATA, me); - return 1; + return true; } - -int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *name) +bool ED_mesh_color_remove_active(Mesh *me) { CustomData *ldata = GET_CD_DATA(me, ldata); - CustomDataLayer *cdl; - int index; - - index = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name); - cdl = (index == -1) ? NULL : &ldata->layers[index]; - - if (!cdl) - return 0; - - delete_customdata_layer(C, ob, cdl); - DAG_id_tag_update(&me->id, 0); - WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); - - return 1; + const int n = CustomData_get_active_layer(ldata, CD_MLOOPCOL); + if (n != -1) { + return ED_mesh_color_remove_index(me, n); + } + else { + return false; + } +} +bool ED_mesh_color_remove_named(Mesh *me, const char *name) +{ + CustomData *ldata = GET_CD_DATA(me, ldata); + const int n = CustomData_get_named_layer(ldata, CD_MLOOPCOL, name); + if (n != -1) { + return ED_mesh_color_remove_index(me, n); + } + else { + return false; + } } /*********************** UV texture operators ************************/ @@ -550,7 +580,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1) + if (ED_mesh_uv_texture_add(me, NULL, true) == -1) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -670,7 +700,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (!ED_mesh_uv_texture_remove(C, ob, me)) + if (!ED_mesh_uv_texture_remove_active(me)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -695,11 +725,10 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1) + if (ED_mesh_color_add(me, NULL, true) == -1) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -725,7 +754,7 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_context(C); Mesh *me = ob->data; - if (!ED_mesh_color_remove(C, ob, me)) + if (!ED_mesh_color_remove_active(me)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -757,7 +786,7 @@ static int mesh_customdata_clear_exec__internal(bContext *C, int tot; CustomData *data = mesh_customdata_get_type(me, htype, &tot); - BLI_assert(CustomData_layertype_is_singleton(type) == TRUE); + BLI_assert(CustomData_layertype_is_singleton(type) == true); if (CustomData_has_layer(data, type)) { if (me->edit_btmesh) { @@ -786,21 +815,21 @@ static int mesh_customdata_clear_mask_poll(bContext *C) /* special case - can't run this if we're in sculpt mode */ if (ob->mode & OB_MODE_SCULPT) { - return FALSE; + return false; } if (me->id.lib == NULL) { CustomData *data = GET_CD_DATA(me, vdata); if (CustomData_has_layer(data, CD_PAINT_MASK)) { - return TRUE; + return true; } data = GET_CD_DATA(me, ldata); if (CustomData_has_layer(data, CD_GRID_PAINT_MASK)) { - return TRUE; + return true; } } } - return FALSE; + return false; } static int mesh_customdata_clear_mask_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -843,11 +872,11 @@ static int mesh_customdata_clear_skin_poll(bContext *C) if (me->id.lib == NULL) { CustomData *data = GET_CD_DATA(me, vdata); if (CustomData_has_layer(data, CD_MVERT_SKIN)) { - return TRUE; + return true; } } } - return FALSE; + return false; } static int mesh_customdata_clear_skin_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -875,20 +904,20 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) { int *polyindex = NULL; float (*face_nors)[3]; - int tessface_input = FALSE; + bool tessface_input = false; if (mesh->totface > 0 && mesh->totpoly == 0) { BKE_mesh_convert_mfaces_to_mpolys(mesh); /* would only be converting back again, don't bother */ - tessface_input = TRUE; + tessface_input = true; } if (calc_edges || ((mesh->totpoly || mesh->totface) && mesh->totedge == 0)) BKE_mesh_calc_edges(mesh, calc_edges, true); if (calc_tessface) { - if (tessface_input == FALSE) { + if (tessface_input == false) { BKE_mesh_tessface_calc(mesh); } } @@ -911,7 +940,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) mesh->totloop, mesh->totpoly, NULL /* polyNors_r */, mesh->mface, mesh->totface, - polyindex, face_nors, FALSE); + polyindex, face_nors, false); #else BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, @@ -1239,7 +1268,7 @@ void ED_mesh_calc_normals(Mesh *mesh) #ifdef USE_BMESH_MPOLY_NORMALS BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL, NULL, 0, NULL, NULL, FALSE); + NULL, NULL, 0, NULL, NULL, false); #else BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 5dab022dd2f..89a320ca928 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -59,24 +59,24 @@ struct LinkNode; */ /*calls a bmesh op, reporting errors to the user, etc*/ -int EDBM_op_callf(struct BMEditMesh *em, struct wmOperator *op, const char *fmt, ...); +bool EDBM_op_callf(struct BMEditMesh *em, struct wmOperator *op, const char *fmt, ...); -int EDBM_op_call_and_selectf(struct BMEditMesh *em, struct wmOperator *op, - const char *selectslot, const char *fmt, ...); +bool EDBM_op_call_and_selectf(struct BMEditMesh *em, struct wmOperator *op, + const char *selectslot, const char *fmt, ...); /* same as above, but doesn't report errors.*/ -int EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...); +bool EDBM_op_call_silentf(struct BMEditMesh *em, const char *fmt, ...); /* these next two functions are the split version of EDBM_op_callf, so you can * do stuff with a bmesh operator, after initializing it but before executing * it. * * execute the operator with BM_Exec_Op */ -int EDBM_op_init(struct BMEditMesh *em, struct BMOperator *bmop, - struct wmOperator *op, const char *fmt, ...); +bool EDBM_op_init(struct BMEditMesh *em, struct BMOperator *bmop, + struct wmOperator *op, const char *fmt, ...); /*cleans up after a bmesh operator*/ -int EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop, - struct wmOperator *op, const int report); +bool EDBM_op_finish(struct BMEditMesh *em, struct BMOperator *bmop, + struct wmOperator *op, const bool do_report); void EDBM_stats_update(struct BMEditMesh *em); diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 8d5bfe624fd..2111b6f3409 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -320,7 +320,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, if (createob) { /* create new object */ - obedit = ED_object_add_type(C, OB_MESH, co, rot, FALSE, lay); + obedit = ED_object_add_type(C, OB_MESH, co, rot, false, lay); } else { obedit = base->object; @@ -330,7 +330,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, copy_v3_v3(obedit->rot, rot); } - ED_object_enter_editmode(C, EM_DO_UNDO | EM_IGNORE_LAYER); + ED_object_editmode_enter(C, EM_DO_UNDO | EM_IGNORE_LAYER); em = BMEdit_FromObject(obedit); if (!createob) { @@ -401,7 +401,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, EDBM_vert_at_index(em, face[0]), EDBM_vert_at_index(em, face[2]), EDBM_vert_at_index(em, face[1]), NULL, - NULL, FALSE); + NULL, false); /* set navigation polygon idx to the custom layer */ polygonIdx = (int *)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST); @@ -416,7 +416,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); if (createob) { @@ -500,7 +500,7 @@ static int navmesh_face_copy_exec(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); /* do work here */ - BMFace *efa_act = BM_active_face_get(em->bm, FALSE, FALSE); + BMFace *efa_act = BM_active_face_get(em->bm, false, false); if (efa_act) { if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { @@ -633,16 +633,16 @@ static int navmesh_obmode_data_poll(bContext *C) Mesh *me = ob->data; return CustomData_has_layer(&me->pdata, CD_RECAST); } - return FALSE; + return false; } static int navmesh_obmode_poll(bContext *C) { Object *ob = ED_object_active_context(C); if (ob && (ob->mode == OB_MODE_OBJECT) && (ob->type == OB_MESH)) { - return TRUE; + return true; } - return FALSE; + return false; } static int navmesh_reset_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index cf3877a8d93..42a139d7961 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -212,52 +212,52 @@ void ED_operatormacros_mesh(void) WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip"); - RNA_boolean_set(otmacro->ptr, "use_fill", FALSE); + RNA_boolean_set(otmacro->ptr, "use_fill", false); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); /* annoying we can't pass 'use_fill' through the macro */ ot = WM_operatortype_append_macro("MESH_OT_rip_move_fill", "Rip Fill", "Rip-fill polygons and move the result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_rip"); - RNA_boolean_set(otmacro->ptr, "use_fill", TRUE); + RNA_boolean_set(otmacro->ptr, "use_fill", true); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); - RNA_boolean_set(otmacro->ptr, "mirror", FALSE); + RNA_boolean_set(otmacro->ptr, "mirror", false); } /* note mesh keymap also for other space? */ @@ -274,29 +274,29 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "vertex_only", FALSE); + RNA_boolean_set(kmi->ptr, "vertex_only", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_bevel", BKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "vertex_only", TRUE); + RNA_boolean_set(kmi->ptr, "vertex_only", true); /* selecting */ /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "deselect", FALSE); - RNA_boolean_set(kmi->ptr, "toggle", FALSE); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "deselect", FALSE); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", true); kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "deselect", FALSE); - RNA_boolean_set(kmi->ptr, "toggle", FALSE); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "deselect", FALSE); - RNA_boolean_set(kmi->ptr, "toggle", TRUE); + RNA_boolean_set(kmi->ptr, "extend", false); + RNA_boolean_set(kmi->ptr, "deselect", false); + RNA_boolean_set(kmi->ptr, "toggle", true); WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); @@ -311,9 +311,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "deselect", FALSE); + RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "deselect", TRUE); + RNA_boolean_set(kmi->ptr, "deselect", true); WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); @@ -324,16 +324,16 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) /* hide */ kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "unselected", FALSE); + RNA_boolean_set(kmi->ptr, "unselected", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "unselected", TRUE); + RNA_boolean_set(kmi->ptr, "unselected", true); WM_keymap_add_item(keymap, "MESH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); /* tools */ kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "inside", FALSE); + RNA_boolean_set(kmi->ptr, "inside", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "inside", TRUE); + RNA_boolean_set(kmi->ptr, "inside", true); WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0); @@ -346,9 +346,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "use_beauty", TRUE); + RNA_boolean_set(kmi->ptr, "use_beauty", true); kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "use_beauty", FALSE); + RNA_boolean_set(kmi->ptr, "use_beauty", false); WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0); @@ -374,20 +374,20 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TRANSFORM_OT_vert_slide", VKEY, KM_PRESS, KM_SHIFT, 0); /* use KM_CLICK because same key is used for tweaks */ kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "rotate_source", TRUE); + RNA_boolean_set(kmi->ptr, "rotate_source", true); kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT | KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "rotate_source", FALSE); + RNA_boolean_set(kmi->ptr, "rotate_source", false); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_delete", DELKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "use_occlude_geometry", TRUE); - RNA_boolean_set(kmi->ptr, "only_selected", FALSE); + RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true); + RNA_boolean_set(kmi->ptr, "only_selected", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "use_occlude_geometry", FALSE); - RNA_boolean_set(kmi->ptr, "only_selected", TRUE); + RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false); + RNA_boolean_set(kmi->ptr, "only_selected", true); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); @@ -407,7 +407,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) } ED_keymap_proportional_cycle(keyconf, keymap); - ED_keymap_proportional_editmode(keyconf, keymap, TRUE); + ED_keymap_proportional_editmode(keyconf, keymap, true); knifetool_modal_keymap(keyconf); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index e8f55edddab..562bc4a8e02 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -430,8 +430,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) multiresModifier_prepare_join(scene, base->object, ob); - if ((mmd = get_multires_modifier(scene, base->object, TRUE))) { - ED_object_iter_other(bmain, base->object, TRUE, + if ((mmd = get_multires_modifier(scene, base->object, true))) { + ED_object_iter_other(bmain, base->object, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); } @@ -566,8 +566,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) DAG_relations_tag_update(bmain); // removed objects, need to rebuild dag #if 0 - ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); + ED_object_editmode_enter(C, EM_WAITCURSOR); + ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); #else /* toggle editmode using lower level functions so this can be called from python */ EDBM_mesh_make(scene->toolsettings, scene, ob); @@ -724,9 +724,9 @@ static void mesh_octree_add_nodes(MocNode **basetable, const float co[3], const float fx, fy, fz; int vx, vy, vz; - if ((finite(co[0]) == FALSE) || - (finite(co[1]) == FALSE) || - (finite(co[2]) == FALSE)) + if ((finite(co[0]) == false) || + (finite(co[1]) == false) || + (finite(co[2]) == false)) { return; } @@ -910,7 +910,7 @@ int mesh_mirrtopo_table(Object *ob, char mode) } } else if (mode == 's') { /* start table */ - ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, FALSE); + ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, false); } else if (mode == 'e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); @@ -957,9 +957,9 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c intptr_t poinval; /* ignore nan verts */ - if ((finite(co[0]) == FALSE) || - (finite(co[1]) == FALSE) || - (finite(co[2]) == FALSE)) + if ((finite(co[0]) == false) || + (finite(co[1]) == false) || + (finite(co[2]) == false)) { return NULL; } @@ -1174,9 +1174,9 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em) * Face selection in object mode, * currently only weight-paint and vertex-paint use this. * - * \return boolean TRUE == Found + * \return boolean true == Found */ -int ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size) +bool ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size) { ViewContext vc; Mesh *me = ob->data; @@ -1184,7 +1184,7 @@ int ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int * BLI_assert(me && GS(me->id.name) == ID_ME); if (!me || me->totpoly == 0) - return 0; + return false; view3d_set_viewcontext(C, &vc); @@ -1201,17 +1201,17 @@ int ED_mesh_pick_face(bContext *C, Object *ob, const int mval[2], unsigned int * } if ((*index) <= 0 || (*index) > (unsigned int)me->totpoly) - return 0; + return false; (*index)--; - return 1; + return true; } /** * Use when the back buffer stores face index values. but we want a vert. * This gets the face then finds the closest vertex to mval. */ -int ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size) +bool ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size) { unsigned int poly_index; Mesh *me = ob->data; @@ -1257,18 +1257,18 @@ int ED_mesh_pick_face_vert(bContext *C, Object *ob, const int mval[2], unsigned if (v_idx_best != -1) { *index = v_idx_best; - return 1; + return true; } } - return 0; + return false; } /** * Vertex selection in object mode, * currently only weight paint uses this. * - * \return boolean TRUE == Found + * \return boolean true == Found */ typedef struct VertPickData { const MVert *mvert; @@ -1296,7 +1296,7 @@ static void ed_mesh_pick_vert__mapFunc(void *userData, int index, const float co } } } -int ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size, int use_zbuf) +bool ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int *index, int size, bool use_zbuf) { ViewContext vc; Mesh *me = ob->data; @@ -1304,7 +1304,7 @@ int ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int * BLI_assert(me && GS(me->id.name) == ID_ME); if (!me || me->totvert == 0) - return 0; + return false; view3d_set_viewcontext(C, &vc); @@ -1322,7 +1322,7 @@ int ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int * } if ((*index) <= 0 || (*index) > (unsigned int)me->totvert) - return 0; + return false; (*index)--; } @@ -1341,7 +1341,7 @@ int ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int * ED_view3d_init_mats_rv3d(ob, rv3d); if (dm == NULL) { - return 0; + return false; } /* setup data */ @@ -1356,11 +1356,11 @@ int ED_mesh_pick_vert(bContext *C, Object *ob, const int mval[2], unsigned int * dm->release(dm); if (data.v_idx_best == -1) { - return 0; + return false; } *index = data.v_idx_best; } - return 1; + return true; } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 6781624aec6..3fe8b93ada3 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -411,7 +411,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ -int mouse_mball(bContext *C, const int mval[2], int extend, int deselect, int toggle) +bool mouse_mball(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { static MetaElem *startelem = NULL; Object *obedit = CTX_data_edit_object(C); @@ -487,11 +487,11 @@ int mouse_mball(bContext *C, const int mval[2], int extend, int deselect, int to WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); - return 1; + return true; } } - return 0; + return false; } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 312cceac77d..63582feadb7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -372,7 +372,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa /* for as long scene has editmode... */ if (CTX_data_edit_object(C)) - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ ob = BKE_object_add(scene, type); @@ -390,7 +390,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa } if (enter_editmode) - ED_object_enter_editmode(C, EM_IGNORE_LAYER); + ED_object_editmode_enter(C, EM_IGNORE_LAYER); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); @@ -452,20 +452,20 @@ static int effector_add_exec(bContext *C, wmOperator *op) if (!ob) return OPERATOR_CANCELLED; - rename_id(&ob->id, "CurveGuide"); + rename_id(&ob->id, DATA_("CurveGuide")); ((Curve *)ob->data)->flag |= CU_PATH | CU_3D; - ED_object_enter_editmode(C, 0); + ED_object_editmode_enter(C, 0); ED_object_new_primitive_matrix(C, ob, loc, rot, mat, FALSE); BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, ob, mat, CU_NURBS | CU_PRIM_PATH, 1)); if (!enter_editmode) - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); } else { ob = ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); if (!ob) return OPERATOR_CANCELLED; - rename_id(&ob->id, "Field"); + rename_id(&ob->id, DATA_("Field")); if (ELEM(type, PFIELD_WIND, PFIELD_VORTEX)) ob->empty_drawtype = OB_SINGLE_ARROW; } @@ -578,7 +578,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && !enter_editmode) { - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); @@ -661,7 +661,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) if ((obedit == NULL) || (obedit->type != OB_ARMATURE)) { obedit = ED_object_add_type(C, OB_ARMATURE, loc, rot, TRUE, layer); - ED_object_enter_editmode(C, 0); + ED_object_editmode_enter(C, 0); newob = 1; } else { @@ -678,7 +678,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) /* userdef */ if (newob && !enter_editmode) - ED_object_exit_editmode(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); @@ -822,13 +822,13 @@ void OBJECT_OT_drop_named_image(wmOperatorType *ot) static const char *get_lamp_defname(int type) { switch (type) { - case LA_LOCAL: return "Point"; - case LA_SUN: return "Sun"; - case LA_SPOT: return "Spot"; - case LA_HEMI: return "Hemi"; - case LA_AREA: return "Area"; + case LA_LOCAL: return DATA_("Point"); + case LA_SUN: return DATA_("Sun"); + case LA_SPOT: return DATA_("Spot"); + case LA_HEMI: return DATA_("Hemi"); + case LA_AREA: return DATA_("Area"); default: - return "Lamp"; + return DATA_("Lamp"); } } @@ -980,7 +980,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) BKE_nlatrack_add_strip(nlt, strip); /* auto-name the strip, and give the track an interesting name */ - strcpy(nlt->name, "SoundTrack"); + strcpy(nlt->name, DATA_("SoundTrack")); BKE_nlastrip_validate_name(adt, strip); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); @@ -1707,7 +1707,7 @@ static int convert_exec(bContext *C, wmOperator *op) DAG_relations_tag_update(bmain); } -// XXX ED_object_enter_editmode(C, 0); +// XXX ED_object_editmode_enter(C, 0); // XXX exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR); /* freedata, but no undo */ if (basact) { diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index dc54207b4e6..00af771e45d 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -323,7 +323,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - MultiresBakeRender bkr = {0}; + MultiresBakeRender bkr = {NULL}; ob = base->object; @@ -419,7 +419,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa } for (data = bkj->data.first; data; data = data->next) { - MultiresBakeRender bkr = {0}; + MultiresBakeRender bkr = {NULL}; /* copy data stored in job descriptor */ bkr.bake_filter = bkj->bake_filter; @@ -572,7 +572,7 @@ static void init_bake_internal(BakeRender *bkr, bContext *C) bScreen *sc = CTX_wm_screen(C); /* get editmode results */ - ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + ED_object_editmode_load(CTX_data_edit_object(C)); bkr->sa = sc ? BKE_screen_find_big_area(sc, SPACE_IMAGE, 10) : NULL; /* can be NULL */ bkr->main = CTX_data_main(C); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index ca57ab76c57..12400209866 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -312,29 +312,26 @@ void OBJECT_OT_hide_render_set(wmOperatorType *ot) /* ******************* toggle editmode operator ***************** */ -void ED_object_exit_editmode(bContext *C, int flag) +/** + * Load EditMode data back into the object, + * optionally freeing the editmode data. + */ +static bool ED_object_editmode_load_ex(Object *obedit, const bool freedata) { - /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ + if (obedit == NULL) { + return false; + } - Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); - int freedata = flag & EM_FREEDATA; - - if (obedit == NULL) return; - - if (flag & EM_WAITCURSOR) waitcursor(1); if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - -// if (EM_texFaceCheck()) - + if (me->edit_btmesh->bm->totvert > MESH_MAX_VERTS) { error("Too many vertices"); - return; + return false; } - + EDBM_mesh_load(obedit); - + if (freedata) { EDBM_mesh_free(me->edit_btmesh); MEM_freeN(me->edit_btmesh); @@ -367,6 +364,29 @@ void ED_object_exit_editmode(bContext *C, int flag) if (freedata) free_editMball(obedit); } + return true; +} + +bool ED_object_editmode_load(Object *obedit) +{ + return ED_object_editmode_load_ex(obedit, false); +} + +void ED_object_editmode_exit(bContext *C, int flag) +{ + /* Note! only in exceptional cases should 'EM_DO_UNDO' NOT be in the flag */ + /* Note! if 'EM_FREEDATA' isn't in the flag, use ED_object_editmode_load directly */ + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + const bool freedata = (flag & EM_FREEDATA) != 0; + + if (flag & EM_WAITCURSOR) waitcursor(1); + + if (ED_object_editmode_load_ex(obedit, freedata) == false) { + if (flag & EM_WAITCURSOR) waitcursor(0); + return; + } + /* freedata only 0 now on file saves and render */ if (freedata) { ListBase pidlist; @@ -390,17 +410,17 @@ void ED_object_exit_editmode(bContext *C, int flag) if (flag & EM_DO_UNDO) ED_undo_push(C, "Editmode"); - - if (flag & EM_WAITCURSOR) waitcursor(0); - + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, scene); obedit->mode &= ~OB_MODE_EDIT; } + + if (flag & EM_WAITCURSOR) waitcursor(0); } -void ED_object_enter_editmode(bContext *C, int flag) +void ED_object_editmode_enter(bContext *C, int flag) { Scene *scene = CTX_data_scene(C); Base *base = NULL; @@ -537,9 +557,9 @@ static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ToolSettings *toolsettings = CTX_data_tool_settings(C); if (!CTX_data_edit_object(C)) - ED_object_enter_editmode(C, EM_WAITCURSOR); + ED_object_editmode_enter(C, EM_WAITCURSOR); else - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ ED_space_image_uv_sculpt_update(CTX_wm_manager(C), toolsettings); @@ -589,7 +609,7 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) if (base->object->type == OB_ARMATURE) { if (base->object == CTX_data_edit_object(C)) { - ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); ED_armature_enter_posemode(C, base); } else if (base->object->mode & OB_MODE_POSE) diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 163a869613b..e138d2fe24a 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -40,11 +40,11 @@ struct Mesh; struct HookModifierData; /* add hook menu */ -enum { +enum eObject_Hook_Add_Mode { OBJECT_ADDHOOK_NEWOB = 1, OBJECT_ADDHOOK_SELOB, OBJECT_ADDHOOK_SELOB_BONE -} eObject_Hook_Add_Mode; +}; /* internal exports only */ diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 053f1ffabd0..9d3b2b7272d 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -638,7 +638,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) return data.bp; } -int mouse_lattice(bContext *C, const int mval[2], int extend, int deselect, int toggle) +bool mouse_lattice(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { ViewContext vc; BPoint *bp = NULL; @@ -663,10 +663,10 @@ int mouse_lattice(bContext *C, const int mval[2], int extend, int deselect, int WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit->data); - return 1; + return true; } - return 0; + return false; } /******************************** Undo *************************/ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index c9070dc6205..2239148ca1c 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -198,7 +198,7 @@ static int object_has_modifier(const Object *ob, const ModifierData *exclude, * If the callback ever returns TRUE, iteration will stop and the * function value will be TRUE. Otherwise the function returns FALSE. */ -int ED_object_iter_other(Main *bmain, Object *orig_ob, int include_orig, +int ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig, int (*callback)(Object *ob, void *callback_data), void *callback_data) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 6039ff6d34b..34a6d359f6b 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -843,20 +843,20 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent return OPERATOR_CANCELLED; } -static int parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +static bool parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); int type = RNA_enum_get(ptr, "type"); /* Only show XMirror for PAR_ARMATURE_ENVELOPE and PAR_ARMATURE_AUTO! */ - if (strcmp(prop_id, "xmirror") == 0) { + if (STREQ(prop_id, "xmirror")) { if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO)) - return TRUE; + return true; else - return FALSE; + return false; } - return TRUE; + return true; } static void parent_set_ui(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index baa0199baf7..b7303b2af51 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -439,7 +439,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else if (nr == OBJECT_SELECT_LINKED_OBDATA) { - if (ob->data == 0) + if (ob->data == NULL) return OPERATOR_CANCELLED; changed = object_select_all_by_obdata(C, ob->data); @@ -894,13 +894,13 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) static int object_select_by_layer_exec(bContext *C, wmOperator *op) { unsigned int layernum; - short extend, match; + bool extend, match; extend = RNA_boolean_get(op->ptr, "extend"); layernum = RNA_int_get(op->ptr, "layers"); match = RNA_enum_get(op->ptr, "match"); - if (extend == 0) { + if (extend == false) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); @@ -910,12 +910,12 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - int ok = 0; + bool ok = false; - if (match == 1) /* exact */ + if (match == true) /* exact */ ok = (base->lay == (1 << (layernum - 1))); else /* shared layers */ - ok = (base->lay & (1 << (layernum - 1))); + ok = (base->lay & (1 << (layernum - 1))) != 0; if (ok) ED_base_object_select(base, BA_SELECT); @@ -1072,7 +1072,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) static int object_select_mirror_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - short extend; + bool extend; extend = RNA_boolean_get(op->ptr, "extend"); @@ -1093,7 +1093,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) } } - if (extend == 0) ED_base_object_select(primbase, BA_DESELECT); + if (extend == false) ED_base_object_select(primbase, BA_DESELECT); } CTX_DATA_END; @@ -1128,11 +1128,11 @@ void OBJECT_OT_select_mirror(wmOperatorType *ot) static int object_select_random_exec(bContext *C, wmOperator *op) { float percent; - short extend; + bool extend; extend = RNA_boolean_get(op->ptr, "extend"); - if (extend == 0) { + if (extend == false) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { ED_base_object_select(base, BA_DESELECT); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 48316cfccb7..aa4652af0ba 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -202,7 +202,6 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) static int output_toggle_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - Scene *scene = CTX_data_scene(C); DynamicPaintSurface *surface; DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); int output = RNA_enum_get(op->ptr, "output"); /* currently only 1/0 */ @@ -223,9 +222,9 @@ static int output_toggle_exec(bContext *C, wmOperator *op) /* Vertex Color Layer */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { if (!exists) - ED_mesh_color_add(C, scene, ob, ob->data, name, 1); + ED_mesh_color_add(ob->data, name, true); else - ED_mesh_color_remove_named(C, ob, ob->data, name); + ED_mesh_color_remove_named(ob->data, name); } /* Vertex Weight Layer */ else if (surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 329f1f67c4a..e972b7d6620 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1403,7 +1403,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /************************ pick select operator ************************/ -int PE_mouse_particles(bContext *C, const int mval[2], int extend, int deselect, int toggle) +int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle) { PEData data; Scene *scene= CTX_data_scene(C); @@ -1584,7 +1584,7 @@ void PE_deselect_all_visible(PTCacheEdit *edit) } } -int PE_border_select(bContext *C, rcti *rect, int select, int extend) +int PE_border_select(bContext *C, rcti *rect, bool select, bool extend) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -1636,7 +1636,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) /************************ lasso select operator ************************/ -int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short extend, short select) +int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, bool extend, bool select) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index b138bc63a68..1268d577f44 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -542,7 +542,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even BKE_sequencer_cache_cleanup(); /* get editmode results */ - ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ + ED_object_editmode_load(CTX_data_edit_object(C)); // store spare // get view3d layer, local layer, make this nice api call to render diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index ebd2cc941d0..7c52b7d0d39 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -27,14 +27,14 @@ * \ingroup edrend */ - #include <stdlib.h> - -#include "WM_api.h" +#include "BLI_utildefines.h" #include "ED_render.h" +#include "WM_api.h" + #include "render_intern.h" // own include #if (defined(WITH_QUICKTIME) && !defined(USE_QTKIT)) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 948e272eca0..b851dc3be94 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -304,7 +304,17 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.alphamode = R_ADDSKY; sce->r.cfra = scene->r.cfra; - BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); + + if (id_type == ID_TE && sp->pr_method == PR_ICON_RENDER) { + /* force blender internal for texture icons render, + * seems commonly used render engines does not support + * such kind of rendering + */ + BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); + } + else { + BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); + } if (id_type == ID_MA) { Material *mat = NULL, *origmat = (Material *)id; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6045bdfebfe..bf458290b09 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1458,7 +1458,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) return; if (ed_screen_used(CTX_wm_manager(C), screen)) - ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_DO_UNDO); for (sc = CTX_data_main(C)->screen.first; sc; sc = sc->id.next) { if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 8b69e6e831d..d5d5add215c 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -254,7 +254,7 @@ int ED_operator_node_active(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - if (snode && ntreeIsValid(snode->edittree)) + if (snode && snode->edittree) return 1; return 0; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 0fbb4c25e78..20edd3d32e7 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -232,11 +232,11 @@ static int screenshot_cancel(bContext *UNUSED(C), wmOperator *op) return OPERATOR_CANCELLED; } -static int screenshot_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) +static bool screenshot_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - return !(strcmp(prop_id, "filepath") == 0); + return !(STREQ(prop_id, "filepath")); } static void screenshot_draw(bContext *UNUSED(C), wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 92a55151b66..4f935ebdd8c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -398,7 +398,6 @@ typedef struct PaintOperation { double starttime; ViewContext vc; - wmTimer *timer; } PaintOperation; void paint_brush_init_tex(Brush *brush) @@ -531,9 +530,6 @@ static void paint_stroke_done(const bContext *C, struct PaintStroke *stroke) paint_redraw(C, pop, 1); - if (pop->timer) - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer); - settings->imapaint.flag &= ~IMAGEPAINT_DRAWING; if (pop->mode == PAINT_MODE_3D_PROJECT) { diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 921ef6c2879..90a2c8037c4 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -79,9 +79,9 @@ BLI_INLINE unsigned char f_to_char(const float val) } (void)0 #define IMAPAINT_CHAR_RGB_TO_FLOAT(f, c) { \ - (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ - (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ - (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ + (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ + (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ + (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ } (void)0 #define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a90e9150345..7a0f7b817b3 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -116,10 +116,10 @@ BLI_INLINE unsigned char f_to_char(const float val) } (void)0 #define IMAPAINT_CHAR_RGBA_TO_FLOAT(f, c) { \ - (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ - (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ - (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ - (f)[3] = IMAPAINT_CHAR_TO_FLOAT((c)[3]); \ + (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ + (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ + (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ + (f)[3] = IMAPAINT_CHAR_TO_FLOAT((c)[3]); \ } (void)0 #define IMAPAINT_FLOAT_RGB_TO_CHAR(c, f) { \ diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9ba50e95d81..197231124fc 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -293,7 +293,7 @@ static void do_shared_vertexcol(Mesh *me, int do_tessface) /* if no mloopcol: do not do */ /* if mtexpoly: only the involved faces, otherwise all */ - if (me->mloopcol == 0 || me->totvert == 0 || me->totpoly == 0) return; + if (me->mloopcol == NULL || me->totvert == 0 || me->totpoly == 0) return; scol = MEM_callocN(sizeof(float) * me->totvert * 5, "scol"); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 3aee9a5e31e..0cb0a3d6e5c 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -449,7 +449,7 @@ static int sound_mixdown_invoke(bContext *C, wmOperator *op, const wmEvent *even #ifdef WITH_AUDASPACE -static int sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) +static bool sound_mixdown_draw_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); return !(strcmp(prop_id, "filepath") == 0 || diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 10085d8a149..8f39a38157a 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -60,19 +60,19 @@ void ACTION_OT_select_leftright(struct wmOperatorType *ot); void ACTION_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ -enum { +enum eActKeys_LeftRightSelect_Mode { ACTKEYS_LRSEL_TEST = 0, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT -} eActKeys_LeftRightSelect_Mode; +}; /* defines for column-select mode */ -enum { +enum eActKeys_ColumnSelect_Mode { ACTKEYS_COLUMNSEL_KEYS = 0, ACTKEYS_COLUMNSEL_CFRA, ACTKEYS_COLUMNSEL_MARKERS_COLUMN, ACTKEYS_COLUMNSEL_MARKERS_BETWEEN, -} eActKeys_ColumnSelect_Mode; +}; /* ***************************************** */ /* action_edit.c */ @@ -107,22 +107,22 @@ void ACTION_OT_markers_make_local(struct wmOperatorType *ot); /* defines for snap keyframes * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h) */ -enum { +enum eActKeys_Snap_Mode { ACTKEYS_SNAP_CFRA = 1, ACTKEYS_SNAP_NEAREST_FRAME, ACTKEYS_SNAP_NEAREST_SECOND, ACTKEYS_SNAP_NEAREST_MARKER, -} eActKeys_Snap_Mode; +}; /* defines for mirror keyframes * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h) */ -enum { +enum eActKeys_Mirror_Mode { ACTKEYS_MIRROR_CFRA = 1, ACTKEYS_MIRROR_YAXIS, ACTKEYS_MIRROR_XAXIS, ACTKEYS_MIRROR_MARKER, -} eActKeys_Mirror_Mode; +}; /* ***************************************** */ /* action_ops.c */ diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index bb1310d486a..b108f9fa4b5 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -113,15 +113,15 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, { bNode *node; - if (ntreeIsValid(ntree)) { + if (ntree) { for (node = ntree->nodes.first; node; node = node->next) { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); /* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */ - + buttons_texture_user_node_add(users, id, ntree, node, category, RNA_struct_ui_icon(ptr.type), node->name); } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 58626c79363..2d3dc9127c3 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -269,8 +269,18 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, if (display_buffer) { int need_fallback = 1; + /* checkerboard for case alpha */ + if (ibuf->planes == 32) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + fdrawcheckerboard(x, y, x + zoomx * ibuf->x, y + zoomy * ibuf->y); + } + if (ED_space_clip_texture_buffer_supported(sc)) { if (ED_space_clip_load_movieclip_buffer(sc, ibuf, display_buffer)) { + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glPushMatrix(); glTranslatef(x, y, 0.0f); glScalef(zoomx, zoomy, 1.0f); @@ -296,11 +306,14 @@ static void draw_movieclip_buffer(const bContext *C, SpaceClip *sc, ARegion *ar, /* set zoom */ glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); - glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); /* reset zoom */ glPixelZoom(1.0f, 1.0f); } + + if (ibuf->planes == 32) + glDisable(GL_BLEND); } IMB_display_buffer_release(cache_handle); @@ -1471,6 +1484,8 @@ void clip_draw_main(const bContext *C, SpaceClip *sc, ARegion *ar) if (ibuf) { draw_movieclip_buffer(C, sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); + + clip_start_prefetch_job(C); } else { ED_region_grid_draw(ar, zoomx, zoomy); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 728110dfeee..6d9c5b4ba46 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -30,6 +30,15 @@ */ #include <stddef.h> +#include <errno.h> +#include <sys/types.h> +#include <fcntl.h> + +#ifndef WIN32 +# include <unistd.h> +#else +# include <io.h> +#endif #include "MEM_guardedalloc.h" @@ -37,10 +46,13 @@ #include "DNA_object_types.h" /* SELECT */ #include "BLI_utildefines.h" +#include "BLI_fileops.h" #include "BLI_math.h" #include "BLI_string.h" #include "BLI_rect.h" +#include "BLI_threads.h" +#include "BKE_global.h" #include "BKE_main.h" #include "BKE_mask.h" #include "BKE_movieclip.h" @@ -617,6 +629,8 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf, const unsign context->last_texture = glaGetOneInteger(GL_TEXTURE_2D); + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + /* image texture need to be rebinded if displaying another image buffer * assuming displaying happens of footage frames only on which painting doesn't happen. * so not changed image buffer pointer means unchanged image content */ @@ -722,3 +736,380 @@ void ED_space_clip_free_texture_buffer(SpaceClip *sc) MEM_freeN(context); } } + +/* ******** pre-fetching functions ******** */ + +typedef struct PrefetchJob { + MovieClip *clip; + int start_frame, end_frame; + short render_size, render_flag; +} PrefetchJob; + +typedef struct PrefetchQueue { + int current_frame, start_frame, end_frame; + short render_size, render_flag; + + SpinLock spin; + + short *stop; + short *do_update; + float *progress; +} PrefetchQueue; + +typedef struct PrefetchThread { + MovieClip *clip; + PrefetchQueue *queue; +} PrefetchThread; + +/* check whether pre-fetching is allowed */ +static bool check_prefetch_allowed(void) +{ + wmWindowManager *wm; + + /* if there's any job started, better to leave all CPU and + * HDD bandwidth to it + * + * also, display transform could be needed during playback, + * so better to avoid prefetching in this case and reserve + * all the power for display transform + */ + for (wm = G.main->wm.first; wm; wm = wm->id.next) { + if (WM_jobs_has_running_except(wm, WM_JOB_TYPE_CLIP_PREFETCH)) + return false; + + if (ED_screen_animation_playing(wm)) + return false; + } + + return true; +} + +/* read file for specified frame number to the memory */ +static unsigned char *prefetch_read_file_to_memory(MovieClip *clip, int current_frame, short render_size, + short render_flag, size_t *size_r) +{ + MovieClipUser user = {0}; + char name[FILE_MAX]; + size_t size; + int file; + unsigned char *mem; + + user.framenr = current_frame; + user.render_size = render_size; + user.render_flag = render_flag; + + BKE_movieclip_filename_for_frame(clip, &user, name); + + file = open(name, O_BINARY | O_RDONLY, 0); + if (file < 0) { + return NULL; + } + + size = BLI_file_descriptor_size(file); + if (size < 1) { + close(file); + return NULL; + } + + mem = MEM_mallocN(size, "movieclip prefetch memory file"); + + if (read(file, mem, size) != size) { + close(file); + MEM_freeN(mem); + return NULL; + } + + *size_r = size; + + close(file); + + return mem; +} + +/* find first uncached frame within prefetching frame range */ +static int prefetch_find_uncached_frame(MovieClip *clip, int from_frame, int end_frame, + short render_size, short render_flag) +{ + int current_frame; + + for (current_frame = from_frame; current_frame <= end_frame; current_frame++) { + MovieClipUser user = {0}; + + user.framenr = current_frame; + user.render_size = render_size; + user.render_flag = render_flag; + + if (!BKE_movieclip_has_cached_frame(clip, &user)) + break; + } + + return current_frame; +} + +/* get memory buffer for first uncached frame within prefetch frame range */ +static unsigned char *prefetch_thread_next_frame(PrefetchQueue *queue, MovieClip *clip, + size_t *size_r, int *current_frame_r) +{ + unsigned char *mem = NULL; + + BLI_spin_lock(&queue->spin); + if (!*queue->stop && queue->current_frame <= queue->end_frame && check_prefetch_allowed()) { + int current_frame; + current_frame = prefetch_find_uncached_frame(clip, queue->current_frame + 1, queue->end_frame, + queue->render_size, queue->render_flag); + + if (current_frame <= queue->end_frame) { + mem = prefetch_read_file_to_memory(clip, current_frame, queue->render_size, + queue->render_flag, size_r); + + *current_frame_r = current_frame; + + queue->current_frame = current_frame; + + *queue->do_update = 1; + *queue->progress = (float)(queue->current_frame - queue->start_frame) / + (queue->end_frame - queue->start_frame); + } + } + BLI_spin_unlock(&queue->spin); + + return mem; +} + +static void *do_prefetch_thread(void *data_v) +{ + PrefetchThread *data = (PrefetchThread *) data_v; + unsigned char *mem; + size_t size; + int current_frame; + + while ((mem = prefetch_thread_next_frame(data->queue, data->clip, &size, ¤t_frame))) { + ImBuf *ibuf; + MovieClipUser user = {0}; + int flag = IB_rect | IB_alphamode_detect; + int result; + + user.framenr = current_frame; + user.render_size = data->queue->render_size; + user.render_flag = data->queue->render_flag; + + ibuf = IMB_ibImageFromMemory(mem, size, flag, NULL, "prefetch frame"); + + result = BKE_movieclip_put_frame_if_possible(data->clip, &user, ibuf); + + IMB_freeImBuf(ibuf); + + MEM_freeN(mem); + + if (!result) { + /* no more space in the cache, stop reading frames */ + *data->queue->stop = 1; + break; + } + } + + return NULL; +} + +static void start_prefetch_threads(MovieClip *clip, int start_frame, int end_frame, short render_size, + short render_flag, short *stop, short *do_update, float *progress) +{ + ListBase threads; + PrefetchQueue queue; + PrefetchThread *handles; + int tot_thread = BLI_system_thread_count(); + int i; + + /* reserve one thread for the interface */ + if (tot_thread > 1) + tot_thread--; + + /* initialize queue */ + BLI_spin_init(&queue.spin); + + queue.current_frame = start_frame; + queue.start_frame = start_frame; + queue.end_frame = end_frame; + queue.render_size = render_size; + queue.render_flag = render_flag; + + queue.stop = stop; + queue.do_update = do_update; + queue.progress = progress; + + /* fill in thread handles */ + handles = MEM_callocN(sizeof(PrefetchThread) * tot_thread, "prefetch threaded handles"); + + if (tot_thread > 1) + BLI_init_threads(&threads, do_prefetch_thread, tot_thread); + + for (i = 0; i < tot_thread; i++) { + PrefetchThread *handle = &handles[i]; + + handle->clip = clip; + handle->queue = &queue; + + if (tot_thread > 1) + BLI_insert_thread(&threads, handle); + } + + /* run the threads */ + if (tot_thread > 1) + BLI_end_threads(&threads); + else + do_prefetch_thread(handles); + + MEM_freeN(handles); +} + +static void do_prefetch_movie(MovieClip *clip, int start_frame, int end_frame, short render_size, + short render_flag, short *stop, short *do_update, float *progress) +{ + int current_frame; + + for (current_frame = start_frame; current_frame <= end_frame; current_frame++) { + MovieClipUser user = {0}; + ImBuf *ibuf; + + if (!check_prefetch_allowed() || *stop) + break; + + user.framenr = current_frame; + user.render_size = render_size; + user.render_flag = render_flag; + + if (!BKE_movieclip_has_cached_frame(clip, &user)) { + ibuf = BKE_movieclip_anim_ibuf_for_frame(clip, &user); + + if (ibuf) { + int result; + + result = BKE_movieclip_put_frame_if_possible(clip, &user, ibuf); + + if (!result) { + /* no more space in the cache, we could stop prefetching here */ + *stop = 1; + } + + IMB_freeImBuf(ibuf); + } + else { + /* error reading frame, fair enough stop attempting further reading */ + *stop = 1; + } + } + + *do_update = 1; + *progress = (float)(current_frame - start_frame) / (end_frame - start_frame); + } +} + +static void prefetch_startjob(void *pjv, short *stop, short *do_update, float *progress) +{ + PrefetchJob *pj = pjv; + + if (pj->clip->source == MCLIP_SRC_SEQUENCE) { + /* read sequence files in multiple threads */ + start_prefetch_threads(pj->clip, pj->start_frame, pj->end_frame, + pj->render_size, pj->render_flag, + stop, do_update, progress); + } + else if (pj->clip->source == MCLIP_SRC_MOVIE) { + /* read movie in a single thread */ + do_prefetch_movie(pj->clip, pj->start_frame, pj->end_frame, + pj->render_size, pj->render_flag, + stop, do_update, progress); + } + else { + BLI_assert(!"Unknown movie clip source when prefetching frames"); + } +} + +static void prefetch_freejob(void *pjv) +{ + PrefetchJob *pj = pjv; + + MEM_freeN(pj); +} + +static int prefetch_get_final_frame(const bContext *C) +{ + Scene *scene = CTX_data_scene(C); + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + int end_frame; + + /* check whether all the frames from prefetch range are cached */ + end_frame = EFRA; + + if (clip->len) + end_frame = min_ii(end_frame, clip->len); + + return end_frame; +} + +/* returns true if early out is possible */ +static bool prefetch_check_early_out(const bContext *C) +{ + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + int first_uncached_frame, end_frame; + int clip_len; + + if (clip->prefetch_ok) + return true; + + clip_len = BKE_movieclip_get_duration(clip); + + /* check whether all the frames from prefetch range are cached */ + end_frame = prefetch_get_final_frame(C); + + first_uncached_frame = + prefetch_find_uncached_frame(clip, sc->user.framenr, end_frame, + sc->user.render_size, sc->user.render_flag); + + if (first_uncached_frame > end_frame || first_uncached_frame == clip_len) + return true; + + return false; +} + +void clip_start_prefetch_job(const bContext *C) +{ + wmJob *wm_job; + PrefetchJob *pj; + SpaceClip *sc = CTX_wm_space_clip(C); + MovieClip *clip = ED_space_clip_get_clip(sc); + + if (prefetch_check_early_out(C)) + return; + + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), CTX_wm_area(C), "Prefetching", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_PREFETCH); + + if (WM_jobs_is_running(wm_job)) { + /* if job is already running, it'll call clip editor redraw when + * it's finished, so cache line is nicely updated + * this will also trigger call of this function, which will ensure + * all needed frames are prefetched + */ + return; + } + + clip->prefetch_ok = true; + + /* create new job */ + pj = MEM_callocN(sizeof(PrefetchJob), "prefetch job"); + pj->clip = ED_space_clip_get_clip(sc); + pj->start_frame = sc->user.framenr; + pj->end_frame = prefetch_get_final_frame(C); + pj->render_size = sc->user.render_size; + pj->render_flag = sc->user.render_flag; + + WM_jobs_customdata_set(wm_job, pj, prefetch_freejob); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP, 0); + WM_jobs_callbacks(wm_job, prefetch_startjob, NULL, NULL, NULL); + + /* and finally start the job */ + WM_jobs_start(CTX_wm_manager(C), wm_job); +} diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h index cd7da4229d2..99222ec63ac 100644 --- a/source/blender/editors/space_clip/clip_intern.h +++ b/source/blender/editors/space_clip/clip_intern.h @@ -74,6 +74,9 @@ void clip_draw_main(const struct bContext *C, struct SpaceClip *sc, struct ARegi void clip_draw_grease_pencil(struct bContext *C, int onlyv2d); void clip_draw_curfra_label(const int framenr, const float x, const float y); +/* clip_editor.c */ +void clip_start_prefetch_job(const struct bContext *C); + /* clip_graph_draw.c */ void clip_draw_graph(struct SpaceClip *sc, struct ARegion *ar, struct Scene *scene); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 914eb9526a8..8e03691e64f 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1064,11 +1064,14 @@ static unsigned char *proxy_thread_next_frame(ProxyQueue *queue, MovieClip *clip BLI_spin_lock(&queue->spin); if (!*queue->stop && queue->cfra <= queue->efra) { + MovieClipUser user = {0}; char name[FILE_MAX]; size_t size; int file; - BKE_movieclip_filename_for_frame(clip, queue->cfra, name); + user.framenr = queue->cfra; + + BKE_movieclip_filename_for_frame(clip, &user, name); file = open(name, O_BINARY | O_RDONLY, 0); if (file < 0) { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 4f9757a6640..ced19020034 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -236,6 +236,16 @@ static void clip_stabilization_tag_refresh(ScrArea *sa) } } +static void clip_prefetch_tag_refresh(ScrArea *sa) +{ + SpaceClip *sc = (SpaceClip *) sa->spacedata.first; + MovieClip *clip = ED_space_clip_get_clip(sc); + + if (clip) { + clip->prefetch_ok = FALSE; + } +} + /* ******************** default callbacks for clip space ***************** */ static SpaceLink *clip_new(const bContext *C) @@ -351,6 +361,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_FRAME: clip_scopes_tag_refresh(sa); + clip_prefetch_tag_refresh(sa); /* no break! */ case ND_FRAME_RANGE: @@ -359,11 +370,19 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_MOVIECLIP: + if (wmn->data == 0 && wmn->action == 0) { + /* a nit funky, happens from prefetch job to update + * cache line and job progress + */ + ED_area_tag_redraw(sa); + } + switch (wmn->data) { case ND_DISPLAY: case ND_SELECT: clip_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); + clip_prefetch_tag_refresh(sa); break; } switch (wmn->action) { @@ -407,6 +426,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: + clip_prefetch_tag_refresh(sa); ED_area_tag_redraw(sa); break; } @@ -415,6 +435,7 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); + clip_prefetch_tag_refresh(sa); ED_area_tag_redraw(sa); } break; @@ -424,6 +445,10 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); } break; + case NC_WM: + if (wmn->data == ND_FILEREAD) + clip_prefetch_tag_refresh(sa); + break; } } diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 1e79e4b9714..00f1f8c21c9 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -45,8 +45,8 @@ void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dumm /* console_ops.c */ void console_history_free(SpaceConsole *sc, ConsoleLine *cl); void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl); -ConsoleLine *console_history_add_str(struct SpaceConsole *sc, char *str, int own); -ConsoleLine *console_scrollback_add_str(struct SpaceConsole *sc, char *str, int own); +ConsoleLine *console_history_add_str(struct SpaceConsole *sc, char *str, bool own); +ConsoleLine *console_scrollback_add_str(struct SpaceConsole *sc, char *str, bool own); ConsoleLine *console_history_verify(const struct bContext *C); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index b735dee5bdf..74f776549e9 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -116,7 +116,7 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons } /* return 0 if no change made, clamps the range */ -static int console_line_cursor_set(ConsoleLine *cl, int cursor) +static bool console_line_cursor_set(ConsoleLine *cl, int cursor) { int cursor_new; @@ -125,11 +125,11 @@ static int console_line_cursor_set(ConsoleLine *cl, int cursor) else cursor_new = cursor; if (cursor_new == cl->cursor) { - return FALSE; + return false; } cl->cursor = cursor_new; - return TRUE; + return true; } #if 0 // XXX unused @@ -188,7 +188,7 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) } #endif -static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, int own) +static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own) { ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); if (own) ci->line = str; @@ -199,11 +199,11 @@ static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, int ow BLI_addtail(lb, ci); return ci; } -ConsoleLine *console_history_add_str(SpaceConsole *sc, char *str, int own) +ConsoleLine *console_history_add_str(SpaceConsole *sc, char *str, bool own) { return console_lb_add_str__internal(&sc->history, str, own); } -ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, int own) +ConsoleLine *console_scrollback_add_str(SpaceConsole *sc, char *str, bool own) { ConsoleLine *ci = console_lb_add_str__internal(&sc->scrollback, str, own); console_select_offset(sc, ci->len + 1); @@ -276,7 +276,7 @@ static int console_move_exec(bContext *C, wmOperator *op) ConsoleLine *ci = console_history_verify(C); int type = RNA_enum_get(op->ptr, "type"); - int done = FALSE; + bool done = false; int pos; switch (type) { diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a159c88221e..9a7f528be78 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -190,12 +190,12 @@ static void file_panel_operator_header(const bContext *C, Panel *pa) BLI_strncpy(pa->drawname, RNA_struct_ui_name(op->type->srna), sizeof(pa->drawname)); } -static int file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) +static bool file_panel_check_prop(PointerRNA *UNUSED(ptr), PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - return !(strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0 + return !(STREQ(prop_id, "filepath") || + STREQ(prop_id, "directory") || + STREQ(prop_id, "filename") ); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 256c90a1f1a..bdf93b98f22 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -712,7 +712,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 v1[1] = prevbezt->vec[1][1]; v2[0] = prevbezt->vec[2][0]; v2[1] = prevbezt->vec[2][1]; - + v3[0] = bezt->vec[0][0]; v3[1] = bezt->vec[0][1]; v4[0] = bezt->vec[1][0]; @@ -772,6 +772,111 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 glEnd(); } +/* Debugging -------------------------------- */ + +/* Draw indicators which show the value calculated from the driver, + * and how this is mapped to the value that comes out of it. This + * is handy for helping users better understand how to interpret + * the graphs, and also facilitates debugging. + */ +static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) +{ + ChannelDriver *driver = fcu->driver; + View2D *v2d = &ac->ar->v2d; + float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, false); + + /* for now, only show when debugging driver... */ + //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) + // return; + + /* No curve to modify/visualise the result? + * => We still want to show the 1-1 default... + */ + if ((fcu->totvert == 0) && (fcu->modifiers.first == NULL)) { + float t; + + /* draw with thin dotted lines in style of what curve would have been */ + glColor3fv(fcu->color); + + setlinestyle(20); + glLineWidth(2.0f); + + /* draw 1-1 line, stretching just past the screen limits + * NOTE: we need to scale the y-values to be valid for the units + */ + glBegin(GL_LINES); + t = v2d->cur.xmin; + glVertex2f(t, t * unitfac); + + t = v2d->cur.xmax; + glVertex2f(t, t * unitfac); + glEnd(); + + /* cleanup line drawing */ + setlinestyle(0); + glLineWidth(1.0f); + } + + /* draw driver only if actually functional */ + if ((driver->flag & DRIVER_FLAG_INVALID) == 0) { + /* grab "coordinates" for driver outputs */ + float x = driver->curval; + float y = fcu->curval * unitfac; + + /* only draw indicators if the point is in range*/ + if (x >= v2d->cur.xmin) { + float co[2]; + + /* draw dotted lines leading towards this point from both axes ....... */ + glColor3f(0.9f, 0.9f, 0.9f); + setlinestyle(5); + + glBegin(GL_LINES); + /* x-axis lookup */ + co[0] = x; + + if (y >= v2d->cur.ymin) { + co[1] = v2d->cur.ymin - 1.0f; + glVertex2fv(co); + + co[1] = y; + glVertex2fv(co); + } + + /* y-axis lookup */ + co[1] = y; + + co[0] = v2d->cur.xmin - 1.0f; + glVertex2fv(co); + + co[0] = x; + glVertex2fv(co); + glEnd(); + + setlinestyle(0); + + /* x marks the spot .................................................... */ + /* -> outer frame */ + glColor3f(0.9f, 0.9f, 0.9f); + glPointSize(7.0); + + glBegin(GL_POINTS); + glVertex2f(x, y); + glEnd(); + + /* inner frame */ + glColor3f(0.9f, 0.0f, 0.0f); + glPointSize(3.0); + + glBegin(GL_POINTS); + glVertex2f(x, y); + glEnd(); + + glPointSize(1.0f); + } + } +} + /* Public Curve-Drawing API ---------------- */ /* Draw the 'ghost' F-Curves (i.e. snapshots of the curve) @@ -934,6 +1039,11 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } } + /* 3) draw driver debugging stuff */ + if ((ac->datatype == ANIMCONT_DRIVERS) && (fcu->flag & FCURVE_ACTIVE)) { + graph_draw_driver_debug(ac, ale->id, fcu); + } + /* undo mapping of keyframes for drawing if scaled F-Curve */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index b2dbf764c1d..8dc5e9a441d 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -69,19 +69,19 @@ void GRAPH_OT_select_leftright(struct wmOperatorType *ot); void GRAPH_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ -enum { +enum eGraphKeys_LeftRightSelect_Mode { GRAPHKEYS_LRSEL_TEST = 0, GRAPHKEYS_LRSEL_LEFT, GRAPHKEYS_LRSEL_RIGHT -} eGraphKeys_LeftRightSelect_Mode; +}; /* defines for column-select mode */ -enum { +enum eGraphKeys_ColumnSelect_Mode { GRAPHKEYS_COLUMNSEL_KEYS = 0, GRAPHKEYS_COLUMNSEL_CFRA, GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, -} eGraphKeys_ColumnSelect_Mode; +}; /* ***************************************** */ /* graph_edit.c */ @@ -119,25 +119,25 @@ void GRAPH_OT_mirror(struct wmOperatorType *ot); /* defines for snap keyframes * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h) */ -enum { +enum eGraphKeys_Snap_Mode { GRAPHKEYS_SNAP_CFRA = 1, GRAPHKEYS_SNAP_NEAREST_FRAME, GRAPHKEYS_SNAP_NEAREST_SECOND, GRAPHKEYS_SNAP_NEAREST_MARKER, GRAPHKEYS_SNAP_HORIZONTAL, GRAPHKEYS_SNAP_VALUE, -} eGraphKeys_Snap_Mode; +}; /* defines for mirror keyframes * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h) */ -enum { +enum eGraphKeys_Mirror_Mode { GRAPHKEYS_MIRROR_CFRA = 1, GRAPHKEYS_MIRROR_YAXIS, GRAPHKEYS_MIRROR_XAXIS, GRAPHKEYS_MIRROR_MARKER, GRAPHKEYS_MIRROR_VALUE, -} eGraphKeys_Mirror_Mode; +}; /* ----------- */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 7c016cdf3bf..7e0767bfcfb 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1483,15 +1483,15 @@ static int image_save_as_cancel(bContext *UNUSED(C), wmOperator *op) return OPERATOR_CANCELLED; } -static int image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +static bool image_save_as_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { const char *prop_id = RNA_property_identifier(prop); - return !(strcmp(prop_id, "filepath") == 0 || - strcmp(prop_id, "directory") == 0 || - strcmp(prop_id, "filename") == 0 || + return !(STREQ(prop_id, "filepath") || + STREQ(prop_id, "directory") || + STREQ(prop_id, "filename") || /* when saving a copy, relative path has no effect */ - ((strcmp(prop_id, "relative_path") == 0) && RNA_boolean_get(ptr, "copy")) + ((STREQ(prop_id, "relative_path")) && RNA_boolean_get(ptr, "copy")) ); } diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 450b85738ad..98c66d70a75 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -54,12 +54,12 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar); /* nla_select.c */ /* defines for left-right select tool */ -enum { +enum eNlaEdit_LeftRightSelect_Mode { NLAEDIT_LRSEL_TEST = -1, NLAEDIT_LRSEL_NONE, NLAEDIT_LRSEL_LEFT, NLAEDIT_LRSEL_RIGHT -} eNlaEdit_LeftRightSelect_Mode; +}; /* --- */ @@ -73,12 +73,12 @@ void NLA_OT_click_select(wmOperatorType *ot); /* defines for snap strips */ -enum { +enum eNlaEdit_Snap_Mode { NLAEDIT_SNAP_CFRA = 1, NLAEDIT_SNAP_NEAREST_FRAME, NLAEDIT_SNAP_NEAREST_SECOND, NLAEDIT_SNAP_NEAREST_MARKER -} eNlaEdit_Snap_Mode; +}; /* --- */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 0b02aef2fab..a413eb47140 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -114,18 +114,18 @@ static void node_add_menu_class(bContext *C, uiLayout *layout, void *arg_nodecla continue; switch (ntree->type) { - case NTREE_COMPOSIT: - ngroup_type = "CompositorNodeTree"; - node_type = "CompositorNodeGroup"; - break; - case NTREE_SHADER: - ngroup_type = "ShaderNodeTree"; - node_type = "ShaderNodeGroup"; - break; - case NTREE_TEXTURE: - ngroup_type = "TextureNodeTree"; - node_type = "TextureNodeGroup"; - break; + case NTREE_COMPOSIT: + ngroup_type = "CompositorNodeTree"; + node_type = "CompositorNodeGroup"; + break; + case NTREE_SHADER: + ngroup_type = "ShaderNodeTree"; + node_type = "ShaderNodeGroup"; + break; + case NTREE_TEXTURE: + ngroup_type = "TextureNodeTree"; + node_type = "TextureNodeGroup"; + break; } ptr = uiItemFullO(layout, "NODE_OT_group_make", "New Group", ntype->ui_icon, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1165,7 +1165,7 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point if (!node->id) return; col = uiLayoutColumn(layout, FALSE); - row = uiLayoutRow(col, FALSE); + row = uiLayoutRow(col, TRUE); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); prop = RNA_struct_find_property(ptr, "layer"); @@ -2708,8 +2708,57 @@ static void node_template_properties_update(bNodeType *ntype) } } +static void node_socket_undefined_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr)) +{ + uiItemL(layout, "Undefined Socket Type", ICON_ERROR); +} + +static void node_socket_undefined_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), float *r_color) +{ + r_color[0] = 1.0f; + r_color[1] = 0.0f; + r_color[2] = 0.0f; + r_color[3] = 1.0f; +} + +static void node_socket_undefined_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr)) +{ + uiItemL(layout, "Undefined Socket Type", ICON_ERROR); +} + +static void node_socket_undefined_interface_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), float *r_color) +{ + r_color[0] = 1.0f; + r_color[1] = 0.0f; + r_color[2] = 0.0f; + r_color[3] = 1.0f; +} + void ED_node_init_butfuncs(void) { + /* Fallback types for undefined tree, nodes, sockets + * Defined in blenkernel, but not registered in type hashes. + */ + /*extern bNodeTreeType NodeTreeTypeUndefined;*/ + extern bNodeType NodeTypeUndefined; + extern bNodeSocketType NodeSocketTypeUndefined; + + /* default ui functions */ + NodeTypeUndefined.drawfunc = node_draw_default; + NodeTypeUndefined.drawupdatefunc = node_update_default; + NodeTypeUndefined.select_area_func = node_select_area_default; + NodeTypeUndefined.tweak_area_func = node_tweak_area_default; + NodeTypeUndefined.uifunc = NULL; + NodeTypeUndefined.uifuncbut = NULL; + NodeTypeUndefined.drawinputfunc = node_draw_input_default; + NodeTypeUndefined.drawoutputfunc = node_draw_output_default; + NodeTypeUndefined.resize_area_func = node_resize_area_default; + + NodeSocketTypeUndefined.draw = node_socket_undefined_draw; + NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color; + NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw; + NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color; + /* node type ui functions */ NODE_TYPES_BEGIN(ntype) /* default ui functions */ @@ -2762,14 +2811,14 @@ void ED_init_custom_node_socket_type(bNodeSocketType *stype) /* maps standard socket integer type to a color */ static const float std_node_socket_colors[][4] = { - {0.63, 0.63, 0.63, 1.0}, /* SOCK_FLOAT */ - {0.39, 0.39, 0.78, 1.0}, /* SOCK_VECTOR */ - {0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */ - {0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */ - {0.70, 0.65, 0.19, 1.0}, /* SOCK_BOOLEAN */ - {0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */ - {0.06, 0.52, 0.15, 1.0}, /* SOCK_INT */ - {1.0, 1.0, 1.0, 1.0}, /* SOCK_STRING */ + {0.63, 0.63, 0.63, 1.0}, /* SOCK_FLOAT */ + {0.39, 0.39, 0.78, 1.0}, /* SOCK_VECTOR */ + {0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */ + {0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */ + {0.70, 0.65, 0.19, 1.0}, /* SOCK_BOOLEAN */ + {0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */ + {0.06, 0.52, 0.15, 1.0}, /* SOCK_INT */ + {1.0, 1.0, 1.0, 1.0}, /* SOCK_STRING */ }; /* common color callbacks for standard types */ @@ -2786,7 +2835,7 @@ static void std_node_socket_interface_draw_color(bContext *UNUSED(C), PointerRNA copy_v4_v4(r_color, std_node_socket_colors[type]); } -static void std_node_socket_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *ptr, PointerRNA *UNUSED(node_ptr)) +static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr) { bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; @@ -2816,6 +2865,10 @@ static void std_node_socket_draw(bContext *UNUSED(C), uiLayout *layout, PointerR uiItemL(row, sock->name, 0); break; } + + default: + node_socket_button_label(C, layout, ptr, node_ptr); + break; } } @@ -2911,7 +2964,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); @@ -2919,7 +2972,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode) else { glPixelZoom(snode->zoom, snode->zoom); - glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, display_buffer); + glaDrawPixelsAuto(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, display_buffer); glPixelZoom(1.0f, 1.0f); } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 765f2b67549..fb9e1221c38 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -110,6 +110,9 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx if (node->id) id_us_plus(node->id); + if (snode->flag & SNODE_USE_HIDDEN_PREVIEW) + node->flag &= ~NODE_PREVIEW; + snode_update(snode, node); if (snode->nodetree->type == NTREE_TEXTURE) { diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 688377c7f3b..efdb7c0d85d 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -62,7 +62,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - return (snode && ntreeIsValid(snode->nodetree)); + return (snode && snode->nodetree); } /* poll callback for active node */ @@ -70,7 +70,7 @@ static int active_node_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - return (snode && ntreeIsValid(snode->edittree) && nodeGetActive(snode->edittree)); + return (snode && snode->edittree && nodeGetActive(snode->edittree)); } /* active node */ diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 0636dee9bc5..f1915a82f69 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -148,7 +148,7 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree) { - if (!ntreeIsValid(ntree)) + if (!ntree) return; /* look through all datablocks, to support groups */ @@ -359,7 +359,10 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) nsock->locx = locx + NODE_WIDTH(node); /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); + dy = buty; + if (nsock->next) + dy -= NODE_SOCKDY; } node->prvr.xmin = locx + NODE_DYS; @@ -443,7 +446,10 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) nsock->locx = locx; /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); + dy = buty; + if (nsock->next) + dy -= NODE_SOCKDY; } /* little bit space in end */ @@ -861,7 +867,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN NULL, 0, 0, 0, 0, ""); /* body */ - if (node->flag & NODE_CUSTOM_COLOR) + if (!nodeIsRegistered(node)) + UI_ThemeColor4(TH_REDALERT); /* use warning color to indicate undefined types */ + else if (node->flag & NODE_CUSTOM_COLOR) glColor3fv(node->color); else UI_ThemeColor4(TH_NODE); @@ -967,7 +975,19 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + + /* custom color inline */ + if (node->flag & NODE_CUSTOM_COLOR) { + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + + glColor3fv(node->color); + uiDrawBox(GL_LINE_LOOP, rct->xmin + 1, rct->ymin + 1, rct->xmax -1, rct->ymax - 1, hiddenrad); + + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + } + /* title */ if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); @@ -1057,7 +1077,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode) bNodeSocket *sock; int cursor = CURSOR_STD; - if (ntreeIsValid(ntree)) { + if (ntree) { if (node_find_indicated_socket(snode, &node, &sock, SOCK_IN | SOCK_OUT)) { /* pass */ } @@ -1112,7 +1132,6 @@ static void node_draw(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTre void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNodeInstanceKey parent_key) { bNode *node; - bNodeInstanceKey key; bNodeLink *link; int a; @@ -1126,6 +1145,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT /* draw background nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { + bNodeInstanceKey key; #ifdef USE_DRAW_TOT_UPDATE /* unrelated to background nodes, update the v2d->tot, @@ -1153,7 +1173,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { - bNodeInstanceKey key = BKE_node_instance_key(parent_key, ntree, node); + bNodeInstanceKey key; if (node->flag & NODE_BACKGROUND) continue; @@ -1271,7 +1291,7 @@ void drawnodespace(const bContext *C, ARegion *ar) for (curdepth = depth; curdepth >= 0; path = path->next, --curdepth) { ntree = path->nodetree; - if (ntreeIsValid(ntree)) { + if (ntree) { snode_setup_v2d(snode, ar, ntree->view_center[0], ntree->view_center[1]); if (curdepth == 0) { diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 256b02d3288..c74c160080c 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -90,6 +90,11 @@ /* ***************** composite job manager ********************** */ +enum { + COM_RECALC_COMPOSITE = 1, + COM_RECALC_VIEWER = 2 +}; + typedef struct CompoJob { Scene *scene; bNodeTree *ntree; @@ -98,8 +103,55 @@ typedef struct CompoJob { short *do_update; float *progress; short need_sync; + int recalc_flags; } CompoJob; +static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags) +{ + bNode *node; + + for (node = nodetree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_COMPOSITE) { + if (recalc_flags & COM_RECALC_COMPOSITE) + node->flag |= NODE_DO_OUTPUT_RECALC; + } + else if (node->type == CMP_NODE_VIEWER) { + if (recalc_flags & COM_RECALC_VIEWER) + node->flag |= NODE_DO_OUTPUT_RECALC; + } + else if (node->type == NODE_GROUP) { + if (node->id) + compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags); + } + } +} + +static int compo_get_recalc_flags(const bContext *C) +{ + bScreen *sc = CTX_wm_screen(C); + ScrArea *sa; + int recalc_flags = 0; + + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_IMAGE) { + SpaceImage *sima = sa->spacedata.first; + if (sima->image) { + if (sima->image->type == IMA_TYPE_R_RESULT) + recalc_flags |= COM_RECALC_COMPOSITE; + else if (sima->image->type == IMA_TYPE_COMPOSITE) + recalc_flags |= COM_RECALC_VIEWER; + } + } + else if (sa->spacetype == SPACE_NODE) { + SpaceNode *snode = sa->spacedata.first; + if (snode->flag & SNODE_BACKDRAW) + recalc_flags |= COM_RECALC_VIEWER; + } + } + + return recalc_flags; +} + /* called by compo, only to check job 'stop' value */ static int compo_breakjob(void *cjv) { @@ -148,6 +200,9 @@ static void compo_initjob(void *cjv) CompoJob *cj = cjv; cj->localtree = ntreeLocalize(cj->ntree); + + if (cj->recalc_flags) + compo_tag_output_nodes(cj->localtree, cj->recalc_flags); } /* called before redraw notifiers, it moves finished previews over */ @@ -234,6 +289,7 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene /* customdata for preview thread */ cj->scene = CTX_data_scene(C); cj->ntree = nodetree; + cj->recalc_flags = compo_get_recalc_flags(C); /* setup job */ WM_jobs_customdata_set(wm_job, cj, compo_freejob); @@ -329,15 +385,11 @@ void ED_node_shader_default(const bContext *C, ID *id) bNode *in, *out; bNodeSocket *fromsock, *tosock, *sock; bNodeTree *ntree; - PointerRNA ptr; int output_type, shader_type; float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f; ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); - RNA_id_pointer_create((ID *)ntree, &ptr); - RNA_boolean_set(&ptr, "is_local_tree", TRUE); - switch (GS(id->name)) { case ID_MA: { @@ -425,7 +477,6 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - PointerRNA ptr; /* but lets check it anyway */ if (sce->nodetree) { @@ -436,9 +487,6 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname); - RNA_id_pointer_create((ID *)sce->nodetree, &ptr); - RNA_boolean_set(&ptr, "is_local_tree", TRUE); - sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; @@ -470,7 +518,6 @@ void ED_node_texture_default(const bContext *C, Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - PointerRNA ptr; /* but lets check it anyway */ if (tx->nodetree) { @@ -481,9 +528,6 @@ void ED_node_texture_default(const bContext *C, Tex *tx) tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); - RNA_id_pointer_create((ID *)tx->nodetree, &ptr); - RNA_boolean_set(&ptr, "is_local_tree", TRUE); - out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); out->locx = 300.0f; out->locy = 300.0f; @@ -530,11 +574,17 @@ void snode_set_context(const bContext *C) } if (!(snode->flag & SNODE_PIN) || ntree == NULL) { - if (treetype->get_from_context) + if (treetype->get_from_context) { + /* reset and update from context */ + ntree = NULL; + id = NULL; + from = NULL; + treetype->get_from_context(C, treetype, &ntree, &id, &from); + } } - if (snode->nodetree != ntree || snode->id != id || snode->from != snode->from) { + if (snode->nodetree != ntree || snode->id != id || snode->from != from) { ED_node_tree_start(snode, ntree, id, from); } } diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 10f9718f1b6..30ba4108143 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -552,7 +552,7 @@ typedef enum eNodeGroupSeparateType { } eNodeGroupSeparateType; /* Operator Property */ -EnumPropertyItem node_group_separate_types[] = { +static EnumPropertyItem node_group_separate_types[] = { {NODE_GS_COPY, "COPY", 0, "Copy", "Copy to parent node tree, keep group intact"}, {NODE_GS_MOVE, "MOVE", 0, "Move", "Move to parent node tree, remove from group"}, {0, NULL, 0, NULL, NULL} @@ -730,7 +730,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, float min[2], max[2], center[2]; int totselect; int expose_all = FALSE; - bNode *input_node = NULL, *output_node = NULL; /* lazy initialized, in case there are no external links */ + bNode *input_node, *output_node; /* XXX rough guess, not nice but we don't have access to UI constants here ... */ static const float offsetx = 200; @@ -797,6 +797,16 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, /* node groups don't use internal cached data */ ntreeFreeCache(ngroup); + /* create input node */ + input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); + input_node->locx = min[0] - center[0] - offsetx; + input_node->locy = -offsety; + + /* create output node */ + output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); + output_node->locx = max[0] - center[0] + offsetx; + output_node->locy = -offsety; + /* relink external sockets */ for (link = ntree->links.first; link; link = linkn) { int fromselect = node_group_make_use_node(link->fromnode, gnode); @@ -818,13 +828,6 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock); bNodeSocket *input_sock; - /* lazy init */ - if (!input_node) { - input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); - - input_node->locx = min[0] - center[0] - offsetx; - input_node->locy = -offsety; - } /* update the group node and interface node sockets, * so the new interface socket can be linked. */ @@ -843,13 +846,6 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->fromnode, link->fromsock); bNodeSocket *output_sock; - /* lazy init */ - if (!output_node) { - output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); - - output_node->locx = max[0] - center[0] + offsetx; - output_node->locy = -offsety; - } /* update the group node and interface node sockets, * so the new interface socket can be linked. */ @@ -892,13 +888,6 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - /* lazy init */ - if (!input_node) { - input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); - - input_node->locx = min[0] - center[0] - offsetx; - input_node->locy = -offsety; - } node_group_input_verify(ngroup, input_node, (ID *)ngroup); /* create new internal link */ @@ -917,14 +906,6 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - /* lazy init */ - if (!output_node) { - output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); - - output_node->locx = max[0] - center[0] + offsetx; - output_node->locy = -offsety; - } - node_group_output_verify(ngroup, output_node, (ID *)ngroup); /* create new internal link */ diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index a24da7143f9..2f6090d67ce 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -230,13 +230,14 @@ extern const char *node_context_dir[]; #define BASIS_RAD (0.4f * U.widget_unit) #define NODE_DYS (U.widget_unit / 2) #define NODE_DY U.widget_unit +#define NODE_SOCKDY (0.08f * U.widget_unit) #define NODE_WIDTH(node) (node->width * UI_DPI_FAC) #define NODE_MARGIN_X (0.75f * U.widget_unit) #define NODE_SOCKSIZE (0.25f * U.widget_unit) #define NODE_LINK_RESOL 12 // XXX button events (butspace) -enum { +enum eNodeSpace_ButEvents { B_NOP = 0, B_REDR = 1, B_NODE_USEMAT, @@ -253,6 +254,6 @@ enum { B_MATPRV, B_NODE_LOADIMAGE, B_NODE_SETIMAGE, -} eNodeSpace_ButEvents; +}; #endif /* __NODE_INTERN_H__ */ diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 0bc2fba0d0b..527defb1f07 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -606,7 +606,7 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * { bNode *tnode; - if (!ntreeIsValid(ntree)) + if (!ntree) return; /* clear for cycle check */ diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 2d5207e69db..2075cc055e1 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -479,7 +479,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) snode_set_context(C); - if (ntreeIsValid(snode->nodetree)) { + if (snode->nodetree) { if (snode->nodetree->type == NTREE_SHADER) { if (GS(snode->id->name) == ID_MA) { Material *ma = (Material *)snode->id; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 6fcfb457615..29f1b3fb5a3 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -237,7 +237,7 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } if (ob != scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); return 1; } @@ -643,7 +643,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS if (set) { if (scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 258f0338d1e..9b9e7bef42c 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -300,7 +300,7 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, if (base) { // check also library later if (scene->obedit == base->object) - ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); + ED_object_editmode_exit(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); te->directdata = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 3269e772be6..254d15341cd 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -320,10 +320,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e View2D *v2d = UI_view2d_fromcontext(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - short extend = RNA_boolean_get(op->ptr, "extend"); - short linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); - short left_right = RNA_boolean_get(op->ptr, "left_right"); - short linked_time = RNA_boolean_get(op->ptr, "linked_time"); + const bool extend = RNA_boolean_get(op->ptr, "extend"); + const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); + const bool linked_time = RNA_boolean_get(op->ptr, "linked_time"); + bool left_right = RNA_boolean_get(op->ptr, "left_right"); Sequence *seq, *neighbor, *act_orig; int hand, sel_side; @@ -673,7 +673,7 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons Scene *scene = CTX_data_scene(C); View2D *v2d = UI_view2d_fromcontext(C); - short extend = RNA_boolean_get(op->ptr, "extend"); + bool extend = RNA_boolean_get(op->ptr, "extend"); Sequence *mouse_seq; int selected, hand; diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 110e0ab5bc4..58e45bc766f 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -504,10 +504,13 @@ static void text_properties_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; + ED_region_panels_init(wm, ar); + + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - ED_region_panels_init(wm, ar); } static void text_properties_area_draw(const bContext *C, ARegion *ar) diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index f74d1cf8e8b..9972c570db7 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -307,7 +307,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const int do_n void ED_text_format_register_lua(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"lua", NULL}; tft.format_identifier = txtfmt_lua_format_identifier; diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index c95929a720f..a4322fb310e 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -325,7 +325,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const int do_n void ED_text_format_register_osl(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"osl", NULL}; tft.format_identifier = txtfmt_osl_format_identifier; diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 9562d57041f..a401e5dcdac 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -314,7 +314,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const int do_ne void ED_text_format_register_py(void) { - static TextFormatType tft = {0}; + static TextFormatType tft = {NULL}; static const char *ext[] = {"py", NULL}; tft.format_identifier = txtfmt_py_format_identifier; diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index f37437b159d..cb685b59b64 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -144,7 +144,7 @@ static void cp_shade_color3ub(unsigned char cp[3], const int offset) } /* This function sets the gl-color for coloring a certain bone (based on bcolor) */ -static short set_pchan_glColor(short colCode, int boneflag, short constflag) +static bool set_pchan_glColor(short colCode, int boneflag, short constflag) { switch (colCode) { case PCHAN_COLOR_NORMAL: @@ -184,7 +184,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag) } } - return 1; + return true; } break; @@ -196,7 +196,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag) else UI_ThemeColor(TH_BONE_SOLID); - return 1; + return true; } break; @@ -208,7 +208,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag) else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80); else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80); - return 1; + return true; } else return 0; @@ -238,7 +238,7 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag) else UI_ThemeColor(TH_BONE_SOLID); } - return 1; + return true; } break; case PCHAN_COLOR_SPHEREBONE_END: @@ -288,12 +288,12 @@ static short set_pchan_glColor(short colCode, int boneflag, short constflag) UI_ThemeColorShade(TH_BACK, -30); } - return 1; + return true; } break; } - return 0; + return false; } static void set_ebone_glColor(const unsigned int boneflag) @@ -1660,7 +1660,7 @@ static void bone_matrix_translate_y(float mat[4][4], float y) /* assumes object is Armature with pose */ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, const short dt, const unsigned char ob_wire_col[4], - const short do_const_color, const short is_outline) + const bool do_const_color, const bool is_outline) { RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; @@ -1670,7 +1670,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, GLfloat tmp; float smat[4][4], imat[4][4], bmat[4][4]; int index = -1; - short do_dashed = 3, draw_wire = FALSE; + short do_dashed = 3; + bool draw_wire = false; int flag; /* being set below */ @@ -1736,7 +1737,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0)) { if (bone->layer & arm->layer) { - int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); + const bool use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); glPushMatrix(); if (use_custom && pchan->custom_tx) { @@ -1767,7 +1768,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (use_custom) { /* if drawwire, don't try to draw in solid */ if (pchan->bone->flag & BONE_DRAWWIRE) { - draw_wire = 1; + draw_wire = true; } else { draw_custom_bone(scene, v3d, rv3d, pchan->custom, @@ -1801,7 +1802,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, * stick bones and/or wire custom-shapes are drawn in next loop */ - if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == 0)) { + if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == false)) { /* object tag, for bordersel optim */ glLoadName(index & 0xFFFF); index = -1; @@ -1810,7 +1811,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* draw custom bone shapes as wireframes */ if (!(arm->flag & ARM_NO_CUSTOM) && - ((draw_wire) || (dt <= OB_WIRE)) ) + (draw_wire || (dt <= OB_WIRE)) ) { if (arm->flag & ARM_POSEMODE) index = base->selcol; @@ -2384,7 +2385,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2466,7 +2467,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); @@ -2539,7 +2540,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } } @@ -2554,7 +2555,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); - draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, TRUE, FALSE); + draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } } } @@ -2579,16 +2580,16 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* called from drawobject.c, return 1 if nothing was drawn * (ob_wire_col == NULL) when drawing ghost */ -int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, - const short dt, const short dflag, const unsigned char ob_wire_col[4], - const short is_outline) +bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, + const short dt, const short dflag, const unsigned char ob_wire_col[4], + const bool is_outline) { Object *ob = base->object; bArmature *arm = ob->data; - int retval = 0; + bool retval = false; if (v3d->flag2 & V3D_RENDER_OVERRIDE) - return 1; + return true; if (dt > OB_WIRE && !ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { /* we use color for solid lighting */ @@ -2652,7 +2653,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ } else { - retval = 1; + retval = true; } } /* restore */ diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 9000ccbf324..b13f395b80b 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -240,13 +240,13 @@ static struct TextureDrawState { unsigned char obcol[4]; } Gtexdraw = {NULL, 0, 0, 0, false, {0, 0, 0, 0}}; -static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw) +static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw) { static Material *c_ma; static int c_textured; static MTFace c_texface; static int c_backculled; - static int c_badtex; + static bool c_badtex; static int c_lit; static int c_has_texface; @@ -256,12 +256,12 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m int textured = 0; int lit = 0; int has_texface = texface != NULL; - int need_set_tpage = FALSE; + bool need_set_tpage = false; if (clearcache) { c_textured = c_lit = c_backculled = -1; memset(&c_texface, 0, sizeof(MTFace)); - c_badtex = 0; + c_badtex = false; c_has_texface = -1; } else { @@ -307,7 +307,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m } else { GPU_set_tpage(NULL, 0, 0); - c_badtex = 0; + c_badtex = false; } c_textured = textured; c_has_texface = has_texface; @@ -345,7 +345,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob) { unsigned char obcol[4]; - int is_tex, solidtex; + bool is_tex, solidtex; Mesh *me = ob->data; /* XXX scene->obedit warning */ @@ -353,24 +353,24 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O /* texture draw is abused for mask selection mode, do this so wire draw * with face selection in weight paint is not lit. */ if ((v3d->drawtype <= OB_WIRE) && (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT))) { - solidtex = FALSE; + solidtex = false; Gtexdraw.is_lit = 0; } else if (v3d->drawtype == OB_SOLID || ((ob->mode & OB_MODE_EDIT) && v3d->drawtype != OB_TEXTURE)) { /* draw with default lights in solid draw mode and edit mode */ - solidtex = TRUE; + solidtex = true; Gtexdraw.is_lit = -1; } else { /* draw with lights in the scene otherwise */ - solidtex = FALSE; + solidtex = false; Gtexdraw.is_lit = GPU_scene_object_lights(scene, ob, v3d->lay, rv3d->viewmat, !rv3d->is_persp); } rgba_float_to_uchar(obcol, ob->col); - if (solidtex || v3d->drawtype == OB_TEXTURE) is_tex = 1; - else is_tex = 0; + if (solidtex || v3d->drawtype == OB_TEXTURE) is_tex = true; + else is_tex = false; Gtexdraw.ob = ob; Gtexdraw.is_tex = is_tex; @@ -412,7 +412,7 @@ static void draw_textured_end(void) static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, int has_mcol, int matnr) { Material *ma = give_current_material(Gtexdraw.ob, matnr + 1); - int invalidtexture = 0; + bool invalidtexture = false; if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return DM_DRAW_OPTION_SKIP; @@ -867,7 +867,7 @@ static void tex_mat_set_texture_cb(void *userData, int mat_nr, void *attribs) if (ED_object_get_active_image(data->ob, mat_nr, &ima, &iuser, &node)) { /* get openl texture */ int mipmap = 1; - int bindcode = (ima) ? GPU_verify_image(ima, iuser, 0, 0, mipmap, FALSE) : 0; + int bindcode = (ima) ? GPU_verify_image(ima, iuser, 0, 0, mipmap, false) : 0; float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; if (bindcode) { @@ -1020,7 +1020,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; - const short do_light = (v3d->drawtype >= OB_SOLID); + const bool do_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (me->editflag & (ME_EDIT_PAINT_VERT_SEL | ME_EDIT_PAINT_FACE_SEL)) @@ -1070,7 +1070,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); } - else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { + else if ((do_light == false) || (ob->dtx & OB_DRAWWIRE)) { const int use_depth = (v3d->flag & V3D_ZBUF_SELECT) || !(ob->mode & OB_MODE_WEIGHT_PAINT); /* weight paint in solid mode, special case. focus on making the weights clear diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 15c3385f67c..8eae1571933 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -195,61 +195,61 @@ static bool check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) return false; } -static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) +static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) { if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) - return 0; + return false; if (G.f & G_BACKBUFSEL) - return 0; + return false; if ((vd->flag & V3D_ZBUF_SELECT) == 0) - return 1; + return true; /* if its drawing textures with zbuf sel, then don't draw dots */ if (dt == OB_TEXTURE && vd->drawtype == OB_TEXTURE) - return 0; + return false; if ((vd->drawtype >= OB_SOLID) && (vd->flag2 & V3D_SOLID_TEX)) - return 0; + return false; - return 1; + return true; } /* ************************ */ /* check for glsl drawing */ -int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt) +bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt) { if (!GPU_glsl_support()) - return 0; + return false; if (G.f & G_PICKSEL) - return 0; + return false; if (!check_object_draw_texture(scene, v3d, dt)) - return 0; + return false; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) - return 0; + return false; if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) - return 1; + return true; if (BKE_scene_use_new_shading_nodes(scene)) - return 0; + return false; return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); } -static int check_alpha_pass(Base *base) +static bool check_alpha_pass(Base *base) { if (base->flag & OB_FROMDUPLI) - return 0; + return false; if (G.f & G_PICKSEL) - return 0; + return false; if (base->object->mode & OB_MODE_ALL_PAINT) - return 0; + return false; return (base->object->dtx & OB_DRAWTRANSP); } @@ -607,10 +607,16 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char glScalef(scale * sca_x, scale * sca_y, 1.0f); if (ibuf && ibuf->rect) { + const bool use_clip = (U.glalphaclip != 1.0f); /* Setup GL params */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + if (use_clip) { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, U.glalphaclip); + } + /* Use the object color and alpha */ glColor4fv(ob->col); @@ -619,6 +625,11 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char glPixelTransferf(GL_ALPHA_SCALE, 1.0f); glDisable(GL_BLEND); + + if (use_clip) { + glDisable(GL_ALPHA_TEST); + glAlphaFunc(GL_GREATER, 0.0f); + } } if ((dflag & DRAW_CONSTCOLOR) == 0) { @@ -758,7 +769,7 @@ void view3d_cached_text_draw_add(const float co[3], memcpy(++vos, str, alloc_len); } -void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[4][4]) +void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, float mat[4][4]) { RegionView3D *rv3d = ar->regiondata; ListBase *strings = &CachedText[CachedTextLevel - 1]; @@ -1098,13 +1109,13 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, unsigned char col[4]; /* cone can't be drawn for duplicated lamps, because duplilist would be freed to */ /* the moment of view3d_draw_transp() call */ - const short is_view = (rv3d->persp == RV3D_CAMOB && v3d->camera == base->object); - const short drawcone = ((dt > OB_WIRE) && - !(G.f & G_PICKSEL) && - (la->type == LA_SPOT) && - (la->mode & LA_SHOW_CONE) && - !(base->flag & OB_FROMDUPLI) && - !is_view); + const bool is_view = (rv3d->persp == RV3D_CAMOB && v3d->camera == base->object); + const bool drawcone = ((dt > OB_WIRE) && + !(G.f & G_PICKSEL) && + (la->type == LA_SPOT) && + (la->mode & LA_SHOW_CONE) && + !(base->flag & OB_FROMDUPLI) && + !is_view); if (drawcone && !v3d->transp) { /* in this case we need to draw delayed */ @@ -1370,7 +1381,7 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, setlinestyle(0); - if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == FALSE)) { + if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == false)) { drawshadbuflimits(la, ob->obmat); } @@ -1402,20 +1413,22 @@ static void drawlamp(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } } -static void draw_limit_line(float sta, float end, unsigned int col) +static void draw_limit_line(float sta, float end, const short dflag, unsigned int col) { glBegin(GL_LINES); glVertex3f(0.0, 0.0, -sta); glVertex3f(0.0, 0.0, -end); glEnd(); - glPointSize(3.0); - glBegin(GL_POINTS); - cpack(col); - glVertex3f(0.0, 0.0, -sta); - glVertex3f(0.0, 0.0, -end); - glEnd(); - glPointSize(1.0); + if (!(dflag & DRAW_PICKING)) { + glPointSize(3.0); + glBegin(GL_POINTS); + cpack(col); + glVertex3f(0.0, 0.0, -sta); + glVertex3f(0.0, 0.0, -end); + glEnd(); + glPointSize(1.0); + } } @@ -1433,7 +1446,7 @@ static void draw_focus_cross(float dist, float size) #ifdef VIEW3D_CAMERA_BORDER_HACK unsigned char view3d_camera_border_hack_col[3]; -short view3d_camera_border_hack_test = FALSE; +bool view3d_camera_border_hack_test = false; #endif /* ****************** draw clip data *************** */ @@ -1464,7 +1477,7 @@ static void draw_bundle_sphere(void) static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, MovieTrackingObject *tracking_object, const short dflag, const unsigned char ob_wire_col[4], - int *global_track_index, int draw_selected) + int *global_track_index, bool draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingTrack *track; @@ -1619,7 +1632,7 @@ static void draw_viewport_object_reconstruction(Scene *scene, Base *base, View3D static void draw_viewport_reconstruction(Scene *scene, Base *base, View3D *v3d, MovieClip *clip, const short dflag, const unsigned char ob_wire_col[4], - int draw_selected) + const bool draw_selected) { MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object; @@ -1668,13 +1681,13 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base float vec[4][3], asp[2], shift[2], scale[3]; int i; float drawsize; - const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); + const bool is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); MovieClip *clip = BKE_object_movieclip_get(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { - draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, FALSE); - draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, TRUE); + draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, false); + draw_viewport_reconstruction(scene, base, v3d, clip, dflag, ob_wire_col, true); } #ifdef VIEW3D_CAMERA_BORDER_HACK @@ -1689,7 +1702,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base glGetFloatv(GL_CURRENT_COLOR, col); rgb_float_to_uchar(view3d_camera_border_hack_col, col); } - view3d_camera_border_hack_test = TRUE; + view3d_camera_border_hack_test = true; return; } #endif @@ -1756,10 +1769,9 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base glEnd(); } - if (dflag == 0) { - if (cam->flag & (CAM_SHOWLIMITS + CAM_SHOWMIST)) { + if ((dflag & DRAW_SCENESET) == 0) { + if (cam->flag & (CAM_SHOWLIMITS | CAM_SHOWMIST)) { float nobmat[4][4]; - World *wrld; /* draw in normalized object matrix space */ copy_m4_m4(nobmat, ob->obmat); @@ -1770,15 +1782,17 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base glMultMatrixf(nobmat); if (cam->flag & CAM_SHOWLIMITS) { - draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF); + draw_limit_line(cam->clipsta, cam->clipend, dflag, 0x77FFFF); /* qdn: was yafray only, now also enabled for Blender to be used with defocus composite node */ draw_focus_cross(BKE_camera_object_dof_distance(ob), cam->drawsize); } - wrld = scene->world; - if (cam->flag & CAM_SHOWMIST) - if (wrld) draw_limit_line(wrld->miststa, wrld->miststa + wrld->mistdist, 0xFFFFFF); - + if (cam->flag & CAM_SHOWMIST) { + World *world = scene->world; + if (world) { + draw_limit_line(world->miststa, world->miststa + world->mistdist, dflag, 0xFFFFFF); + } + } glPopMatrix(); } } @@ -1857,13 +1871,13 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, short sel) bglEnd(); } -static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int use_wcol) +static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, int actdef_wcol) { int index = ((w * lt->pntsv + v) * lt->pntsu) + u; - if (use_wcol) { + if (actdef_wcol) { float col[3]; - MDeformWeight *mdw = defvert_find_index(lt->dvert + index, use_wcol - 1); + MDeformWeight *mdw = defvert_find_index(lt->dvert + index, actdef_wcol - 1); weight_to_rgb(col, mdw ? mdw->weight : 0.0f); glColor3fv(col); @@ -1884,7 +1898,8 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) Lattice *lt = ob->data; DispList *dl; int u, v, w; - int use_wcol = FALSE, is_edit = (lt->editlatt != NULL); + int actdef_wcol = 0; + const bool is_edit = (lt->editlatt != NULL); /* now we default make displist, this will modifiers work for non animated case */ if (ob->disp.first == NULL) @@ -1897,7 +1912,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) cpack(0x004000); if (ob->defbase.first && lt->dvert) { - use_wcol = ob->actdef; + actdef_wcol = ob->actdef; glShadeModel(GL_SMOOTH); } } @@ -1911,16 +1926,16 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) int uxt = (u == 0 || u == lt->pntsu - 1); if (w && ((uxt || vxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u, v, w - 1, use_wcol); - drawlattice__point(lt, dl, u, v, w, use_wcol); + drawlattice__point(lt, dl, u, v, w - 1, actdef_wcol); + drawlattice__point(lt, dl, u, v, w, actdef_wcol); } if (v && ((uxt || wxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u, v - 1, w, use_wcol); - drawlattice__point(lt, dl, u, v, w, use_wcol); + drawlattice__point(lt, dl, u, v - 1, w, actdef_wcol); + drawlattice__point(lt, dl, u, v, w, actdef_wcol); } if (u && ((vxt || wxt) || !(lt->flag & LT_OUTSIDE))) { - drawlattice__point(lt, dl, u - 1, v, w, use_wcol); - drawlattice__point(lt, dl, u, v, w, use_wcol); + drawlattice__point(lt, dl, u - 1, v, w, actdef_wcol); + drawlattice__point(lt, dl, u, v, w, actdef_wcol); } } } @@ -1928,7 +1943,7 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) glEnd(); /* restoration for weight colors */ - if (use_wcol) + if (actdef_wcol) glShadeModel(GL_FLAT); if (is_edit) { @@ -2422,7 +2437,7 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba /* double lookup */ data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX); - if ((data.orig_index_mf_to_mpoly && data.orig_index_mp_to_orig) == FALSE) { + if ((data.orig_index_mf_to_mpoly && data.orig_index_mp_to_orig) == false) { data.orig_index_mf_to_mpoly = data.orig_index_mp_to_orig = NULL; } @@ -2685,7 +2700,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS if (unit->system) { bUnit_AsString(numstr, sizeof(numstr), len_v3v3(v1, v2) * unit->scale_length, 3, - unit->system, B_UNIT_LENGTH, do_split, FALSE); + unit->system, B_UNIT_LENGTH, do_split, false); } else { sprintf(numstr, conv_float, len_v3v3(v1, v2)); @@ -2708,7 +2723,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS if (unit->system) { \ bUnit_AsString(numstr, sizeof(numstr), \ (double)(area * unit->scale_length * unit->scale_length), \ - 3, unit->system, B_UNIT_AREA, do_split, FALSE); \ + 3, unit->system, B_UNIT_AREA, do_split, false); \ view3d_cached_text_draw_add(vmid, numstr, 0, \ /* Metric system uses unicode "squared" sign! */ \ txt_flag ^ V3D_CACHE_TEXT_ASCII, col); \ @@ -2769,7 +2784,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS if (is_face_sel || do_moving) { BMIter liter; BMLoop *loop; - int is_first = TRUE; + bool is_first = true; BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) { if (is_face_sel || (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) { @@ -2785,7 +2800,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_mat3_m4_v3(ob->obmat, v1); mul_mat3_m4_v3(ob->obmat, v2); } - is_first = FALSE; + is_first = false; } if (do_global) { @@ -2892,7 +2907,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, { Mesh *me = ob->data; - BMFace *efa_act = BM_active_face_get(em->bm, FALSE, FALSE); /* annoying but active faces is stored differently */ + BMFace *efa_act = BM_active_face_get(em->bm, false, false); /* annoying but active faces is stored differently */ BMEdge *eed_act = NULL; BMVert *eve_act = NULL; @@ -3100,8 +3115,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm) { - if ((v3d->transp == FALSE) && /* not when we draw the transparent pass */ - (ob->mode & OB_MODE_ALL_PAINT) == FALSE) /* not when painting (its distracting) - campbell */ + if ((v3d->transp == false) && /* not when we draw the transparent pass */ + (ob->mode & OB_MODE_ALL_PAINT) == false) /* not when painting (its distracting) - campbell */ { glLineWidth(UI_GetThemeValuef(TH_OUTLINE_WIDTH) * 2.0f); glDepthMask(0); @@ -3358,14 +3373,15 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } /* returns 1 if nothing was drawn, for detecting to draw an object center */ -static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const unsigned char ob_wire_col[4], const short dflag) +static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const unsigned char ob_wire_col[4], const short dflag) { Object *ob = base->object; Object *obedit = scene->obedit; Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; - int do_alpha_after = FALSE, drawlinked = 0, retval = 0, glsl, check_alpha, i; + int i; + bool do_alpha_after = false, drawlinked = false, retval = false; /* If we are drawing shadows and any of the materials don't cast a shadow, * then don't draw the object */ @@ -3373,7 +3389,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D for (i = 0; i < ob->totcol; ++i) { Material *ma = give_current_material(ob, i); if (ma && !(ma->mode & MA_SHADBUF)) { - return 1; + return true; } } } @@ -3381,7 +3397,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D if (obedit && ob != obedit && ob->data == obedit->data) { if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {} else if (ob->modifiers.first || obedit->modifiers.first) {} - else drawlinked = 1; + else drawlinked = true; } /* backface culling */ @@ -3400,7 +3416,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D scene->customdata_mask); if (dt > OB_WIRE) { - glsl = draw_glsl_material(scene, ob, v3d, dt); + const bool glsl = draw_glsl_material(scene, ob, v3d, dt); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); } @@ -3415,8 +3431,8 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else { /* ob->bb was set by derived mesh system, do NULL check just to be sure */ if (me->totpoly <= 4 || (!ob->bb || ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) { - glsl = draw_glsl_material(scene, ob, v3d, dt); - check_alpha = check_alpha_pass(base); + const bool glsl = draw_glsl_material(scene, ob, v3d, dt); + const bool check_alpha = check_alpha_pass(base); if (dt == OB_SOLID || glsl) { GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, @@ -3427,7 +3443,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D GPU_end_object_materials(); - if (me->totvert == 0) retval = 1; + if (me->totvert == 0) retval = true; } } @@ -3457,11 +3473,11 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D /* ************** DRAW DISPLIST ****************** */ -static int draw_index_wire = 1; -static int index3_nors_incr = 1; +static bool draw_index_wire = true; +static bool index3_nors_incr = true; /* returns 1 when nothing was drawn */ -static int drawDispListwire(ListBase *dlbase) +static bool drawDispListwire(ListBase *dlbase) { DispList *dl; int parts, nr; @@ -3551,11 +3567,11 @@ static int drawDispListwire(ListBase *dlbase) glDisableClientState(GL_VERTEX_ARRAY); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - return 0; + return false; } static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag, - const unsigned char ob_wire_col[4], int use_glsl) + const unsigned char ob_wire_col[4], const bool use_glsl) { DispList *dl; GPUVertexAttribs gattribs; @@ -3680,14 +3696,14 @@ static void drawCurveDMWired(Object *ob) dm->drawEdges(dm, 1, 0); } -/* return 1 when nothing was drawn */ -static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt) +/* return true when nothing was drawn */ +static bool drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, const char dt) { Object *ob = base->object; DerivedMesh *dm = ob->derivedFinal; if (!dm) { - return 1; + return true; } if (dt > OB_WIRE && dm->getNumTessFaces(dm)) { @@ -3709,15 +3725,15 @@ static int drawCurveDerivedMesh(Scene *scene, View3D *v3d, RegionView3D *rv3d, B drawCurveDMWired(ob); } - return 0; + return false; } /** * Only called by #drawDispList * \return 1 when nothing was drawn */ -static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const short dflag, const unsigned char ob_wire_col[4]) +static bool drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; ListBase *lb = NULL; @@ -3726,8 +3742,8 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d const short render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE); const short solid = (dt > OB_WIRE); - if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) { - return FALSE; + if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == false) { + return false; } switch (ob->type) { @@ -3740,45 +3756,45 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d if (solid) { dl = lb->first; if (dl == NULL) { - return TRUE; + return true; } if (dl->nors == NULL) BKE_displist_normals_add(lb); - index3_nors_incr = 0; + index3_nors_incr = false; - if (BKE_displist_has_faces(lb) == 0) { + if (BKE_displist_has_faces(lb) == false) { if (!render_only) { - draw_index_wire = 0; + draw_index_wire = false; drawDispListwire(lb); - draw_index_wire = 1; + draw_index_wire = true; } } else { if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, TRUE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, FALSE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } if (cu->editnurb && cu->bevobj == NULL && cu->taperobj == NULL && cu->ext1 == 0.0f && cu->ext2 == 0.0f) { cpack(0); - draw_index_wire = 0; + draw_index_wire = false; drawDispListwire(lb); - draw_index_wire = 1; + draw_index_wire = true; } } - index3_nors_incr = 1; + index3_nors_incr = true; } else { if (!render_only || (render_only && BKE_displist_has_faces(lb))) { int retval; - draw_index_wire = 0; + draw_index_wire = false; retval = drawDispListwire(lb); - draw_index_wire = 1; + draw_index_wire = true; return retval; } } @@ -3790,19 +3806,19 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d if (solid) { dl = lb->first; if (dl == NULL) { - return TRUE; + return true; } if (dl->nors == NULL) BKE_displist_normals_add(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, TRUE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, FALSE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } } @@ -3816,19 +3832,19 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d lb = &ob->disp; if (lb->first == NULL) BKE_displist_make_mball(scene, ob); if (lb->first == NULL) { - return TRUE; + return true; } if (solid) { if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, TRUE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, true); GPU_end_object_materials(); } else { GPU_begin_object_materials(v3d, rv3d, scene, ob, 0, NULL); - drawDispListsolid(lb, ob, dflag, ob_wire_col, FALSE); + drawDispListsolid(lb, ob, dflag, ob_wire_col, false); GPU_end_object_materials(); } } @@ -3842,10 +3858,10 @@ static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d return FALSE; } -static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const short dflag, const unsigned char ob_wire_col[4]) +static bool drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const short dflag, const unsigned char ob_wire_col[4]) { - int retval; + bool retval; /* backface culling */ if (v3d->flag2 & V3D_BACKFACE_CULLING) { @@ -5532,11 +5548,11 @@ static void drawspiral(const float cent[3], float rad, float tmat[4][4], int sta float vec[3], vx[3], vy[3]; const float tot_inv = (1.0f / (float)CIRCLE_RESOL); int a; - char inverse = FALSE; + bool inverse = false; float x, y, fac; if (start < 0) { - inverse = TRUE; + inverse = true; start = -start; } @@ -5660,9 +5676,9 @@ static void drawcone(const float vec[3], float radius, float height, float tmat[ glEnd(); } -/* return TRUE if nothing was drawn */ -static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, - const char dt, const short dflag, const unsigned char ob_wire_col[4]) +/* return true if nothing was drawn */ +static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, + const char dt, const short dflag, const unsigned char ob_wire_col[4]) { Object *ob = base->object; MetaBall *mb; @@ -5690,11 +5706,11 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, } if (ml == NULL) { - return TRUE; + return true; } if (v3d->flag2 & V3D_RENDER_OVERRIDE) { - return FALSE; + return false; } invert_m4_m4(imat, rv3d->viewmatob); @@ -5738,7 +5754,7 @@ static int drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, ml = ml->next; } - return FALSE; + return false; } static void draw_forcefield(Object *ob, RegionView3D *rv3d, @@ -6090,24 +6106,24 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; DerivedMesh *dm = ob->derivedFinal; - int hasfaces = 0; + bool has_faces = false; if (dm) { - hasfaces = dm->getNumTessFaces(dm); + has_faces = dm->getNumTessFaces(dm); } else { - hasfaces = BKE_displist_has_faces(&ob->disp); + has_faces = BKE_displist_has_faces(&ob->disp); } - if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { - draw_index_wire = 0; + if (has_faces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { + draw_index_wire = false; if (dm) { draw_mesh_object_outline(v3d, ob, dm); } else { drawDispListwire(&ob->disp); } - draw_index_wire = 1; + draw_index_wire = true; } } else if (ob->type == OB_MBALL) { @@ -6118,7 +6134,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } else if (ob->type == OB_ARMATURE) { if (!(ob->mode & OB_MODE_POSE && base == scene->basact)) - draw_armature(scene, v3d, ar, base, OB_WIRE, FALSE, ob_wire_col, TRUE); + draw_armature(scene, v3d, ar, base, OB_WIRE, 0, ob_wire_col, true); } glLineWidth(1.0); @@ -6143,7 +6159,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign Curve *cu = ob->data; if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { if (ob->type == OB_CURVE) - draw_index_wire = 0; + draw_index_wire = false; if (ob->derivedFinal) { drawCurveDMWired(ob); @@ -6153,7 +6169,7 @@ static void draw_wire_extra(Scene *scene, RegionView3D *rv3d, Object *ob, unsign } if (ob->type == OB_CURVE) - draw_index_wire = 1; + draw_index_wire = true; } } else if (ob->type == OB_MBALL) { @@ -6657,7 +6673,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short else { if (dt > OB_WIRE) GPU_enable_material(0, NULL); /* we use default material */ - empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, FALSE); + empty_object = draw_armature(scene, v3d, ar, base, dt, dflag, ob_wire_col, false); if (dt > OB_WIRE) GPU_disable_material(); } diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 70d3857601f..3933d8e4753 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -105,7 +105,7 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl return numpoints; } -static int convex(const float p0[3], const float up[3], const float a[3], const float b[3]) +static bool convex(const float p0[3], const float up[3], const float a[3], const float b[3]) { /* Vec3 va = a-p0, vb = b-p0; */ float va[3], vb[3], tmp[3]; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 340744839d2..ef16090c39d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -159,7 +159,7 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) /* ideally would return an rv3d but in some cases the region is needed too * so return that, the caller can then access the ar->regiondata */ -int ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) +bool ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) { ScrArea *sa = CTX_wm_area(C); @@ -175,7 +175,7 @@ int ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) if (rv3d && rv3d->viewlock == 0) { *r_v3d = v3d; *r_ar = ar; - return 1; + return true; } else { ARegion *ar_unlock_user = NULL; @@ -198,19 +198,19 @@ int ED_view3d_context_user_region(bContext *C, View3D **r_v3d, ARegion **r_ar) if (ar_unlock_user) { *r_v3d = v3d; *r_ar = ar_unlock_user; - return 1; + return true; } if (ar_unlock) { *r_v3d = v3d; *r_ar = ar_unlock; - return 1; + return true; } } } } - return 0; + return false; } /* Most of the time this isn't needed since you could assume the view matrix was diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index bb286194992..533bb30d8d1 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -158,7 +158,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float TransformProperties *tfp; float median[NBR_TRANSFORM_PROPERTIES], ve_median[NBR_TRANSFORM_PROPERTIES]; int tot, totedgedata, totcurvedata, totlattdata, totskinradius, totcurvebweight; - int meshdata = FALSE; + bool has_meshdata = false; char defstr[320]; PointerRNA data_ptr; @@ -253,7 +253,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } } - meshdata = totedgedata || totskinradius; + has_meshdata = (totedgedata || totskinradius); } else if (ob->type == OB_CURVE || ob->type == OB_SURF) { Curve *cu = ob->data; @@ -360,7 +360,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float if (v3d->flag & V3D_GLOBAL_STATS) mul_m4_v3(ob->obmat, &median[LOC_X]); - if (meshdata) { + if (has_meshdata) { if (totedgedata) { median[M_CREASE] /= (float)totedgedata; median[M_WEIGHT] /= (float)totedgedata; @@ -428,7 +428,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float uiBlockEndAlign(block); /* Meshes... */ - if (meshdata) { + if (has_meshdata) { if (totedgedata) { /* customdata layer added on demand */ uiDefButF(block, NUM, B_OBJECTPANELMEDIAN, @@ -808,8 +808,8 @@ static void editvert_mirror_update(Object *ob, BMVert *eve, int def_nr, int inde if (def_nr == -1) { /* all vgroups, add groups where neded */ int flip_map_len; - int *flip_map = defgroup_flip_map(ob, &flip_map_len, TRUE); - defvert_sync_mapped(dvert_dst, dvert_src, flip_map, flip_map_len, TRUE); + int *flip_map = defgroup_flip_map(ob, &flip_map_len, true); + defvert_sync_mapped(dvert_dst, dvert_src, flip_map, flip_map_len, true); MEM_freeN(flip_map); } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e27f00de748..66047b6e8f4 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -219,20 +219,20 @@ void ED_view3d_clipping_enable(void) } } -static int view3d_clipping_test(const float co[3], float clip[6][4]) +static bool view3d_clipping_test(const float co[3], float clip[6][4]) { if (0.0f < clip[0][3] + dot_v3v3(co, clip[0])) if (0.0f < clip[1][3] + dot_v3v3(co, clip[1])) if (0.0f < clip[2][3] + dot_v3v3(co, clip[2])) if (0.0f < clip[3][3] + dot_v3v3(co, clip[3])) - return 0; + return false; - return 1; + return true; } /* for 'local' ED_view3d_clipping_local must run first * then all comparisons can be done in localspace */ -int ED_view3d_clipping_test(RegionView3D *rv3d, const float co[3], const bool is_local) +bool ED_view3d_clipping_test(RegionView3D *rv3d, const float co[3], const bool is_local) { return view3d_clipping_test(co, is_local ? rv3d->clip_local : rv3d->clip); } @@ -1002,7 +1002,7 @@ void ED_view3d_calc_camera_border_size(Scene *scene, ARegion *ar, View3D *v3d, R { rctf viewborder; - view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, TRUE, TRUE); + view3d_camera_border(scene, ar, v3d, rv3d, &viewborder, true, true); r_size[0] = BLI_rctf_size_x(&viewborder); r_size[1] = BLI_rctf_size_y(&viewborder); } @@ -1099,7 +1099,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) if (v3d->camera->type == OB_CAMERA) ca = v3d->camera->data; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); /* the offsets */ x1 = viewborder.xmin; y1 = viewborder.ymin; @@ -1150,10 +1150,10 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) glRectf(x1i, y1i, x2i, y2i); #ifdef VIEW3D_CAMERA_BORDER_HACK - if (view3d_camera_border_hack_test == TRUE) { + if (view3d_camera_border_hack_test == true) { glColor3ubv(view3d_camera_border_hack_col); glRectf(x1i + 1, y1i + 1, x2i - 1, y2i - 1); - view3d_camera_border_hack_test = FALSE; + view3d_camera_border_hack_test = false; } #endif @@ -1433,6 +1433,13 @@ void view3d_opengl_read_pixels(ARegion *ar, int x, int y, int w, int h, int form } } +/* XXX depth reading exception, for code not using gpu offscreen */ +static void view3d_opengl_read_Z_pixels(ARegion *ar, int x, int y, int w, int h, int format, int type, void *data) +{ + + glReadPixels(ar->winrct.xmin + x, ar->winrct.ymin + y, w, h, format, type, data); +} + void view3d_validate_backbuf(ViewContext *vc) { if (vc->v3d->flag & V3D_INVALID_BACKBUF) @@ -1590,7 +1597,7 @@ exit: /* ************************************************************* */ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, - const short do_foreground, const short do_camera_frame) + const bool do_foreground, const bool do_camera_frame) { RegionView3D *rv3d = ar->regiondata; BGpic *bgpic; @@ -1688,7 +1695,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, if (do_camera_frame) { rctf vb; - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, false); x1 = vb.xmin; y1 = vb.ymin; x2 = vb.xmax; @@ -1819,7 +1826,12 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, glPixelZoom(zoomx, zoomy); glColor4f(1.0f, 1.0f, 1.0f, 1.0f - bgpic->blend); - glaDrawPixelsAuto(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_LINEAR, ibuf->rect); + + /* could not use glaDrawPixelsAuto because it could fallback to + * glaDrawPixelsSafe in some cases, which will end up in misssing + * alpha transparency for the background image (sergey) + */ + glaDrawPixelsTex(x1, y1, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, GL_NEAREST, ibuf->rect); glPixelZoom(1.0, 1.0); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); @@ -1843,7 +1855,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, } static void view3d_draw_bgpic_test(Scene *scene, ARegion *ar, View3D *v3d, - const short do_foreground, const short do_camera_frame) + const bool do_foreground, const bool do_camera_frame) { RegionView3D *rv3d = ar->regiondata; @@ -1990,7 +2002,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas if (base->object->restrictflag & OB_RESTRICT_VIEW) return; tbase.flag = OB_FROMDUPLI | base->flag; - lb = object_duplilist(scene, base->object, FALSE); + lb = object_duplilist(scene, base->object, false); // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ dob = dupli_step(lb->first); @@ -2020,7 +2032,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas /* generate displist, test for new object */ if (dob_prev && dob_prev->ob != dob->ob) { - if (use_displist == TRUE) + if (use_displist == true) glDeleteLists(displist, 1); use_displist = -1; @@ -2042,7 +2054,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas !(bb_tmp = BKE_object_boundbox_get(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name + 2); - use_displist = FALSE; + use_displist = false; } else { // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2); @@ -2058,7 +2070,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas draw_object(scene, ar, v3d, &tbase, DRAW_CONSTCOLOR); glEndList(); - use_displist = TRUE; + use_displist = true; BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } @@ -2099,6 +2111,7 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas draw_dupli_objects_color(scene, ar, v3d, base, color); } +/* XXX warning, not using gpu offscreen here */ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) { int x, y, w, h; @@ -2125,7 +2138,7 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) MEM_freeN(d->depths); d->depths = NULL; - d->damaged = FALSE; + d->damaged = false; } else if (d->w != w || d->h != h || @@ -2144,13 +2157,14 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset"); - d->damaged = TRUE; + d->damaged = true; } if (d->damaged) { - view3d_opengl_read_pixels(ar, d->x, d->y, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); + /* XXX using special function here, it doesn't use the gpu offscreen system */ + view3d_opengl_read_Z_pixels(ar, d->x, d->y, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); glGetDoublev(GL_DEPTH_RANGE, d->depth_range); - d->damaged = FALSE; + d->damaged = false; } } @@ -2172,14 +2186,14 @@ void ED_view3d_depth_update(ARegion *ar) if (d->depths) MEM_freeN(d->depths); d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); - d->damaged = 1; + d->damaged = true; } if (d->damaged) { view3d_opengl_read_pixels(ar, 0, 0, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); glGetDoublev(GL_DEPTH_RANGE, d->depth_range); - d->damaged = 0; + d->damaged = false; } } } @@ -2228,7 +2242,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) glEnable(GL_DEPTH_TEST); if (v3d->flag2 & V3D_SHOW_GPENCIL) { - draw_gpencil_view3d(scene, v3d, ar, TRUE); + draw_gpencil_view3d(scene, v3d, ar, true); } v3d->zbuf = zbuf; @@ -2410,7 +2424,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) if (ob->transflag & OB_DUPLI) { DupliObject *dob; - ListBase *lb = object_duplilist(scene, ob, FALSE); + ListBase *lb = object_duplilist(scene, ob, false); for (dob = lb->first; dob; dob = dob->next) if (dob->ob->type == OB_LAMP) @@ -2449,7 +2463,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) invert_m4_m4(rv3d.persinv, rv3d.viewinv); /* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */ - ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE); + ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, false); GPU_lamp_shadow_buffer_unbind(shadow->lamp); v3d->drawtype = drawtype; @@ -2597,7 +2611,7 @@ void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d) * stuff like shadow buffers */ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, - float viewmat[4][4], float winmat[4][4], int do_bgpic) + float viewmat[4][4], float winmat[4][4], bool do_bgpic) { RegionView3D *rv3d = ar->regiondata; Base *base; @@ -2648,7 +2662,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* important to do before clipping */ if (do_bgpic) { - view3d_draw_bgpic_test(scene, ar, v3d, FALSE, FALSE); + view3d_draw_bgpic_test(scene, ar, v3d, false, false); } if (rv3d->rflag & RV3D_CLIPPING) @@ -2682,7 +2696,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* must be before xray draw which clears the depth buffer */ if (v3d->flag2 & V3D_SHOW_GPENCIL) { if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - draw_gpencil_view3d(scene, v3d, ar, TRUE); + draw_gpencil_view3d(scene, v3d, ar, true); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -2696,7 +2710,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, /* important to do after clipping */ if (do_bgpic) { - view3d_draw_bgpic_test(scene, ar, v3d, TRUE, FALSE); + view3d_draw_bgpic_test(scene, ar, v3d, true, false); } /* cleanup */ @@ -2711,7 +2725,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, if (v3d->flag2 & V3D_SHOW_GPENCIL) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ - draw_gpencil_view3d(scene, v3d, ar, FALSE); + draw_gpencil_view3d(scene, v3d, ar, false); } /* freeing the images again here could be done after the operator runs, leaving for now */ @@ -2753,7 +2767,7 @@ static void offscreen_imbuf_add_sky(ImBuf *ibuf, Scene *scene) /* utility func for ED_view3d_draw_offscreen */ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, int sizex, int sizey, unsigned int flag, - int draw_background, int alpha_mode, char err_out[256]) + bool draw_background, int alpha_mode, char err_out[256]) { RegionView3D *rv3d = ar->regiondata; ImBuf *ibuf; @@ -2811,7 +2825,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in /* creates own 3d views, used by the sequencer */ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, - int use_solid_tex, int draw_background, int alpha_mode, char err_out[256]) + bool use_solid_tex, bool draw_background, int alpha_mode, char err_out[256]) { View3D v3d = {NULL}; ARegion ar = {NULL}; @@ -2917,7 +2931,7 @@ static void draw_viewport_fps(Scene *scene, rcti *rect) static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const char **grid_unit); -static int view3d_main_area_do_render_draw(const bContext *C) +static bool view3d_main_area_do_render_draw(const bContext *C) { Scene *scene = CTX_data_scene(C); RenderEngineType *type = RE_engines_find(scene->r.engine); @@ -2925,7 +2939,7 @@ static int view3d_main_area_do_render_draw(const bContext *C) return (type && type->view_update && type->view_draw); } -static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw_border) +static bool view3d_main_area_draw_engine(const bContext *C, ARegion *ar, const bool draw_border) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); @@ -2940,9 +2954,9 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw type = RE_engines_find(scene->r.engine); if (!(type->view_update && type->view_draw)) - return 0; + return false; - engine = RE_engine_create_ex(type, TRUE); + engine = RE_engine_create_ex(type, true); engine->tile_x = scene->r.tilex; engine->tile_y = scene->r.tiley; @@ -2964,7 +2978,7 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw rcti cliprct; if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, FALSE); + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); cliprct.xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder); cliprct.ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder); @@ -2992,15 +3006,16 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(cliprct.xmin, cliprct.ymin, BLI_rcti_size_x(&cliprct), BLI_rcti_size_y(&cliprct)); } - else - return 0; + else { + return false; + } } glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (v3d->flag & V3D_DISPBGPICS) - view3d_draw_bgpic(scene, ar, v3d, FALSE, TRUE); + view3d_draw_bgpic(scene, ar, v3d, false, true); else fdrawcheckerboard(0, 0, ar->winx, ar->winy); @@ -3009,14 +3024,14 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw type->view_draw(rv3d->render_engine, C); if (v3d->flag & V3D_DISPBGPICS) - view3d_draw_bgpic(scene, ar, v3d, TRUE, TRUE); + view3d_draw_bgpic(scene, ar, v3d, true, true); if (draw_border) { /* restore scissor as it was before */ glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); } - return 1; + return true; } static void view3d_main_area_draw_engine_info(RegionView3D *rv3d, ARegion *ar) @@ -3045,7 +3060,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) GLubyte grid_col[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][4]; static float grid_pos[VIEWGRAD_RES_X][VIEWGRAD_RES_Y][3]; static GLushort indices[VIEWGRAD_RES_X - 1][VIEWGRAD_RES_X - 1][4]; - static char buf_calculated = FALSE; + static bool buf_calculated = false; IMB_colormanagement_pixel_to_display_space_v3(col_hor, &scene->world->horr, &scene->view_settings, &scene->display_settings); @@ -3084,7 +3099,7 @@ static void view3d_main_area_clear(Scene *scene, View3D *v3d, ARegion *ar) } } - buf_calculated = TRUE; + buf_calculated = true; } for (x = 0; x < VIEWGRAD_RES_X; x++) { @@ -3238,7 +3253,6 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* enables anti-aliasing for 3D view drawing */ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) { - // if (!(U.gameflags & USER_DISABLE_AA)) glEnable(GL_MULTISAMPLE_ARB); } @@ -3271,7 +3285,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } } - view3d_draw_bgpic_test(scene, ar, v3d, FALSE, TRUE); + view3d_draw_bgpic_test(scene, ar, v3d, false, true); if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(rv3d); @@ -3335,7 +3349,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const if (v3d->flag2 & V3D_SHOW_GPENCIL) { /* must be before xray draw which clears the depth buffer */ if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - draw_gpencil_view3d(scene, v3d, ar, TRUE); + draw_gpencil_view3d(scene, v3d, ar, true); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -3350,13 +3364,12 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const ED_view3d_clipping_disable(); /* important to do after clipping */ - view3d_draw_bgpic_test(scene, ar, v3d, TRUE, TRUE); + view3d_draw_bgpic_test(scene, ar, v3d, true, true); BIF_draw_manipulator(C); /* Disable back anti-aliasing */ if (U.ogl_multisamples != USER_MULTISAMPLE_NONE) { - // if (!(U.gameflags & USER_DISABLE_AA)) glDisable(GL_MULTISAMPLE_ARB); } @@ -3404,7 +3417,7 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha if (v3d->flag2 & V3D_SHOW_GPENCIL) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ - draw_gpencil_view3d(scene, v3d, ar, FALSE); + draw_gpencil_view3d(scene, v3d, ar, false); } if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -3456,12 +3469,12 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); const char *grid_unit = NULL; - int draw_border = FALSE; + bool draw_border = false; if (rv3d->persp == RV3D_CAMOB) - draw_border = scene->r.mode & R_BORDER; + draw_border = (scene->r.mode & R_BORDER) != 0; else - draw_border = v3d->flag2 & V3D_RENDER_BORDER; + draw_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0; /* draw viewport using opengl */ if (v3d->drawtype != OB_RENDER || !view3d_main_area_do_render_draw(C) || draw_border) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a8e9c8b6cba..9d9dd0535ff 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -88,7 +88,7 @@ /* ********************** view3d_edit: view manipulations ********************* */ -int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) +bool ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) { return ((v3d->camera) && (v3d->camera->id.lib == NULL) && @@ -105,8 +105,8 @@ void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) } } -/* return TRUE if the camera is moved */ -int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) +/* return true if the camera is moved */ +bool ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { ObjectTfmProtectedChannels obtfm; @@ -130,7 +130,7 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); BKE_object_tfm_protected_backup(root_parent, &obtfm); - BKE_object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(root_parent, parent_mat, true, false); BKE_object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); ob_update = v3d->camera; @@ -149,10 +149,10 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); } - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -309,7 +309,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar) } /* 'clip' is used to know if our clip setting has changed */ -void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip) +void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, bool do_clip) { ARegion *ar_sync = NULL; RegionView3D *rv3d = ar->regiondata; @@ -323,7 +323,7 @@ void ED_view3d_quadview_update(ScrArea *sa, ARegion *ar, short do_clip) viewlock = 0; else if ((viewlock & RV3D_BOXVIEW) == 0) { viewlock &= ~RV3D_BOXCLIP; - do_clip = TRUE; + do_clip = true; } for (; ar; ar = ar->prev) { @@ -367,12 +367,12 @@ typedef struct ViewOpsData { float mousevec[3]; /* dolly only */ float reverse, dist0, camzoom0; float grid, far; - short axis_snap; /* view rotate only */ + bool axis_snap; /* view rotate only */ float zfac; /* use for orbit selection and auto-dist */ float ofs[3], dyn_ofs[3]; - short use_dyn_ofs; + bool use_dyn_ofs; int origx, origy, oldx, oldy; int origkey; /* the key that triggered the operator */ @@ -432,7 +432,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even vod->origx = vod->oldx = event->x; vod->origy = vod->oldy = event->y; vod->origkey = event->type; /* the key that triggered the operator. */ - vod->use_dyn_ofs = (U.uiflag & USER_ORBIT_SELECTION) ? 1 : 0; + vod->use_dyn_ofs = (U.uiflag & USER_ORBIT_SELECTION) != 0; copy_v3_v3(vod->ofs, rv3d->ofs); if (vod->use_dyn_ofs) { @@ -454,10 +454,11 @@ static void viewops_data_create(bContext *C, wmOperator *op, const wmEvent *even negate_v3_v3(vod->dyn_ofs, lastofs); } else if (U.uiflag & USER_ZBUF_ORBIT) { + Scene *scene = CTX_data_scene(C); view3d_operator_needs_opengl(C); /* needed for zbuf drawing */ - if ((vod->use_dyn_ofs = ED_view3d_autodist(CTX_data_scene(C), vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true))) { + if ((vod->use_dyn_ofs = ED_view3d_autodist(scene, vod->ar, vod->v3d, event->mval, vod->dyn_ofs, true))) { if (rv3d->is_persp) { float my_origin[3]; /* original G.vd->ofs */ float my_pivot[3]; /* view */ @@ -856,11 +857,11 @@ static int viewrotate_modal(bContext *C, wmOperator *op, const wmEvent *event) event_code = VIEW_CONFIRM; break; case VIEWROT_MODAL_AXIS_SNAP_ENABLE: - vod->axis_snap = TRUE; + vod->axis_snap = true; event_code = VIEW_APPLY; break; case VIEWROT_MODAL_AXIS_SNAP_DISABLE: - vod->axis_snap = FALSE; + vod->axis_snap = false; event_code = VIEW_APPLY; break; case VIEWROT_MODAL_SWITCH_ZOOM: @@ -1703,7 +1704,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) static void viewzoom_apply(ViewOpsData *vod, const int x, const int y, const short viewzoom, const short zoom_invert) { float zfac = 1.0; - short use_cam_zoom; + bool use_cam_zoom; use_cam_zoom = (vod->rv3d->persp == RV3D_CAMOB) && !(vod->rv3d->is_persp && ED_view3d_camera_lock_check(vod->v3d, vod->rv3d)); @@ -1845,9 +1846,9 @@ static int viewzoom_exec(bContext *C, wmOperator *op) RegionView3D *rv3d; ScrArea *sa; ARegion *ar; - short use_cam_zoom; + bool use_cam_zoom; - int delta = RNA_int_get(op->ptr, "delta"); + const int delta = RNA_int_get(op->ptr, "delta"); int mx, my; if (op->customdata) { @@ -2108,7 +2109,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) ARegion *ar; float mousevec[3]; - int delta = RNA_int_get(op->ptr, "delta"); + const int delta = RNA_int_get(op->ptr, "delta"); if (op->customdata) { ViewOpsData *vod = op->customdata; @@ -2176,7 +2177,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) } if (event->type == MOUSEZOOM) { - /* Bypass Zoom invert flag for track pads (pass FALSE always) */ + /* Bypass Zoom invert flag for track pads (pass false always) */ if (U.uiflag & USER_ZOOM_HORIZ) { vod->origx = vod->oldx = event->x; @@ -2253,7 +2254,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot) static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, const float min[3], const float max[3], - int ok_dist) + bool ok_dist) { RegionView3D *rv3d = ar->regiondata; float afm[3]; @@ -2292,7 +2293,7 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, else { /* ortho */ if (size < 0.0001f) { /* bounding box was a single point so do not zoom */ - ok_dist = 0; + ok_dist = false; } else { /* adjust zoom so it looks nicer */ @@ -2327,7 +2328,7 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar, /* same as view3d_from_minmax but for all regions (except cameras) */ static void view3d_from_minmax_multi(bContext *C, View3D *v3d, const float min[3], const float max[3], - const int ok_dist) + const bool ok_dist) { ScrArea *sa = CTX_wm_area(C); ARegion *ar; @@ -2350,14 +2351,14 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in Scene *scene = CTX_data_scene(C); Base *base; float *curs; - const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); - const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || - /* any one of the regions may be locked */ - (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); - int center = RNA_boolean_get(op->ptr, "center"); + const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); + const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || + /* any one of the regions may be locked */ + (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); + const bool center = RNA_boolean_get(op->ptr, "center"); float min[3], max[3]; - int ok = 1, onedone = FALSE; + bool change = false; if (center) { /* in 2.4x this also move the cursor to (0, 0, 0) (with shift+c). */ @@ -2372,16 +2373,16 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in for (base = scene->base.first; base; base = base->next) { if (BASE_VISIBLE(v3d, base)) { - onedone = TRUE; + change = true; if (skip_camera && base->object == v3d->camera) { continue; } - BKE_object_minmax(base->object, min, max, FALSE); + BKE_object_minmax(base->object, min, max, false); } } - if (!onedone) { + if (!change) { ED_region_tag_redraw(ar); /* TODO - should this be cancel? * I think no, because we always move the cursor, with or without @@ -2393,15 +2394,11 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in return OPERATOR_FINISHED; } - if (ok == 0) { - return OPERATOR_FINISHED; - } - if (use_all_regions) { - view3d_from_minmax_multi(C, v3d, min, max, TRUE); + view3d_from_minmax_multi(C, v3d, min, max, true); } else { - view3d_from_minmax(C, v3d, ar, min, max, TRUE); + view3d_from_minmax(C, v3d, ar, min, max, true); } return OPERATOR_FINISHED; @@ -2438,11 +2435,11 @@ static int viewselected_exec(bContext *C, wmOperator *op) Object *ob = OBACT; Object *obedit = CTX_data_edit_object(C); float min[3], max[3]; - int ok = 0, ok_dist = 1; - const short use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); - const short skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || - /* any one of the regions may be locked */ - (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); + bool ok = false, ok_dist = true; + const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); + const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) || + /* any one of the regions may be locked */ + (use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA)); INIT_MINMAX(min, max); @@ -2505,8 +2502,8 @@ static int viewselected_exec(bContext *C, wmOperator *op) } /* account for duplis */ - if (BKE_object_minmax_dupli(scene, base->object, min, max, FALSE) == 0) - BKE_object_minmax(base->object, min, max, FALSE); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max, false) == 0) + BKE_object_minmax(base->object, min, max, false); /* use if duplis not found */ ok = 1; } @@ -2726,7 +2723,7 @@ static int render_border_exec(bContext *C, wmOperator *op) rcti rect; rctf vb, border; - int camera_only = RNA_boolean_get(op->ptr, "camera_only"); + const bool camera_only = RNA_boolean_get(op->ptr, "camera_only"); if (camera_only && rv3d->persp != RV3D_CAMOB) return OPERATOR_PASS_THROUGH; @@ -2737,7 +2734,7 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, FALSE); + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &vb, false); } else { vb.xmin = 0; @@ -3040,7 +3037,7 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot) ot->flag = 0; /* rna */ - WM_operator_properties_gesture_border(ot, FALSE); + WM_operator_properties_gesture_border(ot, false); } /* sets the view to 1:1 camera/render-pixel */ @@ -3106,7 +3103,7 @@ static EnumPropertyItem prop_view_items[] = { static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float q2, float q3, float q4, - short view, int perspo, int align_active) + short view, int perspo, bool align_active) { RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */ float new_quat[4]; @@ -3120,14 +3117,14 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, Object *obact = CTX_data_active_object(C); if (obact == NULL) { /* no active object, ignore this option */ - align_active = FALSE; + align_active = false; } else { float obact_quat[4]; float twmat[3][3]; /* same as transform manipulator when normal is set */ - ED_getTransformOrientationMatrix(C, twmat, FALSE); + ED_getTransformOrientationMatrix(C, twmat, false); mat3_to_quat(obact_quat, twmat); invert_qt(obact_quat); @@ -3137,7 +3134,7 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, } } - if (align_active == FALSE) { + if (align_active == false) { /* normal operation */ if (rv3d->viewlock) { /* only pass on if */ @@ -3186,7 +3183,8 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) RegionView3D *rv3d; Scene *scene = CTX_data_scene(C); static int perspo = RV3D_PERSP; - int viewnum, align_active, nextperspo; + int viewnum, nextperspo; + bool align_active; /* no NULL check is needed, poll checks */ ED_view3d_context_user_region(C, &v3d, &ar); @@ -3197,7 +3195,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* set this to zero, gets handled in axis_set_view */ if (rv3d->viewlock) - align_active = 0; + align_active = false; /* Use this to test if we started out with a camera */ @@ -3584,7 +3582,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) static int background_image_remove_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - int index = RNA_int_get(op->ptr, "index"); + const int index = RNA_int_get(op->ptr, "index"); BGpic *bgpic_rem = BLI_findlink(&v3d->bgpicbase, index); if (bgpic_rem) { @@ -3741,15 +3739,15 @@ void ED_view3d_cursor3d_position(bContext *C, float fp[3], const int mval[2]) } if (ED_view3d_project_float_global(ar, fp, mval_fl, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { - short depth_used = FALSE; + bool depth_used = false; if (U.uiflag & USER_ZBUF_CURSOR) { /* maybe this should be accessed some other way */ view3d_operator_needs_opengl(C); if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true)) - depth_used = TRUE; + depth_used = true; } - if (depth_used == FALSE) { + if (depth_used == false) { float dvec[3]; VECSUB2D(mval_fl, mval_fl, mval); ED_view3d_win_to_delta(ar, mval_fl, dvec, zfac); @@ -3917,7 +3915,7 @@ static float view_autodist_depth_margin(ARegion *ar, const int mval[2], int marg } /* XXX todo Zooms in on a border drawn by the user */ -int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride) +bool ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2], float mouse_worldloc[3], bool alphaoverride) { bglMats mats; /* ZBuffer depth vars */ float depth_close = FLT_MAX; @@ -3930,7 +3928,7 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2] depth_close = view_autodist_depth_margin(ar, mval, 4); if (depth_close == FLT_MAX) - return 0; + return false; cent[0] = (double)mval[0]; cent[1] = (double)mval[1]; @@ -3938,16 +3936,16 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2] if (!gluUnProject(cent[0], cent[1], depth_close, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) { - return 0; + return false; } mouse_worldloc[0] = (float)p[0]; mouse_worldloc[1] = (float)p[1]; mouse_worldloc[2] = (float)p[2]; - return 1; + return true; } -int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) +void ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) { /* Get Z Depths, needed for perspective, nice for ortho */ switch (mode) { @@ -3958,13 +3956,11 @@ int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) draw_depth_gpencil(scene, ar, v3d); break; } - - return 1; } -/* no 4x4 sampling, run view_autodist_init first */ -int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], - int margin, float *force_depth) +/* no 4x4 sampling, run #ED_view3d_autodist_init first */ +bool ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], + int margin, float *force_depth) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; @@ -3977,7 +3973,7 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl depth = view_autodist_depth_margin(ar, mval, margin); if (depth == FLT_MAX) - return 0; + return false; cent[0] = (double)mval[0]; cent[1] = (double)mval[1]; @@ -3987,23 +3983,23 @@ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldl if (!gluUnProject(cent[0], cent[1], depth, mats.modelview, mats.projection, (GLint *)mats.viewport, &p[0], &p[1], &p[2])) { - return 0; + return false; } mouse_worldloc[0] = (float)p[0]; mouse_worldloc[1] = (float)p[1]; mouse_worldloc[2] = (float)p[2]; - return 1; + return true; } -int ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth) +bool ED_view3d_autodist_depth(ARegion *ar, const int mval[2], int margin, float *depth) { *depth = view_autodist_depth_margin(ar, mval, margin); - return (*depth == FLT_MAX) ? 0 : 1; + return (*depth != FLT_MAX); } -static int depth_segment_cb(int x, int y, void *userData) +static bool depth_segment_cb(int x, int y, void *userData) { struct { ARegion *ar; int margin; float depth; } *data = userData; int mval[2]; @@ -4023,8 +4019,8 @@ static int depth_segment_cb(int x, int y, void *userData) } } -int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int mval_end[2], - int margin, float *depth) +bool ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int mval_end[2], + int margin, float *depth) { struct { ARegion *ar; int margin; float depth; } data = {NULL}; int p1[2]; @@ -4041,7 +4037,7 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m *depth = data.depth; - return (*depth == FLT_MAX) ? 0 : 1; + return (*depth != FLT_MAX); } /* problem - ofs[3] can be on same location as camera itself. @@ -4155,7 +4151,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - BKE_object_apply_mat4(ob, mat, TRUE, TRUE); + BKE_object_apply_mat4(ob, mat, true, true); } BGpic *ED_view3D_background_image_new(View3D *v3d) @@ -4198,6 +4194,6 @@ void ED_view3D_lock_clear(View3D *v3d) { v3d->ob_centre = NULL; v3d->ob_centre_bone[0] = '\0'; - v3d->ob_centre_cursor = FALSE; + v3d->ob_centre_cursor = false; v3d->flag2 &= ~V3D_LOCK_CAMERA; } diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 700027d62a2..2cedf7da725 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -78,9 +78,21 @@ enum { FLY_MODAL_FREELOOK_ENABLE, FLY_MODAL_FREELOOK_DISABLE, FLY_MODAL_SPEED, /* mousepan typically */ - }; +/* relative view axis locking - xlock, zlock */ +typedef enum eFlyPanState { + /* disabled */ + FLY_AXISLOCK_STATE_OFF = 0, + + /* enabled but not checking because mouse hasn't moved outside the margin since locking was checked an not needed + * when the mouse moves, locking is set to 2 so checks are done. */ + FLY_AXISLOCK_STATE_IDLE = 1, + + /* mouse moved and checking needed, if no view altering is done its changed back to #FLY_AXISLOCK_STATE_IDLE */ + FLY_AXISLOCK_STATE_ACTIVE = 2 +} eFlyPanState; + /* called in transform_ops.c, on each regeneration of keymaps */ void fly_modal_keymap(wmKeyConfig *keyconf) { @@ -170,11 +182,11 @@ typedef struct FlyInfo { wmTimer *timer; /* needed for redraws */ short state; - short redraw; - unsigned char use_precision; + bool redraw; + bool use_precision; /* if the user presses shift they can look about * without moving the direction there looking */ - unsigned char use_freelook; + bool use_freelook; int mval[2]; /* latest 2D mouse values */ wmNDOFMotionData *ndof; /* latest 3D mouse values */ @@ -182,14 +194,9 @@ typedef struct FlyInfo { /* fly state state */ float speed; /* the speed the view is moving per redraw */ short axis; /* Axis index to move along by default Z to move along the view */ - short pan_view; /* when true, pan the view instead of rotating */ - - /* relative view axis locking - xlock, zlock - * 0) disabled - * 1) enabled but not checking because mouse hasn't moved outside the margin since locking was checked an not needed - * when the mouse moves, locking is set to 2 so checks are done. - * 2) mouse moved and checking needed, if no view altering is done its changed back to 1 */ - short xlock, zlock; + bool pan_view; /* when true, pan the view instead of rotating */ + + eFlyPanState xlock, zlock; float xlock_momentum, zlock_momentum; /* nicer dynamics */ float grid; /* world scale 1.0 default */ @@ -208,7 +215,7 @@ typedef struct FlyInfo { /* are we flying an ortho camera in perspective view, * which was originall in ortho view? * could probably figure it out but better be explicit */ - short is_ortho_cam; + bool is_ortho_cam; void *obtfm; /* backup the objects transform */ /* compare between last state */ @@ -272,7 +279,7 @@ static void drawFlyPixel(const struct bContext *UNUSED(C), ARegion *UNUSED(ar), #define FLY_CANCEL 1 #define FLY_CONFIRM 2 -static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event) +static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); float upvec[3]; /* tmp */ @@ -294,30 +301,30 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->id.lib) { BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an external library"); - return FALSE; + return false; } if (fly->v3d->ob_centre) { BKE_report(op->reports, RPT_ERROR, "Cannot fly when the view is locked to an object"); - return FALSE; + return false; } if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->constraints.first) { BKE_report(op->reports, RPT_ERROR, "Cannot fly an object with constraints"); - return FALSE; + return false; } fly->state = FLY_RUNNING; fly->speed = 0.0f; fly->axis = 2; - fly->pan_view = FALSE; - fly->xlock = FALSE; - fly->zlock = FALSE; + fly->pan_view = false; + fly->xlock = FLY_AXISLOCK_STATE_OFF; + fly->zlock = FLY_AXISLOCK_STATE_OFF; fly->xlock_momentum = 0.0f; fly->zlock_momentum = 0.0f; fly->grid = 1.0f; - fly->use_precision = FALSE; - fly->use_freelook = FALSE; + fly->use_precision = false; + fly->use_freelook = false; #ifdef NDOF_FLY_DRAW_TOOMUCH fly->redraw = 1; @@ -342,7 +349,7 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent copy_m3_m4(mat, fly->rv3d->viewinv); mul_m3_v3(mat, upvec); if (fabsf(upvec[2]) < 0.1f) { - fly->zlock = 1; + fly->zlock = FLY_AXISLOCK_STATE_IDLE; } upvec[0] = 0; upvec[1] = 0; @@ -354,10 +361,10 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent /* check for flying ortho camera - which we cant support well * we _could_ also check for an ortho camera but this is easier */ if ((fly->rv3d->persp == RV3D_CAMOB) && - (fly->rv3d->is_persp == FALSE)) + (fly->rv3d->is_persp == false)) { ((Camera *)fly->v3d->camera->data)->type = CAM_PERSP; - fly->is_ortho_cam = TRUE; + fly->is_ortho_cam = true; } if (fly->rv3d->persp == RV3D_CAMOB) { @@ -601,11 +608,11 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) break; } case FLY_MODAL_PAN_ENABLE: - fly->pan_view = TRUE; + fly->pan_view = true; break; case FLY_MODAL_PAN_DISABLE: //XXX2.5 WM_cursor_warp(CTX_wm_window(C), cent_orig[0], cent_orig[1]); - fly->pan_view = FALSE; + fly->pan_view = false; break; /* implement WASD keys, @@ -677,40 +684,41 @@ static void flyEvent(FlyInfo *fly, const wmEvent *event) break; case FLY_MODAL_AXIS_LOCK_X: - if (fly->xlock) - fly->xlock = 0; + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + fly->xlock = FLY_AXISLOCK_STATE_OFF; else { - fly->xlock = 2; + fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; fly->xlock_momentum = 0.0; } break; case FLY_MODAL_AXIS_LOCK_Z: - if (fly->zlock) - fly->zlock = 0; + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + fly->zlock = FLY_AXISLOCK_STATE_OFF; else { - fly->zlock = 2; + fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; fly->zlock_momentum = 0.0; } break; case FLY_MODAL_PRECISION_ENABLE: - fly->use_precision = TRUE; + fly->use_precision = true; break; case FLY_MODAL_PRECISION_DISABLE: - fly->use_precision = FALSE; + fly->use_precision = false; break; case FLY_MODAL_FREELOOK_ENABLE: - fly->use_freelook = TRUE; + fly->use_freelook = true; break; case FLY_MODAL_FREELOOK_DISABLE: - fly->use_freelook = FALSE; + fly->use_freelook = false; break; } } } -static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orientationChanged, int positionChanged) +static void flyMoveCamera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, + const bool do_rotate, const bool do_translate) { /* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */ @@ -733,7 +741,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mult_m4_m4m4(diff_mat, view_mat, prev_view_imat); mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat); - BKE_object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(fly->root_parent, parent_mat, true, false); // BKE_object_where_is_calc(scene, fly->root_parent); @@ -748,7 +756,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien else { float view_mat[4][4]; ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - BKE_object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); + BKE_object_apply_mat4(v3d->camera, view_mat, true, false); id_key = &v3d->camera->id; } @@ -764,11 +772,11 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien * 2) on each subsequent frame * TODO: need to check in future that frame changed before doing this */ - if (orientationChanged) { + if (do_rotate) { KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_ROTATION_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); } - if (positionChanged) { + if (do_translate) { KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOCATION_ID); ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); } @@ -851,7 +859,8 @@ static int flyApply(bContext *C, FlyInfo *fly) /* Should we redraw? */ if ((fly->speed != 0.0f) || moffset[0] || moffset[1] || - fly->zlock || fly->xlock || + (fly->zlock != FLY_AXISLOCK_STATE_OFF) || + (fly->xlock != FLY_AXISLOCK_STATE_OFF) || dvec[0] || dvec[1] || dvec[2]) { float dvec_tmp[3]; @@ -876,7 +885,7 @@ static int flyApply(bContext *C, FlyInfo *fly) copy_m3_m4(mat, rv3d->viewinv); - if (fly->pan_view == TRUE) { + if (fly->pan_view == true) { /* pan only */ dvec_tmp[0] = -moffset[0]; dvec_tmp[1] = -moffset[1]; @@ -904,10 +913,10 @@ static int flyApply(bContext *C, FlyInfo *fly) axis_angle_to_quat(tmp_quat, upvec, (float)moffset[1] * time_redraw * -FLY_ROTATE_FAC); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); - if (fly->xlock) - fly->xlock = 2; /* check for rotation */ - if (fly->zlock) - fly->zlock = 2; + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */ + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; fly->xlock_momentum = 0.0f; } @@ -940,13 +949,13 @@ static int flyApply(bContext *C, FlyInfo *fly) axis_angle_to_quat(tmp_quat, upvec, (float)moffset[0] * time_redraw * FLY_ROTATE_FAC); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); - if (fly->xlock) - fly->xlock = 2; /* check for rotation */ - if (fly->zlock) - fly->zlock = 2; + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */ + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; } - if (fly->zlock == 2) { + if (fly->zlock == FLY_AXISLOCK_STATE_ACTIVE) { upvec[0] = 1.0f; upvec[1] = 0.0f; upvec[2] = 0.0f; @@ -968,12 +977,13 @@ static int flyApply(bContext *C, FlyInfo *fly) fly->zlock_momentum += FLY_ZUP_CORRECT_ACCEL; } else { - fly->zlock = 1; /* don't check until the view rotates again */ + fly->zlock = FLY_AXISLOCK_STATE_IDLE; /* don't check until the view rotates again */ fly->zlock_momentum = 0.0f; } } - if (fly->xlock == 2 && moffset[1] == 0) { /* only apply xcorrect when mouse isn't applying x rot */ + /* only apply xcorrect when mouse isn't applying x rot */ + if (fly->xlock == FLY_AXISLOCK_STATE_ACTIVE && moffset[1] == 0) { upvec[0] = 0; upvec[1] = 0; upvec[2] = 1; @@ -995,7 +1005,7 @@ static int flyApply(bContext *C, FlyInfo *fly) fly->xlock_momentum += 0.05f; } else { - fly->xlock = 1; /* see above */ + fly->xlock = FLY_AXISLOCK_STATE_IDLE; /* see above */ fly->xlock_momentum = 0.0f; } } @@ -1035,8 +1045,13 @@ static int flyApply(bContext *C, FlyInfo *fly) add_v3_v3(rv3d->ofs, dvec); - if (rv3d->persp == RV3D_CAMOB) - move_camera(C, rv3d, fly, (fly->xlock || fly->zlock || moffset[0] || moffset[1]), fly->speed); + if (rv3d->persp == RV3D_CAMOB) { + const bool do_rotate = ((fly->xlock != FLY_AXISLOCK_STATE_OFF) || + (fly->zlock != FLY_AXISLOCK_STATE_OFF) || + ((moffset[0] || moffset[1]) && !fly->pan_view)); + const bool do_translate = (fly->speed != 0.0f || fly->pan_view); + flyMoveCamera(C, rv3d, fly, do_rotate, do_translate); + } } else { @@ -1059,19 +1074,19 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) const int flag = U.ndof_flag; #if 0 - int shouldRotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == FALSE); - int shouldTranslate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)); + bool do_rotate = (flag & NDOF_SHOULD_ROTATE) && (fly->pan_view == false); + bool do_translate = (flag & (NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM)); #endif - int shouldRotate = (fly->pan_view == FALSE); - int shouldTranslate = TRUE; + bool do_rotate = (fly->pan_view == false); + bool do_translate = true; float view_inv[4]; invert_qt_qt(view_inv, rv3d->viewquat); rv3d->rot_angle = 0.0f; /* disable onscreen rotation doo-dad */ - if (shouldTranslate) { + if (do_translate) { const float forward_sensitivity = 1.0f; const float vertical_sensitivity = 0.4f; const float lateral_sensitivity = 0.6f; @@ -1107,14 +1122,14 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) if (!is_zero_v3(trans)) { /* move center of view opposite of hand motion (this is camera mode, not object mode) */ sub_v3_v3(rv3d->ofs, trans); - shouldTranslate = TRUE; + do_translate = true; } else { - shouldTranslate = FALSE; + do_translate = false; } } - if (shouldRotate) { + if (do_rotate) { const float turn_sensitivity = 1.0f; float rotation[4]; @@ -1122,7 +1137,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) float angle = turn_sensitivity * ndof_to_axis_angle(ndof, axis); if (fabsf(angle) > 0.0001f) { - shouldRotate = TRUE; + do_rotate = true; if (fly->use_precision) angle *= 0.2f; @@ -1164,15 +1179,15 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) rv3d->view = RV3D_VIEW_USER; } else { - shouldRotate = FALSE; + do_rotate = false; } } - if (shouldTranslate || shouldRotate) { - fly->redraw = TRUE; + if (do_translate || do_rotate) { + fly->redraw = true; if (rv3d->persp == RV3D_CAMOB) { - move_camera(C, rv3d, fly, shouldRotate, shouldTranslate); + flyMoveCamera(C, rv3d, fly, do_rotate, do_translate); } } @@ -1191,7 +1206,7 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event) op->customdata = fly; - if (initFlyInfo(C, fly, op, event) == FALSE) { + if (initFlyInfo(C, fly, op, event) == false) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -1217,7 +1232,7 @@ static int fly_cancel(bContext *C, wmOperator *op) static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) { int exit_code; - short do_draw = FALSE; + bool do_draw = false; FlyInfo *fly = op->customdata; RegionView3D *rv3d = fly->rv3d; Object *fly_object = fly->root_parent ? fly->root_parent : fly->v3d->camera; @@ -1240,7 +1255,7 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) exit_code = flyEnd(C, fly); if (exit_code != OPERATOR_RUNNING_MODAL) - do_draw = TRUE; + do_draw = true; if (do_draw) { if (rv3d->persp == RV3D_CAMOB) { diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 430ed8698d7..854bd9f6cf8 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -147,7 +147,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) ScrArea *sa = CTX_wm_area(C); View3D *v3d = sa->spacedata.first; int nr = RNA_int_get(op->ptr, "nr"); - int toggle = RNA_boolean_get(op->ptr, "toggle"); + const bool toggle = RNA_boolean_get(op->ptr, "toggle"); if (nr < 0) return OPERATOR_CANCELLED; @@ -198,7 +198,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) if (v3d->scenelock) handle_view3d_lock(C); - DAG_on_visible_update(CTX_data_main(C), FALSE); + DAG_on_visible_update(CTX_data_main(C), false); ED_area_tag_redraw(sa); @@ -215,10 +215,10 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *even if (event->shift) RNA_boolean_set(op->ptr, "extend", TRUE); else - RNA_boolean_set(op->ptr, "extend", FALSE); + RNA_boolean_set(op->ptr, "extend", false); if (event->alt) { - int nr = RNA_int_get(op->ptr, "nr") + 10; + const int nr = RNA_int_get(op->ptr, "nr") + 10; RNA_int_set(op->ptr, "nr", nr); } view3d_layers_exec(C, op); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 8bce8cd3e01..11cd0fdb1d7 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -122,14 +122,14 @@ void draw_motion_paths_cleanup(View3D *v3d); /* drawobject.c */ void draw_object(Scene *scene, struct ARegion *ar, View3D *v3d, Base *base, const short dflag); -int draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const char dt); +bool draw_glsl_material(Scene *scene, struct Object *ob, View3D *v3d, const char dt); void draw_object_instance(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, const char dt, int outline); void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob); void drawaxes(float size, char drawtype); void view3d_cached_text_draw_begin(void); void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]); -void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, float mat[4][4]); +void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write, float mat[4][4]); enum { V3D_CACHE_TEXT_ZBUF = (1 << 0), @@ -140,9 +140,9 @@ enum { }; /* drawarmature.c */ -int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, - const short dt, const short dflag, const unsigned char ob_wire_col[4], - const short is_outline); +bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, + const short dt, const short dflag, const unsigned char ob_wire_col[4], + const bool is_outline); /* drawmesh.c */ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, @@ -176,7 +176,7 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot); void VIEW3D_OT_game_start(struct wmOperatorType *ot); -int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[4][4], struct BoundBox *bb); +bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const struct BoundBox *bb); void view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); @@ -200,7 +200,7 @@ void view3d_toolshelf_register(struct ARegionType *art); void view3d_tool_props_register(struct ARegionType *art); /* view3d_snap.c */ -int ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3]); +bool ED_view3d_minmax_verts(struct Object *obedit, float min[3], float max[3]); void VIEW3D_OT_snap_selected_to_grid(struct wmOperatorType *ot); void VIEW3D_OT_snap_selected_to_cursor(struct wmOperatorType *ot); @@ -239,7 +239,7 @@ void draw_smoke_heat(struct SmokeDomainSettings *domain, struct Object *ob); #define VIEW3D_CAMERA_BORDER_HACK #ifdef VIEW3D_CAMERA_BORDER_HACK extern unsigned char view3d_camera_border_hack_col[3]; -extern short view3d_camera_border_hack_test; +extern bool view3d_camera_border_hack_test; #endif #endif /* __VIEW3D_INTERN_H__ */ diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 30a100283cc..7d728234c92 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -110,8 +110,8 @@ eV3DProjStatus ED_view3d_project_base(const struct ARegion *ar, struct Base *bas } /* perspmat is typically... - * - 'rv3d->perspmat', is_local == FALSE - * - 'rv3d->persmatob', is_local == TRUE + * - 'rv3d->perspmat', is_local == false + * - 'rv3d->persmatob', is_local == true */ static eV3DProjStatus ed_view3d_project__internal(const ARegion *ar, float perspmat[4][4], const bool is_local, /* normally hidden */ @@ -231,39 +231,39 @@ eV3DProjStatus ED_view3d_project_float_ex(const ARegion *ar, float perspmat[4][4 eV3DProjStatus ED_view3d_project_short_global(const ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_short_ex(ar, rv3d->persmat, FALSE, co, r_co, flag); + return ED_view3d_project_short_ex(ar, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ eV3DProjStatus ED_view3d_project_short_object(const ARegion *ar, const float co[3], short r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_short_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag); + return ED_view3d_project_short_ex(ar, rv3d->persmatob, true, co, r_co, flag); } /* --- int --- */ eV3DProjStatus ED_view3d_project_int_global(const ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_int_ex(ar, rv3d->persmat, FALSE, co, r_co, flag); + return ED_view3d_project_int_ex(ar, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ eV3DProjStatus ED_view3d_project_int_object(const ARegion *ar, const float co[3], int r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_int_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag); + return ED_view3d_project_int_ex(ar, rv3d->persmatob, true, co, r_co, flag); } /* --- float --- */ eV3DProjStatus ED_view3d_project_float_global(const ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_float_ex(ar, rv3d->persmat, FALSE, co, r_co, flag); + return ED_view3d_project_float_ex(ar, rv3d->persmat, false, co, r_co, flag); } /* object space, use ED_view3d_init_mats_rv3d before calling */ eV3DProjStatus ED_view3d_project_float_object(const ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag) { RegionView3D *rv3d = ar->regiondata; - return ED_view3d_project_float_ex(ar, rv3d->persmatob, TRUE, co, r_co, flag); + return ED_view3d_project_float_ex(ar, rv3d->persmatob, true, co, r_co, flag); } @@ -367,7 +367,7 @@ void ED_view3d_win_to_3d(const ARegion *ar, const float depth_pt[3], const float ED_view3d_win_to_vector(ar, mval, mousevec); add_v3_v3v3(line_end, line_sta, mousevec); - if (isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], TRUE) == 0) { + if (isect_line_plane_v3(out, line_sta, line_end, depth_pt, rv3d->viewinv[2], true) == 0) { /* highly unlikely to ever happen, mouse vec paralelle with view plane */ zero_v3(out); } @@ -435,7 +435,8 @@ void ED_view3d_win_to_vector(const ARegion *ar, const float mval[2], float out[3 normalize_v3(out); } -void ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +void ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2], + float ray_start[3], float ray_end[3]) { RegionView3D *rv3d = ar->regiondata; @@ -472,9 +473,10 @@ void ED_view3d_win_to_segment(const ARegion *ar, View3D *v3d, const float mval[2 * \param mval The area relative 2d location (such as event->mval, converted into float[2]). * \param ray_start The world-space starting point of the segment. * \param ray_end The world-space end point of the segment. - * \return success, FALSE if the segment is totally clipped. + * \return success, false if the segment is totally clipped. */ -int ED_view3d_win_to_segment_clip(const ARegion *ar, View3D *v3d, const float mval[2], float ray_start[3], float ray_end[3]) +bool ED_view3d_win_to_segment_clip(const ARegion *ar, View3D *v3d, const float mval[2], + float ray_start[3], float ray_end[3]) { RegionView3D *rv3d = ar->regiondata; ED_view3d_win_to_segment(ar, v3d, mval, ray_start, ray_end); @@ -482,14 +484,14 @@ int ED_view3d_win_to_segment_clip(const ARegion *ar, View3D *v3d, const float mv /* clipping */ if (rv3d->rflag & RV3D_CLIPPING) { /* if the ray is totally clipped, - * restore the original values but return FALSE + * restore the original values but return false * caller can choose what to do */ float tray_start[3] = {UNPACK3(ray_start)}; float tray_end[3] = {UNPACK3(ray_end)}; int a; for (a = 0; a < 4; a++) { - if (clip_line_plane(tray_start, tray_end, rv3d->clip[a]) == FALSE) { - return FALSE; + if (clip_line_plane(tray_start, tray_end, rv3d->clip[a]) == false) { + return false; } } @@ -498,7 +500,7 @@ int ED_view3d_win_to_segment_clip(const ARegion *ar, View3D *v3d, const float mv copy_v3_v3(ray_end, tray_end); } - return TRUE; + return true; } diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index 410d20a1dc0..d6cc218e266 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -924,7 +924,7 @@ static int view3d_ruler_modal(bContext *C, wmOperator *op, const wmEvent *event) void VIEW3D_OT_ruler(wmOperatorType *ot) { /* identifiers */ - ot->name = "3D Ruler & Protractor"; + ot->name = "Ruler/Protractor"; ot->description = "Interactive ruler"; ot->idname = "VIEW3D_OT_ruler"; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b441e48f59d..a84075fb60e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -127,7 +127,7 @@ bool view3d_get_view_aligned_coordinate(ARegion *ar, float fp[3], const int mval ED_view3d_win_to_delta(ar, mval_f, dvec, zfac); sub_v3_v3(fp, dvec); - return TRUE; + return true; } else { /* fallback to the view center */ @@ -262,17 +262,17 @@ typedef struct LassoSelectUserData { rctf _rect_fl; const int (*mcords)[2]; int moves; - int select; + bool select; /* runtime */ int pass; - int is_done; - int is_change; + bool is_done; + bool is_change; } LassoSelectUserData; static void view3d_userdata_lassoselect_init(LassoSelectUserData *r_data, ViewContext *vc, const rcti *rect, const int (*mcords)[2], - const int moves, const int select) + const int moves, const bool select) { r_data->vc = vc; @@ -286,8 +286,8 @@ static void view3d_userdata_lassoselect_init(LassoSelectUserData *r_data, /* runtime */ r_data->pass = 0; - r_data->is_done = FALSE; - r_data->is_change = FALSE; + r_data->is_done = false; + r_data->is_change = false; } static int view3d_selectable_data(bContext *C) @@ -356,7 +356,7 @@ static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChann bArmature *arm = data->vc->obact->data; if (PBONE_SELECTABLE(arm, pchan->bone)) { - int is_point_done = FALSE; + bool is_point_done = false; int points_proj_tot = 0; const int x0 = screen_co_a[0]; @@ -370,7 +370,7 @@ static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChann if (BLI_rcti_isect_pt(data->rect, x0, y0) && BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, INT_MAX)) { - is_point_done = TRUE; + is_point_done = true; } } @@ -380,23 +380,23 @@ static void do_lasso_select_pose__doSelectBone(void *userData, struct bPoseChann if (BLI_rcti_isect_pt(data->rect, x1, y1) && BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, INT_MAX)) { - is_point_done = TRUE; + is_point_done = true; } } /* if one of points selected, we skip the bone itself */ - if ((is_point_done == TRUE) || - ((is_point_done == FALSE) && (points_proj_tot == 2) && + if ((is_point_done == true) || + ((is_point_done == false) && (points_proj_tot == 2) && BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, INT_MAX))) { if (data->select) pchan->bone->flag |= BONE_SELECTED; else pchan->bone->flag &= ~BONE_SELECTED; - data->is_change = TRUE; + data->is_change = true; } data->is_change |= is_point_done; } } -static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, short select) +static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[][2], short moves, bool select) { ViewContext vc_tmp; LassoSelectUserData data; @@ -437,11 +437,11 @@ static void object_deselect_all_visible(Scene *scene, View3D *v3d) } } -static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], const short moves, short extend, short select) +static void do_lasso_select_objects(ViewContext *vc, const int mcords[][2], const short moves, bool extend, bool select) { Base *base; - if (extend == 0 && select) + if (extend == false && select) object_deselect_all_visible(vc->scene, vc->v3d); for (base = vc->scene->base.first; base; base = base->next) { @@ -486,7 +486,7 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, cons BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, IS_CLIPPED)) { BM_edge_select_set(data->vc->em->bm, eed, data->select); - data->is_done = TRUE; + data->is_done = true; } } else { @@ -507,7 +507,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, cons } } -static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { LassoSelectUserData data; ToolSettings *ts = vc->scene->toolsettings; @@ -521,7 +521,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); - if (extend == 0 && select) + if (extend == false && select) EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT); /* for non zbuf projections, don't change the GL state */ @@ -543,7 +543,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m data.pass = 0; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); - if (data.is_done == 0) { + if (data.is_done == false) { data.pass = 1; mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } @@ -595,7 +595,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP } } -static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { LassoSelectUserData data; rcti rect; @@ -604,7 +604,7 @@ static void do_lasso_select_curve(ViewContext *vc, const int mcords[][2], short view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); - if (extend == 0 && select) + if (extend == false && select) CU_deselect_all(vc->obedit); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -621,7 +621,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, const bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } -static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { LassoSelectUserData data; rcti rect; @@ -630,7 +630,7 @@ static void do_lasso_select_lattice(ViewContext *vc, const int mcords[][2], shor view3d_userdata_lassoselect_init(&data, vc, &rect, mcords, moves, select); - if (extend == 0 && select) + if (extend == false && select) ED_setflagsLatt(vc->obedit, 0); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -643,7 +643,7 @@ static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBo bArmature *arm = data->vc->obedit->data; if (EBONE_SELECTABLE(arm, ebone)) { - int is_point_done = FALSE; + bool is_point_done = false; int points_proj_tot = 0; const int x0 = screen_co_a[0]; @@ -657,7 +657,7 @@ static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBo if (BLI_rcti_isect_pt(data->rect, x0, y0) && BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, INT_MAX)) { - is_point_done = TRUE; + is_point_done = true; if (data->select) ebone->flag |= BONE_ROOTSEL; else ebone->flag &= ~BONE_ROOTSEL; } @@ -669,26 +669,26 @@ static void do_lasso_select_armature__doSelectBone(void *userData, struct EditBo if (BLI_rcti_isect_pt(data->rect, x1, y1) && BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, INT_MAX)) { - is_point_done = TRUE; + is_point_done = true; if (data->select) ebone->flag |= BONE_TIPSEL; else ebone->flag &= ~BONE_TIPSEL; } } /* if one of points selected, we skip the bone itself */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && + if ((is_point_done == false) && (points_proj_tot == 2) && BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, INT_MAX)) { if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - data->is_change = TRUE; + data->is_change = true; } data->is_change |= is_point_done; } } -static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { LassoSelectUserData data; rcti rect; @@ -699,7 +699,7 @@ static void do_lasso_select_armature(ViewContext *vc, const int mcords[][2], sho ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); - if (extend == 0 && select) + if (extend == false && select) ED_armature_deselect_all_visible(vc->obedit); armature_foreachScreenBone(vc, do_lasso_select_armature__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); @@ -721,17 +721,17 @@ static void do_lasso_select_mball__doSelectElem(void *userData, struct MetaElem { if (data->select) ml->flag |= SELECT; else ml->flag &= ~SELECT; - data->is_change = TRUE; + data->is_change = true; } } -static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_meta(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { LassoSelectUserData data; rcti rect; MetaBall *mb = (MetaBall *)vc->obedit->data; - if (extend == 0 && select) + if (extend == false && select) BKE_mball_deselect_all(mb); BLI_lasso_boundbox(&rect, mcords, moves); @@ -753,7 +753,7 @@ static void do_lasso_select_meshobject__doSelectVert(void *userData, MVert *mv, BKE_BIT_TEST_SET(mv->flag, data->select, SELECT); } } -static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { const int use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT); Object *ob = vc->obact; @@ -763,8 +763,8 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh if (me == NULL || me->totvert == 0) return; - if (extend == 0 && select) - paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ + if (extend == false && select) + paintvert_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */ BLI_lasso_boundbox(&rect, mcords, moves); @@ -790,7 +790,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh paintvert_flush_flags(ob); } -static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, short extend, short select) +static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], short moves, bool extend, bool select) { Object *ob = vc->obact; Mesh *me = ob ? ob->data : NULL; @@ -799,8 +799,8 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh if (me == NULL || me->totpoly == 0) return; - if (extend == 0 && select) - paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ + if (extend == false && select) + paintface_deselect_all_visible(ob, SEL_DESELECT, false); /* flush selection at the end */ bm_vertoffs = me->totpoly + 1; /* max index array */ @@ -847,7 +847,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) static void view3d_lasso_select(bContext *C, ViewContext *vc, const int mcords[][2], short moves, - short extend, short select) + bool extend, bool select) { Object *ob = CTX_data_active_object(C); @@ -902,7 +902,7 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { - short extend, select; + bool extend, select; view3d_operator_needs_opengl(C); /* setup view context for argument to callbacks */ @@ -1031,9 +1031,9 @@ static EnumPropertyItem *object_select_menu_enum_itemf(bContext *C, PointerRNA * static int object_select_menu_exec(bContext *C, wmOperator *op) { - int name_index = RNA_enum_get(op->ptr, "name"); - short toggle = RNA_boolean_get(op->ptr, "toggle"); - short changed = 0; + const int name_index = RNA_enum_get(op->ptr, "name"); + const bool toggle = RNA_boolean_get(op->ptr, "toggle"); + bool change = false; const char *name = object_mouse_select_menu_data[name_index].idname; if (!toggle) { @@ -1041,7 +1041,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op) { if (base->flag & SELECT) { ED_base_object_select(base, BA_DESELECT); - changed = 1; + change = true; } } CTX_DATA_END; @@ -1053,7 +1053,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op) if (STREQ(name, base->object->id.name + 2)) { ED_base_object_activate(C, base); ED_base_object_select(base, BA_SELECT); - changed = 1; + change = true; } } CTX_DATA_END; @@ -1062,7 +1062,7 @@ static int object_select_menu_exec(bContext *C, wmOperator *op) memset(object_mouse_select_menu_data, 0, sizeof(object_mouse_select_menu_data)); /* undo? */ - if (changed) { + if (change) { WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -1112,12 +1112,12 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], short toggle) { short baseCount = 0; - short ok; + bool ok; LinkNode *linklist = NULL; CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { - ok = FALSE; + ok = false; /* two selection methods, the CTRL select uses max dist of 15 */ if (buffer) { @@ -1125,7 +1125,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int for (a = 0; a < hits; a++) { /* index was converted */ if (base->selcol == buffer[(4 * a) + 3]) - ok = TRUE; + ok = true; } } else { @@ -1134,7 +1134,7 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int temp = abs(base->sx - mval[0]) + abs(base->sy - mval[1]); if (temp < dist) - ok = TRUE; + ok = true; } if (ok) { @@ -1185,15 +1185,15 @@ static Base *object_mouse_select_menu(bContext *C, ViewContext *vc, unsigned int } } -static int selectbuffer_has_bones(const unsigned int *buffer, const unsigned int hits) +static bool selectbuffer_has_bones(const unsigned int *buffer, const unsigned int hits) { unsigned int i; for (i = 0; i < hits; i++) { if (buffer[(4 * i) + 3] & 0xFFFF0000) { - return TRUE; + return true; } } - return FALSE; + return false; } /* we want a select buffer with bones, if there are... */ @@ -1203,7 +1203,7 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff rcti rect; int offs; short hits15, hits9 = 0, hits5 = 0; - short has_bones15 = FALSE, has_bones9 = FALSE, has_bones5 = FALSE; + bool has_bones15 = false, has_bones9 = false, has_bones5 = false; BLI_rcti_init(&rect, mval[0] - 14, mval[0] + 14, mval[1] - 14, mval[1] + 14); hits15 = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); @@ -1255,20 +1255,22 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff } /* returns basact */ -static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], Base *startbase, int has_bones) +static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const int mval[2], + Base *startbase, bool has_bones) { Scene *scene = vc->scene; View3D *v3d = vc->v3d; Base *base, *basact = NULL; static int lastmval[2] = {-100, -100}; - int a, do_nearest = FALSE; + int a; + bool do_nearest = false; /* define if we use solid nearest select or not */ if (v3d->drawtype > OB_WIRE) { - do_nearest = TRUE; + do_nearest = true; if (ABS(mval[0] - lastmval[0]) < 3 && ABS(mval[1] - lastmval[1]) < 3) { if (!has_bones) /* hrms, if theres bones we always do nearest */ - do_nearest = FALSE; + do_nearest = false; } } lastmval[0] = mval[0]; lastmval[1] = mval[1]; @@ -1362,7 +1364,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) hits = mixed_bones_object_selectbuffer(&vc, buffer, mval); if (hits > 0) { - const int has_bones = selectbuffer_has_bones(buffer, hits); + const bool has_bones = selectbuffer_has_bones(buffer, hits); basact = mouse_select_eval_buffer(&vc, buffer, hits, mval, vc.scene->base.first, has_bones); } @@ -1389,7 +1391,7 @@ static void deselect_all_tracks(MovieTracking *tracking) } /* mval is region coords */ -static int mouse_select(bContext *C, const int mval[2], short extend, short deselect, short toggle, short obcenter, short enumerate) +static bool mouse_select(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, bool obcenter, short enumerate) { ViewContext vc; ARegion *ar = CTX_wm_region(C); @@ -1397,7 +1399,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese Scene *scene = CTX_data_scene(C); Base *base, *startbase = NULL, *basact = NULL, *oldbasact = NULL; float dist = 100.0f; - int retval = 0; + int retval = false; short hits; const float mval_fl[2] = {(float)mval[0], (float)mval[1]}; @@ -1449,7 +1451,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese if (hits > 0) { /* note: bundles are handling in the same way as bones */ - const int has_bones = selectbuffer_has_bones(buffer, hits); + const bool has_bones = selectbuffer_has_bones(buffer, hits); /* note; shift+alt goes to group-flush-selecting */ if (has_bones == 0 && enumerate) { @@ -1502,7 +1504,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese basact->flag |= SELECT; basact->object->flag = basact->flag; - retval = 1; + retval = true; WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, track); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -1526,7 +1528,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese basact->flag |= SELECT; basact->object->flag = basact->flag; - retval = 1; + retval = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object); @@ -1546,7 +1548,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short dese /* so, do we have something selected? */ if (basact) { - retval = 1; + retval = true; if (vc.obedit) { /* only do select */ @@ -1601,8 +1603,8 @@ typedef struct BoxSelectUserData { /* runtime */ int pass; - int is_done; - int is_change; + bool is_done; + bool is_change; } BoxSelectUserData; static void view3d_userdata_boxselect_init(BoxSelectUserData *r_data, @@ -1618,29 +1620,29 @@ static void view3d_userdata_boxselect_init(BoxSelectUserData *r_data, /* runtime */ r_data->pass = 0; - r_data->is_done = FALSE; - r_data->is_change = FALSE; + r_data->is_done = false; + r_data->is_change = false; } -int edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2]) +bool edge_inside_circle(const float cent[2], float radius, const float screen_co_a[2], const float screen_co_b[2]) { int radius_squared = radius * radius; /* check points in circle itself */ if (len_squared_v2v2(cent, screen_co_a) <= radius_squared) { - return TRUE; + return true; } if (len_squared_v2v2(cent, screen_co_b) <= radius_squared) { - return TRUE; + return true; } else { /* pointdistline */ if (dist_squared_to_line_segment_v2(cent, screen_co_a, screen_co_b) < (float)radius_squared) { - return TRUE; + return true; } } - return FALSE; + return false; } static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, const float screen_co[2], int UNUSED(index)) @@ -1651,7 +1653,7 @@ static void do_paintvert_box_select__doSelectVert(void *userData, MVert *mv, con BKE_BIT_TEST_SET(mv->flag, data->select, SELECT); } } -static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_paintvert_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { const int use_zbuf = (vc->v3d->flag & V3D_ZBUF_SELECT); Mesh *me; @@ -1669,8 +1671,8 @@ static int do_paintvert_box_select(ViewContext *vc, rcti *rect, int select, int return OPERATOR_CANCELLED; - if (extend == 0 && select) - paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE); + if (extend == false && select) + paintvert_deselect_all_visible(vc->obact, SEL_DESELECT, false); if (use_zbuf) { selar = MEM_callocN(me->totvert + 1, "selar"); @@ -1754,13 +1756,13 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi } } } -static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_nurbs_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { BoxSelectUserData data; view3d_userdata_boxselect_init(&data, vc, rect, select); - if (extend == 0 && select) + if (extend == false && select) CU_deselect_all(vc->obedit); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -1777,13 +1779,13 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, const fl bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } -static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_lattice_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { BoxSelectUserData data; view3d_userdata_boxselect_init(&data, vc, rect, select); - if (extend == 0 && select) + if (extend == false && select) ED_setflagsLatt(vc->obedit, 0); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -1808,7 +1810,7 @@ static void do_mesh_box_select__doSelectEdge(void *userData, BMEdge *eed, const if (data->pass == 0) { if (edge_fully_inside_rect(data->rect_fl, screen_co_a, screen_co_b)) { BM_edge_select_set(data->vc->em->bm, eed, data->select); - data->is_done = TRUE; + data->is_done = true; } } else { @@ -1826,7 +1828,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, BMFace *efa, const BM_face_select_set(data->vc->em->bm, efa, data->select); } } -static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { BoxSelectUserData data; ToolSettings *ts = vc->scene->toolsettings; @@ -1834,7 +1836,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten view3d_userdata_boxselect_init(&data, vc, rect, select); - if (extend == 0 && select) + if (extend == false && select) EDBM_flag_disable_all(vc->em, BM_ELEM_SELECT); /* for non zbuf projections, don't change the GL state */ @@ -1879,7 +1881,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exten return OPERATOR_FINISHED; } -static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int extend) +static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { MetaBall *mb = (MetaBall *)vc->obedit->data; MetaElem *ml; @@ -1890,7 +1892,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int exten hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect); - if (extend == 0 && select) + if (extend == false && select) BKE_mball_deselect_all(mb); for (ml = mb->editelems->first; ml; ml = ml->next) { @@ -1913,7 +1915,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int exten return OPERATOR_FINISHED; } -static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, short extend) +static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { bArmature *arm = vc->obedit->data; EditBone *ebone; @@ -1928,7 +1930,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho for (ebone = arm->edbo->first; ebone; ebone = ebone->next) ebone->flag &= ~BONE_DONE; - if (extend == 0 && select) + if (extend == false && select) ED_armature_deselect_all_visible(vc->obedit); /* first we only check points inside the border */ @@ -1983,7 +1985,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, sho return OPERATOR_CANCELLED; } -static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, int select, int extend) +static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, bool select, bool extend) { Bone *bone; Object *ob = vc->obact; @@ -1999,7 +2001,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i else bone_only = 0; - if (extend == 0 && select) { + if (extend == false && select) { if (bone_only) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { @@ -2091,8 +2093,8 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) { ViewContext vc; rcti rect; - short extend; - short select; + bool extend; + bool select; int ret = OPERATOR_CANCELLED; @@ -2187,12 +2189,12 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) ot->flag = OPTYPE_UNDO; /* rna */ - WM_operator_properties_gesture_border(ot, TRUE); + WM_operator_properties_gesture_border(ot, true); } /* mouse selection in weight paint */ /* gets called via generic mouse select operator */ -static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, short deselect, short toggle, Object *obact) +static bool mouse_weight_paint_vertex_select(bContext *C, const int mval[2], bool extend, bool deselect, bool toggle, Object *obact) { View3D *v3d = CTX_wm_view3d(C); const int use_zbuf = (v3d->flag & V3D_ZBUF_SELECT); @@ -2213,14 +2215,14 @@ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], shor mv->flag ^= SELECT; } else { - paintvert_deselect_all_visible(obact, SEL_DESELECT, FALSE); + paintvert_deselect_all_visible(obact, SEL_DESELECT, false); mv->flag |= SELECT; } paintvert_flush_flags(obact); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obact->data); - return 1; + return true; } - return 0; + return false; } /* ****** Mouse Select ****** */ @@ -2230,13 +2232,13 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even { Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); - short extend = RNA_boolean_get(op->ptr, "extend"); - short deselect = RNA_boolean_get(op->ptr, "deselect"); - short toggle = RNA_boolean_get(op->ptr, "toggle"); - short center = RNA_boolean_get(op->ptr, "center"); - short enumerate = RNA_boolean_get(op->ptr, "enumerate"); - short object = RNA_boolean_get(op->ptr, "object"); - int retval = 0; + bool extend = RNA_boolean_get(op->ptr, "extend"); + bool deselect = RNA_boolean_get(op->ptr, "deselect"); + bool toggle = RNA_boolean_get(op->ptr, "toggle"); + bool center = RNA_boolean_get(op->ptr, "center"); + bool enumerate = RNA_boolean_get(op->ptr, "enumerate"); + bool object = RNA_boolean_get(op->ptr, "object"); + bool retval = false; view3d_operator_needs_opengl(C); @@ -2247,10 +2249,10 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, const wmEvent *even /* ack, this is incorrect but to do this correctly we would need an * alternative editmode/objectmode keymap, this copies the functionality * from 2.4x where Ctrl+Select in editmode does object select only */ - center = FALSE; + center = false; } - if (obedit && object == FALSE) { + if (obedit && object == false) { if (obedit->type == OB_MESH) retval = EDBM_select_pick(C, event->mval, extend, deselect, toggle); else if (obedit->type == OB_ARMATURE) @@ -2317,7 +2319,7 @@ typedef struct CircleSelectUserData { float radius_squared; /* runtime */ - int is_change; + bool is_change; } CircleSelectUserData; static void view3d_userdata_circleselect_init(CircleSelectUserData *r_data, @@ -2333,7 +2335,7 @@ static void view3d_userdata_circleselect_init(CircleSelectUserData *r_data, r_data->radius_squared = rad * rad; /* runtime */ - r_data->is_change = FALSE; + r_data->is_change = false; } static void mesh_circle_doSelectVert(void *userData, BMVert *eve, const float screen_co[2], int UNUSED(index)) @@ -2540,14 +2542,14 @@ static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChan bArmature *arm = data->vc->obact->data; if (PBONE_SELECTABLE(arm, pchan->bone)) { - int is_point_done = FALSE; + bool is_point_done = false; int points_proj_tot = 0; /* project head location to screenspace */ if (screen_co_a[0] != IS_CLIPPED) { points_proj_tot++; if (pchan_circle_doSelectJoint(data, pchan, screen_co_a)) { - is_point_done = TRUE; + is_point_done = true; } } @@ -2555,7 +2557,7 @@ static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChan if (screen_co_b[0] != IS_CLIPPED) { points_proj_tot++; if (pchan_circle_doSelectJoint(data, pchan, screen_co_a)) { - is_point_done = TRUE; + is_point_done = true; } } @@ -2566,12 +2568,12 @@ static void do_circle_select_pose__doSelectBone(void *userData, struct bPoseChan /* only if the endpoints didn't get selected, deal with the middle of the bone too * It works nicer to only do this if the head or tail are not in the circle, * otherwise there is no way to circle select joints alone */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && + if ((is_point_done == false) && (points_proj_tot == 2) && edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { if (data->select) pchan->bone->flag |= BONE_SELECTED; else pchan->bone->flag &= ~BONE_SELECTED; - data->is_change = TRUE; + data->is_change = true; } data->is_change |= is_point_done; @@ -2626,22 +2628,22 @@ static void do_circle_select_armature__doSelectBone(void *userData, struct EditB bArmature *arm = data->vc->obedit->data; if (EBONE_SELECTABLE(arm, ebone)) { - int is_point_done = FALSE; + bool is_point_done = false; int points_proj_tot = 0; /* project head location to screenspace */ if (screen_co_a[0] != IS_CLIPPED) { points_proj_tot++; - if (armature_circle_doSelectJoint(data, ebone, screen_co_a, TRUE)) { - is_point_done = TRUE; + if (armature_circle_doSelectJoint(data, ebone, screen_co_a, true)) { + is_point_done = true; } } /* project tail location to screenspace */ if (screen_co_b[0] != IS_CLIPPED) { points_proj_tot++; - if (armature_circle_doSelectJoint(data, ebone, screen_co_b, FALSE)) { - is_point_done = TRUE; + if (armature_circle_doSelectJoint(data, ebone, screen_co_b, false)) { + is_point_done = true; } } @@ -2652,12 +2654,12 @@ static void do_circle_select_armature__doSelectBone(void *userData, struct EditB /* only if the endpoints didn't get selected, deal with the middle of the bone too * It works nicer to only do this if the head or tail are not in the circle, * otherwise there is no way to circle select joints alone */ - if ((is_point_done == FALSE) && (points_proj_tot == 2) && + if ((is_point_done == false) && (points_proj_tot == 2) && edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - data->is_change = TRUE; + data->is_change = true; } data->is_change |= is_point_done; @@ -2688,7 +2690,7 @@ static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) { if (data->select) ml->flag |= SELECT; else ml->flag &= ~SELECT; - data->is_change = TRUE; + data->is_change = true; } } static void mball_circle_select(ViewContext *vc, int select, const int mval[2], float rad) @@ -2728,12 +2730,12 @@ static void obedit_circle_select(ViewContext *vc, short select, const int mval[2 } } -static int object_circle_select(ViewContext *vc, int select, const int mval[2], float rad) +static bool object_circle_select(ViewContext *vc, int select, const int mval[2], float rad) { Scene *scene = vc->scene; const float radius_squared = rad * rad; const float mval_fl[2] = {mval[0], mval[1]}; - int is_change = FALSE; + bool is_change = false; int select_flag = select ? SELECT : 0; Base *base; @@ -2746,7 +2748,7 @@ static int object_circle_select(ViewContext *vc, int select, const int mval[2], { if (len_squared_v2v2(mval_fl, screen_co) <= radius_squared) { ED_base_object_select(base, select); - is_change = TRUE; + is_change = true; } } } @@ -2760,8 +2762,8 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); - int radius = RNA_int_get(op->ptr, "radius"); - int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + const int radius = RNA_int_get(op->ptr, "radius"); + const int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); int select; const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 6edcf980d58..eb32baf4c3f 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -101,7 +101,7 @@ static void special_transvert_update(Object *obedit) if (obedit->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(obedit); - BM_mesh_normals_update(em->bm, TRUE); /* does face centers too */ + BM_mesh_normals_update(em->bm, true); /* does face centers too */ } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { Curve *cu = obedit->data; @@ -1075,7 +1075,7 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) /* **************************************************** */ -int ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) +bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) { TransVert *tv; float centroid[3], vec[3], bmat[3][3]; @@ -1085,7 +1085,7 @@ int ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) if (ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)) make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS); - if (tottrans == 0) return 0; + if (tottrans == 0) return false; copy_m3_m4(bmat, obedit->obmat); @@ -1101,5 +1101,5 @@ int ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) MEM_freeN(transvmain); transvmain = NULL; - return 1; + return true; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b2e10fa8457..b227d32d987 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -460,7 +460,7 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o /* only touch location */ BKE_object_tfm_protected_backup(camera_ob, &obtfm); - BKE_object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + BKE_object_apply_mat4(camera_ob, obmat_new, true, true); BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); /* notifiers */ @@ -479,7 +479,7 @@ static int view3d_camera_to_view_selected_poll(bContext *C) if (v3d && v3d->camera && v3d->camera->id.lib == NULL) { RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d) { - if (rv3d->is_persp == FALSE) { + if (rv3d->is_persp == false) { CTX_wm_operator_poll_msg_set(C, "Only valid for a perspective camera view"); } else if (!rv3d->viewlock) { @@ -612,7 +612,7 @@ void ED_view3d_clipping_calc(BoundBox *bb, float planes[4][4], bglMats *mats, co } -int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], BoundBox *bb) +bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const BoundBox *bb) { /* return 1: draw */ @@ -620,8 +620,8 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], BoundBox *bb) float vec[4], min, max; int a, flag = -1, fl; - if (bb == NULL) return 1; - if (bb->flag & OB_BB_DISABLED) return 1; + if (bb == NULL) return true; + if (bb->flag & OB_BB_DISABLED) return true; mult_m4_m4m4(mat, rv3d->persmat, obmat); @@ -641,10 +641,10 @@ int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], BoundBox *bb) if (vec[2] > max) fl += 32; flag &= fl; - if (flag == 0) return 1; + if (flag == 0) return true; } - return 0; + return false; } float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y) @@ -663,7 +663,7 @@ float ED_view3d_depth_read_cached(ViewContext *vc, int x, int y) void ED_view3d_depth_tag_update(RegionView3D *rv3d) { if (rv3d->depths) - rv3d->depths->damaged = 1; + rv3d->depths->damaged = true; } /* copies logic of get_view3d_viewplane(), keep in sync */ @@ -951,7 +951,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b Base tbase; tbase.flag = OB_FROMDUPLI; - lb = object_duplilist(scene, base->object, FALSE); + lb = object_duplilist(scene, base->object, false); for (dob = lb->first; dob; dob = dob->next) { tbase.object = dob->ob; @@ -975,7 +975,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } } } - v3d->xray = FALSE; /* restore */ + v3d->xray = false; /* restore */ } glPopName(); /* see above (pushname) */ @@ -1073,14 +1073,14 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) return lay; } -static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportList *reports) +static bool view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportList *reports) { View3D *v3d = sa->spacedata.first; Base *base; float min[3], max[3], box[3]; float size = 0.0f, size_persp = 0.0f, size_ortho = 0.0f; unsigned int locallay; - int ok = FALSE; + bool ok = false; if (v3d->localvd) { return ok; @@ -1092,13 +1092,13 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL if (locallay == 0) { BKE_report(reports, RPT_ERROR, "No more than 8 local views"); - ok = FALSE; + ok = false; } else { if (scene->obedit) { - BKE_object_minmax(scene->obedit, min, max, FALSE); + BKE_object_minmax(scene->obedit, min, max, false); - ok = TRUE; + ok = true; BASACT->lay |= locallay; scene->obedit->lay = BASACT->lay; @@ -1106,10 +1106,10 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - BKE_object_minmax(base->object, min, max, FALSE); + BKE_object_minmax(base->object, min, max, false); base->lay |= locallay; base->object->lay = base->lay; - ok = TRUE; + ok = true; } } } @@ -1125,7 +1125,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL size_ortho = ED_view3d_radius_to_ortho_dist(v3d->lens, size / 2.0f) * VIEW3D_MARGIN; } - if (ok == TRUE) { + if (ok == true) { ARegion *ar; v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); @@ -1220,7 +1220,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } -static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) +static bool view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d = sa->spacedata.first; struct Base *base; @@ -1247,12 +1247,12 @@ static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) } } - DAG_on_visible_update(bmain, FALSE); + DAG_on_visible_update(bmain, false); - return TRUE; + return true; } else { - return FALSE; + return false; } } @@ -1262,7 +1262,7 @@ static int localview_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); - int change; + bool change; if (v3d->localvd) { change = view3d_localview_exit(bmain, scene, sa); @@ -1403,7 +1403,7 @@ static int game_engine_poll(bContext *C) return 1; } -int ED_view3d_context_activate(bContext *C) +bool ED_view3d_context_activate(bContext *C) { bScreen *sc = CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); @@ -1416,20 +1416,20 @@ int ED_view3d_context_activate(bContext *C) break; if (!sa) - return 0; + return false; for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->regiontype == RGN_TYPE_WINDOW) break; if (!ar) - return 0; + return false; /* bad context switch .. */ CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); - return 1; + return true; } static int game_engine_exec(bContext *C, wmOperator *op) @@ -1466,7 +1466,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) { /* Letterbox */ rctf cam_framef; - ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, FALSE); + ED_view3d_calc_camera_border(startscene, ar, CTX_wm_view3d(C), rv3d, &cam_framef, false); cam_frame.xmin = cam_framef.xmin + ar->winrct.xmin; cam_frame.xmax = cam_framef.xmax + ar->winrct.xmin; cam_frame.ymin = cam_framef.ymin + ar->winrct.ymin; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 43c73fd46fc..cf960c953c3 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5742,10 +5742,10 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t) /* * motion tracking * */ -enum { +enum transDataTracking_Mode { transDataTracking_ModeTracks = 0, - transDataTracking_ModeCurves = 1, -} transDataTracking_Mode; + transDataTracking_ModeCurves = 1 +}; typedef struct TransDataTracking { int mode, flag; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 4fe36a15802..b12c0906fa0 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -884,7 +884,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], return result; } -void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], int activeOnly) +void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[3][3], const bool activeOnly) { float normal[3] = {0.0, 0.0, 0.0}; float plane[3] = {0.0, 0.0, 0.0}; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 6ea37644533..a3a1e6534bf 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1013,7 +1013,7 @@ static int select_edgeloop_uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, } static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit *hit, - float limit[2], const short extend) + float limit[2], const bool extend) { BMFace *efa; BMIter iter, liter; @@ -1124,7 +1124,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit /*********************** linked select ***********************/ -static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, const float limit[2], NearestHit *hit, int extend) +static void select_linked(Scene *scene, Image *ima, BMEditMesh *em, const float limit[2], NearestHit *hit, bool extend) { BMFace *efa; BMLoop *l; @@ -1909,7 +1909,7 @@ static int sticky_select(float *limit, int hitv[4], int v, float *hituv[4], floa return 0; } -static int mouse_select(bContext *C, const float co[2], int extend, int loop) +static int mouse_select(bContext *C, const float co[2], bool extend, bool loop) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); @@ -2227,11 +2227,11 @@ static int mouse_select(bContext *C, const float co[2], int extend, int loop) static int select_exec(bContext *C, wmOperator *op) { float co[2]; - int extend, loop; + bool extend, loop; RNA_float_get_array(op->ptr, "location", co); extend = RNA_boolean_get(op->ptr, "extend"); - loop = 0; + loop = false; return mouse_select(C, co, extend, loop); } @@ -2272,11 +2272,11 @@ static void UV_OT_select(wmOperatorType *ot) static int select_loop_exec(bContext *C, wmOperator *op) { float co[2]; - int extend, loop; + bool extend, loop; RNA_float_get_array(op->ptr, "location", co); extend = RNA_boolean_get(op->ptr, "extend"); - loop = 1; + loop = true; return mouse_select(C, co, extend, loop); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 9de43fc9d6b..b80862d4db5 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -121,7 +121,7 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) return 1; if (em && em->bm->totface && !CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) - ED_mesh_uv_texture_add(C, obedit->data, NULL, TRUE); + ED_mesh_uv_texture_add(obedit->data, NULL, true); if (!ED_uvedit_test(obedit)) return 0; |