diff options
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_edit.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 113 |
1 files changed, 54 insertions, 59 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 8cb2f33e353..8251533223e 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,7 +367,7 @@ 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 */ @@ -856,11 +856,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: @@ -2176,7 +2176,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 +2253,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 +2292,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 +2327,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; @@ -2357,7 +2357,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in int 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 +2372,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 +2393,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,7 +2434,7 @@ 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; + bool ok = false, ok_dist = true; 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 */ @@ -2505,8 +2501,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; } @@ -2737,7 +2733,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 +3036,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 +3102,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 +3116,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 +3133,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 +3182,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 +3194,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 */ @@ -3741,15 +3738,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 +3914,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 +3927,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 +3935,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 +3955,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 #ED_view3d_autodist_init first */ -int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], - int margin, float *force_depth) +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 +3972,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 +3982,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 +4018,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 +4036,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 +4150,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 +4193,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; } |