From 595a491e63d6f3f3462675d38cfa71b4e784fe9c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Jul 2015 03:36:03 +1000 Subject: Add tessellation data to DerivedMesh (LoopTri) This stores loop indices into the loop array giving easier acess to data such as vertex-colors and UV's, removing the need to store an MFace duplicate of custom-data. This doesn't yet move all internal code from MFace to LoopTri just yet. Only applies to: - opengl drawing - sculpting (pbvh) - vertex/weight paint Thanks to @psy-fi for review, fixes and improvements to drawing! --- source/blender/editors/mesh/editface.c | 39 +--- source/blender/editors/sculpt_paint/paint_vertex.c | 204 +-------------------- source/blender/editors/space_view3d/drawmesh.c | 137 +++++++------- 3 files changed, 67 insertions(+), 313 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index ca3c8a97d40..0017cd3c2ae 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -62,9 +62,8 @@ void paintface_flush_flags(Object *ob) Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MPoly *polys, *mp_orig; - MFace *faces; const int *index_array = NULL; - int totface, totpoly; + int totpoly; int i; if (me == NULL) @@ -79,26 +78,7 @@ void paintface_flush_flags(Object *ob) if (dm == NULL) return; - /* - * Try to push updated mesh poly flags to three other data sets: - * - Mesh polys => Mesh tess faces - * - Mesh polys => Final derived polys - * - Final derived polys => Final derived tessfaces - */ - - if ((index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX))) { - faces = me->mface; - totface = me->totface; - - /* loop over tessfaces */ - for (i = 0; i < totface; i++) { - if (index_array[i] != ORIGINDEX_NONE) { - /* Copy flags onto the original tessface from its original poly */ - mp_orig = me->mpoly + index_array[i]; - faces[i].flag = mp_orig->flag; - } - } - } + /* Mesh polys => Final derived polys */ if ((index_array = CustomData_get_layer(&dm->polyData, CD_ORIGINDEX))) { polys = dm->getPolyArray(dm); @@ -113,21 +93,6 @@ void paintface_flush_flags(Object *ob) } } } - - if ((index_array = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))) { - polys = dm->getPolyArray(dm); - faces = dm->getTessFaceArray(dm); - totface = dm->getNumTessFaces(dm); - - /* loop over tessfaces */ - for (i = 0; i < totface; i++) { - if (index_array[i] != ORIGINDEX_NONE) { - /* Copy flags onto the final tessface from its final poly */ - mp_orig = polys + index_array[i]; - faces[i].flag = mp_orig->flag; - } - } - } } void paintface_hide(Object *ob, const bool unselected) diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index e34bcf7c97b..cafc773c48c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -91,45 +91,6 @@ static bool vertex_paint_use_fast_update_check(Object *ob) return false; } -/* if the polygons from the mesh and the 'derivedFinal' match - * we can assume that no modifiers are applied and that its worth adding tessellated faces - * so 'vertex_paint_use_fast_update_check()' returns true */ -static bool vertex_paint_use_tessface_check(Object *ob, Mesh *me) -{ - DerivedMesh *dm = ob->derivedFinal; - - if (me && dm) { - return (me->mpoly == CustomData_get_layer(&dm->polyData, CD_MPOLY)); - } - - return false; -} - -static void update_tessface_data(Object *ob, Mesh *me) -{ - if (vertex_paint_use_tessface_check(ob, me)) { - /* assume if these exist, that they are up to date & valid */ - if (!me->mcol || !me->mface) { - /* should always be true */ - /* XXX Why this clearing? tessface_calc will reset it anyway! */ -#if 0 - if (me->mcol) { - memset(me->mcol, 255, 4 * sizeof(MCol) * me->totface); - } -#endif - - /* create tessfaces because they will be used for drawing & fast updates */ - BKE_mesh_tessface_calc(me); /* does own call to update pointers */ - } - } - else { - if (me->totface) { - /* this wont be used, theres no need to keep it */ - BKE_mesh_tessface_clear(me); - } - } - -} /* polling - retrieve whether cursor should be set or operator should be done */ /* Returns true if vertex paint mode is active */ @@ -205,80 +166,7 @@ unsigned int vpaint_get_current_col(Scene *scene, VPaint *vp) return *(unsigned int *)col; } -static void do_shared_vertex_tesscol(Mesh *me, bool *mfacetag) -{ - /* if no mcol: do not do */ - /* if tface: only the involved faces, otherwise all */ - const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; - MFace *mface; - int a; - short *scolmain, *scol; - char *mcol; - const bool *mftag; - - if (me->mcol == NULL || me->totvert == 0 || me->totface == 0) return; - - scolmain = MEM_callocN(4 * sizeof(short) * me->totvert, "colmain"); - - mface = me->mface; - mcol = (char *)me->mcol; - for (a = me->totface; a > 0; a--, mface++, mcol += 16) { - if ((use_face_sel == false) || (mface->flag & ME_FACE_SEL)) { - scol = scolmain + 4 * mface->v1; - scol[0]++; scol[1] += mcol[1]; scol[2] += mcol[2]; scol[3] += mcol[3]; - scol = scolmain + 4 * mface->v2; - scol[0]++; scol[1] += mcol[5]; scol[2] += mcol[6]; scol[3] += mcol[7]; - scol = scolmain + 4 * mface->v3; - scol[0]++; scol[1] += mcol[9]; scol[2] += mcol[10]; scol[3] += mcol[11]; - if (mface->v4) { - scol = scolmain + 4 * mface->v4; - scol[0]++; scol[1] += mcol[13]; scol[2] += mcol[14]; scol[3] += mcol[15]; - } - } - } - - a = me->totvert; - scol = scolmain; - while (a--) { - if (scol[0] > 1) { - scol[1] = divide_round_i(scol[1], scol[0]); - scol[2] = divide_round_i(scol[2], scol[0]); - scol[3] = divide_round_i(scol[3], scol[0]); - } - scol += 4; - } - - mface = me->mface; - mcol = (char *)me->mcol; - mftag = mfacetag; - for (a = me->totface; a > 0; a--, mface++, mcol += 16, mftag += 4) { - if ((use_face_sel == false) || (mface->flag & ME_FACE_SEL)) { - if (mftag[0]) { - scol = scolmain + 4 * mface->v1; - mcol[1] = scol[1]; mcol[2] = scol[2]; mcol[3] = scol[3]; - } - - if (mftag[1]) { - scol = scolmain + 4 * mface->v2; - mcol[5] = scol[1]; mcol[6] = scol[2]; mcol[7] = scol[3]; - } - - if (mftag[2]) { - scol = scolmain + 4 * mface->v3; - mcol[9] = scol[1]; mcol[10] = scol[2]; mcol[11] = scol[3]; - } - - if (mface->v4 && mftag[3]) { - scol = scolmain + 4 * mface->v4; - mcol[13] = scol[1]; mcol[14] = scol[2]; mcol[15] = scol[3]; - } - } - } - - MEM_freeN(scolmain); -} - -static void do_shared_vertexcol(Mesh *me, bool *mlooptag, bool *mfacetag, const bool do_tessface) +static void do_shared_vertexcol(Mesh *me, bool *mlooptag) { const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; MPoly *mp; @@ -332,10 +220,6 @@ static void do_shared_vertexcol(Mesh *me, bool *mlooptag, bool *mfacetag, const } MEM_freeN(scol); - - if (has_shared && do_tessface) { - do_shared_vertex_tesscol(me, mfacetag); - } } static bool make_vertexcol(Object *ob) /* single ob */ @@ -352,17 +236,12 @@ static bool make_vertexcol(Object *ob) /* single ob */ /* copies from shadedisplist to mcol */ if (!me->mloopcol && me->totloop) { - if (!me->mcol) { - CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); - } if (!me->mloopcol) { CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop); } BKE_mesh_update_customdata_pointers(me, true); } - update_tessface_data(ob, me); - DAG_id_tag_update(&me->id, 0); return (me->mloopcol != NULL); @@ -593,7 +472,7 @@ bool ED_vpaint_smooth(Object *ob) /* remove stale me->mcol, will be added later */ BKE_mesh_tessface_clear(me); - do_shared_vertexcol(me, mlooptag, NULL, false); + do_shared_vertexcol(me, mlooptag); MEM_freeN(mlooptag); @@ -2753,35 +2632,13 @@ typedef struct VPaintData { * array, otherwise we need to refresh the modifier stack */ bool use_fast_update; - /* mpoly -> mface mapping */ - MeshElemMap *polyfacemap; - void *polyfacemap_mem; - /* loops tagged as having been painted, to apply shared vertex color * blending only to modified loops */ bool *mlooptag; - bool *mfacetag; bool is_texbrush; } VPaintData; -static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me) -{ - const int *tessface_origindex; - - vd->polyfacemap = NULL; - vd->polyfacemap_mem = NULL; - - tessface_origindex = CustomData_get_layer(&me->fdata, CD_ORIGINDEX); - - if (!tessface_origindex) - return; - - BKE_mesh_origindex_map_create(&vd->polyfacemap, (int **)&vd->polyfacemap_mem, - me->totpoly, - tessface_origindex, me->totface); -} - static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const float UNUSED(mouse[2])) { Scene *scene = CTX_data_scene(C); @@ -2804,11 +2661,6 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f if (me->mloopcol == NULL) return false; - /* Update tessface data if needed - * Added here too because e.g. switching to/from edit mode would remove tessface data, - * yet "fast_update" could still be used! */ - update_tessface_data(ob, me); - /* make mode data storage */ vpd = MEM_callocN(sizeof(struct VPaintData), "VPaintData"); paint_stroke_set_mode_data(stroke, vpd); @@ -2825,7 +2677,6 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f /* are we painting onto a modified mesh?, * if not we can skip face map trickyness */ if (vertex_paint_use_fast_update_check(ob)) { - vpaint_build_poly_facemap(vpd, me); vpd->use_fast_update = true; /* printf("Fast update!\n");*/ } @@ -2837,8 +2688,6 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f /* to keep tracked of modified loops for shared vertex color blending */ if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { vpd->mlooptag = MEM_mallocN(sizeof(bool) * me->totloop, "VPaintData mlooptag"); - if (vpd->use_fast_update) - vpd->mfacetag = MEM_mallocN(sizeof(bool) * me->totface * 4, "VPaintData mfacetag"); } /* for filtering */ @@ -2859,14 +2708,10 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Mesh *me, ViewContext *vc = &vpd->vc; Brush *brush = BKE_paint_brush(&vp->paint); MPoly *mpoly = &me->mpoly[index]; - MFace *mf; - MCol *mc; MLoop *ml; - MLoopCol *mlc; unsigned int *lcol = ((unsigned int *)me->mloopcol) + mpoly->loopstart; unsigned int *lcolorig = ((unsigned int *)vp->vpaint_prev) + mpoly->loopstart; bool *mlooptag = (vpd->mlooptag) ? vpd->mlooptag + mpoly->loopstart : NULL; - bool *mftag; float alpha; int i, j; int totloop = mpoly->totloop; @@ -2923,35 +2768,6 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Mesh *me, if (mlooptag) mlooptag[i] = 1; } } - - if (vpd->use_fast_update) { - const MeshElemMap *map = &vpd->polyfacemap[index]; - - /* update vertex colors for tessellations incrementally, - * rather then regenerating the tessellation altogether */ - for (i = 0; i < map->count; i++) { - const int index_tessface = map->indices[i]; - - mf = &me->mface[index_tessface]; - mc = &me->mcol[index_tessface * 4]; - mftag = &vpd->mfacetag[index_tessface * 4]; - - ml = me->mloop + mpoly->loopstart; - mlc = me->mloopcol + mpoly->loopstart; - - for (j = 0; j < totloop; j++, ml++, mlc++) { - /* search for the loop vertex within the tessface */ - const int fidx = BKE_MESH_TESSFACE_VINDEX_ORDER(mf, ml->v); - if (fidx != -1) { - MESH_MLOOPCOL_TO_MCOL(mlc, mc + fidx); - if (mlooptag) { - mftag[fidx] = mlooptag[j]; - } - } - } - } - } - } static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) @@ -3003,8 +2819,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* clear modified tag for blur tool */ if (vpd->mlooptag) memset(vpd->mlooptag, 0, sizeof(bool) * me->totloop); - if (vpd->mfacetag) - memset(vpd->mfacetag, 0, sizeof(bool) * me->totface * 4); for (index = 0; index < totindex; index++) { if (indexar[index] && indexar[index] <= me->totpoly) { @@ -3016,8 +2830,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* was disabled because it is slow, but necessary for blur */ if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { - int do_tessface = vpd->use_fast_update; - do_shared_vertexcol(me, vpd->mlooptag, vpd->mfacetag, do_tessface); + do_shared_vertexcol(me, vpd->mlooptag); } ED_region_tag_redraw(vc->ar); @@ -3046,20 +2859,9 @@ static void vpaint_stroke_done(const bContext *C, struct PaintStroke *stroke) /* frees prev buffer */ copy_vpaint_prev(ts->vpaint, NULL, 0); - if (vpd->polyfacemap) { - MEM_freeN(vpd->polyfacemap); - } - - if (vpd->polyfacemap_mem) { - MEM_freeN(vpd->polyfacemap_mem); - } - if (vpd->mlooptag) MEM_freeN(vpd->mlooptag); - if (vpd->mfacetag) - MEM_freeN(vpd->mfacetag); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); MEM_freeN(vpd); diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index b0250dfdec0..9ccacbad4a2 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -80,14 +80,14 @@ typedef struct drawEMTFMapped_userData { BMEditMesh *em; bool has_mcol; int cd_poly_tex_offset; - MFace *mf; - MTFace *tf; + const MPoly *mpoly; + const MTexPoly *mtexpoly; } drawEMTFMapped_userData; typedef struct drawTFace_userData { - Mesh *me; - MFace *mf; - MTFace *tf; + const Mesh *me; + const MPoly *mpoly; + const MTexPoly *mtexpoly; } drawTFace_userData; /**************************** Face Select Mode *******************************/ @@ -590,11 +590,12 @@ static DMDrawOption draw_tface__set_draw(MTexPoly *mtexpoly, const bool UNUSED(h static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol) { + const MPoly *mp = dm->getPolyArray(dm); + const int mpoly_num = dm->getNumPolys(dm); MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY); - MFace *mface = dm->getTessFaceArray(dm); - MCol *finalCol; + MLoopCol *finalCol; int i, j; - MCol *mcol = NULL; + MLoopCol *mloopcol = NULL; /* cache material values to avoid a lot of lookups */ Material *ma = NULL; @@ -606,108 +607,94 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol) } copy_mode = COPY_CALC; if (use_mcol) { - mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL); - if (!mcol) - mcol = dm->getTessFaceDataArray(dm, CD_MCOL); + mloopcol = dm->getLoopDataArray(dm, CD_PREVIEW_MLOOPCOL); + if (!mloopcol) + mloopcol = dm->getLoopDataArray(dm, CD_MLOOPCOL); } - if (CustomData_has_layer(&dm->faceData, CD_TEXTURE_MCOL)) { - finalCol = CustomData_get_layer(&dm->faceData, CD_TEXTURE_MCOL); + if (CustomData_has_layer(&dm->loopData, CD_TEXTURE_MLOOPCOL)) { + finalCol = CustomData_get_layer(&dm->loopData, CD_TEXTURE_MLOOPCOL); } else { - finalCol = MEM_mallocN(sizeof(MCol) * 4 * dm->getNumTessFaces(dm), "add_tface_color_layer"); - - CustomData_add_layer(&dm->faceData, CD_TEXTURE_MCOL, CD_ASSIGN, finalCol, dm->numTessFaceData); + finalCol = MEM_mallocN(sizeof(MLoopCol) * dm->numLoopData, "add_tface_color_layer"); + CustomData_add_layer(&dm->loopData, CD_TEXTURE_MLOOPCOL, CD_ASSIGN, finalCol, dm->numLoopData); } - for (i = 0; i < dm->getNumTessFaces(dm); i++) { - const short mat_nr = mface[i].mat_nr; + for (i = mpoly_num; i--; mp++) { + const short mat_nr = mp->mat_nr; if (UNLIKELY(mat_nr_prev != mat_nr)) { - ma = give_current_material(Gtexdraw.ob, mface[i].mat_nr + 1); + ma = give_current_material(Gtexdraw.ob, mat_nr + 1); copy_mode = COPY_CALC; mat_nr_prev = mat_nr; } /* avoid lookups */ if (copy_mode == COPY_ORIG) { - memcpy(&finalCol[i * 4], &mcol[i * 4], sizeof(MCol) * 4); + memcpy(&finalCol[mp->loopstart], &mloopcol[mp->loopstart], sizeof(*finalCol) * mp->totloop); } else if (copy_mode == COPY_PREV) { - memcpy(&finalCol[i * 4], &finalCol[(i - 1) * 4], sizeof(MCol) * 4); + int loop_index = mp->loopstart; + const MLoopCol *lcol_prev = &finalCol[(mp - 1)->loopstart]; + for (j = 0; j < mp->totloop; j++, loop_index++) { + finalCol[loop_index] = *lcol_prev; + } } /* (copy_mode == COPY_CALC) */ else if (ma && (ma->game.flag & GEMAT_INVISIBLE)) { - if (mcol) { - memcpy(&finalCol[i * 4], &mcol[i * 4], sizeof(MCol) * 4); + if (mloopcol) { + memcpy(&finalCol[mp->loopstart], &mloopcol[mp->loopstart], sizeof(*finalCol) * mp->totloop); copy_mode = COPY_ORIG; } else { - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j].b = 255; - finalCol[i * 4 + j].g = 255; - finalCol[i * 4 + j].r = 255; - } + memset(&finalCol[mp->loopstart], 0xff, sizeof(*finalCol) * mp->totloop); copy_mode = COPY_PREV; } } else if (mtexpoly && set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw)) { - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j].b = 255; - finalCol[i * 4 + j].g = 0; - finalCol[i * 4 + j].r = 255; + int loop_index = mp->loopstart; + for (j = 0; j < mp->totloop; j++, loop_index++) { + finalCol[loop_index].r = 255; + finalCol[loop_index].g = 0; + finalCol[loop_index].b = 255; } copy_mode = COPY_PREV; } else if (ma && (ma->shade_flag & MA_OBCOLOR)) { - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j].b = Gtexdraw.obcol[0]; - finalCol[i * 4 + j].g = Gtexdraw.obcol[1]; - finalCol[i * 4 + j].r = Gtexdraw.obcol[2]; + int loop_index = mp->loopstart;; + for (j = 0; j < mp->totloop; j++, loop_index++) { + copy_v3_v3_char(&finalCol[loop_index].r, (char *)Gtexdraw.obcol); } copy_mode = COPY_PREV; } else { - if (mcol) { - memcpy(&finalCol[i * 4], &mcol[i * 4], sizeof(MCol) * 4); + if (mloopcol) { + memcpy(&finalCol[mp->loopstart], &mloopcol[mp->loopstart], sizeof(*finalCol) * mp->totloop); copy_mode = COPY_ORIG; } else if (mtexpoly) { - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j].b = 255; - finalCol[i * 4 + j].g = 255; - finalCol[i * 4 + j].r = 255; - } + memset(&finalCol[mp->loopstart], 0xff, sizeof(*finalCol) * mp->totloop); copy_mode = COPY_PREV; } else { - if (ma) { - float col[3]; - MCol tcol; - - if (Gtexdraw.color_profile) { - linearrgb_to_srgb_v3_v3(col, &ma->r); - } - else { - copy_v3_v3(col, &ma->r); - } + float col[3]; - tcol.b = FTOCHAR(col[0]); - tcol.g = FTOCHAR(col[1]); - tcol.r = FTOCHAR(col[2]); - tcol.a = 255; + if (ma) { + int loop_index = mp->loopstart; + MLoopCol lcol; - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j] = tcol; + if (Gtexdraw.color_profile) linearrgb_to_srgb_v3_v3(col, &ma->r); + else copy_v3_v3(col, &ma->r); + rgb_float_to_uchar((unsigned char *)&lcol.r, col); + lcol.a = 255; + + for (j = 0; j < mp->totloop; j++, loop_index++) { + finalCol[loop_index] = lcol; } } else { - for (j = 0; j < 4; j++) { - finalCol[i * 4 + j].b = 255; - finalCol[i * 4 + j].g = 255; - finalCol[i * 4 + j].r = 255; - } + memset(&finalCol[mp->loopstart], 0xff, sizeof(*finalCol) * mp->totloop); } copy_mode = COPY_PREV; } @@ -717,7 +704,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol) static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, int UNUSED(mat_nr)) { - Mesh *me = ((drawTFace_userData *)userData)->me; + const Mesh *me = ((drawTFace_userData *)userData)->me; /* array checked for NULL before calling */ MPoly *mpoly = &me->mpoly[origindex]; @@ -915,10 +902,10 @@ static int compareDrawOptions(void *userData, int cur_index, int next_index) { drawTFace_userData *data = userData; - if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) + if (data->mpoly && data->mpoly[cur_index].mat_nr != data->mpoly[next_index].mat_nr) return 0; - if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage) + if (data->mtexpoly && data->mtexpoly[cur_index].tpage != data->mtexpoly[next_index].tpage) return 0; return 1; @@ -929,10 +916,10 @@ static int compareDrawOptionsEm(void *userData, int cur_index, int next_index) { drawEMTFMapped_userData *data = userData; - if (data->mf && data->mf[cur_index].mat_nr != data->mf[next_index].mat_nr) + if (data->mpoly && data->mpoly[cur_index].mat_nr != data->mpoly[next_index].mat_nr) return 0; - if (data->tf && data->tf[cur_index].tpage != data->tf[next_index].tpage) + if (data->mtexpoly && data->mtexpoly[cur_index].tpage != data->mtexpoly[next_index].tpage) return 0; return 1; @@ -964,8 +951,8 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d data.has_mcol = CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL); data.cd_poly_tex_offset = CustomData_get_offset(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY); - data.mf = DM_get_tessface_data_layer(dm, CD_MFACE); - data.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); + data.mpoly = DM_get_poly_data_layer(dm, CD_MPOLY); + data.mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY); dm->drawMappedFacesTex(dm, draw_em_tf_mapped__set_draw, compareDrawOptionsEm, &data, 0); } @@ -976,8 +963,8 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d else { drawTFace_userData userData; - userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); - userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); + userData.mpoly = DM_get_poly_data_layer(dm, CD_MPOLY); + userData.mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY); userData.me = me; dm->drawMappedFacesTex(dm, me->mpoly ? draw_tface_mapped__set_draw : NULL, compareDrawOptions, &userData, uvflag); } @@ -987,8 +974,8 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d update_tface_color_layer(dm, !(ob->mode & OB_MODE_TEXTURE_PAINT)); - userData.mf = DM_get_tessface_data_layer(dm, CD_MFACE); - userData.tf = DM_get_tessface_data_layer(dm, CD_MTFACE); + userData.mpoly = DM_get_poly_data_layer(dm, CD_MPOLY); + userData.mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY); userData.me = NULL; dm->drawFacesTex(dm, draw_tface__set_draw, compareDrawOptions, &userData, uvflag); -- cgit v1.2.3