- reduced number of references to r_viewpoint in hw_sprites.cpp

This commit is contained in:
Christoph Oelckers 2018-06-19 10:29:09 +02:00
parent cf1641d0f6
commit 18f43dea1e
1 changed files with 20 additions and 17 deletions

View File

@ -403,7 +403,8 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
return;
}
AActor *camera = r_viewpoint.camera;
auto &vp = r_viewpoint;
AActor *camera = vp.camera;
if (thing->renderflags & RF_INVISIBLE || !thing->RenderStyle.IsVisible(thing->Alpha))
{
@ -425,26 +426,26 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
}
// [RH] Interpolate the sprite's position to make it look smooth
DVector3 thingpos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
DVector3 thingpos = thing->InterpolatedPosition(vp.TicFrac);
if (thruportal == 1) thingpos += level.Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
// Some added checks if the camera actor is not supposed to be seen. It can happen that some portal setup has this actor in view in which case it may not be skipped here
if (thing == camera && !r_viewpoint.showviewer)
if (thing == camera && !vp.showviewer)
{
DVector3 thingorigin = thing->Pos();
if (thruportal == 1) thingorigin += level.Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
if (fabs(thingorigin.X - r_viewpoint.ActorPos.X) < 2 && fabs(thingorigin.Y - r_viewpoint.ActorPos.Y) < 2) return;
if (fabs(thingorigin.X - vp.ActorPos.X) < 2 && fabs(thingorigin.Y - vp.ActorPos.Y) < 2) return;
}
// Thing is invisible if close to the camera.
if (thing->renderflags & RF_MAYBEINVISIBLE)
{
if (fabs(thingpos.X - r_viewpoint.Pos.X) < 32 && fabs(thingpos.Y - r_viewpoint.Pos.Y) < 32) return;
if (fabs(thingpos.X - vp.Pos.X) < 32 && fabs(thingpos.Y - vp.Pos.Y) < 32) return;
}
// Too close to the camera. This doesn't look good if it is a sprite.
if (fabs(thingpos.X - r_viewpoint.Pos.X) < 2 && fabs(thingpos.Y - r_viewpoint.Pos.Y) < 2)
if (fabs(thingpos.X - vp.Pos.X) < 2 && fabs(thingpos.Y - vp.Pos.Y) < 2)
{
if (r_viewpoint.Pos.Z >= thingpos.Z - 2 && r_viewpoint.Pos.Z <= thingpos.Z + thing->Height + 2)
if (vp.Pos.Z >= thingpos.Z - 2 && vp.Pos.Z <= thingpos.Z + thing->Height + 2)
{
// exclude vertically moving objects from this check.
if (!thing->Vel.isZero())
@ -466,7 +467,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
if (speed >= thing->target->radius / 2)
{
double clipdist = clamp(thing->Speed, thing->target->radius, thing->target->radius * 2);
if ((thingpos - r_viewpoint.Pos).LengthSquared() < clipdist * clipdist) return;
if ((thingpos - vp.Pos).LengthSquared() < clipdist * clipdist) return;
}
}
thing->flags7 |= MF7_FLYCHEAT; // do this only once for the very first frame, but not if it gets into range again.
@ -479,7 +480,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
}
// disabled because almost none of the actual game code is even remotely prepared for this. If desired, use the INTERPOLATE flag.
if (thing->renderflags & RF_INTERPOLATEANGLES)
Angles = thing->InterpolatedAngles(r_viewpoint.TicFrac);
Angles = thing->InterpolatedAngles(vp.TicFrac);
else
Angles = thing->Angles;
@ -506,7 +507,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
// [RH] Make floatbobbing a renderer-only effect.
if (thing->flags2 & MF2_FLOATBOB)
{
float fz = thing->GetBobOffset(r_viewpoint.TicFrac);
float fz = thing->GetBobOffset(vp.TicFrac);
z += fz;
}
@ -514,7 +515,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
if (!modelframe)
{
bool mirror;
DAngle ang = (thingpos - r_viewpoint.Pos).Angle();
DAngle ang = (thingpos - vp.Pos).Angle();
FTextureID patch;
// [ZZ] add direct picnum override
if (isPicnumOverride)
@ -531,7 +532,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
int rot;
if (!(thing->renderflags & RF_FLATSPRITE) || thing->flags7 & MF7_SPRITEANGLE)
{
sprangle = thing->GetSpriteAngle(ang, r_viewpoint.TicFrac);
sprangle = thing->GetSpriteAngle(ang, vp.TicFrac);
rot = -1;
}
else
@ -632,7 +633,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
gltexture = nullptr;
}
depth = FloatToFixed((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin);
depth = FloatToFixed((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
// light calculation
@ -927,7 +928,8 @@ void GLSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
}
}
double timefrac = r_viewpoint.TicFrac;
auto &vp = r_viewpoint;
double timefrac = vp.TicFrac;
if (paused || bglobal.freeze || (level.flags2 & LEVEL2_FROZEN))
timefrac = 0.;
float xvf = (particle->Vel.X) * timefrac;
@ -954,7 +956,7 @@ void GLSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
z1=z-scalefac;
z2=z+scalefac;
depth = FloatToFixed((x - r_viewpoint.Pos.X) * r_viewpoint.TanCos + (y - r_viewpoint.Pos.Y) * r_viewpoint.TanSin);
depth = FloatToFixed((x - vp.Pos.X) * vp.TanCos + (y - vp.Pos.Y) * vp.TanSin);
actor=nullptr;
this->particle=particle;
@ -984,6 +986,7 @@ void HWDrawInfo::ProcessActorsInPortal(FLinePortalSpan *glport, area_t in_area)
TMap<AActor*, bool> processcheck;
if (glport->validcount == validcount) return; // only process once per frame
glport->validcount = validcount;
auto &vp = r_viewpoint;
for (auto port : glport->lines)
{
line_t *line = port->mOrigin;
@ -1007,9 +1010,9 @@ void HWDrawInfo::ProcessActorsInPortal(FLinePortalSpan *glport, area_t in_area)
DVector3 newpos = savedpos;
sector_t fakesector;
if (!r_viewpoint.showviewer && th == r_viewpoint.camera)
if (!vp.showviewer && th == vp.camera)
{
if (fabs(savedpos.X - r_viewpoint.ActorPos.X) < 2 && fabs(savedpos.Y - r_viewpoint.ActorPos.Y) < 2)
if (fabs(savedpos.X - vp.ActorPos.X) < 2 && fabs(savedpos.Y - vp.ActorPos.Y) < 2)
{
continue;
}