From b13a9e69ebea793b1c991886a56384e4a68259f1 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 8 Sep 2022 22:09:25 +1000 Subject: [PATCH] - Blood: Floatify `VIEW::pos` and remove old union. --- source/games/blood/src/osdcmd.cpp | 3 +-- source/games/blood/src/prediction.cpp | 4 ++-- source/games/blood/src/view.cpp | 13 +++++-------- source/games/blood/src/view.h | 8 +------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/source/games/blood/src/osdcmd.cpp b/source/games/blood/src/osdcmd.cpp index 7d91a9ec8..62e544632 100644 --- a/source/games/blood/src/osdcmd.cpp +++ b/source/games/blood/src/osdcmd.cpp @@ -38,8 +38,7 @@ void GameInterface::WarpToCoords(double x, double y, double z, DAngle ang, int h gView->actor->spr.pos.XY() = { x , y }; pPlayer->actor->spr.pos.XY() = gView->actor->spr.pos.XY(); - pView->x = gView->actor->int_pos().X; - pView->y = gView->actor->int_pos().Y; + pView->pos.XY() = gView->actor->spr.pos.XY(); pPlayer->zView = pView->viewz = gView->zView = z; if (ang != DAngle::fromDeg(INT_MIN)) diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index e63f1f868..7c763c1d5 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -101,8 +101,8 @@ void viewUpdatePrediction(InputPacket* pInput) static void sub_158B4(PLAYER* pPlayer) { - predict.viewz = predict.z - pPlayer->pPosture[pPlayer->lifeMode][predict.posture].eyeAboveZ; - predict.zWeapon = predict.z - pPlayer->pPosture[pPlayer->lifeMode][predict.posture].weaponAboveZ; + predict.viewz = predict.pos.Z * worldtoint - pPlayer->pPosture[pPlayer->lifeMode][predict.posture].eyeAboveZ; + predict.zWeapon = predict.pos.Z * worldtoint - pPlayer->pPosture[pPlayer->lifeMode][predict.posture].weaponAboveZ; } static void fakeProcessInput(PLAYER* pPlayer, InputPacket* pInput) diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 988639f23..64c43e5f2 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -62,8 +62,7 @@ void viewBackupView(int nPlayer) PLAYER* pPlayer = &gPlayer[nPlayer]; VIEW* pView = &gPrevView[nPlayer]; pView->angle = pPlayer->angle.ang; - pView->x = pPlayer->actor->int_pos().X; - pView->y = pPlayer->actor->int_pos().Y; + pView->pos.XY() = pPlayer->actor->spr.pos.XY(); pView->viewz = pPlayer->zView; pView->weaponZ = pPlayer->zWeapon - pPlayer->zView - 0xc00; pView->horiz = pPlayer->horizon.horiz; @@ -89,8 +88,7 @@ void viewCorrectViewOffsets(int nPlayer, vec3_t const* oldpos) { PLAYER* pPlayer = &gPlayer[nPlayer]; VIEW* pView = &gPrevView[nPlayer]; - pView->x += pPlayer->actor->int_pos().X - oldpos->X; - pView->y += pPlayer->actor->int_pos().Y - oldpos->Y; + pView->pos.XY() += pPlayer->actor->spr.pos.XY() - DVector2(oldpos->X, oldpos->Y) * inttoworld; pView->viewz += pPlayer->actor->int_pos().Z - oldpos->Z; } @@ -470,9 +468,8 @@ static void DrawMap(DBloodActor* view, const double smoothratio) tm = 1; } VIEW* pView = &gPrevView[gViewIndex]; - auto xy = DVector2(interpolatedvalue(pView->x, view->int_pos().X, smoothratio * (1. / MaxSmoothRatio)), interpolatedvalue(pView->y, view->int_pos().Y, smoothratio * (1. / MaxSmoothRatio))) * inttoworld; auto ang = !SyncInput() ? gView->angle.sum() : gView->angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio)); - DrawOverheadMap(xy, ang, smoothratio * (1. / MaxSmoothRatio)); + DrawOverheadMap(interpolatedvalue(pView->pos, view->spr.pos, smoothratio * (1. / MaxSmoothRatio)).XY(), ang, smoothratio * (1. / MaxSmoothRatio)); if (tm) setViewport(hud_size); } @@ -518,8 +515,8 @@ static void SetupView(int& cX, int& cY, int& cZ, DAngle& cA, fixedhoriz& cH, sec #endif { VIEW* pView = &gPrevView[gViewIndex]; - cX = interpolatedvalue(pView->x, gView->actor->int_pos().X, smoothratio * (1. / MaxSmoothRatio)); - cY = interpolatedvalue(pView->y, gView->actor->int_pos().Y, smoothratio * (1. / MaxSmoothRatio)); + cX = interpolatedvalue(pView->pos.X, gView->actor->spr.pos.X, smoothratio * (1. / MaxSmoothRatio)) * worldtoint; + cY = interpolatedvalue(pView->pos.Y, gView->actor->spr.pos.Y, smoothratio * (1. / MaxSmoothRatio)) * worldtoint; cZ = interpolatedvalue(pView->viewz, gView->zView, smoothratio * (1. / MaxSmoothRatio)); zDelta = interpolatedvalue(pView->weaponZ, gView->zWeapon - gView->zView - (12 << 8), smoothratio * (1. / MaxSmoothRatio)); bobWidth = interpolatedvalue(pView->bobWidth, gView->bobWidth, smoothratio * (1. / MaxSmoothRatio)); diff --git a/source/games/blood/src/view.h b/source/games/blood/src/view.h index fa75320e2..a63655d26 100644 --- a/source/games/blood/src/view.h +++ b/source/games/blood/src/view.h @@ -51,13 +51,7 @@ struct VIEW { int zWeaponVel; int posture; // posture double spin; // spin - union { - struct - { - int32_t x, y, z; - }; - vec3_t pos; - }; + DVector3 pos; int xvel; //xvel int yvel; //yvel int zvel; //zvel