Commit: c86395c02d4128a0b48f49bd0aa265bae60ea870
Author: Campbell Barton
Date:   Wed Dec 23 02:47:34 2015 +1100
Branches: master
https://developer.blender.org/rBc86395c02d4128a0b48f49bd0aa265bae60ea870

View3D: use c99 compound literals for smoothview params

Smooth-view functions took many arguments which were often NULL,
now take struct instead.

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

M       source/blender/editors/space_view3d/view3d_edit.c
M       source/blender/editors/space_view3d/view3d_intern.h
M       source/blender/editors/space_view3d/view3d_view.c

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

diff --git a/source/blender/editors/space_view3d/view3d_edit.c 
b/source/blender/editors/space_view3d/view3d_edit.c
index b09cbed..069541a 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2880,14 +2880,16 @@ static void view3d_from_minmax(bContext *C, View3D 
*v3d, ARegion *ar,
 
        if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, 
rv3d)) {
                rv3d->persp = RV3D_PERSP;
-               ED_view3d_smooth_view(C, v3d, ar, v3d->camera, NULL,
-                                     new_ofs, NULL, ok_dist ? &new_dist : 
NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){
+                           .camera_old=v3d->camera, .ofs = new_ofs,
+                           .dist = ok_dist ? &new_dist : NULL});
        }
        else {
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     new_ofs, NULL, ok_dist ? &new_dist : 
NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.ofs = new_ofs, .dist = 
ok_dist ? &new_dist : NULL});
        }
 
        /* smooth view does viewlock RV3D_BOXVIEW copy */
@@ -3196,10 +3198,10 @@ static int viewcenter_cursor_exec(bContext *C, 
wmOperator *op)
                /* non camera center */
                float new_ofs[3];
                negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d));
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     new_ofs, NULL, NULL, NULL,
-                                     smooth_viewtx);
-               
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.ofs = new_ofs});
+
                /* smooth view does viewlock RV3D_BOXVIEW copy */
        }
        
@@ -3243,9 +3245,9 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator 
*op, const wmEvent *ev
                        ED_view3d_win_to_3d_int(ar, new_ofs, event->mval, 
new_ofs);
                }
                negate_v3(new_ofs);
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     new_ofs, NULL, NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.ofs = new_ofs});
        }
 
        return OPERATOR_FINISHED;
@@ -3628,9 +3630,9 @@ static int view3d_zoom_border_exec(bContext *C, 
wmOperator *op)
        /* clamp after because we may have been zooming out */
        CLAMP(new_dist, dist_range[0], dist_range[1]);
 
-       ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                             new_ofs, NULL, &new_dist, NULL,
-                             smooth_viewtx);
+       ED_view3d_smooth_view(
+               C, v3d, ar, smooth_viewtx,
+               &(const V3D_SmoothParams){.ofs = new_ofs, .dist = &new_dist});
 
        if (rv3d->viewlock & RV3D_BOXVIEW)
                view3d_boxview_sync(CTX_wm_area(C), ar);
@@ -3785,9 +3787,9 @@ static void axis_set_view(bContext *C, View3D *v3d, 
ARegion *ar,
 
        if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
                /* to camera */
-               ED_view3d_smooth_view(C, v3d, ar, v3d->camera, NULL,
-                                     rv3d->ofs, quat, NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.camera_old = v3d->camera, 
.ofs = rv3d->ofs, .quat = quat});
        }
        else if (orig_persp == RV3D_CAMOB && v3d->camera) {
                /* from camera */
@@ -3799,15 +3801,15 @@ static void axis_set_view(bContext *C, View3D *v3d, 
ARegion *ar,
                /* so we animate _from_ the camera location */
                ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, 
&rv3d->dist, NULL);
 
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     ofs, quat, &dist, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.ofs = ofs, .quat = quat, 
.dist = &dist});
        }
        else {
                /* no camera involved */
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     NULL, quat, NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.quat = quat});
        }
 }
 
@@ -3896,9 +3898,11 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
 
                                /* finally do snazzy view zooming */
                                rv3d->persp = RV3D_CAMOB;
-                               ED_view3d_smooth_view(C, v3d, ar, NULL, 
v3d->camera,
-                                                     rv3d->ofs, 
rv3d->viewquat, &rv3d->dist, &v3d->lens,
-                                                     smooth_viewtx);
+                               ED_view3d_smooth_view(
+                                       C, v3d, ar, smooth_viewtx,
+                                       &(const V3D_SmoothParams){
+                                           .camera = v3d->camera, .ofs = 
rv3d->ofs, .quat = rv3d->viewquat,
+                                           .dist = &rv3d->dist, .lens = 
&v3d->lens});
 
                        }
                        else {
@@ -4031,9 +4035,9 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
                                smooth_viewtx = 0;
                        }
 
-                       ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                             ofs_new_pt, quat_new, NULL, NULL,
-                                             smooth_viewtx);
+                       ED_view3d_smooth_view(
+                               C, v3d, ar, smooth_viewtx,
+                               &(const V3D_SmoothParams){.ofs = ofs_new_pt, 
.quat = quat_new});
 
                        return OPERATOR_FINISHED;
                }
@@ -4198,9 +4202,9 @@ static int viewroll_exec(bContext *C, wmOperator *op)
                negate_v3(mousevec);
                view_roll_angle(ar, quat_new, rv3d->viewquat, mousevec, angle);
 
