mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Fix alias bounding box sizes, so that large critters don't disappear when at edge of view frustrum...
(Taken and debugged from tutorial on quakesrc.org)
This commit is contained in:
parent
9482c151c2
commit
df55030fa8
4 changed files with 24 additions and 13 deletions
|
@ -346,6 +346,8 @@ extern aliashdr_t *pheader;
|
|||
extern stvert_t *stverts;
|
||||
extern mtriangle_t *triangles;
|
||||
extern trivertx_t *poseverts[MAXALIASFRAMES];
|
||||
extern int aliasbboxmins[3];
|
||||
extern int aliasbboxmaxs[3];
|
||||
|
||||
//===================================================================
|
||||
|
||||
|
|
|
@ -55,12 +55,6 @@ static const char rcsid[] =
|
|||
byte player_8bit_texels[320 * 200];
|
||||
|
||||
|
||||
/*
|
||||
ALIAS MODELS
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// a pose is a single set of vertexes. a frame may be
|
||||
// an animating sequence of poses
|
||||
|
||||
|
@ -202,6 +196,9 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame, int extra
|
|||
// byte values, don't worry about endianness
|
||||
frame->bboxmin.v[i] = pdaliasframe->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pdaliasframe->bboxmax.v[i];
|
||||
|
||||
aliasbboxmins[i] = min (frame->bboxmin.v[i], aliasbboxmins[i]);
|
||||
aliasbboxmaxs[i] = max (frame->bboxmax.v[i], aliasbboxmaxs[i]);
|
||||
}
|
||||
|
||||
pinframe = (trivertx_t *) (pdaliasframe + 1);
|
||||
|
@ -236,6 +233,9 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, int extra
|
|||
// these are byte values, so we don't have to worry about endianness
|
||||
frame->bboxmin.v[i] = pingroup->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pingroup->bboxmax.v[i];
|
||||
|
||||
aliasbboxmins[i] = min (frame->bboxmin.v[i], aliasbboxmins[i]);
|
||||
aliasbboxmaxs[i] = max (frame->bboxmax.v[i], aliasbboxmaxs[i]);
|
||||
}
|
||||
|
||||
pin_intervals = (daliasinterval_t *) (pingroup + 1);
|
||||
|
|
|
@ -52,10 +52,6 @@ static const char rcsid[] =
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
/*
|
||||
ALIAS MODELS
|
||||
*/
|
||||
|
||||
aliashdr_t *pheader;
|
||||
|
||||
stvert_t *stverts;
|
||||
|
@ -67,6 +63,8 @@ int triangles_size = 0;
|
|||
// sequence of poses
|
||||
trivertx_t *poseverts[MAXALIASFRAMES];
|
||||
int posenum = 0;
|
||||
int aliasbboxmins[3], aliasbboxmaxs[3];
|
||||
|
||||
|
||||
void *
|
||||
Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
|
||||
|
@ -264,6 +262,8 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
|||
// load the frames
|
||||
posenum = 0;
|
||||
pframetype = (daliasframetype_t *) &pintriangles[pheader->mdl.numtris];
|
||||
aliasbboxmins[0] = aliasbboxmins[1] = aliasbboxmins[2] = 99999;
|
||||
aliasbboxmaxs[0] = aliasbboxmaxs[1] = aliasbboxmaxs[2] = -99999;
|
||||
|
||||
for (i = 0; i < numframes; i++) {
|
||||
aliasframetype_t frametype;
|
||||
|
@ -286,9 +286,12 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
|||
|
||||
mod->type = mod_alias;
|
||||
|
||||
// FIXME: do this right
|
||||
mod->mins[0] = mod->mins[1] = mod->mins[2] = -16;
|
||||
mod->maxs[0] = mod->maxs[1] = mod->maxs[2] = 16;
|
||||
for (i = 0; i < 3; i++) {
|
||||
mod->mins[i] = aliasbboxmins[i] * pheader->mdl.scale[i] +
|
||||
pheader->mdl.scale_origin[i];
|
||||
mod->maxs[i] = aliasbboxmaxs[i] * pheader->mdl.scale[i] +
|
||||
pheader->mdl.scale_origin[i];
|
||||
}
|
||||
|
||||
// build the draw lists
|
||||
Mod_MakeAliasModelDisplayLists (mod, pheader, buffer, com_filesize, extra);
|
||||
|
|
|
@ -118,6 +118,9 @@ Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame, int extra
|
|||
// byte values, don't worry about endianness
|
||||
frame->bboxmin.v[i] = pdaliasframe->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pdaliasframe->bboxmax.v[i];
|
||||
|
||||
aliasbboxmins[i] = min (frame->bboxmin.v[i], aliasbboxmins[i]);
|
||||
aliasbboxmaxs[i] = max (frame->bboxmax.v[i], aliasbboxmaxs[i]);
|
||||
}
|
||||
|
||||
pinframe = (trivertx_t *) (pdaliasframe + 1);
|
||||
|
@ -183,6 +186,9 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame, int extra
|
|||
// these are byte values, so we don't have to worry about endianness
|
||||
frame->bboxmin.v[i] = pingroup->bboxmin.v[i];
|
||||
frame->bboxmax.v[i] = pingroup->bboxmax.v[i];
|
||||
|
||||
aliasbboxmins[i] = min (frame->bboxmin.v[i], aliasbboxmins[i]);
|
||||
aliasbboxmaxs[i] = max (frame->bboxmax.v[i], aliasbboxmaxs[i]);
|
||||
}
|
||||
|
||||
frame->frame = (byte *) paliasgroup - (byte *) pheader;
|
||||
|
|
Loading…
Reference in a new issue