diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-01-09 20:03:42 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-01-09 20:06:15 +0300 |
commit | b99687169debea80d0777ba83ac185f1f2e04b83 (patch) | |
tree | 8b9c66c8f8f9229f2647729c881f7b1516d91fb5 /source/blender/editors/sculpt_paint/paint_utils.c | |
parent | 1187b98d4849572932b159462d1da610c89cd77c (diff) |
Fix texture sampling with generative modifiers - sample backbuffer
returns indices in mesh face range
Diffstat (limited to 'source/blender/editors/sculpt_paint/paint_utils.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 427505bbe3e..9c2c13f9a2d 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -52,6 +52,7 @@ #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_image.h" +#include "BKE_material.h" #include "BKE_paint.h" #include "BKE_report.h" @@ -390,11 +391,11 @@ static int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int * } -static Image *imapaint_face_image(DerivedMesh *dm, int face_index) +static Image *imapaint_face_image(Object *ob, Mesh *me, int face_index) { Image *ima; - MFace *mf = dm->getTessFaceArray(dm) + face_index; - Material *ma = dm->mat[mf->mat_nr]; + MPoly *mp = me->mpoly + face_index; + Material *ma = give_current_material(ob, mp->mat_nr + 1);; ima = ma && ma->texpaintslot ? ma->texpaintslot[ma->paint_active_slot].ima : NULL; return ima; @@ -449,16 +450,15 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr bool use_material = (imapaint->mode == IMAGEPAINT_MODE_MATERIAL); if (ob) { + Mesh *me = (Mesh *)ob->data; DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); ViewContext vc; const int mval[2] = {x, y}; unsigned int faceindex; - unsigned int totface = dm->getNumTessFaces(dm); + unsigned int totface = me->totface; MTFace *dm_mtface = dm->getTessFaceDataArray(dm, CD_MTFACE); - DM_update_materials(dm, ob); - if (dm_mtface) { view3d_set_viewcontext(C, &vc); @@ -468,7 +468,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr Image *image; if (use_material) - image = imapaint_face_image(dm, faceindex); + image = imapaint_face_image(ob, me, faceindex); else image = imapaint->canvas; |