From 93624e9d6277af0ebdb001bcf9ae36d4c461c9f1 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 23 Mar 2018 06:35:32 +0000 Subject: [PATCH] don't bug out so much on skeletal models when frametimes are negative (can happen via csqc) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5226 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/com_mesh.c | 14 +++++++++----- engine/common/mathlib.c | 3 +-- engine/gl/gl_alias.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index 448d7d7dd..f8f3f3928 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -1004,8 +1004,8 @@ typedef struct } skellerps_t; static qboolean Alias_BuildSkelLerps(skellerps_t *lerps, struct framestateregion_s *fs, int numbones, galiasinfo_t *inf) { - unsigned int frame1; - unsigned int frame2; + int frame1; //signed, because frametime might be negative... + int frame2; float mlerp; //minor lerp, poses within a group. int l = 0; galiasanimation_t *g; @@ -1042,18 +1042,22 @@ static qboolean Alias_BuildSkelLerps(skellerps_t *lerps, struct framestateregion } mlerp = time*g->rate; - frame1=mlerp; + frame1=floor(mlerp); frame2=frame1+1; mlerp-=frame1; if (g->loop) { //loop normally. frame1=frame1%g->numposes; frame2=frame2%g->numposes; + if (frame1 < 0) + frame1 += g->numposes; + if (frame2 < 0) + frame2 += g->numposes; } else { - frame1=(frame1>g->numposes-1)?g->numposes-1:frame1; - frame2=(frame2>g->numposes-1)?g->numposes-1:frame2; + frame1=bound(0, frame1, g->numposes-1); + frame2=bound(0, frame2, g->numposes-1); } if (lerps->skeltype == SKEL_IDENTITY) diff --git a/engine/common/mathlib.c b/engine/common/mathlib.c index 996b0c56b..c05012eb1 100644 --- a/engine/common/mathlib.c +++ b/engine/common/mathlib.c @@ -1895,10 +1895,9 @@ vec_t QDECL VectorNormalize2 (const vec3_t v, vec3_t out) float length, ilength; length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; - + length = sqrt (length); if (length) { - length = sqrt (length); // FIXME ilength = 1/length; out[0] = v[0]*ilength; out[1] = v[1]*ilength; diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index c7f6689ae..bed989551 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -1726,7 +1726,7 @@ void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches) continue; skin = skin?skin:NULL; shader = e->forcedshader?e->forcedshader:regshader; - if (shader) + if (shader && !(shader->flags & SHADER_NODRAW)) { b = BE_GetTempBatch(); if (!b)