From e7dbf553e867908e668ecb59b78785747d238f2f Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 31 Jul 2014 11:46:19 +0200 Subject: Fix T41257. We need to allow faces without slots to initialize a UV layer or seam checking code will go bananas. --- .../editors/sculpt_paint/paint_image_proj.c | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 6c41c8efa55..c27cbff20a0 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -356,7 +356,7 @@ static TexPaintSlot *project_paint_face_paint_slot(const ProjPaintState *ps, int { MFace *mf = ps->dm_mface + face_index; Material *ma = ps->dm->mat[mf->mat_nr]; - return &ma->texpaintslot[ma->paint_active_slot]; + return ma->texpaintslot + ma->paint_active_slot; } static Image *project_paint_face_paint_image(const ProjPaintState *ps, int face_index) @@ -367,7 +367,8 @@ static Image *project_paint_face_paint_image(const ProjPaintState *ps, int face_ else { MFace *mf = ps->dm_mface + face_index; Material *ma = ps->dm->mat[mf->mat_nr]; - return ma->texpaintslot[ma->paint_active_slot].ima; + TexPaintSlot *slot = ma->texpaintslot + ma->paint_active_slot; + return slot ? slot->ima : NULL; } } @@ -3288,18 +3289,20 @@ static void project_paint_begin(ProjPaintState *ps) if (!ps->do_stencil_brush) { slot = project_paint_face_paint_slot(ps, face_index); /* all faces should have a valid slot, reassert here */ - if (slot == NULL) - continue; - - if (slot != slot_last) { - if (!slot->uvname || !(tf_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname))) - tf_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE); - slot_last = slot; + if (slot == NULL) { + tf_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE); } + else { + if (slot != slot_last) { + if (!slot->uvname || !(tf_base = CustomData_get_layer_named(&ps->dm->faceData, CD_MTFACE, slot->uvname))) + tf_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE); + slot_last = slot; + } - /* don't allow using the same inage for painting and stencilling */ - if (slot->ima == ps->stencil_ima) - continue; + /* don't allow using the same inage for painting and stencilling */ + if (slot->ima == ps->stencil_ima) + continue; + } } *tf = tf_base + face_index; -- cgit v1.2.3