~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/src/toets.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: toets.c,v 1.96 2007/01/17 04:02:09 nicholasbishop Exp $
3
2
 *
4
3
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
4
 *
121
120
        return 0;
122
121
}
123
122
 
 
123
/* run when pressing 1,3 or 7 */
 
124
static void axis_set_view(float q1, float q2, float q3, float q4, short view, int perspo)
 
125
{
 
126
        float new_quat[4];
 
127
        new_quat[0]= q1; new_quat[1]= q2;
 
128
        new_quat[2]= q3; new_quat[3]= q4;
 
129
        G.vd->view=0;
 
130
        
 
131
        if (G.vd->persp==2 && G.vd->camera) {
 
132
                /* Is this switching from a camera view ? */
 
133
                float orig_ofs[3];
 
134
                float orig_lens= G.vd->lens;
 
135
                VECCOPY(orig_ofs, G.vd->ofs);
 
136
                view_settings_from_ob(G.vd->camera, G.vd->ofs, G.vd->viewquat, &G.vd->dist, &G.vd->lens);
 
137
                
 
138
                if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
139
                else if(G.vd->persp>=2) G.vd->persp= perspo;
 
140
                
 
141
                smooth_view(G.vd, orig_ofs, new_quat, NULL, &orig_lens);
 
142
        } else {
 
143
                
 
144
                if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
 
145
                else if(G.vd->persp>=2) G.vd->persp= perspo;
 
146
                
 
147
                smooth_view(G.vd, NULL, new_quat, NULL, NULL);
 
148
        }
 
149
        G.vd->view= view;
 
150
}
 
151
 
124
152
void persptoetsen(unsigned short event)
125
153
{
126
154
        static Object *oldcamera=0;
128
156
        static int perspo=1;
129
157
        int preview3d_event= 1;
130
158
        
 
159
        float new_dist, orig_ofs[3];
 
160
        
 
161
        /* Use this to test if we started out with a camera */
 
162
        Object *act_cam_orig=NULL;
 
163
        if (G.vd->persp == 2)
 
164
                act_cam_orig = G.vd->camera;
 
165
        
131
166
        if(event==PADENTER) {
132
167
                if (G.qual == LR_SHIFTKEY) {
133
168
                        view3d_set_1_to_1_viewborder(G.vd);
135
170
                        if (G.vd->persp==2) {
136
171
                                G.vd->camzoom= 0;
137
172
                        } else {
138
 
                                G.vd->dist= 10.0;
 
173
                                new_dist = 10.0;
 
174
                                smooth_view(G.vd, NULL, NULL, &new_dist, NULL);
139
175
                        }
140
176
                }
141
177
        }
150
186
                        /* G.vd->persp= 3; */
151
187
                }
152
188
                else if(event==PAD7) {
153
 
                        G.vd->viewquat[0]= 0.0;
154
 
                        G.vd->viewquat[1]= -1.0;
155
 
                        G.vd->viewquat[2]= 0.0;
156
 
                        G.vd->viewquat[3]= 0.0;
157
 
                        G.vd->view= 7;
158
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0; 
159
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
189
                        axis_set_view(0.0, -1.0, 0.0, 0.0, 7, perspo);
160
190
                }
161
191
                else if(event==PAD1) {
162
 
                        G.vd->viewquat[0]= 0.0;
163
 
                        G.vd->viewquat[1]= 0.0;
164
 
                        G.vd->viewquat[2]= (float)-cos(M_PI/4.0);
165
 
                        G.vd->viewquat[3]= (float)-cos(M_PI/4.0);
166
 
                        G.vd->view=1;
167
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
168
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
192
                        axis_set_view(0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), 1, perspo);
169
193
                }
