|
|
@ -851,11 +851,11 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded ) |
|
|
|
char poolname[MAX_VA_STRING]; |
|
|
|
char poolname[MAX_VA_STRING]; |
|
|
|
studiohdr_t *phdr; |
|
|
|
studiohdr_t *phdr; |
|
|
|
|
|
|
|
|
|
|
|
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", loadmodel->name ); |
|
|
|
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name ); |
|
|
|
|
|
|
|
|
|
|
|
if( loaded ) *loaded = false; |
|
|
|
if( loaded ) *loaded = false; |
|
|
|
loadmodel->mempool = Mem_AllocPool( poolname ); |
|
|
|
mod->mempool = Mem_AllocPool( poolname ); |
|
|
|
loadmodel->type = mod_studio; |
|
|
|
mod->type = mod_studio; |
|
|
|
|
|
|
|
|
|
|
|
phdr = R_StudioLoadHeader( mod, buffer ); |
|
|
|
phdr = R_StudioLoadHeader( mod, buffer ); |
|
|
|
if( !phdr ) return; // bad model
|
|
|
|
if( !phdr ) return; // bad model
|
|
|
@ -886,9 +886,9 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded ) |
|
|
|
// give space for textures and skinrefs
|
|
|
|
// give space for textures and skinrefs
|
|
|
|
size1 = thdr->numtextures * sizeof( mstudiotexture_t ); |
|
|
|
size1 = thdr->numtextures * sizeof( mstudiotexture_t ); |
|
|
|
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short ); |
|
|
|
size2 = thdr->numskinfamilies * thdr->numskinref * sizeof( short ); |
|
|
|
mod->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length + size1 + size2 ); |
|
|
|
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length + size1 + size2 ); |
|
|
|
memcpy( loadmodel->cache.data, buffer, phdr->length ); // copy main mdl buffer
|
|
|
|
memcpy( mod->cache.data, buffer, phdr->length ); // copy main mdl buffer
|
|
|
|
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
|
|
|
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
|
|
|
phdr->numskinfamilies = thdr->numskinfamilies; |
|
|
|
phdr->numskinfamilies = thdr->numskinfamilies; |
|
|
|
phdr->numtextures = thdr->numtextures; |
|
|
|
phdr->numtextures = thdr->numtextures; |
|
|
|
phdr->numskinref = thdr->numskinref; |
|
|
|
phdr->numskinref = thdr->numskinref; |
|
|
@ -905,52 +905,52 @@ void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded ) |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOTE: don't modify source buffer because it's used for CRC computing
|
|
|
|
// NOTE: don't modify source buffer because it's used for CRC computing
|
|
|
|
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length ); |
|
|
|
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length ); |
|
|
|
memcpy( loadmodel->cache.data, buffer, phdr->length ); |
|
|
|
memcpy( mod->cache.data, buffer, phdr->length ); |
|
|
|
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
|
|
|
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
|
|
|
#if !XASH_DEDICATED |
|
|
|
#if !XASH_DEDICATED |
|
|
|
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr ); |
|
|
|
ref.dllFuncs.Mod_StudioLoadTextures( mod, phdr ); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
|
|
|
|
// NOTE: we wan't keep raw textures in memory. just cutoff model pointer above texture base
|
|
|
|
loadmodel->cache.data = Mem_Realloc( loadmodel->mempool, loadmodel->cache.data, phdr->texturedataindex ); |
|
|
|
mod->cache.data = Mem_Realloc( mod->mempool, mod->cache.data, phdr->texturedataindex ); |
|
|
|
phdr = (studiohdr_t *)loadmodel->cache.data; // get the new pointer on studiohdr
|
|
|
|
phdr = (studiohdr_t *)mod->cache.data; // get the new pointer on studiohdr
|
|
|
|
phdr->length = phdr->texturedataindex; // update model size
|
|
|
|
phdr->length = phdr->texturedataindex; // update model size
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// just copy model into memory
|
|
|
|
// just copy model into memory
|
|
|
|
loadmodel->cache.data = Mem_Calloc( loadmodel->mempool, phdr->length ); |
|
|
|
mod->cache.data = Mem_Calloc( mod->mempool, phdr->length ); |
|
|
|
memcpy( loadmodel->cache.data, buffer, phdr->length ); |
|
|
|
memcpy( mod->cache.data, buffer, phdr->length ); |
|
|
|
|
|
|
|
|
|
|
|
phdr = loadmodel->cache.data; |
|
|
|
phdr = mod->cache.data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// setup bounding box
|
|
|
|
// setup bounding box
|
|
|
|
if( !VectorCompare( vec3_origin, phdr->bbmin )) |
|
|
|
if( !VectorCompare( vec3_origin, phdr->bbmin )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// clipping bounding box
|
|
|
|
// clipping bounding box
|
|
|
|
VectorCopy( phdr->bbmin, loadmodel->mins ); |
|
|
|
VectorCopy( phdr->bbmin, mod->mins ); |
|
|
|
VectorCopy( phdr->bbmax, loadmodel->maxs ); |
|
|
|
VectorCopy( phdr->bbmax, mod->maxs ); |
|
|
|
} |
|
|
|
} |
|
|
|
else if( !VectorCompare( vec3_origin, phdr->min )) |
|
|
|
else if( !VectorCompare( vec3_origin, phdr->min )) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// movement bounding box
|
|
|
|
// movement bounding box
|
|
|
|
VectorCopy( phdr->min, loadmodel->mins ); |
|
|
|
VectorCopy( phdr->min, mod->mins ); |
|
|
|
VectorCopy( phdr->max, loadmodel->maxs ); |
|
|
|
VectorCopy( phdr->max, mod->maxs ); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
// well compute bounds from vertices and round to nearest even values
|
|
|
|
// well compute bounds from vertices and round to nearest even values
|
|
|
|
Mod_StudioComputeBounds( phdr, loadmodel->mins, loadmodel->maxs, true ); |
|
|
|
Mod_StudioComputeBounds( phdr, mod->mins, mod->maxs, true ); |
|
|
|
RoundUpHullSize( loadmodel->mins ); |
|
|
|
RoundUpHullSize( mod->mins ); |
|
|
|
RoundUpHullSize( loadmodel->maxs ); |
|
|
|
RoundUpHullSize( mod->maxs ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
loadmodel->numframes = Mod_StudioBodyVariations( loadmodel ); |
|
|
|
mod->numframes = Mod_StudioBodyVariations( mod ); |
|
|
|
loadmodel->radius = RadiusFromBounds( loadmodel->mins, loadmodel->maxs ); |
|
|
|
mod->radius = RadiusFromBounds( mod->mins, mod->maxs ); |
|
|
|
loadmodel->flags = phdr->flags; // copy header flags
|
|
|
|
mod->flags = phdr->flags; // copy header flags
|
|
|
|
|
|
|
|
|
|
|
|
if( loaded ) *loaded = true; |
|
|
|
if( loaded ) *loaded = true; |
|
|
|
} |
|
|
|
} |
|
|
|