[Bf-blender-cvs] [cf3ce73] master: Texture painting:

Antony Riakiotakis noreply at git.blender.org
Thu Aug 28 20:46:08 CEST 2014


Commit: cf3ce7322a9b6c1453869a369eba02f4fd077234
Author: Antony Riakiotakis
Date:   Thu Aug 28 16:40:38 2014 +0200
Branches: master
https://developer.blender.org/rBcf3ce7322a9b6c1453869a369eba02f4fd077234

Texture painting:

Include explicit control for texturing:

This commit introduces a painting mode option, available in
the slots panel. The default value "Material"  will create slots from the
blender material, same as just merged from the paint branch.

The new option "Image", will use an explicit image field that artists can use
to select the image to paint on. This will should allow painting regardless
of the renderer used or for use in modifiers.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/intern/material.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_view3d/drawmesh.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_material.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 046e54d..5c758b6 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -17,6 +17,7 @@
 # ##### END GPL LICENSE BLOCK #####
 
 # <pep8 compliant>
+from bpy.types import Menu
 
 
 class UnifiedPaintPanel():
@@ -86,6 +87,18 @@ class UnifiedPaintPanel():
         parent.template_color_picker(ptr, prop_name, value_slider=value_slider)
 
 
+class VIEW3D_MT_tools_projectpaint_clone(Menu):
+    bl_label = "Clone Layer"
+
+    def draw(self, context):
+        layout = self.layout
+
+        for i, tex in enumerate(context.active_object.data.uv_textures):
+            props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
+            props.data_path = "active_object.data.uv_texture_clone_index"
+            props.value = i
+
+
 def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=False):
     capabilities = brush.image_paint_capabilities
 
@@ -139,24 +152,38 @@ def brush_texpaint_common(panel, context, layout, brush, settings, projpaint=Fal
     elif brush.image_tool == 'CLONE':
         col.separator()
         if projpaint:
-            col.prop(settings, "use_clone_layer", text="Clone from paint slot")
+            if settings.mode == 'MATERIAL':
+                col.prop(settings, "use_clone_layer", text="Clone from paint slot")
+            elif settings.mode == 'IMAGE':
+                col.prop(settings, "use_clone_layer", text="Clone from image/UV map")
 
             if settings.use_clone_layer:
                 ob = context.active_object
                 col = layout.column()
 
-                if len(ob.material_slots) > 1:
-                    col.label("Materials")
-                    col.template_list("MATERIAL_UL_matslots", "",
-                                      ob, "material_slots",
-                                      ob, "active_material_index", rows=2)
-
-                mat = ob.active_material
-                if mat:
-                    col.label("Clone Slot")
-                    col.template_list("TEXTURE_UL_texpaintslots", "",
-                                      mat, "texture_paint_images",
-                                      mat, "paint_clone_slot", rows=2)
+                if settings.mode == 'MATERIAL':
+                    if len(ob.material_slots) > 1:
+                        col.label("Materials")
+                        col.template_list("MATERIAL_UL_matslots", "",
+                                          ob, "material_slots",
+                                          ob, "active_material_index", rows=2)
+
+                    mat = ob.active_material
+                    if mat:
+                        col.label("Clone Slot")
+                        col.template_list("TEXTURE_UL_texpaintslots", "",
+                                          mat, "texture_paint_images",
+                                          mat, "paint_clone_slot", rows=2)
+
+                elif settings.mode == 'IMAGE':
+                    mesh = ob.data
+
+                    clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
+                    col.label("Image")
+                    col.template_ID(settings, "clone_image")
+                    col.label("UV Map")
+                    col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False)
+                    
 
         else:
             col.prop(brush, "clone_image", text="Image")
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 59c68fc..6b0c5b1 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1026,31 +1026,39 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
         ob = context.active_object
         col = layout.column()
 
-        if len(ob.material_slots) > 1:
-            col.label("Materials")
-            col.template_list("MATERIAL_UL_matslots", "layers",
-                              ob, "material_slots",
-                              ob, "active_material_index", rows=2)
-
-        mat = ob.active_material
-        if mat:
-            col.label("Available Paint Slots")
-            col.template_list("TEXTURE_UL_texpaintslots", "",
-                              mat, "texture_paint_images",
-                              mat, "paint_active_slot", rows=2)
+        col.label("Painting Mode")
+        col.prop(settings, "mode", text = "")
+        col.separator()
 
