[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34355] trunk/blender/source/blender: Fixed bug [#25649] Image editor paint icon missing until enter weight

Nicholas Bishop nicholasbishop at gmail.com
Sun Jan 16 19:33:09 CET 2011


Revision: 34355
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34355
Author:   nicholasbishop
Date:     2011-01-16 18:33:08 +0000 (Sun, 16 Jan 2011)
Log Message:
-----------
Fixed bug [#25649] Image editor paint icon missing until enter weight
paint

A couple underlying issues:

* Paint icon was looking only at the object mode to determine what the
  "current" mode is, but that gave problems when the object mode was
  anything other than texpaint, but 2D image paint was turned on. Fix
  was to also look at what space is being drawn, and only if it's in
  the 3D view does it look at the ob mode.

* The brushes lists weren't getting filtered correctly in the same
  case where 2D image paint was on but a different object mode is
  enabled. Fixed by changing the brush rna poll to look at the paint
  source, rather than the object mode.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_icons.c
    trunk/blender/source/blender/makesdna/DNA_brush_types.h
    trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c

Modified: trunk/blender/source/blender/editors/interface/interface_icons.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_icons.c	2011-01-16 17:12:02 UTC (rev 34354)
+++ trunk/blender/source/blender/editors/interface/interface_icons.c	2011-01-16 18:33:08 UTC (rev 34355)
@@ -48,6 +48,7 @@
 #include "DNA_brush_types.h"
 #include "DNA_object_types.h"
 #include "DNA_screen_types.h"
+#include "DNA_space_types.h"
 
 #include "RNA_access.h"
 #include "RNA_enum_types.h"
@@ -1028,14 +1029,15 @@
 	}
 	else {
 		Object *ob = CTX_data_active_object(C);
-		EnumPropertyItem *items;
+		SpaceImage *sima;
+		EnumPropertyItem *items = NULL;
 		int tool, mode = 0;
 
-		/* this is not nice, should probably make brushes be
-		   strictly in one paint mode only to avoid checking
-		   object mode here */
+		/* XXX: this is not nice, should probably make brushes
+		   be strictly in one paint mode only to avoid
+		   checking various context stuff here */
 
-		if(ob) {
+		if(CTX_wm_view3d(C) && ob) {
 			if(ob->mode & OB_MODE_SCULPT)
 				mode = OB_MODE_SCULPT;
 			else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT))
@@ -1043,13 +1045,11 @@
 			else if(ob->mode & OB_MODE_TEXTURE_PAINT)
 				mode = OB_MODE_TEXTURE_PAINT;
 		}
+		else if((sima = CTX_wm_space_image(C)) &&
+			(sima->flag & SI_DRAWTOOL)) {
+			mode = OB_MODE_TEXTURE_PAINT;
+		}
 
-		/* check if cached icon is OK */
-		if(!mode || (id->icon_id && mode == br->icon_mode))
-			return id->icon_id;
-
-		br->icon_mode = mode;
-
 		/* reset the icon */
 		if(mode == OB_MODE_SCULPT) {
 			items = brush_sculpt_tool_items;
@@ -1064,7 +1064,7 @@
 			tool = br->imagepaint_tool;
 		}
 
-		if(!RNA_enum_icon_from_value(items, tool, &id->icon_id))
+		if(!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id))
 			id->icon_id = 0;
 	}
 

Modified: trunk/blender/source/blender/makesdna/DNA_brush_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_brush_types.h	2011-01-16 17:12:02 UTC (rev 34354)
+++ trunk/blender/source/blender/makesdna/DNA_brush_types.h	2011-01-16 18:33:08 UTC (rev 34355)
@@ -57,10 +57,7 @@
 	struct ImBuf *icon_imbuf;
 	PreviewImage *preview;
 	char icon_filepath[240];
-	int icon_mode;			/* store paint mode for which brush's icon was last generated */
-	int pad;
 
-
 	float normal_weight;
 
 	short blend;		/* blend mode */

Modified: trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c	2011-01-16 17:12:02 UTC (rev 34354)
+++ trunk/blender/source/blender/makesrna/intern/rna_sculpt_paint.c	2011-01-16 18:33:08 UTC (rev 34355)
@@ -160,19 +160,23 @@
 static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value)
 {
 	Scene *scene= (Scene *)ptr->id.data;
-	Object *ob = OBACT;
+	ToolSettings *ts = scene->toolsettings;
 	Brush *brush= value.id.data;
-	
-	/* weak, for object painting we need to check against the object mode
-	 * but for 2D view image painting we always want texture brushes 
-	 * this is not quite correct since you could be in object weightpaint
-	 * mode at the same time as the 2D image view, but for now its *good enough* */
-	if(ob && ob->mode & OB_MODE_ALL_PAINT) {
-		return ob->mode & brush->ob_mode;
-	}
-	else {
-		return OB_MODE_TEXTURE_PAINT & brush->ob_mode;
-	}
+	int mode = 0;
+
+	/* check the origin of the Paint struct to see which paint
+	   mode to select from */
+
+	if(ptr->data == &ts->imapaint)
+		mode = OB_MODE_TEXTURE_PAINT;
+	else if(ptr->data == ts->sculpt)
+		mode = OB_MODE_SCULPT;
+	else if(ptr->data == ts->vpaint)
+		mode = OB_MODE_VERTEX_PAINT;
+	else if(ptr->data == ts->wpaint)
+		mode = OB_MODE_WEIGHT_PAINT;
+
+	return brush->ob_mode & mode;
 }
 
 #else




More information about the Bf-blender-cvs mailing list