diff --git a/include/r_local.h b/include/r_local.h index 955265f39..83cd00338 100644 --- a/include/r_local.h +++ b/include/r_local.h @@ -164,6 +164,8 @@ maliasskindesc_t *R_AliasGetSkindesc (int skinnum, aliashdr_t *hdr); maliasframedesc_t *R_AliasGetFramedesc (int framenum, aliashdr_t *hdr); float R_AliasGetLerpedFrames (entity_t *ent, aliashdr_t *hdr); float R_IQMGetLerpedFrames (entity_t *ent, iqm_t *hdr); +iqmframe_t *R_IQMBlendFrames (const iqm_t *iqm, int frame1, int frame2, + int blend); float R_EntityBlend (entity_t *ent, int pose, float interval); void R_BeginEdgeFrame (void); void R_ScanEdges (void); diff --git a/libs/video/renderer/glsl/glsl_iqm.c b/libs/video/renderer/glsl/glsl_iqm.c index 2d081d978..482a3b40b 100644 --- a/libs/video/renderer/glsl/glsl_iqm.c +++ b/libs/video/renderer/glsl/glsl_iqm.c @@ -217,26 +217,7 @@ glsl_R_DrawIQM (void) Mat4Mult (iqm_vp, ent->transform, mvp_mat); blend = R_IQMGetLerpedFrames (ent, iqm); - frame = Hunk_TempAlloc (iqm->num_joints * sizeof (iqmframe_t)); -#if 0 - for (i = 0; i < iqm->num_joints; i++) { - iqmframe_t *f1 = &iqm->frames[ent->pose1][i]; - iqmframe_t *f2 = &iqm->frames[ent->pose2][i]; - DualQuatBlend (f1->rt, f2->rt, blend, frame[i].rt); - QuatBlend (f1->shear, f2->shear, blend, frame[i].shear); - QuatBlend (f1->scale, f2->scale, blend, frame[i].scale); - } -#else - for (i = 0; i < iqm->num_joints; i++) { - iqmframe_t *f1 = &iqm->frames[ent->pose1][i]; - iqmframe_t *f2 = &iqm->frames[ent->pose2][i]; - iqmjoint *j = &iqm->joints[i]; - Mat4Blend ((float *) f1, (float *) f2, blend, (float*)&frame[i]); - if (j->parent >= 0) - Mat4Mult ((float*)&frame[j->parent], - (float*)&frame[i], (float*)&frame[i]); - } -#endif + frame = R_IQMBlendFrames (iqm, ent->pose1, ent->pose2, blend); qfeglUniform3fv (iqm_shader.ambient.location, 1, ambientcolor); for (i = 0; i < MAX_IQM_LIGHTS; i++) { diff --git a/libs/video/renderer/r_iqm.c b/libs/video/renderer/r_iqm.c index 012f4da91..854a4581d 100644 --- a/libs/video/renderer/r_iqm.c +++ b/libs/video/renderer/r_iqm.c @@ -65,3 +65,32 @@ R_IQMGetLerpedFrames (entity_t *ent, iqm_t *iqm) frame = (int) (time * anim->framerate) + anim->first_frame; return R_EntityBlend (ent, frame, anim->framerate); } + +iqmframe_t * +R_IQMBlendFrames (const iqm_t *iqm, int frame1, int frame2, int blend) +{ + iqmframe_t *frame; + int i; + + frame = Hunk_TempAlloc (iqm->num_joints * sizeof (iqmframe_t)); +#if 0 + for (i = 0; i < iqm->num_joints; i++) { + iqmframe_t *f1 = &iqm->frames[frame1][i]; + iqmframe_t *f2 = &iqm->frames[frame2][i]; + DualQuatBlend (f1->rt, f2->rt, blend, frame[i].rt); + QuatBlend (f1->shear, f2->shear, blend, frame[i].shear); + QuatBlend (f1->scale, f2->scale, blend, frame[i].scale); + } +#else + for (i = 0; i < iqm->num_joints; i++) { + iqmframe_t *f1 = &iqm->frames[frame1][i]; + iqmframe_t *f2 = &iqm->frames[frame2][i]; + iqmjoint *j = &iqm->joints[i]; + Mat4Blend ((float *) f1, (float *) f2, blend, (float*)&frame[i]); + if (j->parent >= 0) + Mat4Mult ((float*)&frame[j->parent], + (float*)&frame[i], (float*)&frame[i]); + } +#endif + return frame; +}