Skip to content
Permalink
Browse files

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.
  • Loading branch information...
zturtleman committed Aug 2, 2018
1 parent 1994801 commit c7ebe82131db2c94d01c87803df588b367cd29d3
Showing with 28 additions and 0 deletions.
  1. +14 −0 code/renderergl1/tr_model_iqm.c
  2. +14 −0 code/renderergl2/tr_model_iqm.c
@@ -566,6 +566,8 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
if( header->ofs_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;
@@ -641,6 +643,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
if( header->ofs_bounds ) {
iqmData->bounds = (float*)dataPtr;
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 )
@@ -907,6 +912,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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;
}
@@ -569,6 +569,8 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
}
if( header->ofs_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;
@@ -644,6 +646,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
if( header->ofs_bounds ) {
iqmData->bounds = (float*)dataPtr;
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 )
@@ -910,6 +915,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
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
if ( iqmData->num_surfaces && iqmData->num_joints <= glRefConfig.glslMaxAnimatedBones )

0 comments on commit c7ebe82

Please sign in to comment.
You can’t perform that action at this time.