Merge sw and sw32 alias frame selection.

I'm leaving GL for later because lerping complicates things. I'll sort it
out when I implement lerping in GLSL.
This commit is contained in:
Bill Currie 2012-01-02 17:47:22 +09:00
parent 1c480bf75e
commit 72e3a8d507
5 changed files with 49 additions and 82 deletions

View file

@ -278,16 +278,10 @@ typedef struct {
int fb_texnum;
} maliasskindesc_t;
typedef struct {
trivertx_t bboxmin;
trivertx_t bboxmax;
int frame;
} maliasgroupframedesc_t;
typedef struct {
int numframes;
int intervals;
maliasgroupframedesc_t frames[1];
maliasframedesc_t frames[1];
} maliasgroup_t;
typedef struct {

View file

@ -187,7 +187,8 @@ void R_DrawSolidClippedSubmodelPolygons (model_t *pmodel);
void R_AddPolygonEdges (emitpoint_t *pverts, int numverts, int miplevel);
surf_t *R_GetSurf (void);
void R_AliasDrawModel (alight_t *plighting);
maliasskindesc_t *R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr);
maliasskindesc_t *R_AliasGetSkindesc (int skinnum, aliashdr_t *hdr);
maliasframedesc_t *R_AliasGetFramedesc (int framenum, aliashdr_t *hdr);
void R_BeginEdgeFrame (void);
void R_ScanEdges (void);
void D_DrawSurfaces (void);

View file

@ -77,3 +77,41 @@ R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
return pskindesc;
}
VISIBLE maliasframedesc_t *
R_AliasGetFramedesc (int framenum, aliashdr_t *hdr)
{
float *intervals;
float fullinterval, time, targettime;
maliasframedesc_t *frame;
maliasgroup_t *group;
int numframes;
int i;
if ((framenum >= hdr->mdl.numframes) || (framenum < 0)) {
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupFrame: no such frame %d\n",
framenum);
framenum = 0;
}
frame = &hdr->frames[framenum];
if (frame->type == ALIAS_SINGLE)
return frame;
group = (maliasgroup_t *) ((byte *) hdr + frame->frame);
intervals = (float *) ((byte *) hdr + group->intervals);
numframes = group->numframes;
fullinterval = intervals[numframes - 1];
time = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by 0
targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) {
if (intervals[i] > targettime)
break;
}
return &group->frames[i];
}

View file

@ -613,43 +613,10 @@ R_AliasSetupLighting (alight_t *plighting)
static void
R_AliasSetupFrame (void)
{
int frame, numframes, i;
float fullinterval, targettime, time;
float *pintervals;
maliasgroup_t *paliasgroup;
maliasframedesc_t *frame;
frame = currententity->frame;
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupFrame: no such frame %d\n",
frame);
frame = 0;
}
if (paliashdr->frames[frame].type == ALIAS_SINGLE) {
r_apverts = (trivertx_t *)
((byte *) paliashdr + paliashdr->frames[frame].frame);
return;
}
paliasgroup = (maliasgroup_t *)
((byte *) paliashdr + paliashdr->frames[frame].frame);
pintervals = (float *) ((byte *) paliashdr + paliasgroup->intervals);
numframes = paliasgroup->numframes;
fullinterval = pintervals[numframes - 1];
time = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by 0
targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) {
if (pintervals[i] > targettime)
break;
}
r_apverts = (trivertx_t *)
((byte *) paliashdr + paliasgroup->frames[i].frame);
frame = R_AliasGetFramedesc (currententity->frame, paliashdr);
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
}

View file

@ -606,43 +606,10 @@ R_AliasSetupLighting (alight_t *plighting)
static void
R_AliasSetupFrame (void)
{
int frame;
int i, numframes;
maliasgroup_t *paliasgroup;
float *pintervals, fullinterval, targettime, time;
maliasframedesc_t *frame;
frame = currententity->frame;
if ((frame >= pmdl->numframes) || (frame < 0)) {
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupFrame: no such frame %d\n",
frame);
frame = 0;
}
if (paliashdr->frames[frame].type == ALIAS_SINGLE) {
r_apverts = (trivertx_t *)
((byte *) paliashdr + paliashdr->frames[frame].frame);
return;
}
paliasgroup = (maliasgroup_t *)
((byte *) paliashdr + paliashdr->frames[frame].frame);
pintervals = (float *) ((byte *) paliashdr + paliasgroup->intervals);
numframes = paliasgroup->numframes;
fullinterval = pintervals[numframes - 1];
time = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasGroup, we guaranteed all interval values
// are positive, so we don't have to worry about division by 0
targettime = time - ((int) (time / fullinterval)) * fullinterval;
for (i = 0; i < (numframes - 1); i++) {
if (pintervals[i] > targettime)
break;
}
r_apverts = (trivertx_t *)
((byte *) paliashdr + paliasgroup->frames[i].frame);
frame = R_AliasGetFramedesc (currententity->frame, paliashdr);
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
}