X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=r_lerpanim.c;h=7fc8b096e10e3ee85b268e7d765ad6e7aa0f739f;hb=3d902554fddb52a62f90927c4784d6a7dd8ee377;hp=753e4af25fe51c7269174cb1d30cad83af92fd73;hpb=dbce962f09403fd5888d0bd858ceefc90bc3ea2b;p=xonotic%2Fdarkplaces.git diff --git a/r_lerpanim.c b/r_lerpanim.c index 753e4af2..7fc8b096 100644 --- a/r_lerpanim.c +++ b/r_lerpanim.c @@ -6,47 +6,53 @@ // 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) - 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; + + if (!model || !model->type) + return; - numframes = r->model->numframes; + numframes = model->numframes; if (r->frame1 >= numframes) { - Con_DPrintf ("CL_LerpAnimation: no such frame %d\n", r->frame1); + Con_DPrintf("CL_LerpAnimation: no such frame %d\n", r->frame1); r->frame1 = 0; } if (r->frame2 >= numframes) { - Con_DPrintf ("CL_LerpAnimation: no such frame %d\n", r->frame2); + Con_DPrintf("CL_LerpAnimation: no such frame %d\n", r->frame2); r->frame2 = 0; } // note: this could be removed, if the rendering code allows an empty blend array if (r->frame1 < 0) - Host_Error ("CL_LerpAnimation: frame1 is NULL\n"); + { + Con_Printf ("CL_LerpAnimation: frame1 is NULL\n"); + r->frame1 = 0; + } - // round off very close blend percentages - if (r->framelerp < (1.0f / 65536.0f)) - r->framelerp = 0; - if (r->framelerp >= (65535.0f / 65536.0f)) + // check r_lerpmodels and round off very close blend percentages + 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) @@ -55,22 +61,19 @@ void R_LerpAnimation(entity_render_t *r) sub1 = (int) (sublerp); sub2 = sub1 + 1; sublerp -= sub1; - if (sublerp < (1.0f / 65536.0f)) + if (!dolerp) sublerp = 0; - if (sublerp >= (65535.0f / 65536.0f)) + else if (sublerp >= (65535.0f / 65536.0f)) sublerp = 1; + else if (sublerp < (1.0f / 65536.0f)) + sublerp = 0; if (scene->loop) { sub1 = (sub1 % scene->framecount); sub2 = (sub2 % scene->framecount); } - else - { - sub1 = bound(0, sub1, (scene->framecount - 1)); - sub2 = bound(0, sub2, (scene->framecount - 1)); - } - sub1 += scene->firstframe; - sub2 += scene->firstframe; + sub1 = bound(0, sub1, (scene->framecount - 1)) + scene->firstframe; + sub2 = bound(0, sub2, (scene->framecount - 1)) + scene->firstframe; f = sub1; d = (1 - sublerp) * lerp; #define FRAMEBLENDINSERT\ @@ -104,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) @@ -113,22 +116,19 @@ void R_LerpAnimation(entity_render_t *r) sub1 = (int) (sublerp); sub2 = sub1 + 1; sublerp -= sub1; - if (sublerp < (1.0f / 65536.0f)) + if (!dolerp) sublerp = 0; - if (sublerp >= (65535.0f / 65536.0f)) + else if (sublerp >= (65535.0f / 65536.0f)) sublerp = 1; + else if (sublerp < (1.0f / 65536.0f)) + sublerp = 0; if (scene->loop) { sub1 = (sub1 % scene->framecount); sub2 = (sub2 % scene->framecount); } - else - { - sub1 = bound(0, sub1, (scene->framecount - 1)); - sub2 = bound(0, sub2, (scene->framecount - 1)); - } - sub1 += scene->firstframe; - sub2 += scene->firstframe; + sub1 = bound(0, sub1, (scene->framecount - 1)) + scene->firstframe; + sub2 = bound(0, sub2, (scene->framecount - 1)) + scene->firstframe; f = sub1; d = (1 - sublerp) * lerp; FRAMEBLENDINSERT