Merge branch 'kill-hud-feetoffset' into 'next'

Fix offsetting of rotated sprites drawn in the HUD by Lua

See merge request STJr/SRB2!2171
This commit is contained in:
Monster Iestyn 2023-11-26 19:23:13 +00:00
commit 8d55cadbcf
6 changed files with 16 additions and 19 deletions

View file

@ -5322,7 +5322,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
rollangle = R_GetRollAngle(spriterotangle);
}
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
if (rotsprite != NULL)
{

View file

@ -517,7 +517,7 @@ static int libd_getSpritePatch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &spriteinfo[i], rot);
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &spriteinfo[i], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false);
lua_pushboolean(L, true);
@ -629,7 +629,7 @@ static int libd_getSprite2Patch(lua_State *L)
INT32 rot = R_GetRollAngle(rollangle);
if (rot) {
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), true, &skins[i].sprinfo[j], rot);
patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<<angle), &skins[i].sprinfo[j], rot);
LUA_PushUserdata(L, rotsprite, META_PATCH);
lua_pushboolean(L, false);
lua_pushboolean(L, true);

View file

@ -922,7 +922,7 @@ typedef struct
UINT16 flip;
#ifdef ROTSPRITE
rotsprite_t *rotated[2][16]; // Rotated patches
rotsprite_t *rotated[16]; // Rotated patches
#endif
} spriteframe_t;

View file

@ -37,7 +37,7 @@ patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip);
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
boolean flip,
void *info, INT32 rotationangle);
angle_t R_ModelRotationAngle(interpmobjstate_t *interp);
angle_t R_SpriteRotationAngle(interpmobjstate_t *interp);

View file

@ -10,7 +10,7 @@
/// \brief Patch rotation.
#include "r_patchrotation.h"
#include "r_things.h" // FEETADJUST
#include "r_things.h" // FEETADJUST (todo: is this needed anymore? -- Monster Iestyn 21 Sep 2023 )
#include "z_zone.h"
#include "w_wad.h"
#include "r_main.h" // R_PointToAngle
@ -66,23 +66,20 @@ patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip)
patch_t *Patch_GetRotatedSprite(
spriteframe_t *sprite,
size_t frame, size_t spriteangle,
boolean flip, boolean adjustfeet,
boolean flip,
void *info, INT32 rotationangle)
{
rotsprite_t *rotsprite;
rotsprite_t *rotsprite = sprite->rotated[spriteangle];
spriteinfo_t *sprinfo = (spriteinfo_t *)info;
INT32 idx = rotationangle;
UINT8 type = (adjustfeet ? 1 : 0);
if (rotationangle < 1 || rotationangle >= ROTANGLES)
return NULL;
rotsprite = sprite->rotated[type][spriteangle];
if (rotsprite == NULL)
{
rotsprite = RotatedPatch_Create(ROTANGLES);
sprite->rotated[type][spriteangle] = rotsprite;
sprite->rotated[spriteangle] = rotsprite;
}
if (flip)
@ -111,10 +108,6 @@ patch_t *Patch_GetRotatedSprite(
}
RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip);
//BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
if (adjustfeet)
((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS;
}
return rotsprite->patches[idx];

View file

@ -138,8 +138,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch
#ifdef ROTSPRITE
for (r = 0; r < 16; r++)
{
sprtemp[frame].rotated[0][r] = NULL;
sprtemp[frame].rotated[1][r] = NULL;
sprtemp[frame].rotated[r] = NULL;
}
#endif
@ -337,6 +336,11 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
spritecachedinfo[numspritelumps].height = height<<FRACBITS;
// BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer
// Monster Iestyn (21 Sep 2023): the above comment no longer makes sense in context!!! So I give an explanation here!
// FEETADJUST was originally an OpenGL-exclusive hack from Doom Legacy to avoid the player's feet being clipped as
// a result of rendering partially under the ground, but sometime before SRB2 2.1's release this was changed to apply
// to the software renderer as well.
// TODO: kill FEETADJUST altogether somehow and somehow fix OpenGL not to clip sprites that are partially underground (if possible)?
spritecachedinfo[numspritelumps].topoffset += FEETADJUST;
//----------------------------------------------------
@ -1794,7 +1798,7 @@ static void R_ProjectSprite(mobj_t *thing)
rollangle = R_GetRollAngle(spriterotangle);
}
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle);
rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle);
if (rotsprite != NULL)
{