[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21704] branches/blender2.5/blender: Sculpt+Paint/2.5:

Nicholas Bishop nicholasbishop at gmail.com
Sun Jul 19 19:44:44 CEST 2009


Revision: 21704
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21704
Author:   nicholasbishop
Date:     2009-07-19 19:44:44 +0200 (Sun, 19 Jul 2009)

Log Message:
-----------
Sculpt+Paint/2.5:

* Moved brush NKEY panel from C to Python. Could use some UI review :)
* Added a NULL check in bpy_internal_import.c, was crashing here on Python errors
* Added RNA for vpaint brush and for weight paint
* Added context for vpaint/wpaint similar to edit_object and sculpt_object

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/space_view3d.py
    branches/blender2.5/blender/source/blender/editors/screen/screen_context.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_vpaint.c
    branches/blender2.5/blender/source/blender/python/generic/bpy_internal_import.c

Modified: branches/blender2.5/blender/release/ui/space_view3d.py
===================================================================
--- branches/blender2.5/blender/release/ui/space_view3d.py	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/release/ui/space_view3d.py	2009-07-19 17:44:44 UTC (rev 21704)
@@ -197,10 +197,59 @@
 		row.itemR(sculpt, "lock_y", text="Y", toggle=True)
 		row.itemR(sculpt, "lock_z", text="Z", toggle=True)
 
+class VIEW3D_PT_brush(bpy.types.Panel):
+	__space_type__ = "VIEW_3D"
+	__region_type__ = "UI"
+	__label__ = "Brush"
+
+	def brush_src(self, context):
+		ts = context.scene.tool_settings
+		if context.sculpt_object:
+			return ts.sculpt
+		elif context.vpaint_object:
+			return ts.vpaint
+		elif context.wpaint_object:
+			return ts.wpaint
+		return False
+
+	def poll(self, context):
+		return self.brush_src(context)
+
+	def draw(self, context):
+		src = self.brush_src(context)
+		brush = src.brush
+		layout = self.layout
+
+		layout.split().row().template_ID(src, "brush")
+
+		split = layout.split()
+		col = split.column(align=True)
+		col.itemR(brush, "size", slider=True)
+		if context.wpaint_object:
+			col.itemR(context.scene.tool_settings, "vertex_group_weight", text="Weight", slider=True)
+		col.itemR(brush, "strength", slider=True)
+
+		if context.sculpt_object:
+			layout.split().row().itemR(brush, "sculpt_tool")
+
+		split = layout.split()
+		col = split.column()
+		col.itemR(brush, "airbrush")
+		col.itemR(brush, "anchored")
+		col.itemR(brush, "rake")
+		col = split.column()
+		col.itemR(brush, "space")
+		col.itemR(brush, "spacing")
+
+		split = layout.split()
+		split.template_curve_mapping(brush.curve)
+
 bpy.types.register(VIEW3D_MT_view_navigation)
 bpy.types.register(VIEW3D_MT_view)
 bpy.types.register(VIEW3D_HT_header)
+bpy.types.register(VIEW3D_PT_sculpt)
+bpy.types.register(VIEW3D_PT_brush)
 bpy.types.register(VIEW3D_PT_3dview_properties)
 bpy.types.register(VIEW3D_PT_3dview_display)
 bpy.types.register(VIEW3D_PT_background_image)
-bpy.types.register(VIEW3D_PT_sculpt)
+

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_context.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_context.c	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_context.c	2009-07-19 17:44:44 UTC (rev 21704)
@@ -37,6 +37,8 @@
 
 #include "RNA_access.h"
 
+#include "ED_object.h"
+
 int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result)
 {
 	bScreen *sc= CTX_wm_screen(C);
@@ -47,8 +49,8 @@
 		static const char *dir[] = {
 			"scene", "selected_objects", "selected_bases",
 			"selected_editable_objects", "selected_editable_bases"
-			"active_base",
-			"active_object", "edit_object", "sculpt_object", NULL};
+			"active_base", "active_object", "edit_object",
+			"sculpt_object", "vpaint_object", "wpaint_object", NULL};
 
 		CTX_data_dir_set(result, dir);
 		return 1;
