Interpolate bob angle

This commit is contained in:
nukeykt 2019-11-09 01:55:26 +09:00 committed by Christoph Oelckers
parent aff6ef67c0
commit 688fa2e778
7 changed files with 19 additions and 9 deletions

View file

@ -2082,6 +2082,8 @@ static void GameMove(void)
// YELLOW SECTION
MoveThings();
obobangle = bobangle;
if (totalvel[nLocalPlayer] == 0)
{
bobangle = 0;

View file

@ -662,7 +662,7 @@ loc_flag:
}
if (nPlayer == nLocalPlayer) {
bobangle = 512;
obobangle = bobangle = 512;
}
if (nWeapon == kWeaponFlamer && (!(nSectFlag & kSectUnderwater)))
@ -911,7 +911,7 @@ loc_flag:
}
}
void DrawWeapons()
void DrawWeapons(int smooth)
{
if (bCamera) {
return;
@ -947,18 +947,19 @@ void DrawWeapons()
int nVal = totalvel[nLocalPlayer] >> 1;
// CHECKME - not & 0x7FF?
int yOffset = (nVal * (sintable[bobangle & 0x3FF] >> 8)) >> 9;
int nBobAngle = angle_interpolate16(obobangle, bobangle, smooth);
int yOffset = (nVal * (sintable[nBobAngle & 0x3FF] >> 8)) >> 9;
int xOffset = 0;
if (var_34 == 1)
{
xOffset = ((Sin(bobangle + 512) >> 8) * nVal) >> 8;
xOffset = ((Sin(nBobAngle + 512) >> 8) * nVal) >> 8;
}
else
{
xOffset = 0;
bobangle = 512;
obobangle = bobangle = 512;
}
if (nWeapon == 3 && var_34 == 1) {

View file

@ -45,6 +45,6 @@ void StopFiringWeapon(short nPlayer);
void FireWeapon(short nPlayer);
void CheckClip(short nPlayer);
void MoveWeapons(short nPlayer);
void DrawWeapons();
void DrawWeapons(int smooth);
#endif

View file

@ -47,7 +47,7 @@ struct PlayerSave
fix16_t lPlayerXVel = 0;
fix16_t lPlayerYVel = 0;
fix16_t nPlayerDAng = 0;
short bobangle = 0;
short obobangle = 0, bobangle = 0;
short bPlayerPan = 0;
short bLockPan = 0;

View file

@ -86,7 +86,7 @@ extern short nPlayerScore[];
extern short nPlayerClip[];
extern short bobangle;
extern short obobangle, bobangle;
extern int totalvel[];
extern int16_t eyelevel[], oeyelevel[];

View file

@ -574,7 +574,7 @@ void DrawView(int smoothRatio)
{
if (nSnakeCam < 0)
{
DrawWeapons();
DrawWeapons(smoothRatio);
DrawStatus();
}
else

View file

@ -2,6 +2,8 @@
#ifndef __view_h__
#define __view_h__
#include "build.h"
extern short bSubTitles;
extern short nViewTop;
extern short bClip;
@ -39,4 +41,9 @@ extern short bTouchFloor;
extern short nChunkTotal;
static inline int angle_interpolate16(int a, int b, int smooth)
{
return a + mulscale16(((b+1024-a)&2047)-1024, smooth);
}
#endif