Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add angled sprite code from QuakeSpasm and FTEQW #278

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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