camera override option for scene strips.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 9 Mar 2010 13:52:52 +0000 (13:52 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 9 Mar 2010 13:52:52 +0000 (13:52 +0000)
release/scripts/ui/space_sequencer.py
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_sequencer/sequencer_draw.c
source/blender/makesdna/DNA_sequence_types.h
source/blender/makesrna/intern/rna_sequencer.c

index 1ca33a1..8badf74 100644 (file)
@@ -617,6 +617,10 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel):
         strip = act_strip(context)
 
         layout.template_ID(strip, "scene")
+
+        layout.label(text="Camera Override")
+        layout.template_ID(strip, "scene_camera")
+
         layout.prop(strip, "use_opengl")
 
 
index 7f04b20..336f45f 100644 (file)
@@ -64,6 +64,7 @@
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_sequence_types.h"
 #include "DNA_space_types.h"
 #include "DNA_texture_types.h"
 #include "DNA_userdef_types.h"
 #include "BKE_sca.h"
 #include "BKE_scene.h"
 #include "BKE_screen.h"
+#include "BKE_sequencer.h"
 #include "BKE_softbody.h"
 
 #include "LBM_fluidsim.h"
@@ -591,7 +593,16 @@ void unlink_object(Scene *scene, Object *ob)
                                }
                        }
 #endif
+                       if(sce->ed) {
+                               Sequence *seq;
+                               SEQ_BEGIN(sce->ed, seq)
+                                       if(seq->scene_camera==ob) {
+                                               seq->scene_camera= NULL;
+                                       }
+                               SEQ_END
+                       }
                }
+
                sce= sce->id.next;
        }
        
index 3a85676..481c1ef 100644 (file)
@@ -2136,6 +2136,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
                else if (se->ibuf==NULL && sce_valid) {
                        int frame= seq->sfra + se->nr + seq->anim_startofs;
                        int oldcfra = seq->scene->r.cfra;
+                       Object *oldcamera= seq->scene->camera;
 
                        /* Hack! This function can be called from do_render_seq(), in that case
                           the seq->scene can already have a Render initialized with same name,
@@ -2158,16 +2159,22 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
 
                        seq->scene->r.cfra= frame;
 
-                       if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && have_seq==0) {
+                       if(sequencer_view3d_cb && (seq->flag & SEQ_USE_SCENE_OPENGL) && (seq->scene == scene || have_seq==0)) {
                                /* opengl offscreen render */
+                               if(seq->scene_camera)   seq->scene->camera= seq->scene_camera;
+                               else                                    scene_camera_switch_update(seq->scene);
 
-                               scene_camera_switch_update(seq->scene);
                                scene_update_for_newframe(seq->scene, seq->scene->lay);
                                se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty);
                        }
                        else {
                                RenderResult rres;
 
+#ifdef DURIAN_CAMERA_SWITCH
+                               /* stooping to new low's in hackyness :( */
+                               scene_marker_tfm_translate(seq->scene, MAXFRAME*2, 0);
+#endif
+
                                if(rendering)
                                        re= RE_NewRender(" do_build_seq_ibuf", RE_SLOT_DEFAULT);
                                else
@@ -2192,12 +2199,18 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int
                                RE_ReleaseResultImage(re);
 
                                // BIF_end_render_callbacks();
+
+#ifdef DURIAN_CAMERA_SWITCH
+                               /* stooping to new low's in hackyness :( */
+                               scene_marker_tfm_translate(seq->scene, MAXFRAME*-2, 0);
+#endif
                        }
                        
                        /* restore */
                        scene->r.scemode |= doseq;
 
                        seq->scene->r.cfra = oldcfra;
+                       seq->scene->camera= oldcamera;
 
                        copy_to_ibuf_still(seq, se);
 
