From 9c9b145dabb9b5d4c13b06c12030c1b5dbd670bf Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Mon, 27 Oct 2014 10:42:59 +0100 Subject: Fix T42393 crash in texture paint sampling in image mode when mesh did not have a material --- source/blender/editors/sculpt_paint/paint_utils.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index e03c8a5f106..d41af26a4d1 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -292,6 +292,7 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c MVert mv[4]; float matrix[4][4], proj[4][4]; GLint view[4]; + ImagePaintMode mode = scene->toolsettings->imapaint.mode; /* compute barycentric coordinates */ @@ -320,19 +321,25 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c if (findex == faceindex) { dm->getTessFace(dm, a, &mf); - ma = dm->mat[mf.mat_nr]; - slot = &ma->texpaintslot[ma->paint_active_slot]; - dm->getVert(dm, mf.v1, &mv[0]); dm->getVert(dm, mf.v2, &mv[1]); dm->getVert(dm, mf.v3, &mv[2]); if (mf.v4) dm->getVert(dm, mf.v4, &mv[3]); - if (!(slot && slot->uvname && (tf_base = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))) - tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + if (mode == IMAGEPAINT_MODE_MATERIAL) { + ma = dm->mat[mf.mat_nr]; + slot = &ma->texpaintslot[ma->paint_active_slot]; - tf = &tf_base[a]; + if (!(slot && slot->uvname && (tf_base = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))) + tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + + tf = &tf_base[a]; + } + else { + tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + tf = &tf_base[a]; + } p[0] = xy[0]; p[1] = xy[1]; -- cgit v1.2.3