Revision: 18083
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18083
Author:   ton
Date:     2008-12-26 19:15:46 +0100 (Fri, 26 Dec 2008)

Log Message:
-----------
2.5

Brought back 'smooth view'. Took some hours to untangle it all,
code was spread all over, instead of localized in 1 call. Tsk!
Still not perfect, but at least more in control. For the hackers;
check void smooth_view() in view3d_view.c, here all 3d view
stuff should be handled, so it can optionally use animating.

For the users: 'smooth view' now plays at a maximum of 30 hz,
and doesn't block anymore. So even slow animated views remain
responsive if you press many numpad keys.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_view3d_types.h
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c

Modified: 
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-26 18:00:38 UTC (rev 18082)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c     
2008-12-26 18:15:46 UTC (rev 18083)
@@ -4248,6 +4248,8 @@
                                v3d->clipbb= newdataadr(fd, v3d->clipbb);
                                v3d->retopo_view_data= NULL;
                                v3d->properties_storage= NULL;
+                               v3d->sms= NULL;
+                               v3d->smooth_timer= NULL;
                        }
                        else if (sl->spacetype==SPACE_OOPS) {
                                SpaceOops *soops= (SpaceOops*) sl;

Modified: 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c   
    2008-12-26 18:00:38 UTC (rev 18082)
+++ 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c   
    2008-12-26 18:15:46 UTC (rev 18083)
@@ -724,24 +724,13 @@
                        new_dist*= size;
                }
 
-               if (v3d->persp==V3D_CAMOB && v3d->camera) {
-                       /* switch out of camera view */
-                       float orig_lens= v3d->lens;
-
+               if (v3d->persp==V3D_CAMOB) {
                        v3d->persp= V3D_PERSP;
-                       v3d->dist= 0.0;
-                       view_settings_from_ob(v3d->camera, v3d->ofs, NULL, 
NULL, &v3d->lens);
-                       smooth_view(v3d, new_ofs, NULL, &new_dist, &orig_lens); 
/* TODO - this dosnt work yet */
-
-               } else {
-                       if(v3d->persp==V3D_CAMOB) v3d->persp= V3D_PERSP;
-                       smooth_view(v3d, new_ofs, NULL, &new_dist, NULL); /* 
TODO - this dosnt work yet */
+                       smooth_view(C, NULL, v3d->camera, new_ofs, NULL, 
&new_dist, NULL); 
                }
        }
 // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
 
-       ED_region_tag_redraw(ar);
-
        return OPERATOR_FINISHED;
 }
 
@@ -861,24 +850,16 @@
        v3d->cursor[1]= -new_ofs[1];
        v3d->cursor[2]= -new_ofs[2];
 
-       if (v3d->persp==V3D_CAMOB && v3d->camera) {
-               float orig_lens= v3d->lens;
-
-               v3d->persp=V3D_PERSP;
-               v3d->dist= 0.0f;
-               view_settings_from_ob(v3d->camera, v3d->ofs, NULL, NULL, 
&v3d->lens);
-               smooth_view(v3d, new_ofs, NULL, &new_dist, &orig_lens);
-       } else {
-               if(v3d->persp==V3D_CAMOB)
-                       v3d->persp= V3D_PERSP;
-
-               smooth_view(v3d, new_ofs, NULL, &new_dist, NULL);
+       if (v3d->persp==V3D_CAMOB) {
+               v3d->persp= V3D_PERSP;
+               smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, 
NULL);
+       } 
+       else {
+               smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
        }
 
 // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
 
-       ED_region_tag_redraw(ar);
-
        return OPERATOR_FINISHED;
 }
 void VIEW3D_OT_viewcenter(wmOperatorType *ot)
@@ -914,56 +895,47 @@
        {V3D_VIEW_PANDOWN, "PANDOWN", "Pan Down", "Pan the view Down"},
        {0, NULL, NULL, NULL}};
 