-            if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'):
-                row = col.row(align=True)
-                row.operator_menu_enum("paint.add_texture_paint_slot", "type")
-                row.operator("paint.delete_texture_paint_slot", text="", icon='X')
+        if settings.mode == 'MATERIAL':
+            if len(ob.material_slots) > 1:
+                col.label("Materials")
+                col.template_list("MATERIAL_UL_matslots", "layers",
+                                  ob, "material_slots",
+                                  ob, "active_material_index", rows=2)
+
+            mat = ob.active_material
+            if mat:
+                col.label("Available Paint Slots")
+                col.template_list("TEXTURE_UL_texpaintslots", "",
+                                  mat, "texture_paint_images",
+                                  mat, "paint_active_slot", rows=2)
 
-                if mat.texture_paint_slots:
-                    slot = mat.texture_paint_slots[mat.paint_active_slot]
+                if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'):
+                    row = col.row(align=True)
+                    row.operator_menu_enum("paint.add_texture_paint_slot", "type")
+                    row.operator("paint.delete_texture_paint_slot", text="", icon='X')
 
-                    col.prop(mat.texture_slots[slot.index], "blend_type")
-                    col.separator()
-                    col.label("UV Map")
-                    col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
+                    if mat.texture_paint_slots:
+                        slot = mat.texture_paint_slots[mat.paint_active_slot]
+
+                        col.prop(mat.texture_slots[slot.index], "blend_type")
+                        col.separator()
+                        col.label("UV Map")
+                        col.prop_search(slot, "uv_layer", ob.data, "uv_textures", text="")
+
+        elif settings.mode == 'IMAGE':
+            col.template_ID(settings, "canvas")
 
         col.separator()
         col.operator("image.save_dirty", text="Save All Images")
@@ -1089,7 +1097,6 @@ class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
 
         col.label("Image")
         row = col.row(align=True)
-        row.operator("image.new", icon='ZOOMIN', text="Add New").texstencil = True;
         row.template_ID(ipaint, "stencil_image")
  
         col.label("Visualization")
@@ -1643,18 +1650,6 @@ class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
         self.unified_paint_settings(col, context)
 
 
-class VIEW3D_MT_tools_projectpaint_clone(Menu):
-    bl_label = "Clone Layer"
-
-    def draw(self, context):
-        layout = self.layout
-
-        for i, tex in enumerate(context.active_object.data.uv_textures):
-            props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
-            props.data_path = "active_object.data.uv_texture_clone_index"
-            props.value = i
-
-
 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
     bl_label = "Mask Layer"
 
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 5014714..e750039 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -274,8 +274,7 @@ Material *localize_material(Material *ma)
 	if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col);
 	if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec);
 
-	if (ma->texpaintslot) man->texpaintslot = MEM_dupallocN(man->texpaintslot);
-
+	ma->texpaintslot = NULL;
 	man->preview = NULL;
 	
 	if (ma->nodetree)
@@ -1328,9 +1327,16 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
 
 	if (ma->texpaintslot) {
 		MEM_freeN(ma->texpaintslot);
+		ma->tot_slots = 0;
 		ma->texpaintslot = NULL;
 	}
 
+	if (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_IMAGE) {
+		ma->paint_active_slot = 0;
+		ma->paint_clone_slot = 0;
+		return;
+	}
+	
 	if (use_nodes || ma->use_nodes) {
 		bNode *node, *active_node;
 
@@ -1342,10 +1348,9 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
 				count++;
 		}
 
-		ma->tot_slots = count;
-
 		if (count == 0) {
 			ma->paint_active_slot = 0;
+			ma->paint_clone_slot = 0;
 			return;
 		}
 		ma->texpaintslot = MEM_callocN(sizeof(*ma->texpaintslot) * count, "texpaint_slots");
@@ -1367,10 +1372,9 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
 			}
 		}
 
-		ma->tot_slots = count;
-
 		if (count == 0) {
 			ma->paint_active_slot = 0;
+			ma->paint_clone_slot = 0;
 			return;
 		}
 
@@ -1387,6 +1391,8 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma)
 		}
 	}
 
+	ma->tot_slots = count;
+	
 	if (ma->paint_active_slot >= count) {
 		ma->paint_active_slot = count - 1;
 	}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 8ada7b7..b2e49be 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5152,6 +5152,14 @@ static void lib_link_scene(FileData *fd, Main *main)
 				sce->toolsettings->imapaint.stencil =
 				        newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.stencil);
 
+			if (sce->toolsettings->imapaint.clone)
+				sce->toolsettings->imapaint.clone =
+				        newlibadr_us(fd, sce->id.lib, sce->toolsettings->imapaint.clone);
+
+			if (sce->toolsettings->imapai

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list