diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 9b0a13db9..54da31135 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -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)); } +// 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) { return q16horiz(oval.asq16() + MulScale((val - oval).asq16(), int(smoothratio), scale)); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 703a2edd2..8a923e8be 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -237,7 +237,8 @@ void V_AddBlend (float r, float g, float b, float a, float v_blend[4]) void drawoverlays(double smoothratio) { player_struct* pp; - int cposx, cposy, cang; + int cposx, cposy; + DAngle cang; pp = &ps[screenpeek]; // set palette here, in case the 3D view is off. @@ -275,22 +276,22 @@ void drawoverlays(double smoothratio) { cposx = interpolatedvalue(omyx, myx, smoothratio); cposy = interpolatedvalue(omyy, myy, smoothratio); - cang = (!SyncInput() ? myang : interpolatedangle(omyang, myang, smoothratio)).asbuild(); + cang = !SyncInput() ? myang : interpolatedangle(omyang, myang, smoothratio); } else { 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); - 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 { cposx = pp->player_int_opos().X; 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(); } } diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 98542e0d4..16efdde08 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -38,7 +38,7 @@ BEGIN_DUKE_NS int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; int globalskillsound; -binangle myang, omyang; +DAngle myang, omyang; fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; int mycursectnum, myjumpingcounter; uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; @@ -54,7 +54,7 @@ void resetmys() myy = omyy = ps[myconnectindex].pos.Y; myz = omyz = ps[myconnectindex].pos.Z; myxvel = myyvel = myzvel = 0; - myang = ps[myconnectindex].angle.ang; + myang = DAngle::fromBam(ps[myconnectindex].angle.ang.asbam()); myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff; mycursectnum = sectnum(ps[myconnectindex].cursector); diff --git a/source/games/duke/src/prediction.h b/source/games/duke/src/prediction.h index 2e0e8f29a..84b21b34a 100644 --- a/source/games/duke/src/prediction.h +++ b/source/games/duke/src/prediction.h @@ -5,7 +5,7 @@ BEGIN_DUKE_NS extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; extern int globalskillsound; extern int mycursectnum, myjumpingcounter; -extern binangle myang, omyang; +extern DAngle myang, omyang; extern fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; extern uint8_t myjumpingtoggle, myonground, myhardlanding,myreturntocenter; extern int fakemovefifoplc; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 84126b104..edb980960 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -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); - 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) { int cposx, cposy, cposz, fz, cz; - binangle cang, rotscrnang; + DAngle cang, rotscrnang; fixedhoriz choriz; player_struct* p; @@ -258,12 +258,12 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) if (act->spr.yvel < 0) act->spr.yvel = -100; 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 cstat = act->spr.cstat; 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; } @@ -281,7 +281,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) setgamepalette(setpal(p)); // 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 ((snum == myconnectindex) && (numplayers > 1)) @@ -310,13 +310,13 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) if (SyncInput()) { // 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); - cang = p->angle.interpolatedsum(smoothratio); } else { // 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(); } } @@ -326,13 +326,13 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) if (p->newOwner != nullptr) { auto act = p->newOwner; - cang = buildang(act->interpolatedang(smoothratio)); + cang = DAngle::fromBuild(act->interpolatedang(smoothratio)); choriz = buildhoriz(act->spr.shade); cposx = act->int_pos().X; cposy = act->int_pos().Y; cposz = act->int_pos().Z; sect = act->sector(); - rotscrnang = buildang(0); + rotscrnang = DAngle::fromDeg(0.); smoothratio = MaxSmoothRatio; viewer = act; camview = true; @@ -347,10 +347,10 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) cposz -= isRR() ? 3840 : 3072; viewer = p->GetActor(); - if (!calcChaseCamPos(&cposx, &cposy, &cposz, viewer, §, DAngle::fromBam(cang.asbam()), choriz, smoothratio)) + if (!calcChaseCamPos(&cposx, &cposy, &cposz, viewer, §, cang, choriz, smoothratio)) { cposz += isRR() ? 3840 : 3072; - calcChaseCamPos(&cposx, &cposy, &cposz, viewer, §, DAngle::fromBam(cang.asbam()), choriz, smoothratio); + calcChaseCamPos(&cposx, &cposy, &cposz, viewer, §, cang, choriz, smoothratio); } } @@ -360,7 +360,7 @@ void displayrooms(int snum, double smoothratio, bool sceneonly) if (earthquaketime > 0 && p->on_ground == 1) { 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);