diff --git a/include/QF/model.h b/include/QF/model.h index 7d5287b2f..c393662de 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -279,15 +279,9 @@ typedef struct { } maliasskindesc_t; typedef struct { - trivertx_t bboxmin; - trivertx_t bboxmax; - int frame; -} maliasgroupframedesc_t; - -typedef struct { - int numframes; - int intervals; - maliasgroupframedesc_t frames[1]; + int numframes; + int intervals; + maliasframedesc_t frames[1]; } maliasgroup_t; typedef struct { diff --git a/include/r_local.h b/include/r_local.h index 072e52c5f..b8a2bda25 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -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); diff --git a/libs/video/renderer/r_alias.c b/libs/video/renderer/r_alias.c index 46f33f38a..f2fcfdc34 100644 --- a/libs/video/renderer/r_alias.c +++ b/libs/video/renderer/r_alias.c @@ -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]; +} diff --git a/libs/video/renderer/sw/sw_ralias.c b/libs/video/renderer/sw/sw_ralias.c index 0da1f3fd3..b49d860d9 100644 --- a/libs/video/renderer/sw/sw_ralias.c +++ b/libs/video/renderer/sw/sw_ralias.c @@ -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); } diff --git a/libs/video/renderer/sw32/sw32_ralias.c b/libs/video/renderer/sw32/sw32_ralias.c index 698b243e2..48dc512c2 100644 --- a/libs/video/renderer/sw32/sw32_ralias.c +++ b/libs/video/renderer/sw32/sw32_ralias.c @@ -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); }