[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60638] branches/soc-2013-paint/source/ blender/editors/sculpt_paint/paint_image.c: Make sure the mesh has a material assigned when entering texture paint

Antony Riakiotakis kalast at gmail.com
Wed Oct 9 19:44:10 CEST 2013


Revision: 60638
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60638
Author:   psy-fi
Date:     2013-10-09 17:44:10 +0000 (Wed, 09 Oct 2013)
Log Message:
-----------
Make sure the mesh has a material assigned when entering texture paint
mode. This will prevent crashing. Thanks to Marc Dion for the report.

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-10-09 17:04:16 UTC (rev 60637)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-10-09 17:44:10 UTC (rev 60638)
@@ -66,6 +66,7 @@
 #include "BKE_image.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_material.h"
 #include "BKE_mesh.h"
 #include "BKE_node.h"
 #include "BKE_object.h"
@@ -1357,6 +1358,14 @@
 		toggle_paint_cursor(C, 0);
 	}
 	else {
+		/* Make sure that active object has a material, and assign UVs and image layers (TODO) if they do not exist */
+
+		/* no material, add one */
+		if (ob->totcol == 0) {
+			Material *ma = BKE_material_add(CTX_data_main(C), "Material");
+			assign_material(ob, ma, 1, BKE_MAT_ASSIGN_USERPREF);
+		}
+
 		ob->mode |= mode_flag;
 
 		if (me->mtface == NULL)




More information about the Bf-blender-cvs mailing list