170
194
                else if(event==PAD3) {
171
 
                        G.vd->viewquat[0]= 0.5;
172
 
                        G.vd->viewquat[1]= -0.5;
173
 
                        G.vd->viewquat[2]= 0.5;
174
 
                        G.vd->viewquat[3]= 0.5;
175
 
                        G.vd->view=3;
176
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
177
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
195
                        axis_set_view(0.5, -0.5, 0.5, 0.5, 3, perspo);
178
196
                }
179
197
                else if(event==PADMINUS) {
180
198
                        /* this min and max is also in viewmove() */
212
230
                
213
231
 
214
232
                if(event==PAD7) {
215
 
                        G.vd->viewquat[0]= 1.0;
216
 
                        G.vd->viewquat[1]= 0.0;
217
 
                        G.vd->viewquat[2]= 0.0;
218
 
                        G.vd->viewquat[3]= 0.0;
219
 
                        G.vd->view=7;
220
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
221
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
233
                        axis_set_view(1.0, 0.0, 0.0, 0.0, 7, perspo);
222
234
                }
223
235
                else if(event==PAD1) {
224
 
                        G.vd->viewquat[0]= (float)cos(M_PI/4.0);
225
 
                        G.vd->viewquat[1]= (float)-sin(M_PI/4.0);
226
 
                        G.vd->viewquat[2]= 0.0;
227
 
                        G.vd->viewquat[3]= 0.0;
228
 
                        G.vd->view=1;
229
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
230
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
236
                        axis_set_view((float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, 1, perspo);
231
237
                }
232
238
                else if(event==PAD3) {
233
 
                        G.vd->viewquat[0]= 0.5;
234
 
                        G.vd->viewquat[1]= -0.5;
235
 
                        G.vd->viewquat[2]= -0.5;
236
 
                        G.vd->viewquat[3]= -0.5;
237
 
                        G.vd->view=3;
238
 
                        if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
239
 
                        else if(G.vd->persp>=2) G.vd->persp= perspo;
 
239
                        axis_set_view(0.5, -0.5, -0.5, -0.5, 3, perspo);
240
240
                }
241
241
                else if(event==PADMINUS) {
242
242
                        /* this min and max is also in viewmove() */
254
254
                        if(G.vd->persp!=1) preview3d_event= 0;
255
255
                }
256
256
                else if(event==PAD5) {
257
 
                        if(G.vd->persp==1) G.vd->persp=0;
258
 
                        else G.vd->persp=1;
 
257
                        if (U.smooth_viewtx) {
 
258
                                if(G.vd->persp==1) { G.vd->persp=0;
 
259
                                } else if (act_cam_orig) {
 
260
                                        /* were from a camera view */
 
261
                                        float orig_dist= G.vd->dist;
 
262
                                        float orig_lens= G.vd->lens;
 
263
                                        VECCOPY(orig_ofs, G.vd->ofs);
 
264
 
 
265
                                        G.vd->persp=1;
 
266
                                        G.vd->dist= 0.0;
 
267
 
 
268
                                        view_settings_from_ob(act_cam_orig, G.vd->ofs, NULL, NULL, &G.vd->lens);
 
269
                                        
 
270
                                        smooth_view(G.vd, orig_ofs, NULL, &orig_dist, &orig_lens);
 
271
                                        
 
272
                                } else {
 
273
                                        G.vd->persp=1;
 
274
                                }
 
275
                        } else {
 
276
                                if(G.vd->persp==1) G.vd->persp=0;
 
277
                                else G.vd->persp=1;
 
278
                        }
259
279
                }
260
280
                else if(event==PAD0) {
261
281
                        if(G.qual==LR_ALTKEY) {
262
282
                                if(oldcamera && is_an_active_object(oldcamera)) {
263
283
                                        G.vd->camera= oldcamera;
264
284
                                }
265
 
                                
266
285
                                handle_view3d_lock();
267
286
                        }
268
287
                        else if(BASACT) {
286
305
                                handle_view3d_lock();
287
306
                        }
288
307
                        
289
 
                        if(G.vd->camera) {
 
308
                        if(G.vd->camera && (G.vd->camera != act_cam_orig)) {
290
309
                                G.vd->persp= 2;
291
310
                                G.vd->view= 0;
 
311
                                
292
312
                                if(((G.qual & LR_CTRLKEY) && (G.qual & LR_ALTKEY)) || (G.qual & LR_SHIFTKEY)) {
293
313
                                        void setcameratoview3d(void);   // view.c
294
314
                                        setcameratoview3d();
295
315
                                        DAG_object_flush_update(G.scene, G.scene->camera, OB_RECALC_OB);
296
316
                                        BIF_undo_push("View to Camera position");
297
317
                                        allqueue(REDRAWVIEW3D, 0);
298
 
                                }                               
 
318
                                
 
319
                                } else if (U.smooth_viewtx) {
 
320
                                        /* move 3d view to camera view */
 
321
                                        float orig_lens = G.vd->lens;
 
322
                                        VECCOPY(orig_ofs, G.vd->ofs);
 
323
                                        
 
324
                                        if (act_cam_orig)
 
325
                                                view_settings_from_ob(act_cam_orig, G.vd->ofs, G.vd->viewquat, &G.vd->dist, &G.vd->lens);
 
326
                                        
 
327
                                        smooth_view_to_camera(G.vd);
 
328
                                        VECCOPY(G.vd->ofs, orig_ofs);
 
329
                                        G.vd->lens = orig_lens;
 
330
                                }
 
331
                                
 
332
                        
299
333
                        }
300
334
                }
301
335
                else if(event==PAD9) {
317
351
                                G.vd->view= 0;
318
352
                        }
319
353
                        if(event==PAD2 || event==PAD8) {
320
 
                                
321
354
                                /* horizontal axis */
322
355
                                VECCOPY(q1+1, G.vd->viewinv[0]);
323
356
                                
324
 
                                Normalise(q1+1);
 
357
                                Normalize(q1+1);
325
358
                                phi= (float)(M_PI/360.0)*U.pad_rot_angle;
326
359
                                if(event==PAD2) phi= -phi;
327
360
                                si= (float)sin(phi);
378
411
                ofs = 1;
379
412
        } else ofs = 0;
380
413
 
381
 
        for (recent = G.recent_files.first, i=0; (i<10) && (recent); recent = recent->next, i++) {
 
414
        for (recent = G.recent_files.first, i=0; (i<U.recent_files) && (recent); recent = recent->next, i++) {
382
415
                if (strcmp(recent->filename, G.sce)) {
383
416
                        p+= sprintf(p, "|%s %%x%d", recent->filename, i+ofs+1);
384
417
                }
604
637
                                CFRA--;
605
638
                        
606
639
                        if(G.qual==LR_SHIFTKEY)
607
 
                                CFRA= SFRA;
 
640
                                CFRA= PSFRA;
608
641
                        if(CFRA<1) CFRA=1;
609
642
        
610
643
                        update_for_newframe();
632
665
                                CFRA++;
633
666
 
634
667
                        if(G.qual==LR_SHIFTKEY)
635
 
                                CFRA= EFRA;
 
668
                                CFRA= PEFRA;
636
669
                        
637
670
                        update_for_newframe();
638
671
                }
873
906
                                }
874
907
                                return 0;
875
908
                        }
 
909
                        /* Python specials? ;)
876
910
                        else if(G.qual==LR_ALTKEY) {
877
911
                                write_videoscape_fs();
878
912
                                return 0;
879
 
                        }
 
913
                        }*/ 
880
914
                }
881
915
                break;
882
916
                
884
918
                if(textspace==0 && textediting==0) {
885
919
                        if(G.qual==LR_CTRLKEY) {
886
920
                                if(okee("Erase all")) {
887
 
                                        if( BIF_read_homefile()==0) error("No file ~/.B.blend");
 
921
                                        if( BIF_read_homefile(0)==0) error("No file ~/.B.blend");
888
922
                                }
889
923
                                return 0;
890
924
                        }