[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59571] branches/soc-2013-paint: At last the patch: Add enumeration of UV coordinate, image using texture

Antony Riakiotakis kalast at gmail.com
Tue Aug 27 22:02:44 CEST 2013


Revision: 59571
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59571
Author:   psy-fi
Date:     2013-08-27 20:02:43 +0000 (Tue, 27 Aug 2013)
Log Message:
-----------
At last the patch: Add enumeration of UV coordinate, image using texture
slots in every material, placed in projection paint panel.

Modified Paths:
--------------
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2013-paint/source/blender/makesdna/DNA_material_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_internal.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_material.c

Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-08-27 19:58:36 UTC (rev 59570)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-08-27 20:02:43 UTC (rev 59571)
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Menu, Panel
+from bpy.types import Menu, Panel, UIList
 from bl_ui.properties_paint_common import UnifiedPaintPanel
 from bl_ui.properties_paint_common import brush_texture_settings
 from bl_ui.properties_paint_common import brush_mask_texture_settings
@@ -1216,7 +1216,21 @@
 
 # ********** default tools for texture-paint ****************
 
+class TEXTURE_UL_texpaintslots(UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        # assert(isinstance(item, bpy.types.MaterialTextureSlot)
+        ma = data
+        slot = item
+        tex = slot.texture if slot else None
 
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            # layout.label(text=tex.image.name, translate=False)
+            layout.label(text=tex.name, translate=False, icon_value=icon)
+        elif self.layout_type in {'GRID'}:
+            layout.alignment = 'CENTER'
+            layout.label(text="")
+
+
 class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
     bl_context = "imagepaint"
     bl_label = "Project Paint"
@@ -1235,9 +1249,17 @@
         ipaint = toolsettings.image_paint
         settings = toolsettings.image_paint
 
-        layout.prop(ipaint, "input_samples")
+        col = layout.column()
 
-        col = layout.column()
+        if ob:
+            col.label("Paint layers")
+            col.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=2)
+            mat = ob.active_material;
+            if mat:
+                col.template_list("TEXTURE_UL_texpaintslots", "", mat, "texture_paint_slots", mat, "active_paint_texture_index", rows=2)
+
+        col.prop(ipaint, "input_samples")
+
         col.prop(ipaint, "use_occlude")
         col.prop(ipaint, "use_backface_culling")
 

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_material_types.h	2013-08-27 19:58:36 UTC (rev 59570)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_material_types.h	2013-08-27 20:02:43 UTC (rev 59571)
@@ -133,8 +133,11 @@
 	short pr_lamp, pr_texture, ml_flag;	/* ml_flag is for disable base material */
 	
 	/* mapping */
-	char mapflag, pad;
+	char mapflag;
 
+	/* texture painting */
+	char texactpaint;
+
 	/* shaders */
 	short diff_shader, spec_shader;
 	float roughness, refrac;

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_internal.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_internal.h	2013-08-27 19:58:36 UTC (rev 59570)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_internal.h	2013-08-27 20:02:43 UTC (rev 59571)
@@ -201,6 +201,9 @@
 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);
+void rna_def_mtex_texpaint(struct StructRNA *srna,
+                         const char *structname);
+
 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);

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_material.c	2013-08-27 19:58:36 UTC (rev 59570)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_material.c	2013-08-27 20:02:43 UTC (rev 59571)
@@ -164,6 +164,26 @@
 	rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, NULL);
 }
 
+/* texture painting on material slots */
+static int rna_texture_paint_material(CollectionPropertyIterator *UNUSED(iter), void *data)
+{
+	MTex *mtex = (*((MTex **)data));
+
+	/* do not skip under these circumstances */
+	if (mtex && mtex->texco == TEXCO_UV &&
+	    mtex->tex && mtex->tex->type == TEX_IMAGE &&
+	    mtex->tex->ima)
+			return 0;
+
+	return 1;
+}
+
+static void rna_MaterialTexturePaint_mtex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+	Material *ma = (Material *)ptr->data;
+	rna_iterator_array_begin(iter, (void *)ma->mtex, sizeof(MTex *), MAX_MTEX, 0, rna_texture_paint_material);
+}
+
 static PointerRNA rna_Material_active_texture_get(PointerRNA *ptr)
 {
 	Material *ma = (Material *)ptr->data;
@@ -1694,6 +1714,7 @@
 	RNA_def_property_ui_text(prop, "Damping", "Damping of the spring force, when inside the physics distance area");
 }
 
+
 void RNA_def_material(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -2035,6 +2056,8 @@
 	                    "rna_Material_active_texture_set", "rna_Material_active_texture_editable",
 	                    "MaterialTextureSlot", "MaterialTextureSlots", "rna_Material_update");
 
+	rna_def_mtex_texpaint(srna, "MaterialTextureSlot");
+
 	/* only material has this one */
 	prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_negative_sdna(prop, NULL, "septex", 1);
@@ -2123,4 +2146,23 @@
 	RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, update);
 }
 
+void rna_def_mtex_texpaint(StructRNA *srna, const char *structname)
+{
+	PropertyRNA *prop;
+
+	/* mtex */
+	prop = RNA_def_property(srna, "texture_paint_slots", PROP_COLLECTION, PROP_NONE);
+	RNA_def_property_struct_type(prop, structname);
+	RNA_def_property_collection_funcs(prop, "rna_MaterialTexturePaint_mtex_begin", "rna_iterator_array_next", "rna_iterator_array_end",
+	                                  "rna_iterator_array_dereference_get", NULL, NULL, NULL, NULL);
+	RNA_def_property_ui_text(prop, "Textures", "Texture slots defining the mapping and influence of textures");
+
+	prop = RNA_def_property(srna, "active_paint_texture_index", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_int_sdna(prop, NULL, "texactpaint");
+	RNA_def_property_range(prop, 0, MAX_MTEX - 1);
+	RNA_def_property_ui_text(prop, "Active Paint Texture Index", "Index of active texture paint slot");
+	RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING_LINKS, "rna_Material_update");
+}
+
+
 #endif




More information about the Bf-blender-cvs mailing list