mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-11 07:41:36 +00:00
*Fixed OpenGL's handling of cv_translucency effects (should not remove shadows if off, but perhaps make them use default alpha?), someone was a bit hasty! *De-stupified the MD2 status checks regarding drawing of sprites - if they're already checked before calling HWR_DrawSprite, there's no point doing them WITHIN the function as well *Split off sprite shadow code into HWR_DrawSpriteShadow for convenience
git-svn-id: https://code.orospakr.ca/svn/srb2/trunk@8983 6de4a73c-47e2-0310-b8c1-93d6ecd3f8cd
This commit is contained in:
parent
6513954789
commit
8232dbca10
1 changed files with 191 additions and 186 deletions
|
@ -3527,119 +3527,11 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v
|
|||
return false;
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawSprite : Draw flat sprites
|
||||
// : (monsters, bonuses, weapons, lights, ...)
|
||||
// Returns :
|
||||
// -----------------+
|
||||
static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float this_scale)
|
||||
{
|
||||
UINT8 i;
|
||||
float tr_x, tr_y, this_scale = 1.0f;
|
||||
FOutVector wallVerts[4];
|
||||
float tr_x, tr_y;
|
||||
FOutVector *wv;
|
||||
GLPatch_t *gpatch; // sprite patch converted to hardware
|
||||
FSurfaceInfo Surf;
|
||||
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
|
||||
if (spr->mobj)
|
||||
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
|
||||
if (hires)
|
||||
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale);
|
||||
|
||||
if (!spr->mobj)
|
||||
return;
|
||||
|
||||
if (!spr->mobj->subsector)
|
||||
return;
|
||||
|
||||
// cache sprite graphics
|
||||
//12/12/99: Hurdler:
|
||||
// OK, I don't change anything for MD2 support because I want to be
|
||||
// sure to do it the right way. So actually, we keep normal sprite
|
||||
// in memory and we add the md2 model if it exists for that sprite
|
||||
|
||||
gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
|
||||
|
||||
#ifdef ALAM_LIGHTING
|
||||
if (!(spr->mobj->flags2 & MF2_DEBRIS) && (spr->mobj->sprite != SPR_PLAY ||
|
||||
(spr->mobj->player && spr->mobj->player->powers[pw_super])))
|
||||
HWR_DL_AddLight(spr, gpatch);
|
||||
#endif
|
||||
|
||||
// create the sprite billboard
|
||||
//
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
// these were already scaled in HWR_ProjectSprite
|
||||
wallVerts[0].x = wallVerts[3].x = spr->x1;
|
||||
wallVerts[2].x = wallVerts[1].x = spr->x2;
|
||||
wallVerts[2].y = wallVerts[3].y = spr->ty;
|
||||
if (spr->mobj && this_scale != 1.0f)
|
||||
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale;
|
||||
else
|
||||
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height;
|
||||
|
||||
// make a wall polygon (with 2 triangles), using the floor/ceiling heights,
|
||||
// and the 2d map coords of start/end vertices
|
||||
wallVerts[0].z = wallVerts[1].z = wallVerts[2].z = wallVerts[3].z = spr->tz;
|
||||
|
||||
// transform
|
||||
wv = wallVerts;
|
||||
|
||||
for (i = 0; i < 4; i++,wv++)
|
||||
{
|
||||
//look up/down ----TOTAL SUCKS!!!--- do the 2 in one!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
tr_x = wv->z;
|
||||
tr_y = wv->y;
|
||||
wv->y = (tr_x * gr_viewludcos) + (tr_y * gr_viewludsin);
|
||||
wv->z = (tr_x * gr_viewludsin) - (tr_y * gr_viewludcos);
|
||||
// ---------------------- mega lame test ----------------------------------
|
||||
|
||||
//scale y before frustum so that frustum can be scaled to screen height
|
||||
wv->y *= ORIGINAL_ASPECT * gr_fovlud;
|
||||
wv->x *= gr_fovlud;
|
||||
}
|
||||
|
||||
if (spr->flip)
|
||||
{
|
||||
wallVerts[0].sow = wallVerts[3].sow = gpatch->max_s;
|
||||
wallVerts[2].sow = wallVerts[1].sow = 0;
|
||||
}else{
|
||||
wallVerts[0].sow = wallVerts[3].sow = 0;
|
||||
wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s;
|
||||
}
|
||||
|
||||
// flip the texture coords (look familiar?)
|
||||
if (spr->vflip)
|
||||
{
|
||||
wallVerts[3].tow = wallVerts[2].tow = gpatch->max_t;
|
||||
wallVerts[0].tow = wallVerts[1].tow = 0;
|
||||
}else{
|
||||
wallVerts[3].tow = wallVerts[2].tow = 0;
|
||||
wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t;
|
||||
}
|
||||
|
||||
// cache the patch in the graphics card memory
|
||||
//12/12/99: Hurdler: same comment as above (for md2)
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
HWR_GetMappedPatch(gpatch, spr->colormap);
|
||||
|
||||
// Draw shadow BEFORE sprite
|
||||
if (cv_shadow.value // Shadows enabled
|
||||
&& !(spr->mobj->flags & MF_SCENERY && spr->mobj->flags & MF_SPAWNCEILING && spr->mobj->flags & MF_NOGRAVITY) // Ceiling scenery have no shadow.
|
||||
&& !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow.
|
||||
#ifdef ALAM_LIGHTING
|
||||
&& !(t_lspr[spr->mobj->sprite]->type // Things with dynamic lights have no shadow.
|
||||
&& (!spr->mobj->player || spr->mobj->player->powers[pw_super])) // Except for non-super players.
|
||||
#endif
|
||||
&& (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground.
|
||||
{
|
||||
////////////////////
|
||||
// SHADOW SPRITE! //
|
||||
////////////////////
|
||||
FOutVector swallVerts[4];
|
||||
FSurfaceInfo sSurf;
|
||||
fixed_t floorheight, mobjfloor;
|
||||
|
@ -3666,7 +3558,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
|||
// The shadow is falling ABOVE it's mobj?
|
||||
// Don't draw it, then!
|
||||
if (spr->mobj->z < floorheight)
|
||||
goto noshadow;
|
||||
return;
|
||||
else
|
||||
{
|
||||
fixed_t floorz;
|
||||
|
@ -3677,7 +3569,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
|||
// The shadow would be falling on a wall? Don't draw it, then.
|
||||
// Would draw midair otherwise.
|
||||
if (floorz < floorheight)
|
||||
goto noshadow;
|
||||
return;
|
||||
}
|
||||
|
||||
floorheight = FixedInt(spr->mobj->z - floorheight);
|
||||
|
@ -3796,8 +3688,8 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
|||
}*/
|
||||
|
||||
// shadow is always half as translucent as the sprite itself
|
||||
if (!cv_translucency.value)
|
||||
; // translucency disabled
|
||||
if (!cv_translucency.value) // use default translucency (main sprite won't have any translucency)
|
||||
sSurf.FlatColor.s.alpha = 0x80; // default
|
||||
else if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
sSurf.FlatColor.s.alpha = 0x20;
|
||||
else if (spr->mobj->frame & FF_TRANSMASK)
|
||||
|
@ -3808,18 +3700,128 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
|||
else
|
||||
sSurf.FlatColor.s.alpha = 0x80; // default
|
||||
|
||||
/// \todo do the test earlier
|
||||
if (!cv_grmd2.value || (md2_models[spr->mobj->sprite].scale < 0.0f) || (md2_models[spr->mobj->sprite].notfound = true) || (md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f) || (md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound = true))
|
||||
{
|
||||
if (sSurf.FlatColor.s.alpha > floorheight/4)
|
||||
{
|
||||
sSurf.FlatColor.s.alpha = (UINT8)(sSurf.FlatColor.s.alpha - floorheight/4);
|
||||
HWD.pfnDrawPolygon(&sSurf, swallVerts, 4, PF_Translucent|PF_Modulated|PF_Clip);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------+
|
||||
// HWR_DrawSprite : Draw flat sprites
|
||||
// : (monsters, bonuses, weapons, lights, ...)
|
||||
// Returns :
|
||||
// -----------------+
|
||||
static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
{
|
||||
UINT8 i;
|
||||
float tr_x, tr_y, this_scale = 1.0f;
|
||||
FOutVector wallVerts[4];
|
||||
FOutVector *wv;
|
||||
GLPatch_t *gpatch; // sprite patch converted to hardware
|
||||
FSurfaceInfo Surf;
|
||||
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
|
||||
if (spr->mobj)
|
||||
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
|
||||
if (hires)
|
||||
this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)spr->mobj->skin)->highresscale);
|
||||
|
||||
if (!spr->mobj)
|
||||
return;
|
||||
|
||||
if (!spr->mobj->subsector)
|
||||
return;
|
||||
|
||||
// cache sprite graphics
|
||||
//12/12/99: Hurdler:
|
||||
// OK, I don't change anything for MD2 support because I want to be
|
||||
// sure to do it the right way. So actually, we keep normal sprite
|
||||
// in memory and we add the md2 model if it exists for that sprite
|
||||
|
||||
gpatch = W_CachePatchNum(spr->patchlumpnum, PU_CACHE);
|
||||
|
||||
#ifdef ALAM_LIGHTING
|
||||
if (!(spr->mobj->flags2 & MF2_DEBRIS) && (spr->mobj->sprite != SPR_PLAY ||
|
||||
(spr->mobj->player && spr->mobj->player->powers[pw_super])))
|
||||
HWR_DL_AddLight(spr, gpatch);
|
||||
#endif
|
||||
|
||||
// create the sprite billboard
|
||||
//
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
|
||||
// these were already scaled in HWR_ProjectSprite
|
||||
wallVerts[0].x = wallVerts[3].x = spr->x1;
|
||||
wallVerts[2].x = wallVerts[1].x = spr->x2;
|
||||
wallVerts[2].y = wallVerts[3].y = spr->ty;
|
||||
if (spr->mobj && this_scale != 1.0f)
|
||||
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale;
|
||||
else
|
||||
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height;
|
||||
|
||||
// make a wall polygon (with 2 triangles), using the floor/ceiling heights,
|
||||
// and the 2d map coords of start/end vertices
|
||||
wallVerts[0].z = wallVerts[1].z = wallVerts[2].z = wallVerts[3].z = spr->tz;
|
||||
|
||||
// transform
|
||||
wv = wallVerts;
|
||||
|
||||
for (i = 0; i < 4; i++,wv++)
|
||||
{
|
||||
//look up/down ----TOTAL SUCKS!!!--- do the 2 in one!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
tr_x = wv->z;
|
||||
tr_y = wv->y;
|
||||
wv->y = (tr_x * gr_viewludcos) + (tr_y * gr_viewludsin);
|
||||
wv->z = (tr_x * gr_viewludsin) - (tr_y * gr_viewludcos);
|
||||
// ---------------------- mega lame test ----------------------------------
|
||||
|
||||
//scale y before frustum so that frustum can be scaled to screen height
|
||||
wv->y *= ORIGINAL_ASPECT * gr_fovlud;
|
||||
wv->x *= gr_fovlud;
|
||||
}
|
||||
|
||||
noshadow:
|
||||
if (spr->flip)
|
||||
{
|
||||
wallVerts[0].sow = wallVerts[3].sow = gpatch->max_s;
|
||||
wallVerts[2].sow = wallVerts[1].sow = 0;
|
||||
}else{
|
||||
wallVerts[0].sow = wallVerts[3].sow = 0;
|
||||
wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s;
|
||||
}
|
||||
|
||||
// flip the texture coords (look familiar?)
|
||||
if (spr->vflip)
|
||||
{
|
||||
wallVerts[3].tow = wallVerts[2].tow = gpatch->max_t;
|
||||
wallVerts[0].tow = wallVerts[1].tow = 0;
|
||||
}else{
|
||||
wallVerts[3].tow = wallVerts[2].tow = 0;
|
||||
wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t;
|
||||
}
|
||||
|
||||
// cache the patch in the graphics card memory
|
||||
//12/12/99: Hurdler: same comment as above (for md2)
|
||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||
HWR_GetMappedPatch(gpatch, spr->colormap);
|
||||
|
||||
// Draw shadow BEFORE sprite
|
||||
if (cv_shadow.value // Shadows enabled
|
||||
&& (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow.
|
||||
&& !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow.
|
||||
#ifdef ALAM_LIGHTING
|
||||
&& !(t_lspr[spr->mobj->sprite]->type // Things with dynamic lights have no shadow.
|
||||
&& (!spr->mobj->player || spr->mobj->player->powers[pw_super])) // Except for non-super players.
|
||||
#endif
|
||||
&& (spr->mobj->z >= spr->mobj->floorz)) // Without this, your shadow shows on the floor, even after you die and fall through the ground.
|
||||
{
|
||||
////////////////////
|
||||
// SHADOW SPRITE! //
|
||||
////////////////////
|
||||
HWR_DrawSpriteShadow(spr, gpatch, this_scale);
|
||||
}
|
||||
|
||||
// This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black.
|
||||
// sprite lighting by modulating the RGB components
|
||||
|
@ -3865,11 +3867,14 @@ noshadow:
|
|||
Surf.FlatColor.rgba = HWR_Lighting(lightlevel, NORMALFOG, FADEFOG, false, false);
|
||||
}
|
||||
|
||||
/// \todo do the test earlier
|
||||
if (!cv_grmd2.value || (md2_models[spr->mobj->sprite].scale < 0.0f))
|
||||
{
|
||||
FBITFIELD blend = 0;
|
||||
if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
if (!cv_translucency.value) // translucency disabled
|
||||
{
|
||||
Surf.FlatColor.s.alpha = 0xFF;
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
else if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
{
|
||||
Surf.FlatColor.s.alpha = 0x40;
|
||||
blend = PF_Translucent;
|
||||
|
@ -4390,10 +4395,10 @@ static void HWR_DrawSprites(void)
|
|||
#endif
|
||||
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
|
||||
{
|
||||
if (!cv_grmd2.value || (cv_grmd2.value && md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound == true))
|
||||
if (!cv_grmd2.value || md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound || md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale < 0.0f)
|
||||
HWR_DrawSprite(spr);
|
||||
}
|
||||
else if (!cv_grmd2.value || (cv_grmd2.value && md2_models[spr->mobj->sprite].notfound == true))
|
||||
else if (!cv_grmd2.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f)
|
||||
HWR_DrawSprite(spr);
|
||||
}
|
||||
}
|
||||
|
@ -4419,7 +4424,7 @@ static void HWR_DrawMD2S(void)
|
|||
#endif
|
||||
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
|
||||
{
|
||||
if ((md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound == false) && (md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale > 0.0f))
|
||||
if (md2_playermodels[(skin_t*)spr->mobj->skin-skins].notfound == false && md2_playermodels[(skin_t*)spr->mobj->skin-skins].scale > 0.0f)
|
||||
HWR_DrawMD2(spr);
|
||||
}
|
||||
else if (md2_models[spr->mobj->sprite].notfound == false && md2_models[spr->mobj->sprite].scale > 0.0f)
|
||||
|
|
Loading…
Reference in a new issue