Move the frame blending into common code.

This commit is contained in:
Bill Currie 2012-05-16 17:44:18 +09:00
parent 8ada7c02a3
commit 041d63c828
3 changed files with 32 additions and 20 deletions

View file

@ -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);

View file

@ -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++) {

View file

@ -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;
}