- Duke: Replace all uses of binangle with DAngle objects.

This commit is contained in:
Mitchell Richters 2022-08-27 18:24:16 +10:00 committed by Christoph Oelckers
parent aee102ba73
commit 0b33f39fcd
5 changed files with 34 additions and 21 deletions

View file

@ -434,6 +434,18 @@ inline constexpr binangle interpolatedangle(binangle oang, binangle ang, int con
return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale)); return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale));
} }
// FIXME: Can't rely on overloading this to functions we're trying to deprecate. OK for now.
inline constexpr DAngle interpolatedangle(DAngle oang, DAngle ang, double const smoothratio, int const scale = 16)
{
return DAngle::fromBam(interpolatedangle(bamang(oang.BAMs()), bamang(ang.BAMs()), int(smoothratio), scale).asbam());
}
// FIXME: Can't rely on overloading this to functions we're trying to deprecate. OK for now.
inline constexpr DAngle interpolatedangle(DAngle oang, DAngle ang, int const smoothratio, int const scale = 16)
{
return DAngle::fromBam(interpolatedangle(bamang(oang.BAMs()), bamang(ang.BAMs()), smoothratio, scale).asbam());
}
inline constexpr fixedhoriz interpolatedhorizon(fixedhoriz oval, fixedhoriz val, double const smoothratio, int const scale = 16) inline constexpr fixedhoriz interpolatedhorizon(fixedhoriz oval, fixedhoriz val, double const smoothratio, int const scale = 16)
{ {
return q16horiz(oval.asq16() + MulScale((val - oval).asq16(), int(smoothratio), scale)); return q16horiz(oval.asq16() + MulScale((val - oval).asq16(), int(smoothratio), scale));

View file

@ -237,7 +237,8 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4])
void drawoverlays(double smoothratio) void drawoverlays(double smoothratio)
{ {
player_struct* pp; player_struct* pp;
int cposx, cposy, cang; int cposx, cposy;
DAngle cang;
pp = &ps[screenpeek]; pp = &ps[screenpeek];
// set palette here, in case the 3D view is off. // set palette here, in case the 3D view is off.
@ -275,22 +276,22 @@ void drawoverlays(double smoothratio)
{ {
cposx = interpolatedvalue(omyx, myx, smoothratio); cposx = interpolatedvalue(omyx, myx, smoothratio);
cposy = interpolatedvalue(omyy, myy, smoothratio); cposy = interpolatedvalue(omyy, myy, smoothratio);
cang = (!SyncInput() ? myang : interpolatedangle(omyang, myang, smoothratio)).asbuild(); cang = !SyncInput() ? myang : interpolatedangle(omyang, myang, smoothratio);
} }
else else
{ {
cposx = interpolatedvalue(pp->player_int_opos().X, pp->player_int_pos().X, smoothratio); cposx = interpolatedvalue(pp->player_int_opos().X, pp->player_int_pos().X, smoothratio);
cposy = interpolatedvalue(pp->player_int_opos().Y, pp->player_int_pos().Y, smoothratio); cposy = interpolatedvalue(pp->player_int_opos().Y, pp->player_int_pos().Y, smoothratio);
cang = (!SyncInput() ? pp->angle.ang : interpolatedangle(pp->angle.oang, pp->angle.ang, smoothratio)).asbuild(); cang = DAngle::fromBam((!SyncInput() ? pp->angle.ang : interpolatedangle(pp->angle.oang, pp->angle.ang, smoothratio)).asbam());
} }
} }
else else
{ {
cposx = pp->player_int_opos().X; cposx = pp->player_int_opos().X;
cposy = pp->player_int_opos().Y; cposy = pp->player_int_opos().Y;
cang = pp->angle.oang.asbuild(); cang = DAngle::fromBam(pp->angle.oang.asbam());
} }
DrawOverheadMap(cposx, cposy, cang, smoothratio); DrawOverheadMap(cposx, cposy, cang.Buildang(), smoothratio);
RestoreInterpolations(); RestoreInterpolations();
} }
} }

