[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60374] branches/soc-2013-paint: Projection paint layers:

Antony Riakiotakis kalast at gmail.com
Thu Sep 26 01:42:42 CEST 2013


Revision: 60374
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60374
Author:   psy-fi
Date:     2013-09-25 23:42:42 +0000 (Wed, 25 Sep 2013)
Log Message:
-----------
Projection paint layers:

* Better naming for new layers
* Allow Custom Size for new layers

Modified Paths:
--------------
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_sculpt_paint.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-09-25 21:34:43 UTC (rev 60373)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-09-25 23:42:42 UTC (rev 60374)
@@ -535,6 +535,8 @@
     def draw(self, context):
         layout = self.layout
 
+        settings = context.tool_settings.image_paint
+
         ob = context.active_object
         col = layout.column()
 
@@ -547,6 +549,10 @@
             #col.label("Only slots with UV mapping and image textures are available")
             
             col.operator_menu_enum("paint.add_layer", "type")
+        
+        row = col.row(align=True)
+        row.prop(settings, "new_layer_xresolution")
+        row.prop(settings, "new_layer_yresolution")
 
 
 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-25 21:34:43 UTC (rev 60373)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-25 23:42:42 UTC (rev 60374)
@@ -4862,6 +4862,10 @@
 	RNA_def_string_file_name(ot->srna, "filepath", "", FILE_MAX, "File Path", "Name of the file");
 }
 
+/* Add layer operator */
+
+#define TEXNAME_MAX 30
+
 static EnumPropertyItem layer_type_items[] = {
 	{MAP_COL, "DIFFUSE_COLOR", 0, "Diffuse Color", ""},
 	{MAP_REF, "DIFFUSE_INTENSITY", 0, "Diffuse Intensity", ""},
@@ -4884,16 +4888,23 @@
 {
 	Material *ma;
 	Object *ob = CTX_data_active_object(C);
-	/* hardcoded for now, allow options later */
-	int width = 1024;
-	int height = 1024;
 	float color[4] = {0.0, 0.0, 0.0, 1.0};
+	int i;
+	ImagePaintSettings *imapaint = &CTX_data_tool_settings(C)->imapaint;
+	int width = imapaint->new_layer_xresolution;
+	int height = imapaint->new_layer_yresolution;
 
 	int type = RNA_enum_get(op->ptr, "type");
 
 	if (!ob)
 		return OPERATOR_CANCELLED;
 
+	/* unlikely, but just in case */
+	if (width * height == 0) {
+		BKE_report(op->reports, RPT_ERROR, "New layer dimensions need to be greater than 0");
+		return OPERATOR_CANCELLED;
+	}
+
 	ma = give_current_material(ob, ob->actcol);
 
 	if (ma) {
@@ -4901,12 +4912,22 @@
 
 		/* successful creation of mtex layer, now create set */
 		if (mtex) {
+			char imagename[FILE_MAX];
+			char name[TEXNAME_MAX];
 			PointerRNA ptr, idptr;
 			PropertyRNA *prop;
 			Main *bmain = CTX_data_main(C);
 			Image *ima;
 
-			mtex->tex = add_texture(bmain, DATA_("Texture"));
+			/* get the name of the texture layer type */
+			for (i = 0; i < sizeof(layer_type_items); i++) {
+				if (type == layer_type_items[i].value) {
+					BLI_strncpy(name, layer_type_items[i].name, TEXNAME_MAX);
+					break;
+				}
+			}
+
+			mtex->tex = add_texture(bmain, DATA_(name));
 			mtex->mapto = type;
 
 			if (mtex->tex) {
@@ -4923,8 +4944,13 @@
 					RNA_property_update(C, &ptr, prop);
 				}
 
-				ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, "layer_texture", 32, 0, IMA_GENTYPE_BLANK, color);
+				BLI_strncpy(imagename, &ma->id.name[2], FILE_MAX);
+				BLI_strncat_utf8(imagename, "_", FILE_MAX);
+				BLI_strncat_utf8(imagename, name, FILE_MAX);
+				/* take the second letter to avoid the ID identifier */
 
+				ima = mtex->tex->ima = BKE_image_add_generated(bmain, width, height, imagename, 32, 0, IMA_GENTYPE_BLANK, color);
+
 				uiIDContextProperty(C, &ptr, &prop);
 
 				if (prop) {

Modified: branches/soc-2013-paint/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2013-paint/source/blender/makesdna/DNA_scene_types.h	2013-09-25 21:34:43 UTC (rev 60373)
+++ branches/soc-2013-paint/source/blender/makesdna/DNA_scene_types.h	2013-09-25 23:42:42 UTC (rev 60374)
@@ -785,6 +785,10 @@
 	short seam_bleed, normal_angle;
 	short screen_grab_size[2]; /* capture size for re-projection */
 
+	/* new layer default resolution */
+	int new_layer_xresolution;
+	int new_layer_yresolution;
+
 	int pad1;
 
 	void *paintcursor;			/* wm handle */

Modified: branches/soc-2013-paint/source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
--- branches/soc-2013-paint/source/blender/makesrna/intern/rna_sculpt_paint.c	2013-09-25 21:34:43 UTC (rev 60373)
+++ branches/soc-2013-paint/source/blender/makesrna/intern/rna_sculpt_paint.c	2013-09-25 23:42:42 UTC (rev 60374)
@@ -541,6 +541,14 @@
 	prop = RNA_def_int_array(srna, "screen_grab_size", 2, NULL, 0, 0, "screen_grab_size",
 	                         "Size to capture the image for re-projecting", 0, 0);
 	RNA_def_property_range(prop, 512, 16384);
+
+	prop = RNA_def_property(srna, "new_layer_xresolution", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_ui_range(prop, 1, 4096, 0, -1);
+	RNA_def_property_ui_text(prop, "X resolution", "X Resolution of new image");
+
+	prop = RNA_def_property(srna, "new_layer_yresolution", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_ui_range(prop, 1, 4096, 0, -1);
+	RNA_def_property_ui_text(prop, "Y resolution", "Y Resolution of new image");
 }
 
 static void rna_def_particle_edit(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list