Merge the alias skin selection code.

We really don't need 4 copies of identical code when 1 will do :P
This commit is contained in:
Bill Currie 2012-01-02 15:57:43 +09:00
parent 540bccbc27
commit 1c480bf75e
6 changed files with 86 additions and 101 deletions

View file

@ -187,6 +187,7 @@ 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);
void R_BeginEdgeFrame (void);
void R_ScanEdges (void);
void D_DrawSurfaces (void);

View file

@ -10,8 +10,8 @@ EXTRA_LTLIBRARIES= libQFrenderer_sw.la libQFrenderer_sw32.la \
libQFrenderer_gl.la libQFrenderer_glsl.la
common_sources= \
crosshair.c r_cvar.c r_efrag.c r_ent.c r_graph.c r_light.c r_main.c \
r_part.c r_progs.c r_screen.c
crosshair.c r_alias.c r_cvar.c r_efrag.c r_ent.c r_graph.c r_light.c \
r_main.c r_part.c r_progs.c r_screen.c
libQFrenderer_gl_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -rpath $(libdir)
libQFrenderer_gl_la_LIBADD= gl/libgl.la

View file

@ -460,47 +460,6 @@ GL_GetAliasFrameVerts (int frame, aliashdr_t *paliashdr, entity_t *e)
return vo;
}
static maliasskindesc_t *
R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
{
maliasskindesc_t *pskindesc;
maliasskingroup_t *paliasskingroup;
if ((skinnum >= ahdr->mdl.numskins) || (skinnum < 0)) {
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupSkin: no such skin # %d\n",
skinnum);
skinnum = 0;
}
pskindesc = ((maliasskindesc_t *)
((byte *) ahdr + ahdr->skindesc)) + skinnum;
if (pskindesc->type == ALIAS_SKIN_GROUP) {
int numskins, i;
float fullskininterval, skintargettime, skintime;
float *pskinintervals;
paliasskingroup = (maliasskingroup_t *) ((byte *) ahdr +
pskindesc->skin);
pskinintervals = (float *)
((byte *) ahdr + paliasskingroup->intervals);
numskins = paliasskingroup->numskins;
fullskininterval = pskinintervals[numskins - 1];
skintime = r_realtime + currententity->syncbase;
skintargettime = skintime -
((int) (skintime / fullskininterval)) * fullskininterval;
for (i = 0; i < (numskins - 1); i++) {
if (pskinintervals[i] > skintargettime)
break;
}
pskindesc = &paliasskingroup->skindescs[i];
}
return pskindesc;
}
void
R_DrawAliasModel (entity_t *e)
{

View file

@ -0,0 +1,79 @@
/*
r_alias.c
Draw Alias Model
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "QF/sys.h"
#include "r_local.h"
static __attribute__ ((used)) const char rcsid[] = "$Id$";
VISIBLE maliasskindesc_t *
R_AliasGetSkindesc (int skinnum, aliashdr_t *ahdr)
{
maliasskindesc_t *pskindesc;
maliasskingroup_t *paliasskingroup;
if ((skinnum >= ahdr->mdl.numskins) || (skinnum < 0)) {
Sys_MaskPrintf (SYS_DEV, "R_AliasSetupSkin: no such skin # %d\n",
skinnum);
skinnum = 0;
}
pskindesc = ((maliasskindesc_t *)
((byte *) ahdr + ahdr->skindesc)) + skinnum;
if (pskindesc->type == ALIAS_SKIN_GROUP) {
int numskins, i;
float fullskininterval, skintargettime, skintime;
float *pskinintervals;
paliasskingroup = (maliasskingroup_t *) ((byte *) ahdr +
pskindesc->skin);
pskinintervals = (float *)
((byte *) ahdr + paliasskingroup->intervals);
numskins = paliasskingroup->numskins;
fullskininterval = pskinintervals[numskins - 1];
skintime = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval
// values are positive, so we don't have to worry about division by 0
skintargettime = skintime -
((int) (skintime / fullskininterval)) * fullskininterval;
for (i = 0; i < (numskins - 1); i++) {
if (pskinintervals[i] > skintargettime)
break;
}
pskindesc = &paliasskingroup->skindescs[i];
}
return pskindesc;
}

View file

@ -545,10 +545,7 @@ R_AliasPrepareUnclippedPoints (void)
static void
R_AliasSetupSkin (void)
{
int numskins, skinnum, i;
float skintargettime, skintime;
float *pskinintervals, fullskininterval;
maliasskingroup_t *paliasskingroup;
int skinnum;
skinnum = currententity->skinnum;
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
@ -557,33 +554,10 @@ R_AliasSetupSkin (void)
skinnum = 0;
}
pskindesc = ((maliasskindesc_t *)
((byte *) paliashdr + paliashdr->skindesc)) + skinnum;
pskindesc = R_AliasGetSkindesc (skinnum, paliashdr);
a_skinwidth = pmdl->skinwidth;
if (pskindesc->type == ALIAS_SKIN_GROUP) {
paliasskingroup = (maliasskingroup_t *) ((byte *) paliashdr +
pskindesc->skin);
pskinintervals = (float *)
((byte *) paliashdr + paliasskingroup->intervals);
numskins = paliasskingroup->numskins;
fullskininterval = pskinintervals[numskins - 1];
skintime = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval
// values are positive, so we don't have to worry about division by 0
skintargettime = skintime -
((int) (skintime / fullskininterval)) * fullskininterval;
for (i = 0; i < (numskins - 1); i++) {
if (pskinintervals[i] > skintargettime)
break;
}
pskindesc = &paliasskingroup->skindescs[i];
}
r_affinetridesc.pskindesc = pskindesc;
r_affinetridesc.pskin = (void *) ((byte *) paliashdr + pskindesc->skin);
r_affinetridesc.skinwidth = a_skinwidth;

View file

@ -540,10 +540,6 @@ static void
R_AliasSetupSkin (void)
{
int skinnum;
int i, numskins;
maliasskingroup_t *paliasskingroup;
float *pskinintervals, fullskininterval;
float skintargettime, skintime;
skinnum = currententity->skinnum;
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
@ -552,33 +548,9 @@ R_AliasSetupSkin (void)
skinnum = 0;
}
pskindesc = ((maliasskindesc_t *)
((byte *) paliashdr + paliashdr->skindesc)) + skinnum;
pskindesc = R_AliasGetSkindesc (skinnum, paliashdr);
a_skinwidth = pmdl->skinwidth;
if (pskindesc->type == ALIAS_SKIN_GROUP) {
paliasskingroup = (maliasskingroup_t *) ((byte *) paliashdr +
pskindesc->skin);
pskinintervals = (float *)
((byte *) paliashdr + paliasskingroup->intervals);
numskins = paliasskingroup->numskins;
fullskininterval = pskinintervals[numskins - 1];
skintime = r_realtime + currententity->syncbase;
// when loading in Mod_LoadAliasSkinGroup, we guaranteed all interval
// values are positive, so we don't have to worry about division by 0
skintargettime = skintime -
((int) (skintime / fullskininterval)) * fullskininterval;
for (i = 0; i < (numskins - 1); i++) {
if (pskinintervals[i] > skintargettime)
break;
}
pskindesc = &paliasskingroup->skindescs[i];
}
r_affinetridesc.pskindesc = pskindesc;
r_affinetridesc.pskin = (void *) ((byte *) paliashdr + pskindesc->skin);
r_affinetridesc.skinwidth = a_skinwidth;