Break out the entity blend calculations.

This allows alias and sprite model lerping to share the code.
This commit is contained in:
Bill Currie 2012-01-04 18:30:47 +09:00
parent 836209e5c6
commit 6050901e0e
3 changed files with 30 additions and 23 deletions

View file

@ -190,6 +190,7 @@ void R_AliasDrawModel (alight_t *plighting);
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_EntityBlend (entity_t *ent, int pose, float interval);
void R_BeginEdgeFrame (void);
void R_ScanEdges (void);
void D_DrawSurfaces (void);

View file

@ -144,28 +144,8 @@ float
R_AliasGetLerpedFrames (entity_t *ent, aliashdr_t *hdr)
{
maliasframedesc_t *frame;
float frame_interval;
int pose;
float blend;
float interval;
frame = alias_get_frame (ent->frame, hdr, &frame_interval);
pose = frame->firstpose;
ent->frame_interval = frame_interval;
if (ent->pose2 != pose) {
ent->frame_start_time = r_realtime;
if (ent->pose2 == -1) {
ent->pose1 = pose;
} else {
ent->pose1 = ent->pose2;
}
ent->pose2 = pose;
blend = 0.0;
} else if (r_paused) {
blend = 1.0;
} else {
blend = (r_realtime - ent->frame_start_time) / ent->frame_interval;
blend = min (blend, 1.0);
}
return blend;
frame = alias_get_frame (ent->frame, hdr, &interval);
return R_EntityBlend (ent, frame->firstpose, interval);
}

View file

@ -48,6 +48,8 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/sys.h"
#include "r_dynamic.h"
#include "r_local.h"
#include "r_shared.h"
#define ENT_POOL_SIZE 32
@ -118,3 +120,27 @@ R_EnqueueEntity (entity_t *ent)
*vis_tail = ent;
vis_tail = &ent->next;
}
float
R_EntityBlend (entity_t *ent, int pose, float interval)
{
float blend;
ent->frame_interval = interval;
if (ent->pose2 != pose) {
ent->frame_start_time = r_realtime;
if (ent->pose2 == -1) {
ent->pose1 = pose;
} else {
ent->pose1 = ent->pose2;
}
ent->pose2 = pose;
blend = 0.0;
} else if (r_paused) {
blend = 1.0;
} else {
blend = (r_realtime - ent->frame_start_time) / ent->frame_interval;
blend = min (blend, 1.0);
}
return blend;
}