- make viewx etc. global.

- a few minor optimizations.
This commit is contained in:
Christoph Oelckers 2016-04-02 20:07:02 +02:00
parent ccfb2ac233
commit bb13590e07
8 changed files with 22 additions and 29 deletions

View file

@ -52,12 +52,12 @@ void R_3D_AddHeight(secplane_t *add, sector_t *sec)
{ {
HeightLevel *near; HeightLevel *near;
HeightLevel *curr; HeightLevel *curr;
fixed_t height;
height = add->ZatPoint(viewx, viewy); double fheight = add->ZatPoint(ViewPos);
if(height >= FLOAT2FIXED(sec->CenterCeiling())) return; if(fheight >= sec->CenterCeiling()) return;
if(height <= FLOAT2FIXED(sec->CenterFloor())) return; if(fheight <= sec->CenterFloor()) return;
fixed_t height = FLOAT2FIXED(fheight);
fakeActive = 1; fakeActive = 1;
if(height_max >= 0) { if(height_max >= 0) {

View file

@ -49,7 +49,6 @@ enum
extern int fake3D; extern int fake3D;
extern F3DFloor *fakeFloor; extern F3DFloor *fakeFloor;
extern fixed_t fakeHeight;
extern fixed_t fakeAlpha; extern fixed_t fakeAlpha;
extern int fakeActive; extern int fakeActive;
extern fixed_t sclipBottom; extern fixed_t sclipBottom;

View file

@ -556,7 +556,7 @@ void R_AddLine (seg_t *line)
// reject lines that aren't seen from the portal (if any) // 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. // [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; return;
vertex_t *v1, *v2; vertex_t *v1, *v2;
@ -1183,9 +1183,9 @@ void R_Subsector (subsector_t *sub)
fakeFloor->validcount = validcount; fakeFloor->validcount = validcount;
R_3D_NewClip(); R_3D_NewClip();
} }
fakeHeight = FLOAT2FIXED(fakeFloor->top.plane->ZatPoint(frontsector->centerspot)); double fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight < viewz && if (fakeHeight < ViewPos.Z &&
fakeHeight > FLOAT2FIXED(frontsector->floorplane.ZatPoint(frontsector->centerspot))) fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot))
{ {
fake3D = FAKE3D_FAKEFLOOR; fake3D = FAKE3D_FAKEFLOOR;
tempsec = *fakeFloor->model; tempsec = *fakeFloor->model;
@ -1245,9 +1245,9 @@ void R_Subsector (subsector_t *sub)
fakeFloor->validcount = validcount; fakeFloor->validcount = validcount;
R_3D_NewClip(); R_3D_NewClip();
} }
fakeHeight = FLOAT2FIXED(fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot)); double fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot);
if (fakeHeight > viewz && if (fakeHeight > ViewPos.Z &&
fakeHeight < FLOAT2FIXED(frontsector->ceilingplane.ZatPoint(frontsector->centerspot))) fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot))
{ {
fake3D = FAKE3D_FAKECEILING; fake3D = FAKE3D_FAKECEILING;
tempsec = *fakeFloor->model; tempsec = *fakeFloor->model;

View file

@ -354,7 +354,7 @@ public:
int PointOnSide(const DVector3 &pos) const 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; return v < -EQUAL_EPSILON ? -1 : v > EQUAL_EPSILON ? 1 : 0;
} }

View file

@ -38,8 +38,4 @@
#include "r_things.h" #include "r_things.h"
#include "r_draw.h" #include "r_draw.h"
extern fixed_t viewx, viewy, viewz;
extern angle_t viewangle;
extern int viewpitch;
#endif // __R_LOCAL_H__ #endif // __R_LOCAL_H__

View file

@ -68,9 +68,6 @@
#define TEST_ANGLE 2468347904 #define TEST_ANGLE 2468347904
#endif #endif
fixed_t viewx, viewy, viewz;
angle_t viewangle;
int viewpitch;
// TYPES ------------------------------------------------------------------- // TYPES -------------------------------------------------------------------
@ -554,12 +551,6 @@ void R_SetupColormap(player_t *player)
void R_SetupFreelook() void R_SetupFreelook()
{ {
viewx = FLOAT2FIXED(ViewPos.X);
viewy = FLOAT2FIXED(ViewPos.Y);
viewz = FLOAT2FIXED(ViewPos.Z);
viewangle = ViewAngle.BAMs();
viewpitch = ViewPitch.BAMs();
{ {
fixed_t dy; fixed_t dy;

View file

@ -78,9 +78,6 @@ extern int numgamesubsectors;
// //
// POV data. // POV data.
// //
extern fixed_t viewz;
extern angle_t viewangle;
extern AActor* camera; // [RH] camera instead of viewplayer extern AActor* camera; // [RH] camera instead of viewplayer
extern sector_t* viewsector; // [RH] keep track of sector viewing from extern sector_t* viewsector; // [RH] keep track of sector viewing from

View file

@ -149,6 +149,10 @@ int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
FCanvasTextureInfo *FCanvasTextureInfo::List; FCanvasTextureInfo *FCanvasTextureInfo::List;
fixed_t viewx, viewy, viewz;
angle_t viewangle;
int viewpitch;
// CODE -------------------------------------------------------------------- // CODE --------------------------------------------------------------------
static void R_Shutdown (); 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->CopyStackedViewParameters();
Renderer->SetupFrame(player); Renderer->SetupFrame(player);