View file

@ -38,7 +38,7 @@ BEGIN_DUKE_NS
int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel;
int globalskillsound; int globalskillsound;
binangle myang, omyang; DAngle myang, omyang;
fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff;
int mycursectnum, myjumpingcounter; int mycursectnum, myjumpingcounter;
uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
@ -54,7 +54,7 @@ void resetmys()
myy = omyy = ps[myconnectindex].pos.Y; myy = omyy = ps[myconnectindex].pos.Y;
myz = omyz = ps[myconnectindex].pos.Z; myz = omyz = ps[myconnectindex].pos.Z;
myxvel = myyvel = myzvel = 0; myxvel = myyvel = myzvel = 0;
myang = ps[myconnectindex].angle.ang; myang = DAngle::fromBam(ps[myconnectindex].angle.ang.asbam());
myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz;
myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff; myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff;
mycursectnum = sectnum(ps[myconnectindex].cursector); mycursectnum = sectnum(ps[myconnectindex].cursector);

View file

@ -5,7 +5,7 @@ BEGIN_DUKE_NS
extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel;
extern int globalskillsound; extern int globalskillsound;
extern int mycursectnum, myjumpingcounter; extern int mycursectnum, myjumpingcounter;
extern binangle myang, omyang; extern DAngle myang, omyang;
extern fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; extern fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff;
extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter;
extern int fakemovefifoplc; extern int fakemovefifoplc;

View file

