Move from MTFace to MTexPoly w/ texture checks
authorCampbell Barton <ideasman42@gmail.com>
Tue, 14 Jul 2015 12:27:25 +0000 (22:27 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 14 Jul 2015 12:36:00 +0000 (22:36 +1000)
Part of moving away from MFace.

17 files changed:
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/editderivedmesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/intern/gpu_draw.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Ketsji/BL_Material.cpp
source/gameengine/Ketsji/BL_Material.h
source/gameengine/Ketsji/KX_BlenderMaterial.cpp
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_StorageIM.cpp

index 70ae9cda3702da2c370135dfa1c63e59d210a88d..984147de3af4bfbc5e7db404956f1ac1e31a5046 100644 (file)
@@ -142,7 +142,7 @@ typedef int (*DMCompareDrawOptions)(void *userData, int cur_index, int next_inde
 typedef void (*DMSetDrawInterpOptions)(void *userData, int index, float t);
 typedef DMDrawOption (*DMSetDrawOptions)(void *userData, int index);
 typedef DMDrawOption (*DMSetDrawOptionsMappedTex)(void *userData, int origindex, int mat_nr);
-typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTFace *tface, const bool has_vcol, int matnr);
+typedef DMDrawOption (*DMSetDrawOptionsTex)(struct MTexPoly *mtexpoly, const bool has_vcol, int matnr);
 
 typedef enum DMDrawFlag {
        DM_DRAW_USE_COLORS          = (1 << 0),
index d60c5a52dbadc5572fe4914d9f7c24100ab7e4bd..b03024c68d02f81ee02caf4d6d8a95708f08bc88 100644 (file)
@@ -471,7 +471,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
 {
        CDDerivedMesh *cddm = (CDDerivedMesh *) dm;
        const MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE);
-       MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE);
+       MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
        MCol *mcol;
        int i, orig;
        int colType, startFace = 0;
@@ -539,12 +539,14 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
                if (i != tottri - 1)
                        next_actualFace = dm->drawObject->triangle_to_mface[i + 1];
                
+               orig = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace) : ORIGINDEX_NONE;
+
                if (drawParams) {
-                       draw_option = drawParams(use_tface && tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr);
+                       MTexPoly *tp = (use_tface && mtexpoly && orig != ORIGINDEX_NONE) ? &mtexpoly[orig] : NULL;
+                       draw_option = drawParams(tp, (mcol != NULL), mf[actualFace].mat_nr);
                }
                else {
                        if (index_mf_to_mpoly) {
-                               orig = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, actualFace);
                                if (orig == ORIGINDEX_NONE) {
                                        /* XXX, this is not really correct
                                                         * it will draw the previous faces context for this one when we don't know its settings.
index 63cec629bf39fa7023d5b7648dbd49e1291e5db1..58f25179c5c925246db114437a904e05dffc3cdb 100644 (file)
@@ -833,19 +833,15 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
                for (i = 0; i < em->tottri; i++) {
                        BMLoop **ltri = looptris[i];
                        MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
-                       MTFace mtf = {{{0}}};
                        /*unsigned char *cp = NULL;*/ /*UNUSED*/
                        int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
                        DMDrawOption draw_option;
 
                        efa = ltri[0]->f;
 
-                       if (cd_poly_tex_offset != -1) {
-                               ME_MTEXFACE_CPY(&mtf, tp);
+                       if (drawParams) {
+                               draw_option = drawParams(tp, has_vcol, efa->mat_nr);
                        }
-
-                       if (drawParams)
-                               draw_option = drawParams(&mtf, has_vcol, efa->mat_nr);
                        else if (drawParamsMapped)
                                draw_option = drawParamsMapped(userData, BM_elem_index_get(efa), efa->mat_nr);
                        else
@@ -902,19 +898,14 @@ static void emDM_drawFacesTex_common(DerivedMesh *dm,
                for (i = 0; i < em->tottri; i++) {
                        BMLoop **ltri = looptris[i];
                        MTexPoly *tp = (cd_poly_tex_offset != -1) ? BM_ELEM_CD_GET_VOID_P(ltri[0]->f, cd_poly_tex_offset) : NULL;
-                       MTFace mtf = {{{0}}};
                        /*unsigned char *cp = NULL;*/ /*UNUSED*/
                        int drawSmooth = lnors || BM_elem_flag_test(ltri[0]->f, BM_ELEM_SMOOTH);
                        DMDrawOption draw_option;
 
                        efa = ltri[0]->f;
 
-                       if (cd_poly_tex_offset != -1) {
-                               ME_MTEXFACE_CPY(&mtf, tp);
-                       }
-
                        if (drawParams)
-                               draw_option = drawParams(&mtf, has_vcol, efa->mat_nr);
+                               draw_option = drawParams(tp, has_vcol, efa->mat_nr);
                        else if (drawParamsMapped)
                                draw_option = drawParamsMapped(userData, BM_elem_index_get(efa), efa->mat_nr);
                        else
index 3b2cad6e81b2c5d58fb15512f414a314343e3c15..cc680224c31b0c366ee1d7fdd9b49d2400b36668 100644 (file)
@@ -2291,8 +2291,13 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm,
                        gridOffset += gridFaces * gridFaces * numVerts;
                }
 
-               if (drawParams)
-                       draw_option = drawParams(tf, (mcol != NULL), mat_nr);
+               if (drawParams) {
+                       MTexPoly tpoly;
+                       if (tf) {
+                               ME_MTEXFACE_CPY(&tpoly, tf);
+                       }
+                       draw_option = drawParams(tf ? &tpoly : NULL, (mcol != NULL), mat_nr);
+               }
                else if (index != ORIGINDEX_NONE)
                        draw_option = (drawParamsMapped) ? drawParamsMapped(userData, index, mat_nr) : DM_DRAW_OPTION_NORMAL;
                else
index 96ea5d810bf4bc1c025dcb95cc405b554f46de62..35e2ca8557adb6002df265a8f22c51afdcdaa5da 100644 (file)
@@ -79,7 +79,7 @@ typedef struct drawMeshFaceSelect_userData {
 typedef struct drawEMTFMapped_userData {
        BMEditMesh *em;
        bool has_mcol;
-       bool has_mtface;
+       int cd_poly_tex_offset;
        MFace *mf;
        MTFace *tf;
 } drawEMTFMapped_userData;
@@ -236,11 +236,11 @@ static struct TextureDrawState {
        bool texpaint_material; /* use material slots for texture painting */
 } Gtexdraw = {NULL, NULL, NULL, false, 0, 0, 0, false, {0, 0, 0, 0}, false, false};
 
-static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw)
+static bool set_draw_settings_cached(int clearcache, MTexPoly *texface, Material *ma, struct TextureDrawState gtexdraw)
 {
        static Material *c_ma;
        static int c_textured;
-       static MTFace c_texface;
+       static MTexPoly c_texface;
        static int c_backculled;
        static bool c_badtex;
        static int c_lit;
@@ -264,7 +264,7 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
 
        if (clearcache) {
                c_textured = c_lit = c_backculled = -1;
-               memset(&c_texface, 0, sizeof(MTFace));
+               memset(&c_texface, 0, sizeof(c_texface));
                c_badtex = false;
                c_has_texface = -1;
                c_ma = NULL;
@@ -534,7 +534,7 @@ static void draw_textured_end(void)
        glPopMatrix();
 }
 
-static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mcol, int matnr)
+static DMDrawOption draw_tface__set_draw_legacy(MTexPoly *mtexpoly, const bool has_mcol, int matnr)
 {
        Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
        bool invalidtexture = false;
@@ -542,9 +542,9 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
        if (ma && (ma->game.flag & GEMAT_INVISIBLE))
                return DM_DRAW_OPTION_SKIP;
 
-       invalidtexture = set_draw_settings_cached(0, tface, ma, Gtexdraw);
+       invalidtexture = set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw);
 
-       if (tface && invalidtexture) {
+       if (mtexpoly && invalidtexture) {
                glColor3ub(0xFF, 0x00, 0xFF);
                return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
        }
@@ -553,7 +553,7 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
                return DM_DRAW_OPTION_NO_MCOL; /* Don't set color */
        }
        else if (!has_mcol) {
-               if (tface) {
+               if (mtexpoly) {
                        glColor3f(1.0, 1.0, 1.0);
                }
                else {
@@ -575,14 +575,14 @@ static DMDrawOption draw_tface__set_draw_legacy(MTFace *tface, const bool has_mc
        }
 }
 
-static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(has_mcol), int matnr)
+static DMDrawOption draw_tface__set_draw(MTexPoly *mtexpoly, const bool UNUSED(has_mcol), int matnr)
 {
        Material *ma = give_current_material(Gtexdraw.ob, matnr + 1);
 
        if (ma && (ma->game.flag & GEMAT_INVISIBLE)) return DM_DRAW_OPTION_SKIP;
 
-       if (tface || Gtexdraw.is_texpaint)
-               set_draw_settings_cached(0, tface, ma, Gtexdraw);
+       if (mtexpoly || Gtexdraw.is_texpaint)
+               set_draw_settings_cached(0, mtexpoly, ma, Gtexdraw);
 
        /* always use color from mcol, as set in update_tface_color_layer */
        return DM_DRAW_OPTION_NORMAL;
@@ -590,7 +590,7 @@ static DMDrawOption draw_tface__set_draw(MTFace *tface, const bool UNUSED(has_mc
 
 static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
 {
-       MTFace *tface = DM_get_tessface_data_layer(dm, CD_MTFACE);
+       MTexPoly *mtexpoly = DM_get_poly_data_layer(dm, CD_MTEXPOLY);
        MFace *mface = dm->getTessFaceArray(dm);
        MCol *finalCol;
        int i, j;
@@ -624,7 +624,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
                                        finalCol[i * 4 + j].r = 255;
                                }
                }
-               else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
+               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;
@@ -639,7 +639,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol)
                        }
                }
                else if (!mcol) {
-                       if (tface) {
+                       if (mtexpoly) {
                                for (j = 0; j < 4; j++) {
                                        finalCol[i * 4 + j].b = 255;
                                        finalCol[i * 4 + j].g = 255;
@@ -691,14 +691,9 @@ static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, i
        }
        else {
                MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[origindex] : NULL;
-               MTFace mtf = {{{0}}};
                int matnr = mpoly->mat_nr;
-
-               if (tpoly) {
-                       ME_MTEXFACE_CPY(&mtf, tpoly);
-               }
                
-               return draw_tface__set_draw(&mtf, (me->mloopcol != NULL), matnr);
+               return draw_tface__set_draw(tpoly, (me->mloopcol != NULL), matnr);
        }
 }
 
@@ -717,16 +712,11 @@ static DMDrawOption draw_em_tf_mapped__set_draw(void *userData, int origindex, i
                return DM_DRAW_OPTION_SKIP;
        }
        else {
-               MTFace mtf = {{{0}}};
+               MTexPoly *mtexpoly = (data->cd_poly_tex_offset != -1) ?
+                       BM_ELEM_CD_GET_VOID_P(efa, data->cd_poly_tex_offset) : NULL;
                int matnr = (mat_nr != -1) ? mat_nr : efa->mat_nr;
 
-               if (data->has_mtface) {
-                       MTexPoly *tpoly = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY);
-                       ME_MTEXFACE_CPY(&mtf, tpoly);
-               }
-
-               return draw_tface__set_draw_legacy(data->has_mtface ? &mtf : NULL,
-                                                  data->has_mcol, matnr);
+               return draw_tface__set_draw_legacy(mtexpoly, data->has_mcol, matnr);
        }
 }
 
@@ -758,7 +748,6 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
        /* fake values to pass to GPU_render_text() */
        MCol  tmp_mcol[4]  = {{0}};
        MCol *tmp_mcol_pt  = mloopcol ? tmp_mcol : NULL;
-       MTFace tmp_tf      = {{{0}}};
 
        /* don't draw without tfaces */
        if (!mtpoly || !mloopuv)
@@ -783,14 +772,14 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                if (!(mode & GEMAT_INVISIBLE) && (mode & GEMAT_TEXT) && mp->totloop >= 3) {
                        /* get the polygon as a tri/quad */
                        int mp_vi[4];
-                       float v1[3], v2[3], v3[3], v4[3];
+                       float   v_quad_data[4][3];
+                       const float  *v_quad[4];
+                       const float *uv_quad[4];
                        char string[MAX_PROPSTRING];
                        int characters, i, glattrib = -1, badtex = 0;
 
 
                        /* TEXFACE */
-                       ME_MTEXFACE_CPY(&tmp_tf, mtpoly);
-
                        if (glsl) {
                                GPU_enable_material(matnr + 1, &gattribs);
 
@@ -802,7 +791,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                                }
                        }
                        else {
-                               badtex = set_draw_settings_cached(0, &tmp_tf, mat, Gtexdraw);
+                               badtex = set_draw_settings_cached(0, mtpoly, mat, Gtexdraw);
                                if (badtex) {
                                        continue;
                                }
@@ -815,13 +804,17 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
 
                        /* UV */
                        luv = &mloopuv[mp->loopstart];
-                       copy_v2_v2(tmp_tf.uv[0], luv->uv); luv++;
-                       copy_v2_v2(tmp_tf.uv[1], luv->uv); luv++;
-                       copy_v2_v2(tmp_tf.uv[2], luv->uv); luv++;
+                       uv_quad[0] = luv->uv; luv++;
+                       uv_quad[1] = luv->uv; luv++;
+                       uv_quad[2] = luv->uv; luv++;
                        if (mp->totloop >= 4) {
-                               copy_v2_v2(tmp_tf.uv[3], luv->uv);
+                               uv_quad[3] = luv->uv;
+                       }
+                       else {
+                               uv_quad[3] = NULL;
                        }
 
+
                        /* COLOR */
                        if (mloopcol) {
                                unsigned int totloop_clamp = min_ii(4, mp->totloop);
@@ -834,13 +827,22 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                        }
 
                        /* LOCATION */
-                       ddm->getVertCo(ddm, mp_vi[0], v1);
-                       ddm->getVertCo(ddm, mp_vi[1], v2);
-                       ddm->getVertCo(ddm, mp_vi[2], v3);
+                       ddm->getVertCo(ddm, mp_vi[0], v_quad_data[0]);
+                       ddm->getVertCo(ddm, mp_vi[1], v_quad_data[1]);
+                       ddm->getVertCo(ddm, mp_vi[2], v_quad_data[2]);
                        if (mp->totloop >= 4) {
-                               ddm->getVertCo(ddm, mp_vi[3], v4);
+                               ddm->getVertCo(ddm, mp_vi[3], v_quad_data[3]);
                        }
 
+                       v_quad[0] = v_quad_data[0];
+                       v_quad[1] = v_quad_data[1];
+                       v_quad[2] = v_quad_data[2];
+                       if (mp->totloop >= 4) {
+                               v_quad[3] = v_quad_data[2];
+                       }
+                       else {
+                               v_quad[3] = NULL;
+                       }
 
 
                        /* The BM_FONT handling is in the gpu module, shared with the
@@ -855,13 +857,16 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl)
                        if (!mf_smooth) {
                                float nor[3];
 
-                               normal_tri_v3(nor, v1, v2, v3);
+                               normal_tri_v3(nor, v_quad[0], v_quad[1], v_quad[2]);
 
                                glNormal3fv(nor);
                        }
 
-                       GPU_render_text(&tmp_tf, mode, string, characters,
-                                       (unsigned int *)tmp_mcol_pt, v1, v2, v3, (mp->totloop >= 4 ? v4 : NULL), glattrib);
+                       GPU_render_text(
+                               mtpoly, mode, string, characters,
+                               (unsigned int *)tmp_mcol_pt,
+                               v_quad, uv_quad,
+                               glattrib);
                }
        }
 
@@ -919,7 +924,8 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d
 
                data.em = me->edit_btmesh;
                data.has_mcol = CustomData_has_layer(&me->edit_btmesh->bm->ldata, CD_MLOOPCOL);
-               data.has_mtface = CustomData_has_layer(&me->edit_btmesh->bm->pdata, CD_MTEXPOLY);
+               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);
 
index 3b40dad3f3bef07d39389e5493429734a8b49f40..f9816b9716e3dedc71d4eea92d895f83d8e03be2 100644 (file)
@@ -3332,7 +3332,7 @@ static bool uv_snap_uvs_offset(Scene *scene, Image *ima, Object *obedit, const f
        BMFace *efa;
        BMLoop *l;
        BMIter iter, liter;
-       MTexPoly *tface;
+       MTexPoly *mtexpoly;
        MLoopUV *luv;
        bool changed = false;
 
@@ -3340,8 +3340,8 @@ static bool uv_snap_uvs_offset(Scene *scene, Image *ima, Object *obedit, const f
        const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY);
 
        BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-               tface = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
-               if (!uvedit_face_visible_test(scene, ima, efa, tface))
+               mtexpoly = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
+               if (!uvedit_face_visible_test(scene, ima, efa, mtexpoly))
                        continue;
 
                BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
index 845ae9d2b304f98ad0081c1a7db959de02a643c9..2e160683618017bb28b598d49a1643359d481259 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
 struct ImBuf;
 struct Image;
 struct ImageUser;
-struct MTFace;
+struct MTexPoly;
 struct Object;
 struct Scene;
 struct View3D;
@@ -83,7 +83,7 @@ int GPU_get_material_alpha_blend(void);
  *   be drawn using one or the other
  * - passing NULL clears the state again */
 
-int GPU_set_tpage(struct MTFace *tface, int mipmap, int transp);
+int GPU_set_tpage(struct MTexPoly *mtexpoly, int mipmap, int transp);
 void GPU_clear_tpage(bool force);
 
 /* Lights
@@ -97,9 +97,11 @@ int GPU_scene_object_lights(struct Scene *scene, struct Object *ob,
 /* Text render
  * - based on moving uv coordinates */
 
-void GPU_render_text(struct MTFace *tface, int mode,
-       const char *textstr, int textlen, unsigned int *col,
-       float *v1, float *v2, float *v3, float *v4, int glattrib);
+void GPU_render_text(
+        struct MTexPoly *mtexpoly, int mode,
+        const char *textstr, int textlen, unsigned int *col,
+        const float *v_quad[4], const float *uv_quad[4],
+        int glattrib);
 
 /* Mipmap settings
  * - these will free textures on changes */
index e033fbbd1d41bc823ed89ce90b32d3b2c6e1019c..f7060779676b3f678a49828c81fa3a2fb7b3d3bd 100644 (file)
@@ -92,12 +92,18 @@ static void gpu_mcol(unsigned int ucol)
        glColor3ub(cp[3], cp[2], cp[1]);
 }
 
-void GPU_render_text(MTFace *tface, int mode,
-       const char *textstr, int textlen, unsigned int *col,
-       float *v1, float *v2, float *v3, float *v4, int glattrib)
+void GPU_render_text(
+        MTexPoly *mtexpoly, int mode,
+        const char *textstr, int textlen, unsigned int *col,
+        const float *v_quad[4], const float *uv_quad[4],
+        int glattrib)
 {
-       if ((mode & GEMAT_TEXT) && (textlen > 0) && tface->tpage) {
-               Image* ima = (Image *)tface->tpage;
+       if ((mode & GEMAT_TEXT) && (textlen > 0) && mtexpoly->tpage) {
+               const float *v1 = v_quad[0];
+               const float *v2 = v_quad[1];
+               const float *v3 = v_quad[2];
+               const float *v4 = v_quad[3];
+               Image *ima = (Image *)mtexpoly->tpage;
                ImBuf *first_ibuf;
                const size_t textlen_st = textlen;
                size_t index;
@@ -116,7 +122,7 @@ void GPU_render_text(MTFace *tface, int mode,
 
                
                /* color has been set */
-               if (tface->mode & TF_OBCOL)
+               if (mtexpoly->mode & TF_OBCOL)
                        col = NULL;
                else if (!col)
                        glColor3f(1.0f, 1.0f, 1.0f);
@@ -159,12 +165,12 @@ void GPU_render_text(MTFace *tface, int mode,
                        matrixGlyph(first_ibuf, character, & centerx, &centery,
                                &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
 
-                       uv[0][0] = (tface->uv[0][0] - centerx) * sizex + transx;
-                       uv[0][1] = (tface->uv[0][1] - centery) * sizey + transy;
-                       uv[1][0] = (tface->uv[1][0] - centerx) * sizex + transx;
-                       uv[1][1] = (tface->uv[1][1] - centery) * sizey + transy;
-                       uv[2][0] = (tface->uv[2][0] - centerx) * sizex + transx;
-                       uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy;
+                       uv[0][0] = (uv_quad[0][0] - centerx) * sizex + transx;
+                       uv[0][1] = (uv_quad[0][1] - centery) * sizey + transy;
+                       uv[1][0] = (uv_quad[1][0] - centerx) * sizex + transx;
+                       uv[1][1] = (uv_quad[1][1] - centery) * sizey + transy;
+                       uv[2][0] = (uv_quad[2][0] - centerx) * sizex + transx;
+                       uv[2][1] = (uv_quad[2][1] - centery) * sizey + transy;
                        
                        glBegin(GL_POLYGON);
                        if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]);
@@ -183,8 +189,8 @@ void GPU_render_text(MTFace *tface, int mode,
                        glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
 
                        if (v4) {
-                               uv[3][0] = (tface->uv[3][0] - centerx) * sizex + transx;
-                               uv[3][1] = (tface->uv[3][1] - centery) * sizey + transy;
+                               uv[3][0] = (uv_quad[3][0] - centerx) * sizex + transx;
+                               uv[3][1] = (uv_quad[3][1] - centery) * sizey + transy;
 
                                if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[3]);
                                else glTexCoord2fv(uv[3]);
@@ -249,7 +255,7 @@ static struct GPUTextureState {
        int alphablend;
        float anisotropic;
        int gpu_mipmap;
-       MTFace *lasttface;
+       MTexPoly *lasttface;
 } GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.0f, 0, NULL};
 
 /* Mipmap settings */
@@ -899,23 +905,23 @@ static void gpu_verify_repeat(Image *ima)
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
 }
 
-int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend)
+int GPU_set_tpage(MTexPoly *mtexpoly, int mipmap, int alphablend)
 {
        Image *ima;
        
        /* check if we need to clear the state */
-       if (tface == NULL) {
+       if (mtexpoly == NULL) {
                GPU_clear_tpage(false);
                return 0;
        }
 
-       ima = tface->tpage;
-       GTS.lasttface = tface;
+       ima = mtexpoly->tpage;
+       GTS.lasttface = mtexpoly;
 
        gpu_verify_alpha_blend(alphablend);
        gpu_verify_reflection(ima);
 
-       if (GPU_verify_image(ima, NULL, tface->tile, 1, mipmap, false)) {
+       if (GPU_verify_image(ima, NULL, mtexpoly->tile, 1, mipmap, false)) {
                GTS.curtile = GTS.tile;
                GTS.curima = GTS.ima;
                GTS.curtilemode = GTS.tilemode;
index 04fa29c3b1a348e54b69dcc9ef30e72337be10e3..49eb2256b4700e7eab2d670e48adb9612f4de9b7 100644 (file)
@@ -872,10 +872,10 @@ static bool ConvertMaterial(
                material->matname       =(mat->id.name);
 
        if (tface) {
-               material->tface         = *tface;
+               ME_MTEXFACE_CPY(&material->mtexpoly, tface);
        }
        else {
-               memset(&material->tface, 0, sizeof(material->tface));
+               memset(&material->mtexpoly, 0, sizeof(material->mtexpoly));
        }
        material->material      = mat;
        return true;
index 849b5e0f3c34954dc43909706362748ea6fb601a..4f707e6267f9493deb79a28335b935881286baaa 100644 (file)
@@ -69,7 +69,7 @@ void BL_Material::Initialize()
        alpha = 1.f;
        emit = 0.f;
        material = 0;
-       memset(&tface, 0, sizeof(tface));
+       memset(&mtexpoly, 0, sizeof(mtexpoly));
        materialindex = 0;
        amb=0.5f;
        num_enabled = 0;
index 83f9b601e0d1583e2cb8ab650d87c0a5bd7e44f7..9207a41f56ded12aebc8023035406b3d02e712f4 100644 (file)
@@ -84,7 +84,7 @@ public:
 
 
        Material*                       material;
-       MTFace                          tface; /* copy of the derived meshes tface */
+       MTexPoly                        mtexpoly; /* copy of the derived meshes tface */
        Image*                          img[MAXTEX];
        EnvMap*                         cubemap[MAXTEX];
 
index abe565f8e2f4f4f69f9c1ef8d4ea65a71e0b626c..d85d33d983484c355e2789bb2a44957e1b12e134 100644 (file)
@@ -161,10 +161,10 @@ KX_BlenderMaterial::~KX_BlenderMaterial()
                OnExit();
 }
 
-MTFace* KX_BlenderMaterial::GetMTFace() const
+MTexPoly *KX_BlenderMaterial::GetMTexPoly() const
 {
        // fonts on polys
-       return &mMaterial->tface;
+       return &mMaterial->mtexpoly;
 }
 
 unsigned int* KX_BlenderMaterial::GetMCol() const
@@ -191,7 +191,7 @@ Material *KX_BlenderMaterial::GetBlenderMaterial() const
 
 Image *KX_BlenderMaterial::GetBlenderImage() const
 {
-       return mMaterial->tface.tpage;
+       return mMaterial->mtexpoly.tpage;
 }
 
 Scene* KX_BlenderMaterial::GetBlenderScene() const
index 9364abb8eed659631bc60632eb2a73acefa2fccd..df089cb7f99ede5c7155168d26cad6594a0bbaa9 100644 (file)
@@ -84,7 +84,7 @@ public:
 
        Material* GetBlenderMaterial() const;
        Image* GetBlenderImage() const;
-       MTFace* GetMTFace() const;
+       MTexPoly *GetMTexPoly() const;
        unsigned int* GetMCol() const;
        BL_Texture * getTex (unsigned int idx) { 
                return (idx < MAXTEX) ? mTextures + idx : NULL; 
index 03f6e567771f751c390ea848be2c53c818d182fc..d07b4910968b0986820aaeb947983572f43b65fb 100644 (file)
@@ -233,7 +233,7 @@ Image *RAS_IPolyMaterial::GetBlenderImage() const
 {
        return NULL;
 }
-MTFace *RAS_IPolyMaterial::GetMTFace() const
+MTexPoly *RAS_IPolyMaterial::GetMTexPoly() const
 {
        return NULL;
 }
index 14223fc59bdb651561c5b45f85aa49c7c883672a..a34f7a9b3900c22c3f81aa9af8571a3fa6abd68a 100644 (file)
@@ -41,7 +41,7 @@
 #endif
 
 class RAS_IRasterizer;
-struct MTFace;
+struct MTexPoly;
 struct Material;
 struct Image;
 struct Scene;
@@ -167,7 +167,7 @@ public:
 
        virtual Material*   GetBlenderMaterial() const;
        virtual Image*      GetBlenderImage() const;
-       virtual MTFace*         GetMTFace() const;
+       virtual MTexPoly*       GetMTexPoly() const;
        virtual unsigned int* GetMCol() const;
        virtual Scene*          GetBlenderScene() const;
        virtual void            ReleaseMaterial();
index 4904fdd0eb0cdae468bc65cf09d2ff820af00e3d..5b7b752ee982774ce0a3a3b8ecb0a3cf3dfd6a16 100644 (file)
@@ -670,7 +670,9 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
                        // triangle and quad text drawing
                        for (i=0; i<it.totindex; i+=numvert)
                        {
-                               float v[4][3];
+                               float  v[4][3];
+                               const float  *v_ptr[4] = {NULL};
+                               const float *uv_ptr[4] = {NULL};
                                int glattrib, unit;
 
                                for (j=0; j<numvert; j++) {
@@ -679,6 +681,9 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
                                        v[j][0] = vertex->getXYZ()[0];
                                        v[j][1] = vertex->getXYZ()[1];
                                        v[j][2] = vertex->getXYZ()[2];
+                                       v_ptr[j] = v[j];
+
+                                       uv_ptr[j] = vertex->getUV(0);
                                }
 
                                // find the right opengl attribute
@@ -688,7 +693,9 @@ void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
                                                if (m_attrib[unit] == RAS_TEXCO_UV)
                                                        glattrib = unit;
 
-                               GPU_render_text(polymat->GetMTFace(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(), v[0], v[1], v[2], v[3], glattrib);
+                               GPU_render_text(
+                                       polymat->GetMTexPoly(), polymat->GetDrawingMode(), mytext, mytext.Length(), polymat->GetMCol(),
+                                       v_ptr, uv_ptr, glattrib);
 
                                ClearCachingInfo();
                        }
index e0613350b77824c7792c25f7ab5a1dbe7b4e006a..c978b908a6ad79aa5271a7c1273deb97d99cc783 100644 (file)
@@ -179,12 +179,12 @@ static int CheckTexfaceDM(void *mcol, int index)
 }
 */
 
-static DMDrawOption CheckTexDM(MTFace *tface, const bool has_mcol, int matnr)
+static DMDrawOption CheckTexDM(MTexPoly *mtexpoly, const bool has_mcol, int matnr)
 {
 
        // index is the original face index, retrieve the polygon
        if (matnr == current_blmat_nr &&
-               (tface == NULL || tface->tpage == current_image)) {
+               (mtexpoly == NULL || mtexpoly->tpage == current_image)) {
                // must handle color.
                if (current_wireframe)
                        return DM_DRAW_OPTION_NO_MCOL;