From c32a671b3a7f2908c03bcb60f46ca40250dd08fa Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 22 Jul 2014 21:05:54 +0200 Subject: [PATCH] Fix T41141, can't paint texture in cycles. The issue is actually that creating a new image in texture paint mode will set it always as a stencil image. Internally, the code checks if the painted image is the same as the stencil and if it is, no painting is done. Solution is to expose a boolena to the operator for setting the image as a stencil (could be an enum in th future for more uses) Stencil UI is a bit weird here, will definitely redesign. --- release/scripts/startup/bl_ui/space_view3d_toolbar.py | 3 ++- source/blender/editors/space_image/image_ops.c | 11 +++++++---- source/blender/makesrna/intern/rna_material.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 5e7e91c1b88..e68ae62a57b 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1628,7 +1628,8 @@ class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel): stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else "" row.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False) row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA') - col.template_ID(ipaint, "stencil_image", new="image.new") + col.template_ID(ipaint, "stencil_image") + col.operator("image.new").texstencil = True; col.prop(ipaint, "stencil_color") layout.prop(ipaint, "seam_bleed") diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6a72066f031..66bd346ae69 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1896,7 +1896,6 @@ static int image_new_exec(bContext *C, wmOperator *op) SpaceImage *sima; Scene *scene; Object *obedit; - Object *ob; Image *ima; Main *bmain; PointerRNA ptr, idptr; @@ -1905,13 +1904,13 @@ static int image_new_exec(bContext *C, wmOperator *op) char *name = _name; float color[4]; int width, height, floatbuf, gen_type, alpha; + bool stencil; /* retrieve state */ sima = CTX_wm_space_image(C); scene = CTX_data_scene(C); obedit = CTX_data_edit_object(C); bmain = CTX_data_main(C); - ob = OBACT; prop = RNA_struct_find_property(op->ptr, "name"); RNA_property_string_get(op->ptr, prop, name); @@ -1925,7 +1924,8 @@ static int image_new_exec(bContext *C, wmOperator *op) gen_type = RNA_enum_get(op->ptr, "generated_type"); RNA_float_get_array(op->ptr, "color", color); alpha = RNA_boolean_get(op->ptr, "alpha"); - + stencil = RNA_boolean_get(op->ptr, "texstencil"); + if (!alpha) color[3] = 1.0f; @@ -1957,7 +1957,7 @@ static int image_new_exec(bContext *C, wmOperator *op) tex->ima = ima; ED_area_tag_redraw(CTX_wm_area(C)); } - else if (ob && ob->mode == OB_MODE_TEXTURE_PAINT) { + else if (stencil) { ImagePaintSettings *imapaint = &(CTX_data_tool_settings(C)->imapaint); if (imapaint->stencil) @@ -2012,6 +2012,9 @@ void IMAGE_OT_new(wmOperatorType *ot) RNA_def_enum(ot->srna, "generated_type", image_generated_type_items, IMA_GENTYPE_BLANK, "Generated Type", "Fill the image with a grid for UV map testing"); RNA_def_boolean(ot->srna, "float", 0, "32 bit Float", "Create image with 32 bit floating point bit depth"); + prop = RNA_def_boolean(ot->srna, "texstencil", 0, "Stencil", "Set Image as stencil"); + RNA_def_property_flag(prop, PROP_HIDDEN); + } #undef IMA_DEF_NAME diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index 3c9eaf3c5db..46c5cc770b8 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -186,7 +186,7 @@ static void rna_Material_active_paint_texture_index_update(Main *bmain, Scene *s struct bNode *node; int index = 0; for (node = ma->nodetree->nodes.first; node; node = node->next) { - if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { + if (node->typeinfo->nclass == NODE_CLASS_TEXTURE && node->typeinfo->type == SH_NODE_TEX_IMAGE && node->id) { if (index++ == ma->paint_active_slot) { break; }