forked from bartvdbraak/blender
Move from MTFace to MTexPoly w/ texture checks
Part of moving away from MFace.
This commit is contained in:
parent
2cffd6649b
commit
0918461d61
@ -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),
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,12 +804,16 @@ 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) {
|
||||
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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 */
|
||||
|
@ -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, ¢ery,
|
||||
&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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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];
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -233,7 +233,7 @@ Image *RAS_IPolyMaterial::GetBlenderImage() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
MTFace *RAS_IPolyMaterial::GetMTFace() const
|
||||
MTexPoly *RAS_IPolyMaterial::GetMTexPoly() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user