svn merge -r 22371:22571 https://svn.blender.org/svnroot/bf-blender/branches/blender2...
[blender-staging.git] / source / blender / render / intern / source / pipeline.c
index 31091ab020a699452190d25c8ea2c33d38108cdd..b417e07577cbc3f0d2106c1ddc72728ea1b86ad2 100644 (file)
@@ -879,33 +879,26 @@ static void renderresult_add_names(RenderResult *rr)
                        strcpy(rpass->name, get_pass_name(rpass->passtype, -1));
 }
 
-
-/* only for temp buffer files, makes exact copy of render result */
-static void read_render_result(Render *re, int sample)
+/* called for reading temp files, and for external engines */
+static int read_render_result_from_file(char *filename, RenderResult *rr)
 {
        RenderLayer *rl;
        RenderPass *rpass;
        void *exrhandle= IMB_exr_get_handle();
        int rectx, recty;
-       char str[FILE_MAX];
-       
-       RE_FreeRenderResult(re->result);
-       re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM);
 
-       render_unique_exr_name(re, str, sample);
-       if(IMB_exr_begin_read(exrhandle, str, &rectx, &recty)==0) {
+       if(IMB_exr_begin_read(exrhandle, filename, &rectx, &recty)==0) {
                IMB_exr_close(exrhandle);
-               printf("cannot read: %s\n", str);
-               return;
+               return 0;
        }
        
-       printf("read exr tmp file: %s\n", str);
-       
-       if(re->result == NULL || rectx!=re->result->rectx || recty!=re->result->recty) {
+       if(rr == NULL || rectx!=rr->rectx || recty!=rr->recty) {
                printf("error in reading render result\n");
+               IMB_exr_close(exrhandle);
+               return 0;
        }
        else {
-               for(rl= re->result->layers.first; rl; rl= rl->next) {
+               for(rl= rr->layers.first; rl; rl= rl->next) {
                        
                        /* combined */
                        if(rl->rectf) {
@@ -925,10 +918,27 @@ static void read_render_result(Render *re, int sample)
                        
                }
                IMB_exr_read_channels(exrhandle);
-               renderresult_add_names(re->result);
+               renderresult_add_names(rr);
        }
        
        IMB_exr_close(exrhandle);
+
+       return 1;
+}
+
+/* only for temp buffer files, makes exact copy of render result */
+static void read_render_result(Render *re, int sample)
+{
+       char str[FILE_MAX];
+
+       RE_FreeRenderResult(re->result);
+       re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM);
+
+       render_unique_exr_name(re, str, sample);
+       printf("read exr tmp file: %s\n", str);
+
+       if(!read_render_result_from_file(str, re->result))
+               printf("cannot read: %s\n", str);
 }
 
 /* *************************************************** */
@@ -2571,8 +2581,15 @@ static int render_initialize_from_scene(Render *re, Scene *scene, int anim, int
        /* check all scenes involved */
        tag_scenes_for_render(re);
 
-       /* make sure dynamics are up to date */
-       update_physics_cache(re, scene, anim_init);
+       /*
+        * Disabled completely for now,
+        * can be later set as render profile option
+        * and default for background render.
+       */
+       if(0) {
+               /* make sure dynamics are up to date */
+               update_physics_cache(re, scene, anim_init);
+       }
        
        if(scene->r.scemode & R_SINGLE_LAYER)
                push_render_result(re);
@@ -2948,7 +2965,7 @@ void RE_engine_update_stats(RenderEngine *engine, char *stats, char *info)
 
 /* loads in image into a result, size must match
  * x/y offsets are only used on a partial copy when dimensions dont match */
-void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *filename, int x, int y)
+void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, char *filename)
 {
        ImBuf *ibuf = IMB_loadiffname(filename, IB_rect);
 
@@ -2959,7 +2976,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file
 
                        memcpy(layer->rectf, ibuf->rect_float, sizeof(float)*4*layer->rectx*layer->recty);
                } else {
-                       if ((ibuf->x - x >= layer->rectx) && (ibuf->y - y >= layer->recty)) {
+                       if ((ibuf->x >= layer->rectx) && (ibuf->y >= layer->recty)) {
                                ImBuf *ibuf_clip;
 
                                if(ibuf->rect_float==NULL)
@@ -2967,7 +2984,7 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file
 
                                ibuf_clip = IMB_allocImBuf(layer->rectx, layer->recty, 32, IB_rectfloat, 0);
                                if(ibuf_clip) {
-                                       IMB_rectcpy(ibuf_clip, ibuf, 0,0, x,y, layer->rectx, layer->recty);
+                                       IMB_rectcpy(ibuf_clip, ibuf, 0,0, 0,0, layer->rectx, layer->recty);
 
                                        memcpy(layer->rectf, ibuf_clip->rect_float, sizeof(float)*4*layer->rectx*layer->recty);
                                        IMB_freeImBuf(ibuf_clip);
@@ -2987,6 +3004,15 @@ void RE_layer_rect_from_file(RenderLayer *layer, ReportList *reports, char *file
                BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename);
        }
 }
+
+void RE_result_load_from_file(RenderResult *result, ReportList *reports, char *filename)
+{
+       if(!read_render_result_from_file(filename, result)) {
+               BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename);
+               return;
+       }
+}
+
 static void external_render_3d(Render *re, RenderEngineType *type)
 {
        RenderEngine engine;