diff --git a/include/QF/model.h b/include/QF/model.h index fe1991ec6..fd52b20be 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -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]; //=================================================================== diff --git a/libs/models/alias/gl_model_alias.c b/libs/models/alias/gl_model_alias.c index 2b3cac25d..e7f6994cd 100644 --- a/libs/models/alias/gl_model_alias.c +++ b/libs/models/alias/gl_model_alias.c @@ -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); diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index 8806ddc62..01c8188f2 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -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); diff --git a/libs/models/alias/sw_model_alias.c b/libs/models/alias/sw_model_alias.c index e1062a648..357a70a7c 100644 --- a/libs/models/alias/sw_model_alias.c +++ b/libs/models/alias/sw_model_alias.c @@ -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;