From bb13590e07f7590634fbd4e7c8637256b0db3aff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Apr 2016 20:07:02 +0200 Subject: [PATCH] - make viewx etc. global. - a few minor optimizations. --- src/r_3dfloors.cpp | 8 ++++---- src/r_3dfloors.h | 1 - src/r_bsp.cpp | 14 +++++++------- src/r_defs.h | 2 +- src/r_local.h | 4 ---- src/r_main.cpp | 9 --------- src/r_state.h | 3 --- src/r_utility.cpp | 10 ++++++++++ 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/r_3dfloors.cpp b/src/r_3dfloors.cpp index a6aa7d8b5..590d65515 100644 --- a/src/r_3dfloors.cpp +++ b/src/r_3dfloors.cpp @@ -52,12 +52,12 @@ void R_3D_AddHeight(secplane_t *add, sector_t *sec) { HeightLevel *near; HeightLevel *curr; - fixed_t height; - height = add->ZatPoint(viewx, viewy); - if(height >= FLOAT2FIXED(sec->CenterCeiling())) return; - if(height <= FLOAT2FIXED(sec->CenterFloor())) return; + double fheight = add->ZatPoint(ViewPos); + if(fheight >= sec->CenterCeiling()) return; + if(fheight <= sec->CenterFloor()) return; + fixed_t height = FLOAT2FIXED(fheight); fakeActive = 1; if(height_max >= 0) { diff --git a/src/r_3dfloors.h b/src/r_3dfloors.h index 1a16e36a5..e95d35045 100644 --- a/src/r_3dfloors.h +++ b/src/r_3dfloors.h @@ -49,7 +49,6 @@ enum extern int fake3D; extern F3DFloor *fakeFloor; -extern fixed_t fakeHeight; extern fixed_t fakeAlpha; extern int fakeActive; extern fixed_t sclipBottom; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index d0ca0a2f4..f1b9e97ae 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -556,7 +556,7 @@ void R_AddLine (seg_t *line) // reject lines that aren't seen from the portal (if any) // [ZZ] 10.01.2016: lines inside a skybox shouldn't be clipped, although this imposes some limitations on portals in skyboxes. - if (!CurrentPortalInSkybox && CurrentPortal && P_ClipLineToPortal(line->linedef, CurrentPortal->dst, DVector2(FIXED2DBL(viewx), FIXED2DBL(viewy)))) + if (!CurrentPortalInSkybox && CurrentPortal && P_ClipLineToPortal(line->linedef, CurrentPortal->dst, ViewPos)) return; vertex_t *v1, *v2; @@ -1183,9 +1183,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = FLOAT2FIXED(fakeFloor->top.plane->ZatPoint(frontsector->centerspot)); - if (fakeHeight < viewz && - fakeHeight > FLOAT2FIXED(frontsector->floorplane.ZatPoint(frontsector->centerspot))) + double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); + if (fakeHeight < ViewPos.Z && + fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) { fake3D = FAKE3D_FAKEFLOOR; tempsec = *fakeFloor->model; @@ -1245,9 +1245,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = FLOAT2FIXED(fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot)); - if (fakeHeight > viewz && - fakeHeight < FLOAT2FIXED(frontsector->ceilingplane.ZatPoint(frontsector->centerspot))) + double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); + if (fakeHeight > ViewPos.Z && + fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) { fake3D = FAKE3D_FAKECEILING; tempsec = *fakeFloor->model; diff --git a/src/r_defs.h b/src/r_defs.h index f6ff54387..3b3a0e0e1 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -354,7 +354,7 @@ public: int PointOnSide(const DVector3 &pos) const { - double v = a * pos.X + b * pos.Y + c * pos.Z; + double v = a * pos.X + b * pos.Y + c * pos.Z + d; return v < -EQUAL_EPSILON ? -1 : v > EQUAL_EPSILON ? 1 : 0; } diff --git a/src/r_local.h b/src/r_local.h index 17f413572..7977e6923 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -38,8 +38,4 @@ #include "r_things.h" #include "r_draw.h" -extern fixed_t viewx, viewy, viewz; -extern angle_t viewangle; -extern int viewpitch; - #endif // __R_LOCAL_H__ diff --git a/src/r_main.cpp b/src/r_main.cpp index 599b682d5..7509cae84 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -68,9 +68,6 @@ #define TEST_ANGLE 2468347904 #endif -fixed_t viewx, viewy, viewz; -angle_t viewangle; -int viewpitch; // TYPES ------------------------------------------------------------------- @@ -554,12 +551,6 @@ void R_SetupColormap(player_t *player) void R_SetupFreelook() { - viewx = FLOAT2FIXED(ViewPos.X); - viewy = FLOAT2FIXED(ViewPos.Y); - viewz = FLOAT2FIXED(ViewPos.Z); - viewangle = ViewAngle.BAMs(); - viewpitch = ViewPitch.BAMs(); - { fixed_t dy; diff --git a/src/r_state.h b/src/r_state.h index 60cbecebf..5a5501465 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -78,9 +78,6 @@ extern int numgamesubsectors; // // POV data. // -extern fixed_t viewz; -extern angle_t viewangle; - extern AActor* camera; // [RH] camera instead of viewplayer extern sector_t* viewsector; // [RH] keep track of sector viewing from diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 1aae11f55..dea794b96 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -149,6 +149,10 @@ int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window FCanvasTextureInfo *FCanvasTextureInfo::List; +fixed_t viewx, viewy, viewz; +angle_t viewangle; +int viewpitch; + // CODE -------------------------------------------------------------------- static void R_Shutdown (); @@ -1091,6 +1095,12 @@ void R_SetupFrame (AActor *actor) } } + viewx = FLOAT2FIXED(ViewPos.X); + viewy = FLOAT2FIXED(ViewPos.Y); + viewz = FLOAT2FIXED(ViewPos.Z); + viewangle = ViewAngle.BAMs(); + viewpitch = ViewPitch.BAMs(); + Renderer->CopyStackedViewParameters(); Renderer->SetupFrame(player);