Fix T39306: Backface culling in Multitexture always uses mat game settings

Trying to use mat game settings in 3DView makes sense - but only when we are using "Game Engine" as 'renderer'!

Note GLSL code completely ignores mat game settings currently, could be added too...
This commit is contained in:
Bastien Montagne 2014-03-21 10:11:54 +01:00
parent 92a539ec92
commit 0f95149a78
Notes: blender-bot 2023-02-14 10:56:50 +01:00
Referenced by commit a9bb96e659, Fix transparency issues in 3d viewport
Referenced by issue #39306, Backface culling in Multitexture is on permanently
1 changed files with 11 additions and 4 deletions

View File

@ -68,6 +68,8 @@
#include "GPU_draw.h"
#include "GPU_material.h"
#include "RE_engine.h"
#include "ED_mesh.h"
#include "ED_uvedit.h"
@ -214,11 +216,12 @@ static Material *give_current_material_or_def(Object *ob, int matnr)
static struct TextureDrawState {
Object *ob;
bool use_game_mat;
int is_lit, is_tex;
int color_profile;
bool use_backface_culling;
unsigned char obcol[4];
} Gtexdraw = {NULL, 0, 0, 0, false, {0, 0, 0, 0}};
} Gtexdraw = {NULL, false, 0, 0, 0, false, {0, 0, 0, 0}};
static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *ma, struct TextureDrawState gtexdraw)
{
@ -232,7 +235,7 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
Object *litob = NULL; /* to get mode to turn off mipmap in painting mode */
int backculled = 1;
int alphablend = 0;
int alphablend = GPU_BLEND_SOLID;
int textured = 0;
int lit = 0;
int has_texface = texface != NULL;
@ -253,9 +256,12 @@ static bool set_draw_settings_cached(int clearcache, MTFace *texface, Material *
if (gtexdraw.is_lit) lit = 1;
if (ma) {
alphablend = ma->game.alpha_blend;
if (ma->mode & MA_SHLESS) lit = 0;
backculled = (ma->game.flag & GEMAT_BACKCULL) || gtexdraw.use_backface_culling;
backculled = gtexdraw.use_backface_culling;
if (gtexdraw.use_game_mat) {
backculled = backculled || (ma->game.flag & GEMAT_BACKCULL);
alphablend = ma->game.alpha_blend;
}
}
if (texface) {
@ -359,6 +365,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O
Gtexdraw.is_tex = is_tex;
Gtexdraw.color_profile = BKE_scene_check_color_management_enabled(scene);
Gtexdraw.use_game_mat = (RE_engines_find(scene->r.engine)->flag & RE_GAME) != 0;
Gtexdraw.use_backface_culling = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0;
memcpy(Gtexdraw.obcol, obcol, sizeof(obcol));