index b80e3df..7ba8386 100644 (file)
@@ -4143,6 +4143,7 @@ static void lib_link_scene(FileData *fd, Main *main)
                        SEQ_BEGIN(sce->ed, seq) {
                                if(seq->ipo) seq->ipo= newlibadr_us(fd, sce->id.lib, seq->ipo);
                                if(seq->scene) seq->scene= newlibadr(fd, sce->id.lib, seq->scene);
+                               if(seq->scene_camera) seq->scene_camera= newlibadr(fd, sce->id.lib, seq->scene_camera);
                                if(seq->sound) {
                                        seq->scene_sound = NULL;
                                        if(seq->type == SEQ_HD_SOUND)
@@ -11572,6 +11573,7 @@ static void expand_scene(FileData *fd, Main *mainvar, Scene *sce)
 
                SEQ_BEGIN(sce->ed, seq) {
                        if(seq->scene) expand_doit(fd, mainvar, seq->scene);
+                       if(seq->scene_camera) expand_doit(fd, mainvar, seq->scene_camera);
                        if(seq->sound) expand_doit(fd, mainvar, seq->sound);
                }
                SEQ_END
index 13e2a9e..0d72390 100644 (file)
@@ -438,39 +438,46 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
 {
        rctf rect;
        char str[32 + FILE_MAXDIR+FILE_MAXFILE];
+       const char *name= seq->name+2;
        
-       if(seq->name[2]) {
-               sprintf(str, "%d | %s: %s", seq->len, give_seqname(seq), seq->name+2);
+       if(name[0]=='\0')
+               name= give_seqname(seq);
+
+       if(seq->type == SEQ_META) {
+               sprintf(str, "%d | %s", seq->len, name);
        }
-       else{
-               if(seq->type == SEQ_META) {
-                       sprintf(str, "%d | %s", seq->len, give_seqname(seq));
-               }
-               else if(seq->type == SEQ_SCENE) {
-                       if(seq->scene) sprintf(str, "%d | %s: %s", seq->len, give_seqname(seq), seq->scene->id.name+2);
-                       else sprintf(str, "%d | %s", seq->len, give_seqname(seq));
-                       
-               }
-               else if(seq->type == SEQ_IMAGE) {
-                       sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
+       else if(seq->type == SEQ_SCENE) {
+               if(seq->scene) {
+                       if(seq->scene_camera) {
+                               sprintf(str, "%d | %s: %s (%s)", seq->len, name, seq->scene->id.name+2, ((ID *)seq->scene_camera)->name+2);
+                       } else {
+                               sprintf(str, "%d | %s: %s", seq->len, name, seq->scene->id.name+2);
+                       }
                }
-               else if(seq->type & SEQ_EFFECT) {
-                       int can_float = (seq->type != SEQ_PLUGIN)
-                               || (seq->plugin && seq->plugin->version >= 4);
-
-                       if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3)
-                               sprintf(str, "%d | %s: %d>%d (use %d)%s", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, seq->seq3->machine, can_float ? "" : " No float, upgrade plugin!");
-                       else if (seq->seq1 && seq->seq2)
-                               sprintf(str, "%d | %s: %d>%d%s", seq->len, give_seqname(seq), seq->seq1->machine, seq->seq2->machine, can_float ? "" : " No float, upgrade plugin!");
-                       else 
-                               sprintf(str, "%d | %s", seq->len, give_seqname(seq));
-               }
-               else if (seq->type == SEQ_SOUND) {
-                       sprintf(str, "%d | %s", seq->len, seq->sound->name);
-               }
-               else if (seq->type == SEQ_MOVIE) {
-                       sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
+               else {
+                       sprintf(str, "%d | %s", seq->len, name);
                }
+
+       }
+       else if(seq->type == SEQ_IMAGE) {
+               sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
+       }
+       else if(seq->type & SEQ_EFFECT) {
+               int can_float = (seq->type != SEQ_PLUGIN)
+                       || (seq->plugin && seq->plugin->version >= 4);
+
+               if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3)
+                       sprintf(str, "%d | %s: %d>%d (use %d)%s", seq->len, name, seq->seq1->machine, seq->seq2->machine, seq->seq3->machine, can_float ? "" : " No float, upgrade plugin!");
+               else if (seq->seq1 && seq->seq2)
+                       sprintf(str, "%d | %s: %d>%d%s", seq->len, name, seq->seq1->machine, seq->seq2->machine, can_float ? "" : " No float, upgrade plugin!");
+               else
+                       sprintf(str, "%d | %s", seq->len, name);
+       }
+       else if (seq->type == SEQ_SOUND) {
+               sprintf(str, "%d | %s", seq->len, seq->sound->name);
+       }
+       else if (seq->type == SEQ_MOVIE) {
+               sprintf(str, "%d | %s%s", seq->len, seq->strip->dir, seq->strip->stripdata->name);
        }
        
        if(seq->flag & SELECT){
index 14b121a..56d949e 100644 (file)
@@ -149,6 +149,8 @@ typedef struct Sequence {
 
        struct Ipo *ipo;        // xxx depreceated... old animation system
        struct Scene *scene;
+       struct Object *scene_camera; /* override scene camera */
+
        struct anim *anim;
        float effect_fader;
        float speed_fader;
index 14ccd79..8329533 100644 (file)
@@ -920,7 +920,11 @@ static void rna_def_scene(BlenderRNA *brna)
        RNA_def_property_flag(prop, PROP_EDITABLE);
        RNA_def_property_ui_text(prop, "Scene", "Scene that this sequence uses");
        RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
-       
+
+       prop= RNA_def_property(srna, "scene_camera", PROP_POINTER, PROP_NONE);
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera");
+       RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update");
 
        prop= RNA_def_property(srna, "use_opengl", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_SCENE_OPENGL);