Do not try to lerp entities when their model changes.

This avoids sending invalid pose data to the renderer. The symptom was a
vertex array offset higher than the vertex array size. Discovered by calim
of nouveau while he was debugging a driver problem found by QF. Many
thanks.
This commit is contained in:
Bill Currie 2012-04-25 10:09:23 +09:00
parent a7870a98a1
commit 866c56c236
3 changed files with 20 additions and 0 deletions

View file

@ -114,6 +114,7 @@ typedef struct entity_s {
float frame_interval;
int pose1;
int pose2;
struct model_s *pose_model; // no lerp if not the same as model
} entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!

View file

@ -42,8 +42,10 @@
#endif
#include <stdlib.h>
#include "QF/cvar.h"
#include "QF/render.h"
#include "QF/skin.h"
#include "QF/sys.h"
#include "QF/GLSL/defines.h"
#include "QF/GLSL/funcs.h"
@ -168,6 +170,17 @@ set_arrays (const shaderparam_t *vert, const shaderparam_t *norm,
const shaderparam_t *st, aliasvrt_t *pose)
{
byte *pose_offs = (byte *) pose;
if (developer->int_val & SYS_GLSL) {
GLint size;
qfeglGetBufferParameteriv (GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &size);
if (size <= (long)pose_offs) {
Sys_Printf ("Invalid pose");
pose = 0;
}
}
qfeglVertexAttribPointer (vert->location, 3, GL_UNSIGNED_SHORT,
0, sizeof (aliasvrt_t),
pose_offs + field_offset (aliasvrt_t, vertex));

View file

@ -121,6 +121,12 @@ R_EntityBlend (entity_t *ent, int pose, float interval)
{
float blend;
if (ent->pose_model != ent->model) {
ent->pose_model = ent->model;
ent->pose1 = pose;
ent->pose2 = pose;
return 0.0;
}
ent->frame_interval = interval;
if (ent->pose2 != pose) {
ent->frame_start_time = vr_data.realtime;