Commit: af162658e1270b7442eb064360d1bec75c621c1a
Author: Antony Riakiotakis
Date:   Wed Jul 23 20:06:29 2014 +0200
Branches: master
https://developer.blender.org/rBaf162658e1270b7442eb064360d1bec75c621c1a

Texture painting:

Add ability to select UV layer from the layer panel.

===================================================================

M       release/scripts/startup/bl_ui/space_view3d_toolbar.py
M       source/blender/blenkernel/intern/DerivedMesh.c
M       source/blender/blenkernel/intern/material.c
M       source/blender/editors/sculpt_paint/paint_image_proj.c
M       source/blender/editors/sculpt_paint/paint_utils.c
M       source/blender/editors/uvedit/uvedit_draw.c
M       source/blender/makesdna/DNA_material_types.h
M       source/blender/makesrna/intern/rna_internal.h
M       source/blender/makesrna/intern/rna_material.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index e68ae62..6dd3ef2 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1076,7 +1076,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
         if mat:
             col.label("Available Paint Slots")
             col.template_list("TEXTURE_UL_texpaintslots", "",
-                              mat, "texture_paint_slots",
+                              mat, "texture_paint_images",
                               mat, "paint_active_slot", rows=2)
 
             if not mat.use_nodes:
@@ -1087,6 +1087,11 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
                 row.prop(settings, "slot_yresolution_default")
                 col.prop(settings, "slot_color_default")
 
+                slot = mat.texture_paint_slots[mat.paint_active_slot]
+                col.separator()
+                col.label("UV Layer")
+                col.prop_search(slot, "uv_layer", ob.data, "uv_textures", 
text="")
+
 
 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
     bl_category = "Options"
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c 
b/source/blender/blenkernel/intern/DerivedMesh.c
index bdfaf9a..c3e8d2a 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -517,7 +517,7 @@ MTFace *DM_paint_uvlayer_active_get(DerivedMesh *dm, int 
mat_nr)
        BLI_assert(mat_nr < dm->totmat);
 
        if (dm->mat[mat_nr] && dm->mat[mat_nr]->texpaintslot &&
-           
dm->mat[mat_nr]->texpaintslot[dm->mat[mat_nr]->paint_active_slot].uvname[0])
+           
dm->mat[mat_nr]->texpaintslot[dm->mat[mat_nr]->paint_active_slot].uvname)
        {
                tf_base = CustomData_get_layer_named(&dm->faceData, CD_MTFACE,
                                                     
dm->mat[mat_nr]->texpaintslot[dm->mat[mat_nr]->paint_active_slot].uvname);
diff --git a/source/blender/blenkernel/intern/material.c 
b/source/blender/blenkernel/intern/material.c
index 27330fb..b4ab464 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -1388,7 +1388,7 @@ void BKE_texpaint_slot_refresh_cache(Material *ma, bool 
use_nodes)
                for (mtex = ma->mtex, i = 0; i < MAX_MTEX; i++, mtex++) {
                        if (get_mtex_slot_valid_texpaint(*mtex)) {
                                ma->texpaintslot[index].ima = (*mtex)->tex->ima;
-                               BLI_strncpy(ma->texpaintslot[index++].uvname, 
(*mtex)->uvname, 64);
+                               ma->texpaintslot[index++].uvname = 
(*mtex)->uvname;
                        }
                }
        }
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c 
b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 1f0b2c8..5c1af41 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -3292,7 +3292,7 @@ static void project_paint_begin(ProjPaintState *ps)
                                continue;
 
                        if (slot != slot_last) {
-                               if (!slot->uvname[0] || !(tf_base = 
CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname)))
+                               if (!slot->uvname || !(tf_base = 
CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname)))
                                        tf_base = 
CustomData_get_layer(&ps->dm->faceData, CD_MTFACE);
                                slot_last = slot;
                        }
@@ -3313,7 +3313,7 @@ static void project_paint_begin(ProjPaintState *ps)
                        tf_clone = ps->dm_mtface_clone + face_index;
 
                        if (slot_clone != slot_last_clone) {
-                               if (!slot_clone->uvname[0] || !(tf_clone_base = 
CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot_clone->uvname)))
+                               if (!slot->uvname || !(tf_clone_base = 
CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot_clone->uvname)))
                                        tf_clone_base = 
CustomData_get_layer(&ps->dm->faceData, CD_MTFACE);
                                slot_last_clone = slot_clone;
                        }
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c 
b/source/blender/editors/sculpt_paint/paint_utils.c
index eaa4885..0d46317 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -312,7 +312,7 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, 
unsigned int faceindex, c
                        if (mf.v4)
                                dm->getVert(dm, mf.v4, &mv[3]);
 
-                       if (!slot->uvname[0] || !(tf_base = 
CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))
+                       if (!slot->uvname || !(tf_base = 
CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))
                                tf_base = CustomData_get_layer(&dm->faceData, 
CD_MTFACE);
 
                        tf = &tf_base[a];
diff --git a/source/blender/editors/uvedit/uvedit_draw.c 
b/source/blender/editors/uvedit/uvedit_draw.c
index 0f60542..36c96a8 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -497,7 +497,7 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene 
*scene, Object *ob)
                MPoly *mpoly = me->mpoly;
                MLoopUV *mloopuv, *mloopuv_base;
                int a, b;