-static void axis_set_view(View3D *v3d, float q1, float q2, float q3, float q4, 
short view, int perspo)
+static void axis_set_view(bContext *C, View3D *v3d, float q1, float q2, float 
q3, float q4, short view, int perspo)
 {
        float new_quat[4];
        new_quat[0]= q1; new_quat[1]= q2;
        new_quat[2]= q3; new_quat[3]= q4;
        v3d->view=0;
 
-
+       v3d->view= view;
+       
        if (v3d->persp==V3D_CAMOB && v3d->camera) {
-               /* Is this switching from a camera view ? */
-               float orig_ofs[3];
-               float orig_lens= v3d->lens;
-               VECCOPY(orig_ofs, v3d->ofs);
-               view_settings_from_ob(v3d->camera, v3d->ofs, v3d->viewquat, 
&v3d->dist, &v3d->lens);
 
-
                if (U.uiflag & USER_AUTOPERSP) v3d->persp= V3D_ORTHO;
                else if(v3d->persp==V3D_CAMOB) v3d->persp= perspo;
 
-               smooth_view(v3d, orig_ofs, new_quat, NULL, &orig_lens);
-       } else {
+               smooth_view(C, v3d->camera, NULL, v3d->ofs, new_quat, NULL, 
NULL); 
+       } 
+       else {
 
                if (U.uiflag & USER_AUTOPERSP) v3d->persp= V3D_ORTHO;
                else if(v3d->persp==V3D_CAMOB) v3d->persp= perspo;
 
-               smooth_view(v3d, NULL, new_quat, NULL, NULL);
+               smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL);
        }
-       v3d->view= view;
+
 }
 
