mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-24 04:51:19 +00:00
- make FieldOfView a real angle and remove all uses of finetangent.
This commit is contained in:
parent
f301cf7c57
commit
027b8d29b8
8 changed files with 19 additions and 62 deletions
|
@ -179,7 +179,7 @@ static inline int viewangletox(int i)
|
|||
|
||||
// Don't waste time calculating the tangent of values outside the valid range.
|
||||
// Checking the index where tan(i) becomes too large is a lot faster
|
||||
if (i <= 604) // 604 is the highest index with finetangent < -2*FRACUNIT
|
||||
if (i <= 604) // 604 is the highest index with tan < -2
|
||||
{
|
||||
return viewwidth + 1;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ void R_InitTextureMapping ()
|
|||
FocalLengthY = FocalLengthX * YaspectMul;
|
||||
|
||||
// This is 1/FocalTangent before the widescreen extension of FOV.
|
||||
viewingrangerecip = DivScale32(1, finetangent[FINEANGLES/4+(FieldOfView/2)]);
|
||||
viewingrangerecip = FLOAT2FIXED(1. / tan(FieldOfView.Radians() / 2));
|
||||
|
||||
// [RH] Do not generate viewangletox, because texture mapping is no
|
||||
// longer done with trig, so it's not needed.
|
||||
|
|
|
@ -115,8 +115,8 @@ void R_InitSkyMap ()
|
|||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale *= FieldOfView / 2048.f;
|
||||
skyscale *= 2048.0 / FieldOfView;
|
||||
skyiscale *= float(FieldOfView.Degrees / 90.);
|
||||
skyscale *= float(90. / FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
|
|
|
@ -82,7 +82,7 @@ extern AActor* camera; // [RH] camera instead of viewplayer
|
|||
extern sector_t* viewsector; // [RH] keep track of sector viewing from
|
||||
|
||||
extern angle_t xtoviewangle[MAXWIDTH+1];
|
||||
extern int FieldOfView;
|
||||
extern DAngle FieldOfView;
|
||||
|
||||
int R_FindSkin (const char *name, int pclass); // [RH] Find a skin
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@ void R_SetupColormap(player_t *);
|
|||
void R_SetupFreelook();
|
||||
void R_InitRenderer();
|
||||
|
||||
extern float LastFOV;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DCanvas :: Init
|
||||
|
@ -272,8 +270,8 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
|||
unsigned char *savecolormap = fixedcolormap;
|
||||
FSpecialColormap *savecm = realfixedcolormap;
|
||||
|
||||
float savedfov = LastFOV;
|
||||
R_SetFOV ((float)fov);
|
||||
DAngle savedfov = FieldOfView;
|
||||
R_SetFOV ((double)fov);
|
||||
R_RenderViewToCanvas (viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||
R_SetFOV (savedfov);
|
||||
if (Pixels == Canvas->GetBuffer())
|
||||
|
|
|
@ -138,7 +138,6 @@ angle_t LocalViewAngle;
|
|||
int LocalViewPitch;
|
||||
bool LocalKeyboardTurner;
|
||||
|
||||
float LastFOV;
|
||||
int WidescreenRatio;
|
||||
int setblocks;
|
||||
int extralight;
|
||||
|
@ -147,7 +146,7 @@ double FocalTangent;
|
|||
|
||||
unsigned int R_OldBlend = ~0;
|
||||
int validcount = 1; // increment every time a check is made
|
||||
int FieldOfView = 2048; // Fineangles in the SCREENWIDTH wide window
|
||||
DAngle FieldOfView = 90.; // Angles in the SCREENWIDTH wide window
|
||||
|
||||
FCanvasTextureInfo *FCanvasTextureInfo::List;
|
||||
|
||||
|
@ -169,13 +168,6 @@ void R_InitTables (void)
|
|||
int i;
|
||||
const double pimul = M_PI*2/FINEANGLES;
|
||||
|
||||
// viewangle tangent table
|
||||
finetangent[0] = (fixed_t)(FRACUNIT*g_tan ((0.5-FINEANGLES/4)*pimul)+0.5);
|
||||
for (i = 1; i < FINEANGLES/2; i++)
|
||||
{
|
||||
finetangent[i] = (fixed_t)(FRACUNIT*g_tan ((i-FINEANGLES/4)*pimul)+0.5);
|
||||
}
|
||||
|
||||
// finesine table
|
||||
for (i = 0; i < FINEANGLES/4; i++)
|
||||
{
|
||||
|
@ -202,33 +194,18 @@ void R_InitTables (void)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_SetFOV (float fov)
|
||||
void R_SetFOV (DAngle fov)
|
||||
{
|
||||
if (fov < 5.f)
|
||||
fov = 5.f;
|
||||
else if (fov > 170.f)
|
||||
fov = 170.f;
|
||||
if (fov != LastFOV)
|
||||
|
||||
if (fov < 5.) fov = 5.;
|
||||
else if (fov > 170.) fov = 170.;
|
||||
if (fov != FieldOfView)
|
||||
{
|
||||
LastFOV = fov;
|
||||
FieldOfView = (int)(fov * (float)FINEANGLES / 360.f);
|
||||
FieldOfView = fov;
|
||||
setsizeneeded = true;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_GetFOV
|
||||
//
|
||||
// Returns the current field of view in degrees
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
float R_GetFOV ()
|
||||
{
|
||||
return LastFOV;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_SetViewSize
|
||||
|
@ -292,18 +269,16 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
|
|||
}
|
||||
|
||||
|
||||
int fov = FieldOfView;
|
||||
DAngle fov = FieldOfView;
|
||||
|
||||
// For widescreen displays, increase the FOV so that the middle part of the
|
||||
// screen that would be visible on a 4:3 display has the requested FOV.
|
||||
if (centerxwide != centerx)
|
||||
{ // centerxwide is what centerx would be if the display was not widescreen
|
||||
fov = int(atan(double(centerx)*tan(double(fov)*M_PI/(FINEANGLES))/double(centerxwide))*(FINEANGLES)/M_PI);
|
||||
if (fov > 170*FINEANGLES/360)
|
||||
fov = 170*FINEANGLES/360;
|
||||
fov = DAngle::ToDegrees(2 * atan(centerx * tan(fov.Radians()/2) / double(centerxwide)));
|
||||
if (fov > 170.) fov = 170.;
|
||||
}
|
||||
|
||||
FocalTangent = FIXED2FLOAT(finetangent[FINEANGLES/4+fov/2]);
|
||||
FocalTangent = tan(fov.Radians() / 2);
|
||||
Renderer->SetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,7 @@ bool R_GetViewInterpolationStatus();
|
|||
void R_ClearInterpolationPath();
|
||||
void R_AddInterpolationPoint(const DVector3a &vec);
|
||||
void R_SetViewSize (int blocks);
|
||||
void R_SetFOV (float fov);
|
||||
float R_GetFOV ();
|
||||
void R_SetFOV (DAngle fov);
|
||||
void R_SetupFrame (AActor * camera);
|
||||
void R_SetViewAngle ();
|
||||
|
||||
|
|
|
@ -19,22 +19,14 @@
|
|||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finetangent[4096] - Tangens LUT.
|
||||
// Should work with BAM fairly well (12 of 16bit,
|
||||
// effectively, by shifting).
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Guess what, serves as cosine, too.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
// int tantoangle[2049] - ArcTan LUT,
|
||||
// maps tan(angle) to angle fast. Gotta search.
|
||||
//
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "tables.h"
|
||||
|
||||
fixed_t finetangent[4096];
|
||||
fixed_t finesine[10240];
|
||||
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
// Do not try to look them up :-).
|
||||
// In the order of appearance:
|
||||
//
|
||||
// int finetangent[4096] - Tangens LUT.
|
||||
// Should work with BAM fairly well (12 of 16bit,
|
||||
// effectively, by shifting).
|
||||
//
|
||||
// int finesine[10240] - Sine lookup.
|
||||
// Remarkable thing is, how to use BAMs with this?
|
||||
//
|
||||
|
@ -46,9 +42,6 @@
|
|||
// Effective size is 10240.
|
||||
extern fixed_t finesine[5*FINEANGLES/4];
|
||||
|
||||
// Effective size is 4096.
|
||||
extern fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
// Binary Angle Measument, BAM.
|
||||
#define ANGLE_90 (0x40000000)
|
||||
#define ANGLE_180 (0x80000000)
|
||||
|
|
Loading…
Reference in a new issue