mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-02-22 11:51:10 +00:00
Flat sprites for OGL
This commit is contained in:
parent
a587231aa4
commit
39d4f22660
2 changed files with 71 additions and 7 deletions
|
@ -78,6 +78,7 @@ typedef struct gr_vissprite_s
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||||
UINT8 *colormap;
|
UINT8 *colormap;
|
||||||
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing
|
||||||
|
float z1, z2;
|
||||||
} gr_vissprite_t;
|
} gr_vissprite_t;
|
||||||
|
|
||||||
// --------
|
// --------
|
||||||
|
|
|
@ -4223,6 +4223,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||||
GLPatch_t *gpatch; // sprite patch converted to hardware
|
GLPatch_t *gpatch; // sprite patch converted to hardware
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf;
|
||||||
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
|
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
|
||||||
|
//const boolean papersprite = (spr->mobj && (spr->mobj->frame & FF_PAPERSPRITE));
|
||||||
if (spr->mobj)
|
if (spr->mobj)
|
||||||
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
|
this_scale = FIXED_TO_FLOAT(spr->mobj->scale);
|
||||||
if (hires)
|
if (hires)
|
||||||
|
@ -4266,7 +4267,28 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||||
|
|
||||||
// make a wall polygon (with 2 triangles), using the floor/ceiling heights,
|
// make a wall polygon (with 2 triangles), using the floor/ceiling heights,
|
||||||
// and the 2d map coords of start/end vertices
|
// and the 2d map coords of start/end vertices
|
||||||
wallVerts[0].z = wallVerts[1].z = wallVerts[2].z = wallVerts[3].z = spr->tz;
|
wallVerts[0].z = wallVerts[3].z = spr->z1;
|
||||||
|
wallVerts[2].z = wallVerts[1].z = spr->z2;
|
||||||
|
|
||||||
|
// transform
|
||||||
|
wv = wallVerts;
|
||||||
|
|
||||||
|
/*if (spr->mobj->frame & FF_PAPERSPRITE)
|
||||||
|
{
|
||||||
|
float mobjanglecos, mobjanglesin;
|
||||||
|
mobjanglesin = FIXED_TO_FLOAT(FINESINE((spr->mobj->angle-dup_viewangle+ANGLE_90)>>ANGLETOFINESHIFT));
|
||||||
|
mobjanglecos = FIXED_TO_FLOAT(FINECOSINE((spr->mobj->angle-dup_viewangle+ANGLE_90)>>ANGLETOFINESHIFT));
|
||||||
|
for (i = 0; i < 4; i++,wv++)
|
||||||
|
{
|
||||||
|
// x = (x * anglecos) + (z * anglesin)
|
||||||
|
// z = (x * anglesin) - (z * anglecos)
|
||||||
|
// instead of doing the z part we just add spr->tz afterwards because they are all the same
|
||||||
|
// value right now
|
||||||
|
tr_x = wv->x-spr->x2+(spr->x2-spr->x1)/2;
|
||||||
|
//wv->x = (tr_x * mobjanglecos) + (0) + (spr->x1+(spr->x2-spr->x1)/2);
|
||||||
|
wv->z = (tr_x * mobjanglesin) - (0) + (spr->tz);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
wv = wallVerts;
|
wv = wallVerts;
|
||||||
|
@ -5042,6 +5064,10 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
UINT8 flip;
|
UINT8 flip;
|
||||||
angle_t ang;
|
angle_t ang;
|
||||||
INT32 heightsec, phs;
|
INT32 heightsec, phs;
|
||||||
|
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
|
||||||
|
float offset;
|
||||||
|
float ang_scale = 1.0f, ang_scalez = 0.0f;
|
||||||
|
float z1, z2;
|
||||||
|
|
||||||
if (!thing)
|
if (!thing)
|
||||||
return;
|
return;
|
||||||
|
@ -5056,7 +5082,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin);
|
tz = (tr_x * gr_viewcos) + (tr_y * gr_viewsin);
|
||||||
|
|
||||||
// thing is behind view plane?
|
// thing is behind view plane?
|
||||||
if (tz < ZCLIP_PLANE && (!cv_grmd2.value || md2_models[thing->sprite].notfound == true)) //Yellow: Only MD2's dont disappear
|
if (tz < ZCLIP_PLANE && !papersprite && (!cv_grmd2.value || md2_models[thing->sprite].notfound == true)) //Yellow: Only MD2's dont disappear
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tx = (tr_x * gr_viewsin) - (tr_y * gr_viewcos);
|
tx = (tr_x * gr_viewsin) - (tr_y * gr_viewcos);
|
||||||
|
@ -5094,6 +5120,16 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
I_Error("sprframes NULL for sprite %d\n", thing->sprite);
|
I_Error("sprframes NULL for sprite %d\n", thing->sprite);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (sprframe->rotate != SRF_SINGLE || papersprite)
|
||||||
|
{
|
||||||
|
ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
|
||||||
|
if (papersprite)
|
||||||
|
{
|
||||||
|
ang_scale = FIXED_TO_FLOAT(FINESINE(ang>>ANGLETOFINESHIFT));
|
||||||
|
ang_scalez = FIXED_TO_FLOAT(FINECOSINE(ang>>ANGLETOFINESHIFT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sprframe->rotate == SRF_SINGLE)
|
if (sprframe->rotate == SRF_SINGLE)
|
||||||
{
|
{
|
||||||
// use single rotation for all views
|
// use single rotation for all views
|
||||||
|
@ -5104,8 +5140,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// choose a different rotation based on player view
|
// choose a different rotation based on player view
|
||||||
ang = R_PointToAngle (thing->x, thing->y) - thing->angle;
|
|
||||||
|
|
||||||
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right
|
if ((ang < ANGLE_180) && (sprframe->rotate & SRF_RIGHT)) // See from right
|
||||||
rot = 6; // F7 slot
|
rot = 6; // F7 slot
|
||||||
else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left
|
else if ((ang >= ANGLE_180) && (sprframe->rotate & SRF_LEFT)) // See from left
|
||||||
|
@ -5123,9 +5157,20 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
// calculate edges of the shape
|
// calculate edges of the shape
|
||||||
if (flip)
|
if (flip)
|
||||||
tx -= FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale;
|
offset = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset) * this_scale;
|
||||||
else
|
else
|
||||||
tx -= FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset) * this_scale;
|
offset = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset) * this_scale;
|
||||||
|
|
||||||
|
if (ang_scale < 0)
|
||||||
|
{
|
||||||
|
z1 = tz + offset * ang_scalez;
|
||||||
|
tx += offset * ang_scale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
z1 = tz - offset * ang_scalez;
|
||||||
|
tx -= offset * ang_scale;
|
||||||
|
}
|
||||||
|
|
||||||
// project x
|
// project x
|
||||||
x1 = gr_windowcenterx + (tx * gr_centerx / tz);
|
x1 = gr_windowcenterx + (tx * gr_centerx / tz);
|
||||||
|
@ -5136,9 +5181,25 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
|
|
||||||
x1 = tx;
|
x1 = tx;
|
||||||
|
|
||||||
tx += FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width) * this_scale;
|
offset = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width) * this_scale;
|
||||||
|
if (ang_scale < 0)
|
||||||
|
{
|
||||||
|
z2 = z1 - offset * ang_scalez;
|
||||||
|
tx -= offset * ang_scale;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
z2 = z1 + offset * ang_scalez;
|
||||||
|
tx += offset * ang_scale;
|
||||||
|
}
|
||||||
|
if (papersprite && max(z1, z1) < ZCLIP_PLANE)
|
||||||
|
return;
|
||||||
|
|
||||||
x2 = gr_windowcenterx + (tx * gr_centerx / tz);
|
x2 = gr_windowcenterx + (tx * gr_centerx / tz);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (thing->eflags & MFE_VERTICALFLIP)
|
if (thing->eflags & MFE_VERTICALFLIP)
|
||||||
{
|
{
|
||||||
gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
gz = FIXED_TO_FLOAT(thing->z+thing->height) - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale;
|
||||||
|
@ -5185,6 +5246,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
||||||
vis->patchlumpnum = sprframe->lumppat[rot];
|
vis->patchlumpnum = sprframe->lumppat[rot];
|
||||||
vis->flip = flip;
|
vis->flip = flip;
|
||||||
vis->mobj = thing;
|
vis->mobj = thing;
|
||||||
|
vis->z1 = z1;
|
||||||
|
vis->z2 = z2;
|
||||||
|
|
||||||
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
//Hurdler: 25/04/2000: now support colormap in hardware mode
|
||||||
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
|
if ((vis->mobj->flags & MF_BOSS) && (vis->mobj->flags2 & MF2_FRET) && (leveltime & 1)) // Bosses "flash"
|
||||||
|
|
Loading…
Reference in a new issue