From 977d8f8109801059ff89bff9a868b1d02cc42fa2 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 6 Sep 2022 18:36:03 +1000 Subject: [PATCH] - Convert `gi->chaseCamPos()` to return a floating point `DVector3` object. --- source/core/gamefuncs.cpp | 3 ++- source/core/gamestruct.h | 2 +- source/games/blood/src/blood.h | 2 +- source/games/duke/src/duke3d.h | 2 +- source/games/exhumed/src/exhumed.h | 2 +- source/games/sw/src/game.h | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index dd149e1ff..adceafd80 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -44,7 +44,8 @@ bool calcChaseCamPos(int* px, int* py, int* pz, DCoreActor* act, sectortype** ps if (!*psect) return false; // Calculate new pos to shoot backwards, using averaged values from the big three. - vec3_t np = gi->chaseCamPos(ang, horiz); + DVector3 npos = gi->chaseCamPos(ang, horiz); + vec3_t np = {int(npos.X * worldtoint), int(npos.Y * worldtoint), int(npos.Z * zworldtoint)}; auto bakcstat = act->spr.cstat; act->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 0a2e27f6e..dfc3cb346 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -116,7 +116,7 @@ struct GameInterface virtual void ToggleThirdPerson() { } virtual void SwitchCoopView() { Printf("Unsupported command\n"); } virtual void ToggleShowWeapon() { Printf("Unsupported command\n"); } - virtual vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(0,0,0); } + virtual DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(0,0,0); } virtual void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) = 0; virtual void UpdateCameras(double smoothratio) {} virtual void EnterPortal(DCoreActor* viewer, int type) {} diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index d58146f36..e39a25c75 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -142,7 +142,7 @@ struct GameInterface : public ::GameInterface void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(int(-ang.Cos() * 1280.), int(-ang.Sin() * 1280.), FixedToInt(MulScale(horiz.asq16(), 1280, 3)) - (16 << 8)); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 80., horiz.asbuildf() * 0.625 - 16); } void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override; void EnterPortal(DCoreActor* viewer, int type) override; void LeavePortal(DCoreActor* viewer, int type) override; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 80a364033..497120102 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -56,7 +56,7 @@ struct GameInterface : public ::GameInterface void ToggleThirdPerson() override; void SwitchCoopView() override; void ToggleShowWeapon() override; - vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(int(-ang.Cos() * 1024.), int(-ang.Sin() * 1024.), horiz.asq16() >> 9); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 64., horiz.asbuildf() * 0.5); } void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override; diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index 1ecdffd3d..a993b4529 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -236,7 +236,7 @@ struct GameInterface : public ::GameInterface int playerKeyMove() override { return 6; } void WarpToCoords(double x, double y, double z, DAngle ang, int horz) override; void ToggleThirdPerson() override; - vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(int(-ang.Cos() * 1536.), int(-ang.Sin() * 1536.), (horiz.asq16() * 3) >> 10); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 96., horiz.asbuildf() * 0.75); } void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override; int GetCurrentSkill() override; std::pair GetCoordinates() override; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 8f99f3b45..c20b3bcc3 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2028,7 +2028,7 @@ struct GameInterface : public ::GameInterface void WarpToCoords(double x, double y, double z, DAngle ang, int horz) override; void ToggleThirdPerson() override; void SwitchCoopView() override; - vec3_t chaseCamPos(DAngle ang, fixedhoriz horiz) { return vec3_t(int(-ang.Cos() * 2048.), int(-ang.Sin() * 2048.), horiz.asq16() >> 8); } + DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 128., horiz.asbuildf()); } void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override; void UpdateCameras(double smoothratio) override; void EnterPortal(DCoreActor* viewer, int type) override;