mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 07:42:18 +00:00
80 lines
2.1 KiB
C
80 lines
2.1 KiB
C
|
/*
|
||
|
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;
|
||
|
}
|