Bugfix #4561
authorTon Roosendaal <ton@blender.org>
Sun, 2 Jul 2006 09:56:41 +0000 (09:56 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 2 Jul 2006 09:56:41 +0000 (09:56 +0000)
Sequence renders, calling scenes with compositing, didn't execute composite
correctly. Confusement caused by the rule that a "Render" handle has same
name as Scene, which gives conflict for the case when a Scene has
sequencing with Scene strips with its own scene in it.

The previous solution for that conflict caused composite not to work. This
commit solves that, but it is still hackish. Main reason is the still
bad global G.scene, in use by compositor.

source/blender/blenkernel/intern/node_composite.c
source/blender/src/sequence.c

index 0a002d4c1b046163ca075291329a8b8f867279c7..7b22f9e324faab15b27826c0191606012538772e 100644 (file)
@@ -619,7 +619,7 @@ static void node_composit_exec_composite(void *data, bNode *node, bNodeStack **i
        if(node->flag & NODE_DO_OUTPUT) {       /* only one works on out */
                RenderData *rd= data;
                if(rd->scemode & R_DOCOMP) {
-                       RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name));
+                       RenderResult *rr= RE_GetResult(RE_GetRender(G.scene->id.name)); /* G.scene is WEAK! */
                        if(rr) {
                                CompBuf *outbuf, *zbuf=NULL;
                                
@@ -963,7 +963,7 @@ static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, in
 
 static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 {
-       Scene *sce= node->id?(Scene *)node->id:G.scene;
+       Scene *sce= node->id?(Scene *)node->id:G.scene; /* G.scene is WEAK! */
        RenderData *rd= data;
        RenderResult *rr;
        
index b67951b3a1c6ddfb878347c701a73daa0ae00034..075ba650ef51c630035e7f10e7e16a134003b45f 100644 (file)
@@ -891,19 +891,23 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra)
                                Scene *sce= seq->scene, *oldsce= G.scene;
                                Render *re;
                                RenderResult rres;
-                               int doseq;
+                               int doseq, rendering= G.rendering;
+                               char scenename[64];
                                
                                waitcursor(1);
                                
-                               /* This function can be called from do_render_seq(), in that case
-                                  the seq->scene can already have a Render, so we use a default name.
+                               /* 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, 
+                                  so we have to use a default name. (compositor uses G.scene name to
+                                  find render).
                                   However, when called from within the UI (image preview in sequencer)
                                   we do want to use scene Render, that way the render result is defined
                                   for display in render/imagewindow */
-                               if(G.rendering)
-                                       re= RE_NewRender(" do_build_seq_ibuf"); 
-                               else
-                                       re= RE_NewRender(sce->id.name);
+                               if(rendering) {
+                                       BLI_strncpy(scenename, sce->id.name+2, 64);
+                                       strcpy(sce->id.name+2, " do_build_seq_ibuf");
+                               }
+                               re= RE_NewRender(sce->id.name);
                                
                                /* prevent eternal loop */
                                doseq= sce->r.scemode & R_DOSEQ;
@@ -916,6 +920,11 @@ static void do_build_seq_ibuf(Sequence * seq, int cfra)
                                RE_BlenderFrame(re, sce, seq->sfra + se->nr);
                                if(sce!=oldsce) set_scene_bg(oldsce);
                                
+                               /* UGLY WARNING, it is set to zero in  RE_BlenderFrame */
+                               G.rendering= rendering;
+                               if(rendering)
+                                       BLI_strncpy(sce->id.name+2, scenename, 64);
+                               
                                RE_GetResultImage(re, &rres);
                                
                                if(rres.rectf) {