[Bf-blender-cvs] [6d6e3869ce5] blender2.8: Fix T57122: Sample color during texture painting not working.

Bastien Montagne noreply at git.blender.org
Tue Oct 9 17:32:19 CEST 2018


Commit: 6d6e3869ce52085bbd4351de96cbc0e6b51b974b
Author: Bastien Montagne
Date:   Tue Oct 9 17:31:04 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB6d6e3869ce52085bbd4351de96cbc0e6b51b974b

Fix T57122: Sample color during texture painting not working.

Stupid +1/-1 fiddling of mat indices (between MPolys and object...).

Initial investigation and patch by @dfelinto, thx.

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

M	source/blender/editors/sculpt_paint/paint_utils.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index aca563c5eab..9057c3b0609 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -53,6 +53,7 @@
 #include "BKE_customdata.h"
 #include "BKE_image.h"
 #include "BKE_material.h"
+#include "BKE_mesh_runtime.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
 #include "BKE_report.h"
@@ -285,13 +286,15 @@ static void imapaint_tri_weights(
 /* compute uv coordinates of mouse in face */
 static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsigned int faceindex, const int xy[2], float uv[2])
 {
-	const int tottri = me_eval->runtime.looptris.len;
 	int i, findex;
 	float p[2], w[3], absw, minabsw;
 	float matrix[4][4], proj[4][4];
 	GLint view[4];
 	const eImagePaintMode mode = scene->toolsettings->imapaint.mode;
-	const MLoopTri *lt = me_eval->runtime.looptris.array;
+
+	const MLoopTri *lt = BKE_mesh_runtime_looptri_ensure(me_eval);
+	const int tottri = me_eval->runtime.looptris.len;
+
 	const MVert *mvert = me_eval->mvert;
 	const MPoly *mpoly = me_eval->mpoly;
 	const MLoop *mloop = me_eval->mloop;
@@ -327,7 +330,7 @@ static void imapaint_pick_uv(Mesh *me_eval, Scene *scene, Object *ob_eval, unsig
 				const Material *ma;
 				const TexPaintSlot *slot;
 
-				ma = give_current_material(ob_eval, mp->mat_nr);
+				ma = give_current_material(ob_eval, mp->mat_nr + 1);
 				slot = &ma->texpaintslot[ma->paint_active_slot];
 
 				if (!(slot && slot->uvname &&



More information about the Bf-blender-cvs mailing list