~diresu/blender/blender-command-port

« back to all changes in this revision

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

  • Committer: theeth
  • Date: 2008-10-14 16:52:04 UTC
  • Revision ID: vcs-imports@canonical.com-20081014165204-r32w2gm6s0osvdhn
copy back trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: drawscene.c 14582 2008-04-28 00:40:38Z aligorith $
 
3
 *
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software Foundation,
 
18
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 *
 
20
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
 
21
 * All rights reserved.
 
22
 *
 
23
 * The Original Code is: all of this file.
 
24
 *
 
25
 * Contributor(s): none yet.
 
26
 *
 
27
 * ***** END GPL LICENSE BLOCK *****
 
28
 * drawing graphics and editing
 
29
 */
 
30
        
 
31
#include <math.h>
 
32
 
 
33
#include "BLI_blenlib.h"
 
34
#include "BLI_arithb.h"
 
35
 
 
36
#include "DNA_scene_types.h"
 
37
#include "DNA_space_types.h"
 
38
#include "DNA_screen_types.h"
 
39
#include "DNA_userdef_types.h"
 
40
#include "DNA_view3d_types.h"
 
41
 
 
42
#include "BKE_global.h"
 
43
#include "BKE_main.h"
 
44
#include "BKE_scene.h"
 
45
 
 
46
#include "BDR_editobject.h"
 
47
#include "BDR_editface.h"
 
48
#include "BDR_sculptmode.h"
 
49
#include "BDR_vpaint.h"
 
50
 
 
51
#include "BIF_space.h"
 
52
#include "BIF_drawscene.h"
 
53
#include "BIF_editseq.h"
 
54
#include "BIF_poseobject.h"
 
55
 
 
56
#include "BSE_view.h"
 
57
 
 
58
#include "radio.h"
 
59
 
 
60
#include "blendef.h" /* old */
 
61
#include "mydevice.h"
 
62
 
 
63
#ifdef HAVE_CONFIG_H
 
64
#include <config.h>
 
65
#endif
 
66
 
 
67
void set_scene(Scene *sce)              /* also see scene.c: set_scene_bg() */
 
68
{
 
69
        bScreen *sc;
 
70
        
 
71
        /* ending all modes */
 
72
        if( G.obedit) 
 
73
                exit_editmode(EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR);
 
74
        
 
75
        exit_paint_modes();
 
76
        
 
77
        set_last_seq(NULL);
 
78
        
 
79
        G.scene= sce;
 
80
 
 
81
        sc= G.main->screen.first;
 
82
        while(sc) {
 
83
                if((U.flag & USER_SCENEGLOBAL) || sc==G.curscreen) {
 
84
                
 
85
                        if(sce != sc->scene) {
 
86
                                /* all areas endlocalview */
 
87
                                ScrArea *sa= sc->areabase.first;
 
88
                                while(sa) {
 
89
                                        endlocalview(sa);
 
90
                                        sa= sa->next;
 
91
                                }               
 
92
                                sc->scene= sce;
 
93
                        }
 
94
                        
 
95
                }
 
96
                sc= sc->id.next;
 
97
        }
 
98
        
 
99
        copy_view3d_lock(0);    /* space.c */
 
100
 
 
101
        /* are there cameras in the views that are not in the scene? */
 
102
        sc= G.main->screen.first;
 
103
        while(sc) {
 
104
                if( (U.flag & USER_SCENEGLOBAL) || sc==G.curscreen) {
 
105
                        ScrArea *sa= sc->areabase.first;
 
106
                        while(sa) {
 
107
                                SpaceLink *sl= sa->spacedata.first;
 
108
                                while(sl) {
 
109
                                        if(sl->spacetype==SPACE_VIEW3D) {
 
110
                                                View3D *v3d= (View3D*) sl;
 
111
                                                if (!v3d->camera || !object_in_scene(v3d->camera, sce)) {
 
112
                                                        v3d->camera= scene_find_camera(sc->scene);
 
113
                                                        if (sc==G.curscreen) handle_view3d_lock();
 
114
                                                        if (!v3d->camera && v3d->persp==V3D_CAMOB) v3d->persp= V3D_PERSP;
 
115
                                                }
 
116
                                        }
 
117
                                        sl= sl->next;
 
118
                                }
 
119
                                sa= sa->next;
 
120
                        }
 
121
                }
 
122
                sc= sc->id.next;
 
123
        }
 
124
 
 
125
        set_scene_bg(G.scene);
 
126
        scene_update_for_newframe(G.scene, G.scene->lay);
 
127
 
 
128
        set_radglobal();
 
129
                
 
130
        /* complete redraw */
 
131
        allqueue(REDRAWALL, 0);
 
132
        allqueue(REDRAWDATASELECT, 0);  /* does a remake */
 
133
}
 
134
 
 
135