- Blood: Extend 99508e6f15 to find picnum of previous frame in all previous frame's tile indices if the current frame's tile index doesn't match.

* Allows more interpolation magic.
* Revealed an issue with `interpolatedanglef()` that was undetected. Removed in place of a binangle version returned as floating point build.
This commit is contained in:
Mitchell Richters 2021-07-29 19:22:52 +10:00
parent 019922dcf1
commit a67c126129
2 changed files with 14 additions and 8 deletions

View file

@ -387,11 +387,6 @@ inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, int const
return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, scale);
}
inline double interpolatedanglef(double oang, double ang, double const smoothratio, int const scale = 16)
{
return oang + MulScaleF(fmod((ang + 1024. - oang), 2048.) - 1024., smoothratio, scale);
}
inline constexpr binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16)
{
return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, int(smoothratio), scale));

View file

@ -96,21 +96,32 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b
for (int i = 0; i < 8; i++)
{
auto* thisTile = &thisFrame->tiles[i];
auto* prevTile = &prevFrame->tiles[i];
if (thisTile->picnum > 0)
{
TILE_FRAME *prevTile = nullptr;
if (thisTile->picnum == prevFrame->tiles[i].picnum)
{
prevTile = &prevFrame->tiles[i];
}
else for (int j = 0; j < 8; j++) if (thisTile->picnum == prevFrame->tiles[j].picnum)
{
prevTile = &prevFrame->tiles[j];
break;
}
double tileX = x;
double tileY = y;
double tileZ;
double tileA;
if ((nFrames > 1) && (nFrame != oFrame) && (thisTile->picnum == prevTile->picnum) && (smoothratio != MaxSmoothRatio))
if ((nFrames > 1) && (nFrame != oFrame) && (prevTile && (thisTile->picnum == prevTile->picnum)) && (smoothratio != MaxSmoothRatio))
{
tileX += interpolatedvaluef(prevTile->x, thisTile->x, smoothratio);
tileY += interpolatedvaluef(prevTile->y, thisTile->y, smoothratio);
tileZ = interpolatedvaluef(prevTile->z, thisTile->z, smoothratio);
tileA = interpolatedanglef(prevTile->angle, thisTile->angle, smoothratio);
tileA = interpolatedangle(buildang(prevTile->angle), buildang(thisTile->angle), smoothratio).asbuildf();
}
else
{