From 45cfea17f5b1dfecf4c458c8aba4d11f83d9b1ff Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 10:34:04 +0200 Subject: [PATCH 1/2] - removed unused variable. --- src/r_things.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index c2fa165db..7fe8ab017 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1227,7 +1227,6 @@ static void R_ProjectWallSprite(AActor *thing, fixed_t fx, fixed_t fy, fixed_t f void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) { AActor *thing; - F3DFloor *rover; F3DFloor *fakeceiling = NULL; F3DFloor *fakefloor = NULL; From d88a5ac353ec15150865d0dbe7d7503b25535e58 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 13 Apr 2016 10:48:39 +0200 Subject: [PATCH 2/2] - make distancecheck 3D and use the actual view position for calculation. --- src/r_main.cpp | 3 ++- src/r_plane.cpp | 4 ++++ src/r_things.cpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index 8e7452789..1c15f9f1e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -731,7 +731,6 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); } viewangle = pds->src->Delta().Angle().BAMs() - startang; - ViewAngle = AngleToFloat(viewangle); } else { @@ -763,6 +762,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) } } ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; @@ -845,6 +845,7 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) ViewPath[0] = savedpath[0]; ViewPath[1] = savedpath[1]; ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; } //========================================================================== diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 087487cd5..d950075db 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1083,6 +1083,7 @@ void R_DrawHeightPlanes(fixed_t height) viewz = pl->viewz; viewangle = pl->viewangle; ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; MirrorFlags = pl->MirrorFlags; R_DrawSinglePlane (pl, pl->sky & 0x7FFFFFFF, pl->Additive, true); } @@ -1094,6 +1095,7 @@ void R_DrawHeightPlanes(fixed_t height) viewz = oViewZ; viewangle = oViewAngle; ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; } @@ -1256,6 +1258,7 @@ void R_DrawSkyBoxes () viewangle = pl->viewangle; } ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; sky->bInSkybox = true; if (mate != NULL) mate->bInSkybox = true; @@ -1371,6 +1374,7 @@ void R_DrawSkyBoxes () extralight = savedextralight; viewangle = savedangle; ViewAngle = AngleToFloat(viewangle); + ViewPos = { FIXED2DBL(viewx), FIXED2DBL(viewy), FIXED2DBL(viewz) }; R_SetViewAngle (); CurrentPortalInSkybox = false; diff --git a/src/r_things.cpp b/src/r_things.cpp index 7fe8ab017..cc490e6b0 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1248,7 +1248,7 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) FIntCVar *cvar = thing->GetClass()->distancecheck; if (cvar != NULL && *cvar >= 0) { - double dist = thing->Distance2DSquared(camera); + double dist = (thing->PosRelative(viewsector) - ViewPos).LengthSquared(); double check = (double)**cvar; if (dist >= check * check) {