Implemented Voodoo 2 triangle setup cull ping-ponging. Fixes missing triangles in Starsiege Tribes.

This commit is contained in:
SarahW 2016-11-22 19:42:08 +00:00
commit c5889e311f

View file

@ -3443,7 +3443,8 @@ enum
SETUPMODE_STRIP_MODE = (1 << 16), SETUPMODE_STRIP_MODE = (1 << 16),
SETUPMODE_CULLING_ENABLE = (1 << 17), SETUPMODE_CULLING_ENABLE = (1 << 17),
SETUPMODE_CULLING_SIGN = (1 << 18) SETUPMODE_CULLING_SIGN = (1 << 18),
SETUPMODE_DISABLE_PINGPONG = (1 << 19)
}; };
static void triangle_setup(voodoo_t *voodoo) static void triangle_setup(voodoo_t *voodoo)
@ -3521,7 +3522,13 @@ static void triangle_setup(voodoo_t *voodoo)
area = dxAB * dyBC - dxBC * dyAB; area = dxAB * dyBC - dxBC * dyAB;
if (area == 0.0) if (area == 0.0)
{
if ((voodoo->sSetupMode & SETUPMODE_CULLING_ENABLE) &&
!(voodoo->sSetupMode & SETUPMODE_DISABLE_PINGPONG))
voodoo->sSetupMode ^= SETUPMODE_CULLING_SIGN;
return; return;
}
dxAB /= area; dxAB /= area;
dxBC /= area; dxBC /= area;
@ -3530,14 +3537,18 @@ static void triangle_setup(voodoo_t *voodoo)
if (voodoo->sSetupMode & SETUPMODE_CULLING_ENABLE) if (voodoo->sSetupMode & SETUPMODE_CULLING_ENABLE)
{ {
int cull_sign = voodoo->sSetupMode & SETUPMODE_CULLING_SIGN;
int sign = (area < 0.0); int sign = (area < 0.0);
if (!(voodoo->sSetupMode & SETUPMODE_DISABLE_PINGPONG))
voodoo->sSetupMode ^= SETUPMODE_CULLING_SIGN;
if (reverse_cull) if (reverse_cull)
sign = !sign; sign = !sign;
if ((voodoo->sSetupMode & SETUPMODE_CULLING_SIGN) && sign) if (cull_sign && sign)
return; return;
if (!(voodoo->sSetupMode & SETUPMODE_CULLING_SIGN) && !sign) if (!cull_sign && !sign)
return; return;
} }