Skip to content

Commit

Permalink
Add angled sprite code from QuakeSpasm and FTEQW
Browse files Browse the repository at this point in the history
  • Loading branch information
erysdren committed Dec 8, 2023
1 parent 4c6f7f9 commit 782561e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Quake/gl_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -3234,7 +3234,7 @@ static void *Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int fram
Mod_LoadSpriteGroup
=================
*/
static void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum)
static void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum, spriteframetype_t type)
{
dspritegroup_t *pingroup;
mspritegroup_t *pspritegroup;
Expand All @@ -3246,6 +3246,8 @@ static void *Mod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int fram
pingroup = (dspritegroup_t *)pin;

numframes = LittleLong (pingroup->numframes);
if (type == SPR_ANGLED && numframes != 8)
Sys_Error ("Mod_LoadSpriteGroup: Bad # of frames: %d", numframes);

pspritegroup = (mspritegroup_t *) Hunk_AllocName (sizeof (mspritegroup_t) +
(numframes - 1) * sizeof (pspritegroup->frames[0]), loadname);
Expand Down Expand Up @@ -3349,7 +3351,7 @@ static void Mod_LoadSpriteModel (qmodel_t *mod, void *buffer)
else
{
pframetype = (dspriteframetype_t *)
Mod_LoadSpriteGroup (pframetype + 1, &psprite->frames[i].frameptr, i);
Mod_LoadSpriteGroup (pframetype + 1, &psprite->frames[i].frameptr, i, frametype);
}
}

Expand Down
13 changes: 13 additions & 0 deletions Quake/r_sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currentent)
{
pspriteframe = psprite->frames[frame].frameptr;
}
else if (psprite->frames[frame].type == SPR_ANGLED)
{
// erysdren - angled sprites code backported from FTEQW
vec3_t axis[3];
AngleVectors(currentent->angles, axis[0], axis[1], axis[2]);
{
float f = DotProduct(vpn, axis[0]);
float r = DotProduct(vright, axis[0]);
int dir = (atan2(r, f)+1.125*M_PI)*(4/M_PI);
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
pspriteframe = pspritegroup->frames[dir&7];
}
}
else
{
pspritegroup = (mspritegroup_t *)psprite->frames[frame].frameptr;
Expand Down
2 changes: 1 addition & 1 deletion Quake/spritegn.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typedef struct {
float interval;
} dspriteinterval_t;

typedef enum { SPR_SINGLE=0, SPR_GROUP } spriteframetype_t;
typedef enum { SPR_SINGLE=0, SPR_GROUP, SPR_ANGLED } spriteframetype_t;

typedef struct {
spriteframetype_t type;
Expand Down

0 comments on commit 782561e

Please sign in to comment.