- move r_utility globals into r_viewpoint and r_viewwindow

- change r_utility functions to only work on FRenderViewpoint and FViewWindow
This commit is contained in:
Magnus Norddahl 2017-03-11 23:28:07 +01:00
commit 0c9014b984
75 changed files with 817 additions and 839 deletions

View file

@ -38,7 +38,7 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
if (IsThingCulled(thing))
return false;
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
DVector3 pos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
bool flipTextureX = false;
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
@ -59,8 +59,8 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
pos.X += spriteHalfWidth;
left = DVector2(pos.X - ViewSin * spriteHalfWidth, pos.Y + ViewCos * spriteHalfWidth);
right = DVector2(pos.X + ViewSin * spriteHalfWidth, pos.Y - ViewCos * spriteHalfWidth);
left = DVector2(pos.X - r_viewpoint.Sin * spriteHalfWidth, pos.Y + r_viewpoint.Cos * spriteHalfWidth);
right = DVector2(pos.X + r_viewpoint.Sin * spriteHalfWidth, pos.Y - r_viewpoint.Cos * spriteHalfWidth);
return true;
}
@ -70,8 +70,8 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
if (!GetLine(thing, line[0], line[1]))
return;
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
pos.Z += thing->GetBobOffset(r_TicFracF);
DVector3 pos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
pos.Z += thing->GetBobOffset(r_viewpoint.TicFrac);
bool flipTextureX = false;
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
@ -105,7 +105,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
return;
bool foggy = false;
int actualextralight = foggy ? 0 : extralight << 4;
int actualextralight = foggy ? 0 : r_viewpoint.extralight << 4;
std::pair<float, float> offsets[4] =
{
@ -273,7 +273,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing)
FIntCVar *cvar = thing->GetClass()->distancecheck;
if (cvar != nullptr && *cvar >= 0)
{
double dist = (thing->Pos() - ViewPos).LengthSquared();
double dist = (thing->Pos() - r_viewpoint.Pos).LengthSquared();
double check = (double)**cvar;
if (dist >= check * check)
return true;
@ -385,9 +385,9 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
{
// choose a different rotation based on player view
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
pos.Z += thing->GetBobOffset(r_TicFracF);
DAngle ang = (pos - ViewPos).Angle();
DVector3 pos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
pos.Z += thing->GetBobOffset(r_viewpoint.TicFrac);
DAngle ang = (pos - r_viewpoint.Pos).Angle();
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{
@ -420,9 +420,9 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
//picnum = SpriteFrames[sprdef->spriteframes + thing->frame].Texture[0];
// choose a different rotation based on player view
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + thing->frame];
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
pos.Z += thing->GetBobOffset(r_TicFracF);
DAngle ang = (pos - ViewPos).Angle();
DVector3 pos = thing->InterpolatedPosition(r_viewpoint.TicFrac);
pos.Z += thing->GetBobOffset(r_viewpoint.TicFrac);
DAngle ang = (pos - r_viewpoint.Pos).Angle();
angle_t rot;
if (sprframe->Texture[0] == sprframe->Texture[1])
{