[Bf-blender-cvs] [aedcd1c] soc-2013-paint: Projection painting:

Antony Riakiotakis noreply at git.blender.org
Tue Apr 22 17:27:22 CEST 2014


Commit: aedcd1c23e178810698bec47dfa2b304ba819421
Author: Antony Riakiotakis
Date:   Tue Apr 22 18:26:55 2014 +0300
https://developer.blender.org/rBaedcd1c23e178810698bec47dfa2b304ba819421

Projection painting:

* Use dm material cache for faster material lookups
* Fix crash when loading file in texpaint mode.

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

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

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

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index ace43b7..654b7a7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3569,7 +3569,8 @@ static void direct_link_material(FileData *fd, Material *ma)
 	for (a = 0; a < MAX_MTEX; a++) {
 		ma->mtex[a] = newdataadr(fd, ma->mtex[a]);
 	}
-	
+	ma->texpaintslot = NULL;
+
 	ma->ramp_col = newdataadr(fd, ma->ramp_col);
 	ma->ramp_spec = newdataadr(fd, ma->ramp_spec);
 	
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 2c15a95..77e909d 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1408,6 +1408,10 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op)
 		toggle_paint_cursor(C, 0);
 	}
 	else {
+		/* This has to stay here to regenerate the texture paint
+		 * cache in case we are loading a file */
+		refresh_object_texpaint_images(ob);
+
 		paint_proj_mesh_data_ensure(C, ob);
 
 		ob->mode |= mode_flag;
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 77f44c5..71047a8 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -359,7 +359,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, int face_index)
 	}
 	else {
 		MFace *mf = ps->dm_mface + face_index;
-		Material *ma = give_current_material(ps->ob, mf->mat_nr + 1);
+		Material *ma = ps->dm->mat[mf->mat_nr];
 		ima = ma->texpaintslot[ma->paint_active_slot].ima;
 	}
 
@@ -373,7 +373,7 @@ static TexPaintSlot *project_paint_face_paint_slot(const ProjPaintState *ps, int
 	}
 	else {
 		MFace *mf = ps->dm_mface + face_index;
-		Material *ma = give_current_material(ps->ob, mf->mat_nr + 1);
+		Material *ma = ps->dm->mat[mf->mat_nr];
 		return &ma->texpaintslot[ma->paint_active_slot];
 	}
 }
@@ -3021,6 +3021,8 @@ static void project_paint_begin(ProjPaintState *ps)
 		return;
 	}
 
+	DM_update_materials(ps->dm, ps->ob);
+
 	ps->dm_mvert = ps->dm->getVertArray(ps->dm);
 	ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
 	ps->dm_mtface = MEM_mallocN(ps->dm->getNumTessFaces(ps->dm) * sizeof (MTFace *), "proj_paint_mtfaces");




More information about the Bf-blender-cvs mailing list