migrated r_lerpsprites cvar check to r_lerpanim, r_lerpmodels no longer affects sprites
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 29 Oct 2005 00:39:53 +0000 (00:39 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 29 Oct 2005 00:39:53 +0000 (00:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5778 d7cf8633-e32d-0410-b094-e92efae38249

r_lerpanim.c
r_sprites.c

index 831a16e..7fc8b09 100644 (file)
@@ -6,17 +6,20 @@
 // LordHavoc: later note: made FRAMEBLENDINSERT macro
 void R_LerpAnimation(entity_render_t *r)
 {
-       int sub1, sub2, numframes, f, i;
+       int sub1, sub2, numframes, f, i, dolerp;
        double sublerp, lerp, d;
        animscene_t *scene;
        frameblend_t *blend;
-
-       if (!r->model || !r->model->type)
-               return;
+       model_t *model = r->model;
 
        blend = r->frameblend;
+       blend[0].frame = blend[1].frame = blend[2].frame = blend[3].frame = 0;
+       blend[0].lerp = blend[1].lerp = blend[2].lerp = blend[3].lerp = 0;
 
-       numframes = r->model->numframes;
+       if (!model || !model->type)
+               return;
+
+       numframes = model->numframes;
 
        if (r->frame1 >= numframes)
        {
@@ -38,20 +41,18 @@ void R_LerpAnimation(entity_render_t *r)
        }
 
        // check r_lerpmodels and round off very close blend percentages
-       if (!r_lerpmodels.integer)
-               r->framelerp = 1;
-       else if (r->framelerp >= (65535.0f / 65536.0f))
+       dolerp = (model->type == mod_sprite) ? r_lerpsprites.integer : r_lerpmodels.integer;
+
+       if (!dolerp || r->framelerp >= (65535.0f / 65536.0f))
                r->framelerp = 1;
        else if (r->framelerp < (1.0f / 65536.0f))
                r->framelerp = 0;
 
-       blend[0].frame = blend[1].frame = blend[2].frame = blend[3].frame = 0;
-       blend[0].lerp = blend[1].lerp = blend[2].lerp = blend[3].lerp = 0;
-       if (r->model->animscenes)
+       if (model->animscenes)
        {
                if (r->framelerp < 1 && r->frame1 >= 0)
                {
-                       scene = r->model->animscenes + r->frame1;
+                       scene = model->animscenes + r->frame1;
                        lerp = 1 - r->framelerp;
 
                        if (scene->framecount > 1)
@@ -60,8 +61,8 @@ void R_LerpAnimation(entity_render_t *r)
                                sub1 = (int) (sublerp);
                                sub2 = sub1 + 1;
                                sublerp -= sub1;
-                               if (!r_lerpmodels.integer)
-                                       sublerp = 1;
+                               if (!dolerp)
+                                       sublerp = 0;
                                else if (sublerp >= (65535.0f / 65536.0f))
                                        sublerp = 1;
                                else if (sublerp < (1.0f / 65536.0f))
@@ -106,7 +107,7 @@ void R_LerpAnimation(entity_render_t *r)
                }
                if (r->framelerp > 0 && r->frame2 >= 0)
                {
-                       scene = r->model->animscenes + r->frame2;
+                       scene = model->animscenes + r->frame2;
                        lerp = r->framelerp;
 
                        if (scene->framecount > 1)
@@ -115,8 +116,8 @@ void R_LerpAnimation(entity_render_t *r)
                                sub1 = (int) (sublerp);
                                sub2 = sub1 + 1;
                                sublerp -= sub1;
-                               if (!r_lerpmodels.integer)
-                                       sublerp = 1;
+                               if (!dolerp)
+                                       sublerp = 0;
                                else if (sublerp >= (65535.0f / 65536.0f))
                                        sublerp = 1;
                                else if (sublerp < (1.0f / 65536.0f))
index 1a19d36..59068cd 100644 (file)
@@ -113,32 +113,15 @@ void R_DrawSpriteModelCallback(const void *calldata1, int calldata2)
                fog = 0;
        ifog = 1 - fog;
 
-       if (r_lerpsprites.integer)
+       // LordHavoc: interpolated sprite rendering
+       for (i = 0;i < 4;i++)
        {
-               // LordHavoc: interpolated sprite rendering
-               for (i = 0;i < 4;i++)
+               if (ent->frameblend[i].lerp >= 0.01f)
                {
-                       if (ent->frameblend[i].lerp >= 0.01f)
-                       {
-                               frame = ent->model->sprite.sprdata_frames + ent->frameblend[i].frame;
-                               R_DrawSpriteImage((ent->effects & EF_ADDITIVE), (ent->effects & EF_NODEPTHTEST), frame, frame->texture, org, up, left, color[0] * ifog, color[1] * ifog, color[2] * ifog, ent->alpha * ent->frameblend[i].lerp);
-                               if (fog * ent->frameblend[i].lerp >= 0.01f)
-                                       R_DrawSpriteImage(true, (ent->effects & EF_NODEPTHTEST), frame, frame->fogtexture, org, up, left, fogcolor[0],fogcolor[1],fogcolor[2], fog * ent->alpha * ent->frameblend[i].lerp);
-                       }
-               }
-       }
-       else
-       {
-               // LordHavoc: no interpolation
-               frame = NULL;
-               for (i = 0;i < 4 && ent->frameblend[i].lerp;i++)
                        frame = ent->model->sprite.sprdata_frames + ent->frameblend[i].frame;
-
-               if (frame)
-               {
-                       R_DrawSpriteImage((ent->effects & EF_ADDITIVE), (ent->effects & EF_NODEPTHTEST), frame, frame->texture, org, up, left, color[0] * ifog, color[1] * ifog, color[2] * ifog, ent->alpha);
+                       R_DrawSpriteImage((ent->effects & EF_ADDITIVE), (ent->effects & EF_NODEPTHTEST), frame, frame->texture, org, up, left, color[0] * ifog, color[1] * ifog, color[2] * ifog, ent->alpha * ent->frameblend[i].lerp);
                        if (fog * ent->frameblend[i].lerp >= 0.01f)
-                               R_DrawSpriteImage(true, (ent->effects & EF_NODEPTHTEST), frame, frame->fogtexture, org, up, left, fogcolor[0],fogcolor[1],fogcolor[2], fog * ent->alpha);
+                               R_DrawSpriteImage(true, (ent->effects & EF_NODEPTHTEST), frame, frame->fogtexture, org, up, left, fogcolor[0],fogcolor[1],fogcolor[2], fog * ent->alpha * ent->frameblend[i].lerp);
                }
        }
 }