- SW: Increase precision of x/y coordinates where possible.

This commit is contained in:
Mitchell Richters 2020-08-18 17:50:26 +10:00
parent d79c61d559
commit 5cc30ad7c6
4 changed files with 193 additions and 179 deletions

View file

@ -50,6 +50,19 @@ int FindDistance2D(int x, int y)
return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6)); return (x - (x>>5) - (x>>7) + (t>>2) + (t>>6));
} }
double fFindDistance2D(int x, int y)
{
x= abs(x); /* absolute values */
y= abs(y);
if (x<y)
std::swap(x,y);
double t = y + (y / 2.);
return (x - (x / 32.) - (x / 128.) + (t / 4.) + (t / 64.));
}
int FindDistance3D(int x, int y, int z) int FindDistance3D(int x, int y, int z)
{ {

View file

@ -1,4 +1,5 @@
#pragma once #pragma once
int FindDistance2D(int x, int y); int FindDistance2D(int x, int y);
double fFindDistance2D(int x, int y);
int FindDistance3D(int x, int y, int z); int FindDistance3D(int x, int y, int z);

View file

@ -1020,25 +1020,25 @@ pSwordPresent(PANEL_SPRITEp psp)
void void
pSwordSlide(PANEL_SPRITEp psp) pSwordSlide(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel_adj; short vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnSwordBlur(psp); SpawnSwordBlur(psp);
vel_adj = 24; vel_adj = 24;
nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
ny += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; ny += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
} }
@ -1046,26 +1046,26 @@ pSwordSlide(PANEL_SPRITEp psp)
void void
pSwordSlideDown(PANEL_SPRITEp psp) pSwordSlideDown(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel, vel_adj; short vel, vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnSwordBlur(psp); SpawnSwordBlur(psp);
vel_adj = 20; vel_adj = 20;
vel = 2500; vel = 2500;
nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(SwordAng + psp->ang + psp->PlayerP->SwordAng + 512)] >> 6; nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(SwordAng + psp->ang + psp->PlayerP->SwordAng + 512)) / 64.;
ny += psp->vel * synctics * (int) -sintable[NORM_ANGLE(SwordAng + psp->ang + psp->PlayerP->SwordAng)] >> 6; ny += psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(SwordAng + psp->ang + psp->PlayerP->SwordAng)) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
@ -1106,25 +1106,25 @@ pSwordSlideDown(PANEL_SPRITEp psp)
void void
pSwordSlideR(PANEL_SPRITEp psp) pSwordSlideR(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel_adj; short vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnSwordBlur(psp); SpawnSwordBlur(psp);
vel_adj = 24; vel_adj = 24;
nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 1024 + 512)] >> 6; nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 1024 + 512)) / 64.;
ny += psp->vel * synctics * (int) -sintable[NORM_ANGLE(psp->ang + 1024)] >> 6; ny += psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(psp->ang + 1024)) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
} }
@ -1132,26 +1132,26 @@ pSwordSlideR(PANEL_SPRITEp psp)
void void
pSwordSlideDownR(PANEL_SPRITEp psp) pSwordSlideDownR(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel, vel_adj; short vel, vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnSwordBlur(psp); SpawnSwordBlur(psp);
vel_adj = 24; vel_adj = 24;
vel = 2500; vel = 2500;
nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(SwordAng + psp->ang - psp->PlayerP->SwordAng + 1024 + 512)] >> 6; nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(SwordAng + psp->ang - psp->PlayerP->SwordAng + 1024 + 512)) / 64.;
ny += psp->vel * synctics * (int) -sintable[NORM_ANGLE(SwordAng + psp->ang - psp->PlayerP->SwordAng + 1024)] >> 6; ny += psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(SwordAng + psp->ang - psp->PlayerP->SwordAng + 1024)) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
@ -1196,7 +1196,7 @@ pSwordBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = SWORD_SWAY_AMT; psp->sin_amt = SWORD_SWAY_AMT;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -1483,7 +1483,7 @@ pStarBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 10; psp->sin_amt = 10;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -1497,7 +1497,7 @@ pLStarBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 6; psp->sin_amt = 6;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 4; psp->bob_height_divider = 16;
} }
void void
@ -1867,17 +1867,17 @@ pSpawnUziReload(PANEL_SPRITEp oclip)
void void
pUziReload(PANEL_SPRITEp nclip) pUziReload(PANEL_SPRITEp nclip)
{ {
int nx, ny; double nx, ny;
int x = FIXED(nclip->x, nclip->xfract); double x = xs_CRoundToInt(nclip->x * (double)(FRACUNIT)) | nclip->xfract;
int y = FIXED(nclip->y, nclip->yfract); double y = xs_CRoundToInt(nclip->y * (double)(FRACUNIT)) | nclip->yfract;
PANEL_SPRITEp gun = nclip->sibling; PANEL_SPRITEp gun = nclip->sibling;
int xgun = FIXED(gun->x, gun->xfract); double xgun = xs_CRoundToInt(gun->x * (double)(FRACUNIT)) | gun->xfract;
int ygun = FIXED(gun->y, gun->yfract); double ygun = xs_CRoundToInt(gun->y * (double)(FRACUNIT)) | gun->yfract;
nx = nclip->vel * synctics * (int) sintable[NORM_ANGLE(nclip->ang + 512)] >> 6; nx = nclip->vel * synctics * calcSinTableValue(NORM_ANGLE(nclip->ang + 512)) / 64.;
ny = nclip->vel * synctics * (int) -sintable[nclip->ang] >> 6; ny = nclip->vel * synctics * -calcSinTableValue(nclip->ang) / 64.;
nclip->vel += 14 * synctics; nclip->vel += 14 * synctics;
@ -1888,12 +1888,12 @@ pUziReload(PANEL_SPRITEp nclip)
nclip->oy = nclip->y; nclip->oy = nclip->y;
nclip->xfract = LSW(x); nclip->xfract = LSW(x);
nclip->x = MSW(x); nclip->x = x / (double)(FRACUNIT);
nclip->yfract = LSW(y); nclip->yfract = LSW(y);
nclip->y = MSW(y); nclip->y = y / (double)(FRACUNIT);
nx = gun->vel * synctics * (int) sintable[NORM_ANGLE(gun->ang + 512)] >> 6; nx = gun->vel * synctics * calcSinTableValue(NORM_ANGLE(gun->ang + 512)) / 64.;
ny = gun->vel * synctics * (int) -sintable[gun->ang] >> 6; ny = gun->vel * synctics * -calcSinTableValue(gun->ang) / 64.;
xgun -= nx; xgun -= nx;
ygun -= ny; ygun -= ny;
@ -1902,9 +1902,9 @@ pUziReload(PANEL_SPRITEp nclip)
gun->oy = gun->y; gun->oy = gun->y;
gun->xfract = LSW(xgun); gun->xfract = LSW(xgun);
gun->x = MSW(xgun); gun->x = xgun / (double)(FRACUNIT);
gun->yfract = LSW(ygun); gun->yfract = LSW(ygun);
gun->y = MSW(ygun); gun->y = ygun / (double)(FRACUNIT);
if (TEST(nclip->flags, PANF_XFLIP)) if (TEST(nclip->flags, PANF_XFLIP))
{ {
@ -1939,17 +1939,17 @@ pUziReload(PANEL_SPRITEp nclip)
void void
pUziReloadRetract(PANEL_SPRITEp nclip) pUziReloadRetract(PANEL_SPRITEp nclip)
{ {
int nx, ny; double nx, ny;
int x = FIXED(nclip->x, nclip->xfract); double x = xs_CRoundToInt(nclip->x * (double)(FRACUNIT)) | nclip->xfract;
int y = FIXED(nclip->y, nclip->yfract); double y = xs_CRoundToInt(nclip->y * (double)(FRACUNIT)) | nclip->yfract;
PANEL_SPRITEp gun = nclip->sibling; PANEL_SPRITEp gun = nclip->sibling;
int xgun = FIXED(gun->x, gun->xfract); double xgun = xs_CRoundToInt(gun->x * (double)(FRACUNIT)) | gun->xfract;
int ygun = FIXED(gun->y, gun->yfract); double ygun = xs_CRoundToInt(gun->y * (double)(FRACUNIT)) | gun->yfract;
nx = nclip->vel * synctics * (int) sintable[NORM_ANGLE(nclip->ang + 512)] >> 6; nx = nclip->vel * synctics * calcSinTableValue(NORM_ANGLE(nclip->ang + 512)) / 64.;
ny = nclip->vel * synctics * (int) -sintable[nclip->ang] >> 6; ny = nclip->vel * synctics * -calcSinTableValue(nclip->ang) / 64.;
nclip->vel += 18 * synctics; nclip->vel += 18 * synctics;
@ -1960,9 +1960,9 @@ pUziReloadRetract(PANEL_SPRITEp nclip)
nclip->oy = nclip->y; nclip->oy = nclip->y;
nclip->xfract = LSW(x); nclip->xfract = LSW(x);
nclip->x = MSW(x); nclip->x = x / (double)(FRACUNIT);
nclip->yfract = LSW(y); nclip->yfract = LSW(y);
nclip->y = MSW(y); nclip->y = y / (double)(FRACUNIT);
xgun -= nx; xgun -= nx;
ygun -= ny; ygun -= ny;
@ -1971,9 +1971,9 @@ pUziReloadRetract(PANEL_SPRITEp nclip)
gun->oy = gun->y; gun->oy = gun->y;
gun->xfract = LSW(xgun); gun->xfract = LSW(xgun);
gun->x = MSW(xgun); gun->x = xgun / (double)(FRACUNIT);
gun->yfract = LSW(ygun); gun->yfract = LSW(ygun);
gun->y = MSW(ygun); gun->y = ygun / (double)(FRACUNIT);
if (gun->y > UZI_RELOAD_YOFF + tilesiz[gun->picndx].y) if (gun->y > UZI_RELOAD_YOFF + tilesiz[gun->picndx].y)
{ {
@ -2030,15 +2030,15 @@ pUziDoneReload(PANEL_SPRITEp psp)
void void
pUziClip(PANEL_SPRITEp oclip) pUziClip(PANEL_SPRITEp oclip)
{ {
int nx, ny, ox, oy; double nx, ny, ox, oy;
int x = FIXED(oclip->x, oclip->xfract); double x = xs_CRoundToInt(oclip->x * (double)(FRACUNIT)) | oclip->xfract;
int y = FIXED(oclip->y, oclip->yfract); double y = xs_CRoundToInt(oclip->y * (double)(FRACUNIT)) | oclip->yfract;
ox = x; ox = x;
oy = y; oy = y;
nx = oclip->vel * synctics * (int) sintable[NORM_ANGLE(oclip->ang + 512)] >> 6; nx = oclip->vel * synctics * calcSinTableValue(NORM_ANGLE(oclip->ang + 512)) / 64.;
ny = oclip->vel * synctics * (int) -sintable[oclip->ang] >> 6; ny = oclip->vel * synctics * -calcSinTableValue(oclip->ang) / 64.;
oclip->vel += 16 * synctics; oclip->vel += 16 * synctics;
@ -2046,9 +2046,9 @@ pUziClip(PANEL_SPRITEp oclip)
y += ny; y += ny;
oclip->xfract = LSW(x); oclip->xfract = LSW(x);
oclip->x = MSW(x); oclip->x = x / (double)(FRACUNIT);
oclip->yfract = LSW(y); oclip->yfract = LSW(y);
oclip->y = MSW(y); oclip->y = y / (double)(FRACUNIT);
if (oclip->y > UZI_RELOAD_YOFF) if (oclip->y > UZI_RELOAD_YOFF)
{ {
@ -2059,14 +2059,14 @@ pUziClip(PANEL_SPRITEp oclip)
// so it will end up the same for all synctic values // so it will end up the same for all synctic values
for (x = ox, y = oy; oclip->y < UZI_RELOAD_YOFF; ) for (x = ox, y = oy; oclip->y < UZI_RELOAD_YOFF; )
{ {
x += oclip->vel * (int) sintable[NORM_ANGLE(oclip->ang + 512)] >> 6; x += oclip->vel * calcSinTableValue(NORM_ANGLE(oclip->ang + 512)) / 64.;
y += oclip->vel * (int) -sintable[oclip->ang] >> 6; y += oclip->vel * -calcSinTableValue(oclip->ang) / 64.;
} }
oclip->xfract = LSW(x); oclip->xfract = LSW(x);
oclip->x = MSW(x); oclip->x = x / (double)(FRACUNIT);
oclip->yfract = LSW(y); oclip->yfract = LSW(y);
oclip->y = MSW(y); oclip->y = y / (double)(FRACUNIT);
oclip->y = UZI_RELOAD_YOFF; oclip->y = UZI_RELOAD_YOFF;
@ -2281,7 +2281,7 @@ pUziBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -2581,7 +2581,7 @@ pUziShell(PANEL_SPRITEp psp)
// get height // get height
psp->oy = psp->y = psp->yorig; psp->oy = psp->y = psp->yorig;
psp->y += psp->sin_amt * -sintable[psp->sin_ndx] >> 14; psp->y += psp->sin_amt * -calcSinTableValue(psp->sin_ndx) / 16384.;
// if off of the screen kill them // if off of the screen kill them
if (psp->x > 330 || psp->x < -10) if (psp->x > 330 || psp->x < -10)
@ -2638,7 +2638,7 @@ pShotgunShell(PANEL_SPRITEp psp)
psp->ox = psp->x; psp->ox = psp->x;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
if (psp->x > 320 || psp->x < 0 || psp->y > 200) if (psp->x > 320 || psp->x < 0 || psp->y > 200)
{ {
@ -2823,24 +2823,24 @@ pShotgunRecoilDown(PANEL_SPRITEp psp)
{ {
int targetvel; int targetvel;
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
if (psp->PlayerP->WpnShotgunType == 1) if (psp->PlayerP->WpnShotgunType == 1)
targetvel = 890; targetvel = 890;
else else
targetvel = 780; targetvel = 780;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel -= 24 * synctics; psp->vel -= 24 * synctics;
@ -2856,19 +2856,19 @@ pShotgunRecoilDown(PANEL_SPRITEp psp)
void void
pShotgunRecoilUp(PANEL_SPRITEp psp) pShotgunRecoilUp(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel += 15 * synctics; psp->vel += 15 * synctics;
@ -2955,7 +2955,7 @@ pShotgunBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
SWBOOL SWBOOL
@ -3333,19 +3333,19 @@ pRailSetRecoil(PANEL_SPRITEp psp)
void void
pRailRecoilDown(PANEL_SPRITEp psp) pRailRecoilDown(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel -= 24 * synctics; psp->vel -= 24 * synctics;
@ -3361,19 +3361,19 @@ pRailRecoilDown(PANEL_SPRITEp psp)
void void
pRailRecoilUp(PANEL_SPRITEp psp) pRailRecoilUp(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel += 15 * synctics; psp->vel += 15 * synctics;
@ -3422,7 +3422,7 @@ pRailBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -3846,7 +3846,7 @@ pHotheadBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = HOTHEAD_BOB_X_AMT; psp->sin_amt = HOTHEAD_BOB_X_AMT;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 2; psp->bob_height_divider = 4;
} }
void void
@ -4217,19 +4217,19 @@ InitWeaponMicro(PLAYERp pp)
void void
pMicroRecoilDown(PANEL_SPRITEp psp) pMicroRecoilDown(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel -= 24 * synctics; psp->vel -= 24 * synctics;
@ -4245,19 +4245,19 @@ pMicroRecoilDown(PANEL_SPRITEp psp)
void void
pMicroRecoilUp(PANEL_SPRITEp psp) pMicroRecoilUp(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel += 15 * synctics; psp->vel += 15 * synctics;
@ -4314,7 +4314,7 @@ pMicroBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = MICRO_BOB_X_AMT; psp->sin_amt = MICRO_BOB_X_AMT;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -4731,7 +4731,7 @@ pHeartBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -4989,7 +4989,7 @@ pHeartBlood(PANEL_SPRITEp psp)
psp->ox = psp->x; psp->ox = psp->x;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
if (psp->x > 320 || psp->x < 0 || psp->y > 200) if (psp->x > 320 || psp->x < 0 || psp->y > 200)
{ {
@ -5039,7 +5039,7 @@ DoPanelJump(PANEL_SPRITEp psp)
psp->oy = psp->y; psp->oy = psp->y;
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
return 0; return 0;
} }
@ -5073,7 +5073,7 @@ DoPanelFall(PANEL_SPRITEp psp)
psp->oy = psp->y; psp->oy = psp->y;
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
return 0; return 0;
} }
@ -5217,19 +5217,19 @@ pGrenadeRecoilDown(PANEL_SPRITEp psp)
{ {
// short picnum = psp->picndx; // short picnum = psp->picndx;
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel -= 24 * synctics; psp->vel -= 24 * synctics;
@ -5248,19 +5248,19 @@ pGrenadeRecoilDown(PANEL_SPRITEp psp)
void void
pGrenadeRecoilUp(PANEL_SPRITEp psp) pGrenadeRecoilUp(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->vel += 15 * synctics; psp->vel += 15 * synctics;
@ -5279,22 +5279,22 @@ pGrenadeRecoilUp(PANEL_SPRITEp psp)
void void
pGrenadePresent(PANEL_SPRITEp psp) pGrenadePresent(PANEL_SPRITEp psp)
{ {
int x = FIXED(psp->x, psp->xfract); double x = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
int y = FIXED(psp->y, psp->yfract); double y = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
if (TEST(psp->PlayerP->Flags, PF_WEAPON_RETRACT)) if (TEST(psp->PlayerP->Flags, PF_WEAPON_RETRACT))
return; return;
x += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang + 512)] >> 6; x += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang + 512)) / 64.;
y += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; y += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(x); psp->xfract = LSW(x);
psp->x = MSW(x); psp->x = x / (double)(FRACUNIT);
psp->yfract = LSW(y); psp->yfract = LSW(y);
psp->y = MSW(y); psp->y = y / (double)(FRACUNIT);
psp->rotate_ang = NORM_ANGLE(psp->rotate_ang + (6 * synctics)); psp->rotate_ang = NORM_ANGLE(psp->rotate_ang + (6 * synctics));
@ -5323,7 +5323,7 @@ pGrenadeBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -5575,7 +5575,7 @@ pMineBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = 12; psp->sin_amt = 12;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -6216,26 +6216,26 @@ pFistPresent(PANEL_SPRITEp psp)
void void
pFistSlide(PANEL_SPRITEp psp) pFistSlide(PANEL_SPRITEp psp)
{ {
//int nx; //double nx;
int ny; double ny;
short vel_adj; short vel_adj;
//nx = FIXED(psp->x, psp->xfract); //nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnFistBlur(psp); SpawnFistBlur(psp);
vel_adj = 68; vel_adj = 68;
//nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang)] >> 6; //nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang)) / 64.;
ny += psp->vel * synctics * (int) -sintable[psp->ang] >> 6; ny += psp->vel * synctics * -calcSinTableValue(psp->ang) / 64.;
//psp->ox = psp->x; //psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
//psp->xfract = LSW(nx); //psp->xfract = LSW(nx);
//psp->x = MSW(nx); //psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
} }
@ -6243,31 +6243,31 @@ pFistSlide(PANEL_SPRITEp psp)
void void
pFistSlideDown(PANEL_SPRITEp psp) pFistSlideDown(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel, vel_adj; short vel, vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnFistBlur(psp); SpawnFistBlur(psp);
vel_adj = 48; vel_adj = 48;
vel = 3500; vel = 3500;
if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3) if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3)
ny += (psp->vel * synctics * (int) -sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6); ny += (psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.);
else else
{ {
nx -= psp->vel * synctics * (int) sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6; nx -= psp->vel * synctics * calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.;
ny += 3*(psp->vel * synctics * (int) -sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6); ny += 3*(psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.);
} }
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
@ -6336,26 +6336,26 @@ pFistSlideDown(PANEL_SPRITEp psp)
void void
pFistSlideR(PANEL_SPRITEp psp) pFistSlideR(PANEL_SPRITEp psp)
{ {
// int nx //double nx
int ny; double ny;
short vel_adj; short vel_adj;
//nx = FIXED(psp->x, psp->xfract); //nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnFistBlur(psp); SpawnFistBlur(psp);
vel_adj = 68; vel_adj = 68;
//nx += psp->vel * synctics * (int) sintable[NORM_ANGLE(psp->ang)] >> 6; //nx += psp->vel * synctics * calcSinTableValue(NORM_ANGLE(psp->ang)) / 64.;
ny += psp->vel * synctics * (int) -sintable[NORM_ANGLE(psp->ang + 1024)] >> 6; ny += psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(psp->ang + 1024)) / 64.;
//psp->ox = psp->x; //psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
//psp->xfract = LSW(nx); //psp->xfract = LSW(nx);
//psp->x = MSW(nx); //psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
} }
@ -6363,31 +6363,31 @@ pFistSlideR(PANEL_SPRITEp psp)
void void
pFistSlideDownR(PANEL_SPRITEp psp) pFistSlideDownR(PANEL_SPRITEp psp)
{ {
int nx, ny; double nx, ny;
short vel, vel_adj; short vel, vel_adj;
nx = FIXED(psp->x, psp->xfract); nx = xs_CRoundToInt(psp->x * (double)(FRACUNIT)) | psp->xfract;
ny = FIXED(psp->y, psp->yfract); ny = xs_CRoundToInt(psp->y * (double)(FRACUNIT)) | psp->yfract;
SpawnFistBlur(psp); SpawnFistBlur(psp);
vel_adj = 48; vel_adj = 48;
vel = 3500; vel = 3500;
if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3) if (psp->ActionState == ps_Kick || psp->PlayerP->WpnKungFuMove == 3)
ny += (psp->vel * synctics * (int) -sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6); ny += (psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.);
else else
{ {
nx -= psp->vel * synctics * (int) sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6; nx -= psp->vel * synctics * calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.;
ny += 3*(psp->vel * synctics * (int) -sintable[NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)] >> 6); ny += 3*(psp->vel * synctics * -calcSinTableValue(NORM_ANGLE(FistAng + psp->ang + psp->PlayerP->FistAng)) / 64.);
} }
psp->ox = psp->x; psp->ox = psp->x;
psp->oy = psp->y; psp->oy = psp->y;
psp->xfract = LSW(nx); psp->xfract = LSW(nx);
psp->x = MSW(nx); psp->x = nx / (double)(FRACUNIT);
psp->yfract = LSW(ny); psp->yfract = LSW(ny);
psp->y = MSW(ny); psp->y = ny / (double)(FRACUNIT);
psp->vel += vel_adj * synctics; psp->vel += vel_adj * synctics;
@ -6453,7 +6453,7 @@ pFistBobSetup(PANEL_SPRITEp psp)
psp->sin_amt = FIST_SWAY_AMT; psp->sin_amt = FIST_SWAY_AMT;
psp->sin_ndx = 0; psp->sin_ndx = 0;
psp->bob_height_shift = 3; psp->bob_height_divider = 8;
} }
void void
@ -6783,14 +6783,14 @@ pClearSpriteList(PLAYERp pp)
void void
pWeaponBob(PANEL_SPRITEp psp, short condition) pWeaponBob(PANEL_SPRITEp psp, short condition)
{ {
int xdiff = 0, ydiff = 0; double xdiff = 0, ydiff = 0;
short bob_amt, bob_ndx; double bob_amt, bob_ndx;
short bobvel; double bobvel;
PLAYERp pp = psp->PlayerP; PLAYERp pp = psp->PlayerP;
bobvel = FindDistance2D(pp->xvect, pp->yvect) >> 15; bobvel = fFindDistance2D(pp->xvect, pp->yvect) / 32768.;
bobvel = bobvel + DIV4(bobvel); bobvel = bobvel + (bobvel / 4.);
bobvel = min(bobvel, short(128)); bobvel = (bobvel < 128 ? bobvel : 128);
if (condition) if (condition)
{ {
@ -6819,7 +6819,7 @@ pWeaponBob(PANEL_SPRITEp psp, short condition)
psp->sin_ndx &= 2047; psp->sin_ndx &= 2047;
// get height // get height
xdiff = psp->sin_amt * sintable[psp->sin_ndx] >> 14; xdiff = psp->sin_amt * calcSinTableValue(psp->sin_ndx) / 16384.;
// // // //
// bob_xxx moves the weapon up-down // bob_xxx moves the weapon up-down
@ -6830,8 +6830,8 @@ pWeaponBob(PANEL_SPRITEp psp, short condition)
bob_ndx = (psp->sin_ndx + 512) & 1023; bob_ndx = (psp->sin_ndx + 512) & 1023;
// base bob_amt on the players velocity - Max of 128 // base bob_amt on the players velocity - Max of 128
bob_amt = bobvel >> psp->bob_height_shift; bob_amt = bobvel / psp->bob_height_divider;
ydiff = bob_amt * sintable[bob_ndx] >> 14; ydiff = bob_amt * calcSinTableValue(bob_ndx) / 16384.;
} }
// Back up current coordinates for interpolating. // Back up current coordinates for interpolating.

View file

@ -110,9 +110,9 @@ struct PANEL_SPRITEstruct
PLAYERp PlayerP; PLAYERp PlayerP;
// Do not change the order of this line // Do not change the order of this line
uint16_t xfract; uint16_t xfract;
int16_t x; double x;
uint16_t yfract; uint16_t yfract;
int16_t y; // Do not change the order of this double y; // Do not change the order of this
// line // line
PANEL_SPRITE_OVERLAY over[8]; PANEL_SPRITE_OVERLAY over[8];
@ -130,13 +130,13 @@ struct PANEL_SPRITEstruct
short tics, delay; // time vars short tics, delay; // time vars
short ang, rotate_ang; short ang, rotate_ang;
short sin_ndx, sin_amt, sin_arc_speed; short sin_ndx, sin_amt, sin_arc_speed;
short bob_height_shift; double bob_height_divider;
short shade, pal; short shade, pal;
short kill_tics; short kill_tics;
short WeaponType; // remember my own weapon type for weapons with secondary function short WeaponType; // remember my own weapon type for weapons with secondary function
// Weapon interpolation variables. // Weapon interpolation variables.
int16_t ox, oy; double ox, oy;
}; };
typedef struct typedef struct