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.
This commit is contained in:
Antony Riakiotakis
2014-07-22 21:05:54 +02:00
parent 895f0f3dff
commit c32a671b3a
3 changed files with 10 additions and 6 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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;
}