mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-29 23:32:23 +00:00
Calculate bounds for unanimated IQM models
Bounds are optional for animated IQM models but are not possible to include with unanimated models (seems intended for use with separate model containing animations and bounds). Calculating bounds for unanimated IQM models fixes culling and head model on HUD which calculates position from model bounds.
This commit is contained in:
parent
1994801e1c
commit
c7ebe82131
2 changed files with 28 additions and 0 deletions
|
@ -566,6 +566,8 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
}
|
}
|
||||||
if( header->ofs_bounds ) {
|
if( header->ofs_bounds ) {
|
||||||
size += header->num_frames * 6 * sizeof(float); // model bounds
|
size += header->num_frames * 6 * sizeof(float); // model bounds
|
||||||
|
} else if( header->num_meshes && header->num_frames == 0 ) {
|
||||||
|
size += 6 * sizeof(float); // model bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->type = MOD_IQM;
|
mod->type = MOD_IQM;
|
||||||
|
@ -641,6 +643,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
if( header->ofs_bounds ) {
|
if( header->ofs_bounds ) {
|
||||||
iqmData->bounds = (float*)dataPtr;
|
iqmData->bounds = (float*)dataPtr;
|
||||||
dataPtr += header->num_frames * 6 * sizeof(float); // model bounds
|
dataPtr += header->num_frames * 6 * sizeof(float); // model bounds
|
||||||
|
} else if( header->num_meshes && header->num_frames == 0 ) {
|
||||||
|
iqmData->bounds = (float*)dataPtr;
|
||||||
|
dataPtr += 6 * sizeof(float); // model bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
if( header->num_meshes )
|
if( header->num_meshes )
|
||||||
|
@ -907,6 +912,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
bounds++;
|
bounds++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( header->num_meshes && header->num_frames == 0 )
|
||||||
|
{
|
||||||
|
mat = iqmData->bounds;
|
||||||
|
|
||||||
|
ClearBounds( &iqmData->bounds[0], &iqmData->bounds[3] );
|
||||||
|
for ( i = 0 ; i < header->num_vertexes ; i++ ) {
|
||||||
|
AddPointToBounds( &iqmData->positions[i*3], &iqmData->bounds[0], &iqmData->bounds[3] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return qtrue;
|
return qtrue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -569,6 +569,8 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
}
|
}
|
||||||
if( header->ofs_bounds ) {
|
if( header->ofs_bounds ) {
|
||||||
size += header->num_frames * 6 * sizeof(float); // model bounds
|
size += header->num_frames * 6 * sizeof(float); // model bounds
|
||||||
|
} else if( header->num_meshes && header->num_frames == 0 ) {
|
||||||
|
size += 6 * sizeof(float); // model bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->type = MOD_IQM;
|
mod->type = MOD_IQM;
|
||||||
|
@ -644,6 +646,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
if( header->ofs_bounds ) {
|
if( header->ofs_bounds ) {
|
||||||
iqmData->bounds = (float*)dataPtr;
|
iqmData->bounds = (float*)dataPtr;
|
||||||
dataPtr += header->num_frames * 6 * sizeof(float); // model bounds
|
dataPtr += header->num_frames * 6 * sizeof(float); // model bounds
|
||||||
|
} else if( header->num_meshes && header->num_frames == 0 ) {
|
||||||
|
iqmData->bounds = (float*)dataPtr;
|
||||||
|
dataPtr += 6 * sizeof(float); // model bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
if( header->num_meshes )
|
if( header->num_meshes )
|
||||||
|
@ -910,6 +915,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
|
||||||
bounds++;
|
bounds++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( header->num_meshes && header->num_frames == 0 )
|
||||||
|
{
|
||||||
|
mat = iqmData->bounds;
|
||||||
|
|
||||||
|
ClearBounds( &iqmData->bounds[0], &iqmData->bounds[3] );
|
||||||
|
for ( i = 0 ; i < header->num_vertexes ; i++ ) {
|
||||||
|
AddPointToBounds( &iqmData->positions[i*3], &iqmData->bounds[0], &iqmData->bounds[3] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create VAO surfaces
|
// Create VAO surfaces
|
||||||
if ( iqmData->num_surfaces && iqmData->num_joints <= glRefConfig.glslMaxAnimatedBones )
|
if ( iqmData->num_surfaces && iqmData->num_joints <= glRefConfig.glslMaxAnimatedBones )
|
||||||
|
|
Loading…
Reference in a new issue