Working commit for animation smoothing. Pretty much breaks everything that relied on fixed-frame transitions (muzzledlashes) but makes stuff look good otherwise. Needs a DEF-hook to control which frames should be smoothed.

git-svn-id: https://svn.eduke32.com/eduke32@530 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
Plagman 2007-03-30 18:02:00 +00:00
parent b54b8e1e6b
commit fc613042a0
2 changed files with 71 additions and 21 deletions

View file

@ -858,7 +858,7 @@ int mdpause;
static void updateanimation (md2model *m, spritetype *tspr)
{
mdanim_t *anim;
long i, j;
long i, j, k;
int fps;
if (mdpause)
@ -874,11 +874,45 @@ static void updateanimation (md2model *m, spritetype *tspr)
for (anim = m->animations;
anim && anim->startframe != m->cframe;
anim = anim->next) ;
if (!anim) { m->interpol = 0; return; }
if (!anim) {
if (r_animsmoothing && (spriteext[tspr->owner].mdoldframe != m->cframe))
{
if (spriteext[tspr->owner].mdsmooth == 0)
{
spriteext[tspr->owner].mdanimtims = mdtims;
m->interpol = 0;
spriteext[tspr->owner].mdsmooth = 1;
spriteext[tspr->owner].mdcurframe = m->cframe;
}
if (r_animsmoothing && (spriteext[tspr->owner].mdcurframe != m->cframe))
{
spriteext[tspr->owner].mdanimtims = mdtims;
m->interpol = 0;
spriteext[tspr->owner].mdsmooth = 1;
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
spriteext[tspr->owner].mdcurframe = m->cframe;
}
}
else if (r_animsmoothing && (spriteext[tspr->owner].mdcurframe != m->cframe))
{
spriteext[tspr->owner].mdanimtims = mdtims;
m->interpol = 0;
spriteext[tspr->owner].mdsmooth = 1;
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
spriteext[tspr->owner].mdcurframe = m->cframe;
}
else
{
m->interpol = 0;
return;
}
}
if (((long)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
if (anim && ((long)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
(spriteext[tspr->owner].flags & SPREXT_NOMDANIM))
{
if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n");
OSD_Printf("smooth launched ! oldanim %i new anim %i\n", spriteext[tspr->owner].mdanimcur, anim->startframe);
spriteext[tspr->owner].mdanimcur = (short)anim->startframe;
spriteext[tspr->owner].mdanimtims = mdtims;
m->interpol = 0;
@ -887,44 +921,60 @@ if (!anim) { m->interpol = 0; return; }
m->cframe = m->nframe = anim->startframe;
return;
}
m->nframe = anim->startframe;
m->cframe = spriteext[tspr->owner].mdoldframe;
spriteext[tspr->owner].mdsmooth = 1;
return;
}
if (spriteext[tspr->owner].mdsmooth)
fps = anim->fpssc / r_animsmoothing;
fps = ((anim) ? anim->fpssc : 1500) / r_animsmoothing;
else
fps = anim->fpssc;
i = (mdtims-spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120);
j = ((anim->endframe+1-anim->startframe)<<16);
if (anim)
j = ((anim->endframe+1-anim->startframe)<<16);
else
j = 65535;
//Just in case you play the game for a VERY long time...
if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; }
//compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT
if ((i >= j+j) && (fps)) //Keep mdanimtims close to mdtims to avoid the use of MOD
if ((anim) && (i >= j+j) && (fps)) //Keep mdanimtims close to mdtims to avoid the use of MOD
spriteext[tspr->owner].mdanimtims += j/((fps*timerticspersec)/120);
if (anim->flags&MDANIM_ONESHOT)
k = i;
if (anim && (anim->flags&MDANIM_ONESHOT))
{ if (i > j-65536) i = j-65536; }
else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
if (r_animsmoothing)
if (r_animsmoothing && spriteext[tspr->owner].mdsmooth)
{
m->nframe = (i>>16)+anim->startframe;
if (m->nframe != spriteext[tspr->owner].mdcurframe)
{
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
spriteext[tspr->owner].mdcurframe = m->nframe;
}
m->nframe = (anim) ? anim->startframe : spriteext[tspr->owner].mdcurframe;
m->cframe = spriteext[tspr->owner].mdoldframe;
if (m->nframe > anim->startframe)
//OSD_Printf("smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
if (k > 65535)
{
spriteext[tspr->owner].mdanimtims = mdtims;
m->interpol = 0;
spriteext[tspr->owner].mdsmooth = 0;
m->cframe = m->nframe = (anim) ? anim->startframe : spriteext[tspr->owner].mdcurframe;
spriteext[tspr->owner].mdoldframe = m->cframe;
//OSD_Printf("smooth stopped !\n");
return;
}
}
else
{
m->cframe = (i>>16)+anim->startframe;
m->nframe = m->cframe+1; if (m->nframe > anim->endframe) m->nframe = anim->startframe;
spriteext[tspr->owner].mdoldframe = m->cframe;
//OSD_Printf("not smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
}
m->interpol = ((float)(i&65535))/65536.f;
//OSD_Printf("interpol %f\n", m->interpol);
}
// VBO generation and allocation

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Version="8.00"
Name="eduke32"
ProjectGUID="{8E7A6179-0B72-4073-8A4C-E8682D481DAE}"
RootNamespace="eduke32"
@ -44,11 +44,11 @@
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="nmake /f Makefile.msvc DEBUG=1 NOASM=1"
ReBuildCommandLine="nmake /f Makefile.msvc veryclean all DEBUG=1 NOASM=1"
BuildCommandLine="nmake /f Makefile.msvc DEBUG=1"
ReBuildCommandLine="nmake /f Makefile.msvc veryclean all DEBUG=1"
CleanCommandLine="nmake /f Makefile.msvc veryclean"
Output="eduke32.exe"
PreprocessorDefinitions="WIN32;_DEBUG;SUPERBUILD;POLYMOST;USE_OPENGL;NOCOPYPROTECT;RENDERTYPEWIN;NOASM;ENGINE_USING_A_C"
PreprocessorDefinitions="WIN32;_DEBUG;SUPERBUILD;POLYMOST;USE_OPENGL;NOCOPYPROTECT;RENDERTYPEWIN"
IncludeSearchPath=""
ForcedIncludes=""
AssemblySearchPath=""
@ -694,11 +694,11 @@
>
</File>
<File
RelativePath=".\source\jmact\develop.h"
RelativePath=".\source\develop.h"
>
</File>
<File
RelativePath=".\source\develop.h"
RelativePath=".\source\jmact\develop.h"
>
</File>
<File