-               ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
-                                     NULL, quat_new, NULL, NULL,
-                                     smooth_viewtx);
+               ED_view3d_smooth_view(
+                       C, v3d, ar, smooth_viewtx,
+                       &(const V3D_SmoothParams){.quat = quat_new});
 
                viewops_data_free(C, op);
                return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h 
b/source/blender/editors/space_view3d/view3d_intern.h
index 2c6d762..52b14d67 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -208,19 +208,20 @@ void VIEW3D_OT_game_start(struct wmOperatorType *ot);
 bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const struct 
BoundBox *bb, float obmat[4][4]);
 bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const struct BoundBox *bb);
 
+typedef struct V3D_SmoothParams {
+       struct Object *camera_old, *camera;
+       const float *ofs, *quat, *dist, *lens;
+} V3D_SmoothParams;
+
 void ED_view3d_smooth_view_ex(
         struct wmWindowManager *wm, struct wmWindow *win, struct ScrArea *sa,
-        struct View3D *v3d, struct ARegion *ar,
-        struct Object *camera_old, struct Object *camera,
-        const float *ofs, const float *quat, const float *dist, const float 
*lens,
-        const int smooth_viewtx);
+        struct View3D *v3d, struct ARegion *ar, const int smooth_viewtx,
+        const V3D_SmoothParams *sview);
 
 void ED_view3d_smooth_view(
         struct bContext *C,
-        struct View3D *v3d, struct ARegion *ar,
-        struct Object *camera_old, struct Object *camera,
-        const float *ofs, const float *quat, const float *dist, const float 
*lens,
-        const int smooth_viewtx);
+        struct View3D *v3d, struct ARegion *ar, const int smooth_viewtx,
+        const V3D_SmoothParams *sview);
 
 void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rctf *rect);
 void view3d_viewmatrix_set(Scene *scene, const View3D *v3d, RegionView3D 
*rv3d);
diff --git a/source/blender/editors/space_view3d/view3d_view.c 
b/source/blender/editors/space_view3d/view3d_view.c
index 2e9dcdc..1201f70 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -168,10 +168,8 @@ static void view3d_smooth_view_state_restore(const struct 
SmoothView3DState *sms
 void ED_view3d_smooth_view_ex(
         /* avoid passing in the context */
         wmWindowManager *wm, wmWindow *win, ScrArea *sa,
-
-        View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
-        const float *ofs, const float *quat, const float *dist, const float 
*lens,
-        const int smooth_viewtx)
+        View3D *v3d, ARegion *ar, const int smooth_viewtx,
+        const V3D_SmoothParams *sview)
 {
        RegionView3D *rv3d = ar->regiondata;
        struct SmoothView3DStore sms = {{0}};
@@ -199,19 +197,23 @@ void ED_view3d_smooth_view_ex(
         * camera to be moved or changed, so only when the camera is not being 
set should
         * we allow camera option locking to initialize the view settings from 
the camera.
         */
-       if (camera == NULL && oldcamera == NULL) {
+       if (sview->camera == NULL && sview->camera_old == NULL) {
                ED_view3d_camera_lock_init(v3d, rv3d);
        }
 
        /* store the options we want to end with */
-       if (ofs)  copy_v3_v3(sms.dst.ofs, ofs);
-       if (quat) copy_qt_qt(sms.dst.quat, quat);
-       if (dist) sms.dst.dist = *dist;
-       if (lens) sms.dst.lens = *lens;
-
-       if (camera) {
-               sms.dst.dist = ED_view3d_offset_distance(camera->obmat, ofs, 
VIEW3D_DIST_FALLBACK);
-               ED_view3d_from_object(camera, sms.dst.ofs, sms.dst.quat, 
&sms.dst.dist, &sms.dst.lens);
+       if (sview->ofs)
+               copy_v3_v3(sms.dst.ofs, sview->ofs);
+       if (sview->quat)
+               copy_qt_qt(sms.dst.quat, sview->quat);
+       if (sview->dist)
+               sms.dst.dist = *sview->dist;
+       if (sview->lens)
+               sms.dst.lens = *sview->lens;
+
+       if (sview->camera) {
+               sms.dst.dist = ED_view3d_offset_distance(sview->camera->obmat, 
sview->ofs, VIEW3D_DIST_FALLBACK);
+               ED_view3d_from_object(sview->camera, sms.dst.ofs, sms.dst.quat, 
&sms.dst.dist, &sms.dst.lens);
                sms.to_camera = true; /* restore view3d values in end */
        }
        
@@ -219,7 +221,7 @@ void ED_view3d_smooth_view_ex(
        if (smooth_viewtx && v3d->drawtype != OB_RENDER) {
                bool changed = false; /* zero means no difference */
                
-               if (oldcamera != camera)
+               if (sview->camera_old != sview->camera)
                        changed = true;
                else if (sms.dst.dist != rv3d->dist)
                        changed = true;
@@ -234,10 +236,10 @@ void ED_view3d_smooth_view_ex(
                 * so animate the view */
                if (changed) {
                        /* original values */
-                       if (oldcamera) {
-                               sms.src.dist = 
ED_view3d_offset_distance(oldcamera->obmat, rv3d->ofs, 0.0f);
+                       if (sview->camera_old) {
+                               sms.src.dist = 
ED_view3d_offset_distance(sview->camera_old->obmat, rv3d->ofs, 0.0f);
                                /* this */
-                               ED_view3d_from_object(oldc

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to