Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-12-22 18:47:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-12-22 18:50:50 +0300
commitc86395c02d4128a0b48f49bd0aa265bae60ea870 (patch)
tree2faface964c0ead11d908d8061f486025651e2e1 /source/blender/editors/space_view3d/view3d_view.c
parent887829e3d89f1adb01326d15241e2270fe3d71ce (diff)
View3D: use c99 compound literals for smoothview params
Smooth-view functions took many arguments which were often NULL, now take struct instead.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_view.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c77
1 files changed, 42 insertions, 35 deletions
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 2e9dcdc9ba6..1201f70ed94 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(oldcamera, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
+ ED_view3d_from_object(sview->camera_old, sms.src.ofs, sms.src.quat, &sms.src.dist, &sms.src.lens);
}
/* grid draw as floor */
if ((rv3d->viewlock & RV3D_LOCKED) == 0) {
@@ -251,7 +253,7 @@ void ED_view3d_smooth_view_ex(
* we can decrease the time allowed by
* the angle between quats
* this means small rotations wont lag */
- if (quat && !ofs && !dist) {
+ if (sview->quat && !sview->ofs && !sview->dist) {
float vec1[3] = {0, 0, 1}, vec2[3] = {0, 0, 1};
float q1[4], q2[4];
@@ -269,8 +271,8 @@ void ED_view3d_smooth_view_ex(
if (sms.to_camera) {
/* use ortho if we move from an ortho view to an ortho camera */
rv3d->persp = (((rv3d->is_persp == false) &&
- (camera->type == OB_CAMERA) &&
- (((Camera *)camera->data)->type == CAM_ORTHO)) ?
+ (sview->camera->type == OB_CAMERA) &&
+ (((Camera *)sview->camera->data)->type == CAM_ORTHO)) ?
RV3D_ORTHO : RV3D_PERSP);
}
@@ -316,9 +318,8 @@ void ED_view3d_smooth_view_ex(
void ED_view3d_smooth_view(
bContext *C,
- 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 struct V3D_SmoothParams *sview)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -326,8 +327,8 @@ void ED_view3d_smooth_view(
ED_view3d_smooth_view_ex(
wm, win, sa,
- v3d, ar, oldcamera, camera,
- ofs, quat, dist, lens, smooth_viewtx);
+ v3d, ar, smooth_viewtx,
+ sview);
}
/* only meant for timer usage */
@@ -576,9 +577,12 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
if (camera_old != ob) {
ED_view3d_lastview_store(rv3d);
- ED_view3d_smooth_view(C, v3d, ar, camera_old, 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_old = camera_old, .camera = v3d->camera,
+ .ofs = rv3d->ofs, .quat = rv3d->viewquat,
+ .dist = &rv3d->dist, .lens = &v3d->lens});
}
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS | NC_OBJECT | ND_DRAW, CTX_data_scene(C));
@@ -1308,10 +1312,11 @@ static bool view3d_localview_init(
}
ED_view3d_smooth_view_ex(
- wm, win, sa,
- v3d, ar, camera_old, NULL,
- ofs_new, NULL, ok_dist ? &dist_new : NULL, NULL,
- smooth_viewtx);
+ wm, win, sa, v3d, ar, smooth_viewtx,
+ &(const V3D_SmoothParams){
+ .camera_old = camera_old,
+ .ofs = ofs_new, .quat = rv3d->viewquat,
+ .dist = ok_dist ? &dist_new : NULL, .lens = &v3d->lens});
}
}
@@ -1372,9 +1377,11 @@ static void restore_localviewdata(wmWindowManager *wm, wmWindow *win, Main *bmai
ED_view3d_smooth_view_ex(
wm, win, sa,
- v3d, ar, camera_old_rv3d, camera_new_rv3d,
- rv3d->localvd->ofs, rv3d->localvd->viewquat, &rv3d->localvd->dist, NULL,
- smooth_viewtx);
+ v3d, ar, smooth_viewtx,
+ &(const V3D_SmoothParams){
+ .camera_old = camera_old_rv3d, .camera = camera_new_rv3d,
+ .ofs = rv3d->localvd->ofs, .quat = rv3d->localvd->viewquat,
+ .dist = &rv3d->localvd->dist});
if (free) {
MEM_freeN(rv3d->localvd);