From 22b8d0a8d7864e8c305e61c5a1139db164a51c86 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jun 2018 11:21:13 +0200 Subject: [PATCH] - r_viewpoint reduction in hwrenderer --- src/hwrenderer/scene/hw_bsp.cpp | 5 +++-- src/hwrenderer/scene/hw_drawstructs.h | 2 +- src/hwrenderer/scene/hw_sprites.cpp | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hwrenderer/scene/hw_bsp.cpp b/src/hwrenderer/scene/hw_bsp.cpp index 4393424c1..d44bf0679 100644 --- a/src/hwrenderer/scene/hw_bsp.cpp +++ b/src/hwrenderer/scene/hw_bsp.cpp @@ -353,6 +353,7 @@ void HWDrawInfo::RenderThings(subsector_t * sub, sector_t * sector) SetupSprite.Clock(); sector_t * sec=sub->sector; // Handle all things in sector. + auto &vp = r_viewpoint; for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) { auto thing = p->m_thing; @@ -362,7 +363,7 @@ void HWDrawInfo::RenderThings(subsector_t * sub, sector_t * sector) FIntCVar *cvar = thing->GetInfo()->distancecheck; if (cvar != nullptr && *cvar >= 0) { - double dist = (thing->Pos() - r_viewpoint.Pos).LengthSquared(); + double dist = (thing->Pos() - vp.Pos).LengthSquared(); double check = (double)**cvar; if (dist >= check * check) { @@ -383,7 +384,7 @@ void HWDrawInfo::RenderThings(subsector_t * sub, sector_t * sector) FIntCVar *cvar = thing->GetInfo()->distancecheck; if (cvar != nullptr && *cvar >= 0) { - double dist = (thing->Pos() - r_viewpoint.Pos).LengthSquared(); + double dist = (thing->Pos() - vp.Pos).LengthSquared(); double check = (double)**cvar; if (dist >= check * check) { diff --git a/src/hwrenderer/scene/hw_drawstructs.h b/src/hwrenderer/scene/hw_drawstructs.h index 8dcc4632a..e98f4a389 100644 --- a/src/hwrenderer/scene/hw_drawstructs.h +++ b/src/hwrenderer/scene/hw_drawstructs.h @@ -383,7 +383,7 @@ public: void SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool translucent); void PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, float spriteheight); - bool CalculateVertices(HWDrawInfo *di, FVector3 *v); + bool CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp); public: diff --git a/src/hwrenderer/scene/hw_sprites.cpp b/src/hwrenderer/scene/hw_sprites.cpp index e5660c26b..882712145 100644 --- a/src/hwrenderer/scene/hw_sprites.cpp +++ b/src/hwrenderer/scene/hw_sprites.cpp @@ -68,7 +68,7 @@ EXTERN_CVAR(Float, transsouls) // //========================================================================== -bool GLSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v) +bool GLSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp) { if (actor != nullptr && (actor->renderflags & RF_SPRITETYPEMASK) == RF_FLATSPRITE) { @@ -146,8 +146,8 @@ bool GLSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v) { // [CMB] Rotate relative to camera XY position, not just camera direction, // which is nicer in VR - float xrel = xcenter - r_viewpoint.Pos.X; - float yrel = ycenter - r_viewpoint.Pos.Y; + float xrel = xcenter - vp->X; + float yrel = ycenter - vp->Y; float absAngleDeg = RAD2DEG(atan2(-yrel, xrel)); float counterRotationDeg = 270. - di->mAngles.Yaw.Degrees; // counteracts existing sprite rotation float relAngleDeg = counterRotationDeg + absAngleDeg;