Fix #37261 Rendering a Render Layer from another scene doesn't update.

The scene pointer used for looking up the appropriate source of render result images in the image editor was always taken from context. This means that render results for a different scene would never be
displayed in the image editor.

To give feedback on running renders, try to get the running render job's scene pointer in the image editor for render result type images. This only happens during rendering, apart from that the regular
context scene result is displayed.
This commit is contained in:
Lukas Toenne 2013-10-31 17:20:31 +00:00
parent beae4f498d
commit c9fdec14f5
5 changed files with 47 additions and 11 deletions

View File

@ -55,6 +55,7 @@ void ED_render_scene_update(struct Main *bmain, struct Scene *scene, int updated
void ED_render_view3d_shade_update(struct Main *bmain, struct View3D *v3d, struct ScrArea *sa);
void ED_viewport_render_kill_jobs(const struct bContext *C, bool free_database);
struct Scene *ED_render_job_get_scene(const struct bContext *C);
/* render_preview.c */

View File

@ -1237,3 +1237,13 @@ void ED_viewport_render_kill_jobs(const bContext *C, bool free_database)
}
}
Scene *ED_render_job_get_scene(const bContext *C)
{
wmWindowManager *wm = CTX_wm_manager(C);
RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER);
if (rj)
return rj->scene;
return NULL;
}

View File

@ -56,6 +56,7 @@
#include "ED_mask.h"
#include "ED_mesh.h"
#include "ED_node.h"
#include "ED_render.h"
#include "ED_space_api.h"
#include "ED_screen.h"
#include "ED_uvedit.h"
@ -653,7 +654,16 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
glClear(GL_COLOR_BUFFER_BIT);
/* put scene context variable in iuser */
sima->iuser.scene = scene;
if (sima->image && sima->image->type == IMA_TYPE_R_RESULT) {
/* for render result, try to use the currently rendering scene */
Scene *render_scene = ED_render_job_get_scene(C);
if (render_scene)
sima->iuser.scene = render_scene;
else
sima->iuser.scene = scene;
}
else
sima->iuser.scene = scene;
/* we set view2d from own zoom and offset each time */
image_main_area_set_view2d(sima, ar);

View File

@ -378,6 +378,7 @@ int WM_jobs_test(struct wmWindowManager *wm, void *owner, int job_type);
float WM_jobs_progress(struct wmWindowManager *wm, void *owner);
char *WM_jobs_name(struct wmWindowManager *wm, void *owner);
void *WM_jobs_customdata(struct wmWindowManager *wm, void *owner);
void *WM_jobs_customdata_from_type(struct wmWindowManager *wm, int job_type);
int WM_jobs_is_running(struct wmJob *);
void *WM_jobs_customdata_get(struct wmJob *);

View File

@ -166,22 +166,27 @@ static void wm_job_main_thread_yield(wmJob *wm_job, bool ending)
}
/* finds:
* if type, compare for it, otherwise any matching job
* if type or owner, compare for it, otherwise any matching job
*/
static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const int job_type)
{
wmJob *wm_job;
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner) {
if (job_type) {
if ( wm_job->job_type == job_type)
return wm_job;
}
else
if (owner && job_type) {
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner && wm_job->job_type == job_type)
return wm_job;
}
}
else if (owner) {
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->owner == owner)
return wm_job;
}
else if (job_type) {
for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next)
if (wm_job->job_type == job_type)
return wm_job;
}
return NULL;
}
@ -263,7 +268,16 @@ void *WM_jobs_customdata(wmWindowManager *wm, void *owner)
return WM_jobs_customdata_get(wm_job);
return NULL;
}
void *WM_jobs_customdata_from_type(wmWindowManager *wm, int job_type)
{
wmJob *wm_job = wm_job_find(wm, NULL, job_type);
if (wm_job)
return WM_jobs_customdata_get(wm_job);
return NULL;
}
int WM_jobs_is_running(wmJob *wm_job)