Fix T44336: Unable to select cycles-specific passes in UV/image editor
This approach gets rid of iuser->pass for good. Also, I'm commenting out the pass increase/decrease. This was broken since multiview. I will fix it later (before 2.75), but I didn't want to get this patch mangled with that fix. Thanks Sergey Sharybin for the review and feedbacks. Reviewers: sergey Differential Revision: https://developer.blender.org/D1232
This commit is contained in:
parent
02fba106fa
commit
479b669693
@ -2475,7 +2475,7 @@ static void image_init_imageuser(Image *ima, ImageUser *iuser)
|
||||
RenderResult *rr = ima->rr;
|
||||
|
||||
iuser->multi_index = 0;
|
||||
iuser->layer = iuser->pass = iuser->view = 0;
|
||||
iuser->layer = iuser->view = 0;
|
||||
iuser->passtype = SCE_PASS_COMBINED;
|
||||
|
||||
if (rr) {
|
||||
@ -2649,15 +2649,14 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
|
||||
return NULL;
|
||||
|
||||
if (iuser) {
|
||||
short index = 0, rv_index, rl_index = 0, rp_index;
|
||||
short index = 0, rv_index, rl_index = 0;
|
||||
bool is_stereo = (iuser->flag & IMA_SHOW_STEREO) && RE_RenderResult_is_stereo(rr);
|
||||
|
||||
rv_index = is_stereo ? iuser->multiview_eye : iuser->view;
|
||||
if (RE_HasFakeLayer(rr)) rl_index += 1;
|
||||
|
||||
for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) {
|
||||
rp_index = 0;
|
||||
|
||||
for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) {
|
||||
for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++) {
|
||||
if (iuser->layer == rl_index &&
|
||||
iuser->passtype == rpass->passtype &&
|
||||
rv_index == rpass->view_id)
|
||||
@ -2668,20 +2667,16 @@ RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser)
|
||||
if (rpass)
|
||||
break;
|
||||
}
|
||||
|
||||
if (rpass) {
|
||||
iuser->multi_index = index;
|
||||
iuser->pass = rp_index;
|
||||
}
|
||||
else {
|
||||
iuser->multi_index = 0;
|
||||
iuser->pass = 0;
|
||||
}
|
||||
iuser->multi_index = (rpass ? index : 0);
|
||||
}
|
||||
|
||||
if (rpass == NULL) {
|
||||
rl = rr->layers.first;
|
||||
if (rl)
|
||||
rpass = rl->passes.first;
|
||||
|
||||
if (rpass && iuser)
|
||||
iuser->passtype = rpass->passtype;
|
||||
}
|
||||
|
||||
return rpass;
|
||||
|
@ -188,7 +188,7 @@ static void image_buffer_rect_update(RenderJob *rj, RenderResult *rr, ImBuf *ibu
|
||||
* - sergey -
|
||||
*/
|
||||
/* TODO(sergey): Need to check has_combined here? */
|
||||
if (iuser->pass == 0) {
|
||||
if (iuser->passtype == SCE_PASS_COMBINED) {
|
||||
size_t view_id = BKE_scene_multiview_view_id_get(&scene->r, viewname);
|
||||
/* find current float rect for display, first case is after composite... still weak */
|
||||
rectf = RE_RenderViewGetRectf(rr, view_id);
|
||||
@ -519,7 +519,6 @@ static void render_image_update_pass_and_layer(RenderJob *rj, RenderResult *rr,
|
||||
}
|
||||
}
|
||||
|
||||
iuser->pass = sima->iuser.pass;
|
||||
iuser->layer = sima->iuser.layer;
|
||||
|
||||
RE_ReleaseResult(rj->re);
|
||||
|
@ -435,7 +435,7 @@ static void ui_imageuser_pass_menu(bContext *UNUSED(C), uiLayout *layout, void *
|
||||
passflag |= rpass->passtype;
|
||||
|
||||
final:
|
||||
uiDefButS(block, UI_BTYPE_BUT_MENU, B_NOP, IFACE_(rpass->internal_name), 0, 0,
|
||||
uiDefButI(block, UI_BTYPE_BUT_MENU, B_NOP, IFACE_(rpass->internal_name), 0, 0,
|
||||
UI_UNIT_X * 5, UI_UNIT_X, &iuser->passtype, (float) rpass->passtype, 0.0, 0, -1, "");
|
||||
}
|
||||
|
||||
@ -545,6 +545,8 @@ static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v)
|
||||
}
|
||||
static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v)
|
||||
{
|
||||
/* this wasn't working before multiview, it needs to be fixed, but it wasn't working anyways --dfelinto */
|
||||
#if 0
|
||||
RenderResult *rr = rr_v;
|
||||
ImageUser *iuser = iuser_v;
|
||||
RenderLayer *rl = BLI_findlink(&rr->layers, iuser->layer);
|
||||
@ -561,9 +563,16 @@ static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v)
|
||||
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)C;
|
||||
(void)rr_v;
|
||||
(void)iuser_v;
|
||||
#endif
|
||||
}
|
||||
static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v)
|
||||
{
|
||||
/* this wasn't working before multiview, it needs to be fixed, but it wasn't working anyways --dfelinto */
|
||||
#if 0
|
||||
ImageUser *iuser = iuser_v;
|
||||
|
||||
if (iuser->pass > 0) {
|
||||
@ -571,6 +580,11 @@ static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v)
|
||||
BKE_image_multilayer_index(rr_v, iuser);
|
||||
WM_event_add_notifier(C, NC_IMAGE | ND_DRAW, NULL);
|
||||
}
|
||||
#else
|
||||
(void)C;
|
||||
(void)rr_v;
|
||||
(void)iuser_v;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* 5 view button callbacks... */
|
||||
@ -657,7 +671,7 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, Image *image, RenderRes
|
||||
|
||||
/* pass */
|
||||
fake_name = ui_imageuser_pass_fake_name(rl);
|
||||
rpass = (rl ? BLI_findlink(&rl->passes, iuser->pass - (fake_name ? 1 : 0)) : NULL);
|
||||
rpass = (rl ? RE_pass_find_by_type(rl, iuser->passtype, ((RenderView *)rr->views.first)->name) : NULL);
|
||||
|
||||
display_name = rpass ? rpass->internal_name : (fake_name ? fake_name : "");
|
||||
but = uiDefMenuBut(block, ui_imageuser_pass_menu, rnd_pt, display_name, 0, 0, wmenu3, UI_UNIT_Y, TIP_("Select Pass"));
|
||||
|
@ -1533,41 +1533,6 @@ static void save_image_options_to_op(SaveImageOptions *simopts, wmOperator *op)
|
||||
RNA_string_set(op->ptr, "filepath", simopts->filepath);
|
||||
}
|
||||
|
||||
/* returns the pass index for the view_id */
|
||||
static int get_multiview_pass_id(RenderResult *rr, ImageUser *iuser, const int view_id)
|
||||
{
|
||||
RenderLayer *rl;
|
||||
RenderPass *rpass;
|
||||
int passtype;
|
||||
short rl_index = 0, rp_index;
|
||||
|
||||
if (rr == NULL || iuser == NULL)
|
||||
return 0;
|
||||
|
||||
if (BLI_listbase_count_ex(&rr->views, 2) < 2)
|
||||
return iuser->pass;
|
||||
|
||||
if (RE_HasFakeLayer(rr))
|
||||
rl_index ++; /* fake compo/sequencer layer */
|
||||
|
||||
rl = BLI_findlink(&rr->layers, rl_index);
|
||||
if (!rl) return iuser->pass;
|
||||
|
||||
rpass = BLI_findlink(&rl->passes, iuser->pass);
|
||||
passtype = rpass->passtype;
|
||||
|
||||
rp_index = 0;
|
||||
for (rpass = rl->passes.first; rpass; rpass = rpass->next, rp_index++) {
|
||||
if (rpass->passtype == passtype &&
|
||||
rpass->view_id == view_id)
|
||||
{
|
||||
return rp_index;
|
||||
}
|
||||
}
|
||||
|
||||
return iuser->pass;
|
||||
}
|
||||
|
||||
static void save_image_post(wmOperator *op, ImBuf *ibuf, Image *ima, int ok, int save_copy, const char *relbase, int relative, int do_newpath, const char *filepath)
|
||||
{
|
||||
if (ok) {
|
||||
@ -1761,13 +1726,10 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
|
||||
iuser.view = i;
|
||||
iuser.flag &= ~IMA_SHOW_STEREO;
|
||||
|
||||
if (rr) {
|
||||
iuser.pass = get_multiview_pass_id(rr, &sima->iuser, i);
|
||||
if (rr)
|
||||
BKE_image_multilayer_index(rr, &iuser);
|
||||
}
|
||||
else {
|
||||
else
|
||||
BKE_image_multiview_index(ima, &iuser);
|
||||
}
|
||||
|
||||
ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock);
|
||||
ibuf->planes = planes;
|
||||
@ -1810,9 +1772,7 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI
|
||||
|
||||
if (rr) {
|
||||
int id = BLI_findstringindex(&rr->views, names[i], offsetof(RenderView, name));
|
||||
iuser.pass = get_multiview_pass_id(rr, &sima->iuser, id);
|
||||
iuser.view = id;
|
||||
|
||||
BKE_image_multilayer_index(rr, &iuser);
|
||||
}
|
||||
else {
|
||||
|
@ -55,12 +55,10 @@ typedef struct ImageUser {
|
||||
char ok;
|
||||
|
||||
char multiview_eye; /* multiview current eye - for internal use of drawing routines */
|
||||
int passtype;
|
||||
|
||||
short multi_index, view, layer, pass; /* listbase indices, for menu browsing or retrieve buffer */
|
||||
|
||||
short multi_index, view, layer; /* listbase indices, for menu browsing or retrieve buffer */
|
||||
short flag;
|
||||
short passtype;
|
||||
|
||||
} ImageUser;
|
||||
|
||||
typedef struct ImageAnim {
|
||||
|
@ -538,11 +538,6 @@ static void rna_def_imageuser(BlenderRNA *brna)
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
||||
RNA_def_property_ui_text(prop, "Layer", "Layer in multilayer image");
|
||||
|
||||
prop = RNA_def_property(srna, "multilayer_pass", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "pass");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
||||
RNA_def_property_ui_text(prop, "Pass", "Pass in multilayer image");
|
||||
|
||||
prop = RNA_def_property(srna, "multilayer_view", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_int_sdna(prop, NULL, "view");
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
|
||||
|
@ -384,14 +384,7 @@ static PointerRNA rna_BakePixel_next_get(PointerRNA *ptr)
|
||||
|
||||
static RenderPass *rna_RenderPass_find_by_type(RenderLayer *rl, int passtype, const char *view)
|
||||
{
|
||||
RenderPass *rp;
|
||||
for (rp = rl->passes.first; rp; rp = rp->next) {
|
||||
if (rp->passtype == passtype) {
|
||||
if (STREQ(rp->view, view))
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return RE_pass_find_by_type(rl, passtype, view);
|
||||
}
|
||||
|
||||
#else /* RNA_RUNTIME */
|
||||
|
@ -315,6 +315,8 @@ int RE_seq_render_active(struct Scene *scene, struct RenderData *rd);
|
||||
|
||||
bool RE_layers_have_name(struct RenderResult *result);
|
||||
|
||||
struct RenderPass *RE_pass_find_by_type(struct RenderLayer *rl, int passtype, const char *viewname);
|
||||
|
||||
/* shaded view or baking options */
|
||||
#define RE_BAKE_LIGHT 0 /* not listed in rna_scene.c -> can't be enabled! */
|
||||
#define RE_BAKE_ALL 1
|
||||
|
@ -3856,4 +3856,14 @@ bool RE_layers_have_name(struct RenderResult *rr)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
RenderPass *RE_pass_find_by_type(RenderLayer *rl, int passtype, const char *viewname)
|
||||
{
|
||||
RenderPass *rp;
|
||||
for (rp = rl->passes.first; rp; rp = rp->next) {
|
||||
if (rp->passtype == passtype) {
|
||||
if (STREQ(rp->view, viewname))
|
||||
return rp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user