@ -59,10 +59,10 @@ BEGIN_DUKE_NS
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, binangle a, fixedhoriz h, binangle rotscrnang, double smoothratio, bool sceneonly, float fov) void renderView(DDukeActor* playersprite, sectortype* sect, int x, int y, int z, DAngle a, fixedhoriz h, DAngle rotscrnang, double smoothratio, bool sceneonly, float fov)
{ {
if (!sceneonly) drawweapon(smoothratio); if (!sceneonly) drawweapon(smoothratio);
render_drawrooms(playersprite, { x, y, z }, sectnum(sect), DAngle::fromBam(a.asbam()), h, DAngle::fromBam(rotscrnang.asbam()), smoothratio, fov); render_drawrooms(playersprite, { x, y, z }, sectnum(sect), a, h, rotscrnang, smoothratio, fov);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -223,7 +223,7 @@ static int getdrugmode(player_struct *p, int oyrepeat)
void displayrooms(int snum, double smoothratio, bool sceneonly) void displayrooms(int snum, double smoothratio, bool sceneonly)
{ {
int cposx, cposy, cposz, fz, cz; int cposx, cposy, cposz, fz, cz;
binangle cang, rotscrnang; DAngle cang, rotscrnang;
fixedhoriz choriz; fixedhoriz choriz;
player_struct* p; player_struct* p;
@ -258,12 +258,12 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
if (act->spr.yvel < 0) act->spr.yvel = -100; if (act->spr.yvel < 0) act->spr.yvel = -100;
else if (act->spr.yvel > 199) act->spr.yvel = 300; else if (act->spr.yvel > 199) act->spr.yvel = 300;
cang = buildang(interpolatedangle(ud.cameraactor->tempang, act->int_ang(), smoothratio)); cang = DAngle::fromBuild(interpolatedangle(ud.cameraactor->tempang, act->int_ang(), smoothratio));
auto bh = buildhoriz(act->spr.yvel); auto bh = buildhoriz(act->spr.yvel);
auto cstat = act->spr.cstat; auto cstat = act->spr.cstat;
act->spr.cstat = CSTAT_SPRITE_INVISIBLE; act->spr.cstat = CSTAT_SPRITE_INVISIBLE;
renderView(act, act->sector(), act->int_pos().X, act->int_pos().Y, act->int_pos().Z - (4 << 8), cang, bh, buildang(0), smoothratio, sceneonly, fov); renderView(act, act->sector(), act->int_pos().X, act->int_pos().Y, act->int_pos().Z - (4 << 8), cang, bh, DAngle::fromDeg(0.), smoothratio, sceneonly, fov);
act->spr.cstat = cstat; act->spr.cstat = cstat;
} }
@ -281,7 +281,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
setgamepalette(setpal(p)); setgamepalette(setpal(p));
// set screen rotation. // set screen rotation.
rotscrnang = !SyncInput() ? p->angle.rotscrnang : p->angle.interpolatedrotscrn(smoothratio); rotscrnang = DAngle::fromBam((!SyncInput() ? p->angle.rotscrnang : p->angle.interpolatedrotscrn(smoothratio)).asbam());
#if 0 #if 0
if ((snum == myconnectindex) && (numplayers > 1)) if ((snum == myconnectindex) && (numplayers > 1))
@ -310,13 +310,13 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
if (SyncInput()) if (SyncInput())
{ {
// Original code for when the values are passed through the sync struct // Original code for when the values are passed through the sync struct
cang = DAngle::fromBam(p->angle.interpolatedsum(smoothratio).asbam());
choriz = p->horizon.interpolatedsum(smoothratio); choriz = p->horizon.interpolatedsum(smoothratio);
cang = p->angle.interpolatedsum(smoothratio);
} }
else else
{ {
// This is for real time updating of the view direction. // This is for real time updating of the view direction.
cang = p->angle.sum(); cang = DAngle::fromBam(p->angle.sum().asbam());
choriz = p->horizon.sum(); choriz = p->horizon.sum();
} }
} }
@ -326,13 +326,13 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
if (p->newOwner != nullptr) if (p->newOwner != nullptr)
{ {
auto act = p->newOwner; auto act = p->newOwner;
cang = buildang(act->interpolatedang(smoothratio)); cang = DAngle::fromBuild(act->interpolatedang(smoothratio));
choriz = buildhoriz(act->spr.shade); choriz = buildhoriz(act->spr.shade);
cposx = act->int_pos().X; cposx = act->int_pos().X;
cposy = act->int_pos().Y; cposy = act->int_pos().Y;
cposz = act->int_pos().Z; cposz = act->int_pos().Z;
sect = act->sector(); sect = act->sector();
rotscrnang = buildang(0); rotscrnang = DAngle::fromDeg(0.);
smoothratio = MaxSmoothRatio; smoothratio = MaxSmoothRatio;
viewer = act; viewer = act;
camview = true; camview = true;
@ -347,10 +347,10 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
cposz -= isRR() ? 3840 : 3072; cposz -= isRR() ? 3840 : 3072;
viewer = p->GetActor(); viewer = p->GetActor();
if (!calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, DAngle::fromBam(cang.asbam()), choriz, smoothratio)) if (!calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, cang, choriz, smoothratio))
{ {
cposz += isRR() ? 3840 : 3072; cposz += isRR() ? 3840 : 3072;
calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, DAngle::fromBam(cang.asbam()), choriz, smoothratio); calcChaseCamPos(&cposx, &cposy, &cposz, viewer, &sect, cang, choriz, smoothratio);
} }
} }
@ -360,7 +360,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly)
if (earthquaketime > 0 && p->on_ground == 1) if (earthquaketime > 0 && p->on_ground == 1)
{ {
cposz += 256 - (((earthquaketime) & 1) << 9); cposz += 256 - (((earthquaketime) & 1) << 9);
cang += buildang((2 - ((earthquaketime) & 2)) << 2); cang += DAngle::fromBuild((2 - ((earthquaketime) & 2)) << 2);
} }
if (p->GetActor()->spr.pal == 1) cposz -= (18 << 8); if (p->GetActor()->spr.pal == 1) cposz -= (18 << 8);