+
 static int viewnumpad_exec(bContext *C, wmOperator *op)
 {
        ScrArea *sa= CTX_wm_area(C);
        ARegion *ar= CTX_wm_region(C);
        View3D *v3d= sa->spacedata.first;
        Scene *scene= CTX_data_scene(C);
-       Object *act_cam_orig=NULL;
-
        float phi, si, q1[4], vec[3];
        static int perspo=V3D_PERSP;
-       float orig_ofs[3];
        int viewnum;
 
        viewnum = RNA_enum_get(op->ptr, "viewnum");
 
        /* Use this to test if we started out with a camera */
 
-       if (v3d->persp == V3D_CAMOB)
-               act_cam_orig = v3d->camera;
-
        /* Indicate that this view is inverted,
         * but only if it actually _was_ inverted (jobbe) */
        if (viewnum == V3D_VIEW_BOTTOM || viewnum == V3D_VIEW_BACK || viewnum 
== V3D_VIEW_LEFT)
@@ -973,50 +945,36 @@
 
        switch (viewnum) {
                case V3D_VIEW_BOTTOM :
-                       axis_set_view(v3d,0.0, -1.0, 0.0, 0.0, 7, perspo);
+                       axis_set_view(C, v3d, 0.0, -1.0, 0.0, 0.0, 7, perspo);
                        break;
 
                case V3D_VIEW_BACK:
-                       axis_set_view(v3d,0.0, 0.0, (float)-cos(M_PI/4.0), 
(float)-cos(M_PI/4.0), 1, perspo);
+                       axis_set_view(C, v3d, 0.0, 0.0, (float)-cos(M_PI/4.0), 
(float)-cos(M_PI/4.0), 1, perspo);
                        break;
 
                case V3D_VIEW_LEFT:
-                       axis_set_view(v3d,0.5, -0.5, 0.5, 0.5, 3, perspo);
+                       axis_set_view(C, v3d, 0.5, -0.5, 0.5, 0.5, 3, perspo);
                        break;
 
                case V3D_VIEW_TOP:
-                       axis_set_view(v3d,1.0, 0.0, 0.0, 0.0, 7, perspo);
+                       axis_set_view(C, v3d, 1.0, 0.0, 0.0, 0.0, 7, perspo);
                        break;
 
                case V3D_VIEW_FRONT:
-                       axis_set_view(v3d,(float)cos(M_PI/4.0), 
(float)-sin(M_PI/4.0), 0.0, 0.0, 1, perspo);
+                       axis_set_view(C, v3d, (float)cos(M_PI/4.0), 
(float)-sin(M_PI/4.0), 0.0, 0.0, 1, perspo);
                        break;
 
                case V3D_VIEW_RIGHT:
-                       axis_set_view(v3d,0.5, -0.5, -0.5, -0.5, 3, perspo);
+                       axis_set_view(C, v3d, 0.5, -0.5, -0.5, -0.5, 3, perspo);
                        break;
 
                case V3D_VIEW_PERSPORTHO:
 
-                       if (U.smooth_viewtx) {
-                               if(v3d->persp==V3D_PERSP) { 
v3d->persp=V3D_ORTHO;
-                               } else if (act_cam_orig) {
-                                       /* were from a camera view */
-                                       float orig_dist= v3d->dist;
-                                       float orig_lens= v3d->lens;
-                                       VECCOPY(orig_ofs, v3d->ofs);
-                                       v3d->persp=V3D_PERSP;
-                                       v3d->dist= 0.0;
+                       if(v3d->persp!=V3D_ORTHO) 
+                               v3d->persp=V3D_ORTHO;
+                       else v3d->persp=V3D_PERSP;
 
-                                       view_settings_from_ob(act_cam_orig, 
v3d->ofs, NULL, NULL, &v3d->lens);
-                                       smooth_view(v3d, orig_ofs, NULL, 
&orig_dist, &orig_lens);
-                               } else {
-                                       v3d->persp=V3D_PERSP;
-                               }
-                       } else {
-                               if(v3d->persp==V3D_PERSP) v3d->persp=V3D_ORTHO;
-                               else v3d->persp=V3D_PERSP;
-                       }
+                       ED_region_tag_redraw(ar);
                        break;
 
                case V3D_VIEW_CAMERA:
@@ -1027,49 +985,37 @@
                                QUATCOPY(v3d->lviewquat, v3d->viewquat);
                                v3d->lview= v3d->view;
                                v3d->lpersp= v3d->persp;
-                       }
-                       else{
-                               /* return to settings of last view */
-
-                               axis_set_view(v3d,v3d->lviewquat[0], 
v3d->lviewquat[1], v3d->lviewquat[2], v3d->lviewquat[3], v3d->lview, 
v3d->lpersp);
-                       }
+                               
 #if 0
-                       if(G.qual==LR_ALTKEY) {
-                               if(oldcamera && is_an_active_object(oldcamera)) 
{
-                                       v3d->camera= oldcamera;
+                               if(G.qual==LR_ALTKEY) {
+                                       if(oldcamera && 
is_an_active_object(oldcamera)) {
+                                               v3d->camera= oldcamera;
+                                       }
+                                       handle_view3d_lock();
                                }
-                               handle_view3d_lock();
-                       }
 #endif
-
-                       if(BASACT) {
-                       /* check both G.vd as G.scene cameras */
-                       if((v3d->camera==NULL || scene->camera==NULL) && 
OBACT->type==OB_CAMERA) {
-                               v3d->camera= OBACT;
-                               /*handle_view3d_lock();*/
+                               
+                               if(BASACT) {
+                                       /* check both G.vd as G.scene cameras */
+                                       if((v3d->camera==NULL || 
scene->camera==NULL) && OBACT->type==OB_CAMERA) {
+                                               v3d->camera= OBACT;
+                                               /*handle_view3d_lock();*/
+                                       }
                                }
-                       }
-
-                       if(v3d->camera==0) {
-                               v3d->camera= scene_find_camera(scene);
-                               /*handle_view3d_lock();*/
-                       }
-                       if(v3d->camera && (v3d->camera != act_cam_orig)) {
+                               
+                               if(v3d->camera==NULL) {
+                                       v3d->camera= scene_find_camera(scene);
+                                       /*handle_view3d_lock();*/
+                               }
                                v3d->persp= V3D_CAMOB;
-                               v3d->view= 0;
-
-                       } else if (U.smooth_viewtx) {
-                               /* move 3d view to camera view */
-                               float orig_lens = v3d->lens;
-                               VECCOPY(orig_ofs, v3d->ofs);
-
-                               if (act_cam_orig)
-                                       view_settings_from_ob(act_cam_orig, 
v3d->ofs, v3d->viewquat, &v3d->dist, &v3d->lens);
-
-                               smooth_view_to_camera(v3d);
-                               VECCOPY(v3d->ofs, orig_ofs);
-                               v3d->lens = orig_lens;
+                               smooth_view(C, NULL, v3d->camera, v3d->ofs, 
v3d->viewquat, &v3d->dist, &v3d->lens);
+                               
                        }
+                       else{
+                               /* return to settings of last view */
+                               /* does smooth_view too */
+                               axis_set_view(C, v3d, v3d->lviewquat[0], 
v3d->lviewquat[1], v3d->lviewquat[2], v3d->lviewquat[3], v3d->lview, 
v3d->lpersp);
+                       }
                        break;
 
                case V3D_VIEW_STEPLEFT:
@@ -1104,6 +1050,7 @@
                                        QuatMul(v3d->viewquat, v3d->viewquat, 
q1);
                                        v3d->view= 0;
                                }
+                               ED_region_tag_redraw(ar);
                        }
                        break;
 
@@ -1122,6 +1069,7 @@
                        v3d->ofs[1]+= vec[1];
                        v3d->ofs[2]+= vec[2];
 
+                       ED_region_tag_redraw(ar);
                        break;
 
                default :
@@ -1130,9 +1078,6 @@
 
        if(v3d->persp != V3D_CAMOB) perspo= v3d->persp;
 
-
-       WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
-
        return OPERATOR_FINISHED;
 }
 
