Port v.cachePatch second parameter for rotation from Classic
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2662
This commit is contained in:
parent
4a29babb66
commit
9d864729db
3 changed files with 31 additions and 2 deletions
|
|
@ -541,8 +541,9 @@ void HWR_DrawPic(INT32 x, INT32 y, lumpnum_t lumpnum)
|
|||
|
||||
// --------------------------------------------------------------------------
|
||||
// Fills a box of pixels using a flat texture as a pattern
|
||||
// Fixed to properly align like the other draw functions -luigi budd
|
||||
// --------------------------------------------------------------------------
|
||||
void HWR_DrawFlatFill (INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
|
||||
{
|
||||
const size_t len = W_LumpLength(flatlumpnum);
|
||||
|
||||
|
|
|
|||
|
|
@ -357,6 +357,20 @@ static int libd_cachePatch(lua_State *L)
|
|||
}
|
||||
else
|
||||
patch = W_CachePatchLongName(name, PU_PATCH);
|
||||
|
||||
#ifdef ROTSPRITE
|
||||
if (lua_isnumber(L, 2))
|
||||
{
|
||||
angle_t rollangle = luaL_checkangle(L, 2);
|
||||
INT32 rot = R_GetRollAngle(rollangle);
|
||||
if (rot) {
|
||||
patch_t *rotpatch = Patch_GetRotated(patch, rot, false);
|
||||
LUA_PushUserdata(L, rotpatch, META_PATCH);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LUA_PushUserdata(L, patch, META_PATCH);
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,12 +111,26 @@ INT32 R_GetRollAngle(angle_t rollangle)
|
|||
patch_t *Patch_GetRotated(patch_t *patch, INT32 angle, boolean flip)
|
||||
{
|
||||
rotsprite_t *rotsprite = patch->rotated;
|
||||
if (rotsprite == NULL || angle < 1 || angle >= ROTANGLES)
|
||||
if (angle < 1 || angle >= ROTANGLES)
|
||||
return NULL;
|
||||
|
||||
if (rotsprite == NULL)
|
||||
{
|
||||
rotsprite = RotatedPatch_Create(ROTANGLES);
|
||||
patch->rotated = rotsprite;
|
||||
}
|
||||
|
||||
if (flip)
|
||||
angle += rotsprite->angles;
|
||||
|
||||
if (rotsprite->patches[angle] == NULL)
|
||||
{
|
||||
INT32 xpivot = 0, ypivot = 0;
|
||||
xpivot = patch->leftoffset;
|
||||
ypivot = patch->topoffset;
|
||||
RotatedPatch_DoRotation(rotsprite, patch, angle, xpivot, ypivot, flip);
|
||||
}
|
||||
|
||||
return rotsprite->patches[angle];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue