Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2014-07-23 22:06:29 +0400
committerAntony Riakiotakis <kalast@gmail.com>2014-07-23 22:06:41 +0400
commitaf162658e1270b7442eb064360d1bec75c621c1a (patch)
tree638cae16abc9b10dae39763a7df0bd3a9890f228 /source
parent1f55044617d167e81bc56cc359a1adf886045447 (diff)
Texture painting:
Add ability to select UV layer from the layer panel.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c2
-rw-r--r--source/blender/blenkernel/intern/material.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c2
-rw-r--r--source/blender/makesdna/DNA_material_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_internal.h2
-rw-r--r--source/blender/makesrna/intern/rna_material.c35
8 files changed, 38 insertions, 13 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index bdfaf9a1be9..c3e8d2a98af 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 27330fb8db3..b4ab464838e 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 1f0b2c80fc4..5c1af41e05d 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 eaa4885572e..0d463172f99 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 0f605429187..36c96a8d011 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 02d1103c08e..ba617baa4e0 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 9a1053b4666..e3179077cf4 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 46c5cc770b8..bd870685a73 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