@@ -1416,7 +1361,7 @@
                new_dist = ((new_dist*scale) >= 0.001*v3d->grid)? 
new_dist*scale:0.001*v3d->grid;
        }
 
-       smooth_view(v3d, new_ofs, NULL, &new_dist, NULL);
+       smooth_view(NULL, NULL, NULL, new_ofs, NULL, &new_dist, NULL); // XXX
 }
 
 

Modified: 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c 
    2008-12-26 18:00:38 UTC (rev 18082)
+++ 
branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c 
    2008-12-26 18:15:46 UTC (rev 18083)
@@ -259,30 +259,12 @@
                                        if (v3d->camera == base->object && 
v3d->persp==V3D_CAMOB)
                                                return;
                                        
-                                       if (U.smooth_viewtx) {  
-                                               /* move 3d view to camera view 
*/
-                                               float orig_ofs[3], orig_lens = 
v3d->lens;
-                                               VECCOPY(orig_ofs, v3d->ofs);
-                                               
-                                               if (v3d->camera && 
v3d->persp==V3D_CAMOB)
-                                                       
view_settings_from_ob(v3d->camera, v3d->ofs, v3d->viewquat, &v3d->dist, 
&v3d->lens);
-                                               
-                                               v3d->camera = base->object;
-                                               handle_view3d_lock();
-                                               v3d->persp= V3D_CAMOB;
-                                               v3d->view= 0;
-                                               
-                                               smooth_view_to_camera(v3d);
-                                               
-                                               /* restore values */
-                                               VECCOPY(v3d->ofs, orig_ofs);
-                                               v3d->lens = orig_lens;
-                                       } else {
-                                               v3d->camera= base->object;
-                                               handle_view3d_lock();
-                                               v3d->persp= V3D_CAMOB;
-                                               v3d->view= 0;
-                                       }

@@ 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