mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-14 13:51:31 +00:00
I don't like your sprite clipping fix, so here's mine
This commit is contained in:
parent
9ecc48d0e4
commit
6131b80f03
2 changed files with 28 additions and 27 deletions
|
@ -3245,20 +3245,22 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||||
baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t;
|
baseWallVerts[0].t = baseWallVerts[1].t = gpatch->max_t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it has a dispoffset, push it a little towards the camera
|
|
||||||
if (spr->dispoffset)
|
|
||||||
{
|
|
||||||
float co = -gr_viewcos*(0.05f*spr->dispoffset);
|
|
||||||
float si = -gr_viewsin*(0.05f*spr->dispoffset);
|
|
||||||
baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si;
|
|
||||||
baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si;
|
|
||||||
baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co;
|
|
||||||
baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let dispoffset work first since this adjust each vertex
|
// Let dispoffset work first since this adjust each vertex
|
||||||
HWR_RotateSpritePolyToAim(spr, baseWallVerts);
|
HWR_RotateSpritePolyToAim(spr, baseWallVerts);
|
||||||
|
|
||||||
|
// push it toward the camera to mitigate floor-clipping sprites
|
||||||
|
{
|
||||||
|
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz));
|
||||||
|
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact;
|
||||||
|
baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact;
|
||||||
|
baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
realtop = top = baseWallVerts[3].y;
|
realtop = top = baseWallVerts[3].y;
|
||||||
realbot = bot = baseWallVerts[0].y;
|
realbot = bot = baseWallVerts[0].y;
|
||||||
towtop = baseWallVerts[3].t;
|
towtop = baseWallVerts[3].t;
|
||||||
|
@ -3598,20 +3600,23 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||||
HWR_DrawSpriteShadow(spr, gpatch, this_scale);
|
HWR_DrawSpriteShadow(spr, gpatch, this_scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it has a dispoffset, push it a little towards the camera
|
|
||||||
if (spr->dispoffset)
|
|
||||||
{
|
|
||||||
float co = -gr_viewcos*(0.05f*spr->dispoffset);
|
|
||||||
float si = -gr_viewsin*(0.05f*spr->dispoffset);
|
|
||||||
wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si;
|
|
||||||
wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si;
|
|
||||||
wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co;
|
|
||||||
wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let dispoffset work first since this adjust each vertex
|
// Let dispoffset work first since this adjust each vertex
|
||||||
|
// ...nah
|
||||||
HWR_RotateSpritePolyToAim(spr, wallVerts);
|
HWR_RotateSpritePolyToAim(spr, wallVerts);
|
||||||
|
|
||||||
|
// push it toward the camera to mitigate floor-clipping sprites
|
||||||
|
{
|
||||||
|
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->ty - gr_viewz)*(spr->ty - gr_viewz));
|
||||||
|
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact;
|
||||||
|
wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact;
|
||||||
|
wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black.
|
// This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black.
|
||||||
// sprite lighting by modulating the RGB components
|
// sprite lighting by modulating the RGB components
|
||||||
/// \todo coloured
|
/// \todo coloured
|
||||||
|
|
|
@ -259,11 +259,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef,
|
||||||
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
|
||||||
if (rendermode != render_none) // not for psprite
|
if (rendermode != render_none) // not for psprite
|
||||||
spritecachedinfo[numspritelumps].topoffset += 4<<FRACBITS;
|
spritecachedinfo[numspritelumps].topoffset += 4<<FRACBITS;
|
||||||
|
|
||||||
// Idea, how about we do it like literally every hardware renderer ever?
|
|
||||||
if (rendermode == render_opengl)
|
|
||||||
spritecachedinfo[numspritelumps].topoffset += 5<<FRACBITS;
|
|
||||||
|
|
||||||
// Being selective with this causes bad things. :( Like the special stage tokens breaking apart.
|
// Being selective with this causes bad things. :( Like the special stage tokens breaking apart.
|
||||||
/*if (rendermode != render_none // not for psprite
|
/*if (rendermode != render_none // not for psprite
|
||||||
&& SHORT(patch.topoffset)>0 && SHORT(patch.topoffset)<SHORT(patch.height))
|
&& SHORT(patch.topoffset)>0 && SHORT(patch.topoffset)<SHORT(patch.height))
|
||||||
|
|
Loading…
Reference in a new issue