@@ -114,6 +116,18 @@
 
 		return 1;
 	}
+	else if(CTX_data_equals(member, "vpaint_object")) {
+		if(G.f & G_VERTEXPAINT && scene->basact)
+			CTX_data_id_pointer_set(result, &scene->basact->object->id);
+
+		return 1;
+	}
+	else if(CTX_data_equals(member, "wpaint_object")) {
+		if(G.f & G_WEIGHTPAINT && scene->basact)
+			CTX_data_id_pointer_set(result, &scene->basact->object->id);
+
+		return 1;
+	}
 	
 	return 0;
 }

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_buttons.c	2009-07-19 17:44:44 UTC (rev 21704)
@@ -1101,81 +1101,6 @@
 	}
 }
 
-static int view3d_panel_brush_poll(const bContext *C, PanelType *pt)
-{
-	Brush **brp = current_brush_source(CTX_data_scene(C));
-
-	return ((G.f & (G_SCULPTMODE|G_TEXTUREPAINT|G_VERTEXPAINT|G_WEIGHTPAINT)) && brp);
-}
-
-static void view3d_panel_brush(const bContext *C, Panel *pa)
-{
-	uiBlock *block;
-	ToolSettings *ts= CTX_data_tool_settings(C);
-	Brush **brp = current_brush_source(CTX_data_scene(C)), *br;
-	short w = 268, h = 400, cx = 10, cy = h;
-	rctf rect;
-
-	br = *brp;
-
-	block= uiLayoutFreeBlock(pa->layout);
-	uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL);
-
-	uiBlockBeginAlign(block);
-	uiDefIDPoinButs(block, CTX_data_main(C), NULL, &br->id, ID_BR, NULL, cx, cy,
-			brush_idpoin_handle, UI_ID_BROWSE|UI_ID_RENAME|UI_ID_ADD_NEW|UI_ID_OPEN|UI_ID_DELETE|UI_ID_ALONE);
-	cy-= 25;
-	uiBlockEndAlign(block);
-
-	if(!br)
-		return;
-
-	if(G.f & G_SCULPTMODE) {
-		uiBlockBeginAlign(block);	
-		uiDefButC(block,ROW,B_REDR,"Draw",cx,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_DRAW,0,0,"Draw lines on the model");
-		uiDefButC(block,ROW,B_REDR,"Smooth",cx+67,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_SMOOTH,0,0,"Interactively smooth areas of the model");
-		uiDefButC(block,ROW,B_REDR,"Pinch",cx+134,cy,67,19,&br->sculpt_tool,14.0,SCULPT_TOOL_PINCH,0,0,"Interactively pinch areas of the model");
-		uiDefButC(block,ROW,B_REDR,"Inflate",cx+201,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_INFLATE,0,0,"Push vertices along the direction of their normals");
-		cy-= 20;
-		uiDefButC(block,ROW,B_REDR,"Grab", cx,cy,67,19,&br->sculpt_tool,14,SCULPT_TOOL_GRAB,0,0,"Grabs a group of vertices and moves them with the mouse");
-		uiDefButC(block,ROW,B_REDR,"Layer", cx+67,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_LAYER,0,0,"Adds a layer of depth");
-		uiDefButC(block,ROW,B_REDR,"Flatten", cx+134,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_FLATTEN,0,0,"Interactively flatten areas of the model");
-		uiDefButC(block,ROW,B_REDR,"Clay", cx+201,cy,67,19,&br->sculpt_tool,14, SCULPT_TOOL_CLAY,0,0,"Build up depth quickly");
-		cy-= 25;
-		uiBlockEndAlign(block);
-	}
-
-	uiBlockBeginAlign(block);
-	uiDefButI(block,NUMSLI,B_NOP,"Size: ",cx,cy,w,19,&br->size,1.0,200.0,0,0,"Set brush radius in pixels");
-	cy-= 20;
-	if(G.f & G_WEIGHTPAINT) {
-		uiDefButF(block,NUMSLI,B_NOP,"Weight: ",cx,cy,w,19,&ts->vgroup_weight,0,1.0,0,0,"Set vertex weight");
-		cy-= 20;
-	}
-	uiDefButF(block,NUMSLI,B_NOP,"Strength: ",cx,cy,w,19,&br->alpha,0,1.0,0,0,"Set brush strength");
-	cy-= 25;
-	uiBlockEndAlign(block);
-
-	uiBlockBeginAlign(block);
-
-	uiDefButBitS(block, TOG, BRUSH_AIRBRUSH, B_NOP, "Airbrush", cx,cy,w/3,19, &br->flag,0,0,0,0, "Brush makes changes without waiting for the mouse to move");
-	uiDefButBitS(block, TOG, BRUSH_RAKE, B_NOP, "Rake", cx+w/3,cy,w/3,19, &br->flag,0,0,0,0, "");
-	uiDefButBitS(block, TOG, BRUSH_ANCHORED, B_NOP, "Anchored", cx+w*2.0/3,cy,w/3,19, &br->flag,0,0,0,0, "");
-	cy-= 20;
-	uiDefButBitS(block, TOG, BRUSH_SPACE, B_NOP, "Space", cx,cy,w/3,19, &br->flag,0,0,0,0, "");
-	uiDefButF(block,NUMSLI,B_NOP,"Spacing: ",cx+w/3,cy,w*2.0/3,19,&br->spacing,1.0,500,0,0,"");
-	cy-= 20;
-	uiBlockEndAlign(block);
-
-	if(br->curve) {
-		rect.xmin= cx; rect.xmax= cx + w;
-		rect.ymin= cy - 200; rect.ymax= cy;
-		uiBlockBeginAlign(block);
-		curvemap_buttons(block, br->curve, (char)0, B_NOP, 0, &rect);
-		uiBlockEndAlign(block);
-	}
-}
-
 static void view3d_panel_object(const bContext *C, Panel *pa)
 {
 	uiBlock *block;
@@ -1715,14 +1640,7 @@
 	strcpy(pt->label, "Background Image");
 	pt->draw= view3d_panel_background;
 	BLI_addtail(&art->paneltypes, pt);
-*/
-	pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel brush");
-	strcpy(pt->idname, "VIEW3D_PT_brush");
-	strcpy(pt->label, "Brush");
-	pt->draw= view3d_panel_brush;
-	pt->poll= view3d_panel_brush_poll;
-	BLI_addtail(&art->paneltypes, pt);
-/*
+
 	pt= MEM_callocN(sizeof(PanelType), "spacetype view3d panel transform spaces");
 	strcpy(pt->idname, "VIEW3D_PT_transform spaces");
 	strcpy(pt->label, "Transform Orientations");

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_scene.c	2009-07-19 17:44:44 UTC (rev 21704)
@@ -294,6 +294,10 @@
 	RNA_def_property_struct_type(prop, "VPaint");
 	RNA_def_property_ui_text(prop, "Vertex Paint", "");
 
+	prop= RNA_def_property(srna, "wpaint", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "VPaint");
+	RNA_def_property_ui_text(prop, "Weight Paint", "");
+
 	/* Transform */
 	prop= RNA_def_property(srna, "proportional_editing", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "proportional", 0);

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_vpaint.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_vpaint.c	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_vpaint.c	2009-07-19 17:44:44 UTC (rev 21704)
@@ -51,6 +51,10 @@
 	
 	srna= RNA_def_struct(brna, "VPaint", NULL);
 	RNA_def_struct_ui_text(srna, "Vertex Paint", "Properties of the Vpaint tool.");
+    
+	prop= RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE);
+	RNA_def_property_struct_type(prop, "Brush");
+	RNA_def_property_ui_text(prop, "Brush", "");
 
 	prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_items(prop, prop_mode_items);

Modified: branches/blender2.5/blender/source/blender/python/generic/bpy_internal_import.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/generic/bpy_internal_import.c	2009-07-19 17:42:01 UTC (rev 21703)
+++ branches/blender2.5/blender/source/blender/python/generic/bpy_internal_import.c	2009-07-19 17:44:44 UTC (rev 21704)
@@ -65,6 +65,8 @@
 	Main *maggie= bpy_import_main;
 	
 	*found= 0;
+
+	if(!maggie) return NULL;
 	
 	if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */
 	





More information about the Bf-blender-cvs mailing list