Polymer: account for model flipping for backface culling.

The winding order of faces is different if only flipping about X or Y,
and we were unconditionally culling CW faces.

git-svn-id: https://svn.eduke32.com/eduke32@2052 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
plagman 2011-10-02 00:32:00 +00:00
parent 6863a463b4
commit a6d349c90a
2 changed files with 11 additions and 1 deletions

View file

@ -375,7 +375,7 @@ static void polymer_initrendertargets(int32_t count);
#define INDICE(n) ((p->indices) ? (p->indices[(i+n)%p->indicescount]*5) : (((i+n)%p->vertcount)*5)) #define INDICE(n) ((p->indices) ? (p->indices[(i+n)%p->indicescount]*5) : (((i+n)%p->vertcount)*5))
#define SWITCH_CULL_DIRECTION culledface = (culledface == GL_FRONT) ? GL_BACK : GL_FRONT; bglCullFace(culledface) #define SWITCH_CULL_DIRECTION { culledface = (culledface == GL_FRONT) ? GL_BACK : GL_FRONT; bglCullFace(culledface); }
static inline GLfloat dot2f(GLfloat *v1, GLfloat *v2) static inline GLfloat dot2f(GLfloat *v1, GLfloat *v2)
{ {

View file

@ -3943,6 +3943,12 @@ static void polymer_drawmdsprite(spritetype *tspr)
if (tspr->cstat & 4) if (tspr->cstat & 4)
bglScalef(1.0f, -1.0f, 1.0f); bglScalef(1.0f, -1.0f, 1.0f);
if (!(tspr->cstat & 4) != !(tspr->cstat & 8)) {
// Only inverting one coordinate will reverse the winding order of
// faces, so we need to account for that when culling.
SWITCH_CULL_DIRECTION;
}
bglScalef(scale * tspr->xrepeat, scale * tspr->xrepeat, scale * tspr->yrepeat); bglScalef(scale * tspr->xrepeat, scale * tspr->xrepeat, scale * tspr->yrepeat);
bglTranslatef(0.0f, 0.0, m->zadd * 64); bglTranslatef(0.0f, 0.0, m->zadd * 64);
@ -4272,6 +4278,10 @@ static void polymer_drawmdsprite(spritetype *tspr)
bglPopMatrix(); bglPopMatrix();
if (!(tspr->cstat & 4) != !(tspr->cstat & 8)) {
SWITCH_CULL_DIRECTION;
}
globalnoeffect = 0; globalnoeffect = 0;
} }