-               if (!(ma && ma->texpaintslot && 
ma->texpaintslot[ma->paint_active_slot].uvname[0] &&
+               if (!(ma && ma->texpaintslot && 
ma->texpaintslot[ma->paint_active_slot].uvname &&
                      (mloopuv = CustomData_get_layer_named(&me->ldata, 
CD_MLOOPUV, ma->texpaintslot[ma->paint_active_slot].uvname))))
                {
                        mloopuv = me->mloopuv;
diff --git a/source/blender/makesdna/DNA_material_types.h 
b/source/blender/makesdna/DNA_material_types.h
index 02d1103..ba617ba 100644
--- a/source/blender/makesdna/DNA_material_types.h
+++ b/source/blender/makesdna/DNA_material_types.h
@@ -85,7 +85,7 @@ typedef struct GameSettings {
 
 typedef struct TexPaintSlot {
        struct Image *ima; /* image to be painted on */
-       char uvname[64]; /* customdata index for uv layer, MAX_NAME*/
+       char *uvname; /* customdata index for uv layer, MAX_NAME*/
 } TexPaintSlot;
 
 typedef struct Material {
diff --git a/source/blender/makesrna/intern/rna_internal.h 
b/source/blender/makesrna/intern/rna_internal.h
index 9a1053b..e317907 100644
--- a/source/blender/makesrna/intern/rna_internal.h
+++ b/source/blender/makesrna/intern/rna_internal.h
@@ -202,7 +202,7 @@ void rna_def_texmat_common(struct StructRNA *srna, const 
char *texspace_editable
 void rna_def_mtex_common(struct BlenderRNA *brna, struct StructRNA *srna, 
const char *begin, const char *activeget,
                          const char *activeset, const char *activeeditable, 
const char *structname,
                          const char *structname_slots, const char *update, 
const char *update_index);
-void rna_def_mtex_texpaint(struct StructRNA *srna);
+void rna_def_texpaint_slots(struct BlenderRNA *brna, struct StructRNA *srna);
 void rna_def_render_layer_common(struct StructRNA *srna, int scene);
 
 void rna_def_actionbone_group_common(struct StructRNA *srna, int update_flag, 
const char *update_cb);
diff --git a/source/blender/makesrna/intern/rna_material.c 
b/source/blender/makesrna/intern/rna_material.c
index 46c5cc7..bd87068 100644
--- a/source/blender/makesrna/intern/rna_material.c
+++ b/source/blender/makesrna/intern/rna_material.c
@@ -2107,7 +2107,7 @@ void RNA_def_material(BlenderRNA *brna)
                            "rna_Material_active_texture_set", 
"rna_Material_active_texture_editable",
                            "MaterialTextureSlot", "MaterialTextureSlots", 
"rna_Material_update", "rna_Material_update");
 
-       rna_def_mtex_texpaint(srna);
+       rna_def_texpaint_slots(brna, srna);
 
        /* only material has this one */
        prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
@@ -2197,16 +2197,42 @@ void rna_def_mtex_common(BlenderRNA *brna, StructRNA 
*srna, const char *begin,
        RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, 
update_index);
 }
 
-void rna_def_mtex_texpaint(StructRNA *srna)
+static void rna_def_tex_slot(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       srna = RNA_def_struct(brna, "TexPaintSlot", NULL);
+       RNA_def_struct_ui_text(srna, "Texture Paint Slot",
+                              "Slot that contains information about texture 
painting");
+
+       prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
+       RNA_def_property_string_maxlength(prop, 64); /* else it uses the 
pointer size! */
+       RNA_def_property_string_sdna(prop, NULL, "uvname");
+       RNA_def_property_ui_text(prop, "UV Map", "Name of UV map");
+       RNA_def_property_update(prop, 0, "rna_Material_update");
+}
+
+
+void rna_def_texpaint_slots(BlenderRNA *brna, StructRNA *srna)
 {
        PropertyRNA *prop;
 
+       rna_def_tex_slot(brna);
+
        /* mtex */
-       prop = RNA_def_property(srna, "texture_paint_slots", PROP_COLLECTION, 
PROP_NONE);
+       prop = RNA_def_property(srna, "texture_paint_images", PROP_COLLECTION, 
PROP_NONE);
+       RNA_def_property_collection_sdna(prop, NULL, "texpaintslot", NULL);
        RNA_def_property_collection_funcs(prop, "rna_Material_texpaint_begin", 
"rna_iterator_array_next", "rna_iterator_array_end",
                                          "rna_iterator_array_dereference_get", 
NULL, NULL, NULL, NULL);
        RNA_def_property_struct_type(prop, "Image");
-       RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the 
mapping and influence of textures");
+       RNA_def_property_ui_text(prop, "Texture Slot Images", "Texture images 
used for texture painting");
+
+       prop = RNA_def_property(srna, "texture_paint_slots", PROP_COLLECTION, 
PROP_NONE);
+       RNA_def_property_collection_funcs(prop, "rna_Material_texpaint_begin", 
"rna_iterator_array_next", "rna_iterator_array_end",
+                                         "rna_iterator_array_get", NULL, NULL, 
NULL, NULL);
+       RNA_def_property_struct_type(prop, "TexPaintSlot");
+       RNA_def_property_ui_text(prop, "Texture Slots", "Texture slots defining 
the mapping and influence of textures");
 
        prop = RNA_def_property(srna, "paint_active_slot", PROP_INT, 
PROP_UNSIGNED);
        RNA_def_property_range(prop, 0, INT_MAX);
@@ -2219,5 +2245,4 @@ void rna_def_mtex_texpaint(StructRNA *srna)
        RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, NULL);
 }
 
-
 #endif

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to