mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-19 07:51:43 +00:00
Software FOV ported from kart
also fixes high software FOVs having buggy walls
This commit is contained in:
parent
c27d062cc8
commit
8bc58807aa
8 changed files with 57 additions and 60 deletions
|
@ -72,6 +72,7 @@
|
|||
#include "../v_video.h"
|
||||
#include "hw_clip.h"
|
||||
#include "hw_glob.h"
|
||||
#include "../r_main.h"
|
||||
#include "../r_state.h"
|
||||
#include "../tables.h"
|
||||
#include "r_opengl/r_opengl.h"
|
||||
|
@ -328,7 +329,7 @@ angle_t gld_FrustumAngle(void)
|
|||
|
||||
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
|
||||
|
||||
float render_fov = FIXED_TO_FLOAT(cv_grfov.value);
|
||||
float render_fov = FIXED_TO_FLOAT(cv_fov.value);
|
||||
float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right?
|
||||
float render_multiplier = 64.0f / render_fovratio / RMUL;
|
||||
|
||||
|
|
|
@ -5896,7 +5896,7 @@ static void HWR_DrawSkyBackground(player_t *player)
|
|||
if (cv_grskydome.value)
|
||||
{
|
||||
FTransform dometransform;
|
||||
const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd);
|
||||
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
|
||||
postimg_t *type;
|
||||
|
||||
if (splitscreen && player == &players[secondarydisplayplayer])
|
||||
|
@ -6074,7 +6074,7 @@ void HWR_SetViewSize(void)
|
|||
// ==========================================================================
|
||||
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
|
||||
{
|
||||
const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd);
|
||||
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
|
||||
postimg_t *type;
|
||||
|
||||
if (splitscreen && player == &players[secondarydisplayplayer])
|
||||
|
@ -6200,7 +6200,7 @@ if (0)
|
|||
viewangle = localaiming2;
|
||||
|
||||
// Handle stuff when you are looking farther up or down.
|
||||
if ((aimingangle || cv_grfov.value+player->fovadd > 90*FRACUNIT))
|
||||
if ((aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
|
||||
{
|
||||
dup_viewangle += ANGLE_90;
|
||||
HWR_ClearClipSegs();
|
||||
|
@ -6278,7 +6278,7 @@ if (0)
|
|||
// ==========================================================================
|
||||
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
|
||||
{
|
||||
const float fpov = FIXED_TO_FLOAT(cv_grfov.value+player->fovadd);
|
||||
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
|
||||
postimg_t *type;
|
||||
|
||||
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
|
||||
|
@ -6420,7 +6420,7 @@ if (0)
|
|||
viewangle = localaiming2;
|
||||
|
||||
// Handle stuff when you are looking farther up or down.
|
||||
if ((aimingangle || cv_grfov.value+player->fovadd > 90*FRACUNIT))
|
||||
if ((aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
|
||||
{
|
||||
dup_viewangle += ANGLE_90;
|
||||
HWR_ClearClipSegs();
|
||||
|
@ -6549,9 +6549,7 @@ static void CV_grmodellighting_OnChange(void);
|
|||
static void CV_grfiltermode_OnChange(void);
|
||||
static void CV_granisotropic_OnChange(void);
|
||||
static void CV_grfogdensity_OnChange(void);
|
||||
static void CV_grfov_OnChange(void);
|
||||
|
||||
static CV_PossibleValue_t grfov_cons_t[] = {{0, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}};
|
||||
static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSAMPLED, "Nearest"},
|
||||
{HWD_SET_TEXTUREFILTER_BILINEAR, "Bilinear"}, {HWD_SET_TEXTUREFILTER_TRILINEAR, "Trilinear"},
|
||||
{HWD_SET_TEXTUREFILTER_MIXED1, "Linear_Nearest"},
|
||||
|
@ -6560,7 +6558,7 @@ static CV_PossibleValue_t grfiltermode_cons_t[]= {{HWD_SET_TEXTUREFILTER_POINTSA
|
|||
{0, NULL}};
|
||||
CV_PossibleValue_t granisotropicmode_cons_t[] = {{1, "MIN"}, {16, "MAX"}, {0, NULL}};
|
||||
|
||||
consvar_t cv_grfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_fovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfog = {"gr_fog", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfogcolor = {"gr_fogcolor", "AAAAAA", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grsoftwarefog = {"gr_softwarefog", "Off", CV_SAVE, grsoftwarefog_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
@ -6580,7 +6578,6 @@ consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV
|
|||
consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfov = {"gr_fov", "90", CV_FLOAT|CV_CALL, grfov_cons_t, CV_grfov_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_grfogdensity = {"gr_fogdensity", "150", CV_CALL|CV_NOINIT, CV_Unsigned,
|
||||
CV_grfogdensity_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
|
@ -6616,17 +6613,10 @@ static void CV_granisotropic_OnChange(void)
|
|||
HWD.pfnSetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_granisotropicmode.value);
|
||||
}
|
||||
|
||||
static void CV_grfov_OnChange(void)
|
||||
{
|
||||
if ((netgame || multiplayer) && !cv_debug && cv_grfov.value != 90*FRACUNIT)
|
||||
CV_Set(&cv_grfov, cv_grfov.defaultvalue);
|
||||
}
|
||||
|
||||
//added by Hurdler: console varibale that are saved
|
||||
void HWR_AddCommands(void)
|
||||
{
|
||||
CV_RegisterVar(&cv_grfovchange);
|
||||
CV_RegisterVar(&cv_grfov);
|
||||
CV_RegisterVar(&cv_fovchange);
|
||||
|
||||
CV_RegisterVar(&cv_grfogdensity);
|
||||
CV_RegisterVar(&cv_grfogcolor);
|
||||
|
|
|
@ -83,7 +83,6 @@ extern consvar_t cv_grstaticlighting;
|
|||
extern consvar_t cv_grcoronas;
|
||||
extern consvar_t cv_grcoronasize;
|
||||
#endif
|
||||
extern consvar_t cv_grfov;
|
||||
extern consvar_t cv_grmodels;
|
||||
extern consvar_t cv_grmodelinterpolation;
|
||||
extern consvar_t cv_grmodellighting;
|
||||
|
@ -94,7 +93,7 @@ extern consvar_t cv_grsoftwarefog;
|
|||
extern consvar_t cv_grfiltermode;
|
||||
extern consvar_t cv_granisotropicmode;
|
||||
extern consvar_t cv_grcorrecttricks;
|
||||
extern consvar_t cv_grfovchange;
|
||||
extern consvar_t cv_fovchange;
|
||||
extern consvar_t cv_grsolvetjoin;
|
||||
extern consvar_t cv_grspritebillboarding;
|
||||
extern consvar_t cv_grskydome;
|
||||
|
|
|
@ -2224,11 +2224,11 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration,
|
|||
EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
||||
{
|
||||
static boolean special_splitscreen;
|
||||
float used_fov;
|
||||
pglLoadIdentity();
|
||||
if (stransform)
|
||||
{
|
||||
boolean fovx90;
|
||||
|
||||
used_fov = stransform->fovxangle;
|
||||
#ifdef USE_FTRANSFORM_MIRROR
|
||||
// mirroring from Kart
|
||||
if (stransform->mirror)
|
||||
|
@ -2244,32 +2244,28 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
|||
pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f);
|
||||
pglTranslatef(-stransform->x, -stransform->z, -stransform->y);
|
||||
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
pglLoadIdentity();
|
||||
fovx90 = stransform->fovxangle > 0.0f && fabsf(stransform->fovxangle - 90.0f) < 0.5f;
|
||||
special_splitscreen = (stransform->splitscreen && fovx90);
|
||||
if (special_splitscreen)
|
||||
GLPerspective(53.13f, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5)
|
||||
else
|
||||
GLPerspective(stransform->fovxangle, ASPECT_RATIO);
|
||||
pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer)
|
||||
pglMatrixMode(GL_MODELVIEW);
|
||||
special_splitscreen = stransform->splitscreen;
|
||||
}
|
||||
else
|
||||
{
|
||||
used_fov = fov;
|
||||
pglScalef(1.0f, 1.0f, -1.0f);
|
||||
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
pglLoadIdentity();
|
||||
if (special_splitscreen)
|
||||
GLPerspective(53.13f, 2*ASPECT_RATIO); // 53.13 = 2*atan(0.5)
|
||||
else
|
||||
//Hurdler: is "fov" correct?
|
||||
GLPerspective(fov, ASPECT_RATIO);
|
||||
pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer)
|
||||
pglMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
pglLoadIdentity();
|
||||
|
||||
if (special_splitscreen)
|
||||
{
|
||||
used_fov = atan(tan(used_fov*M_PI/360)*0.8)*360/M_PI;
|
||||
GLPerspective(used_fov, 2*ASPECT_RATIO);
|
||||
}
|
||||
else
|
||||
GLPerspective(used_fov, ASPECT_RATIO);
|
||||
|
||||
pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer)
|
||||
pglMatrixMode(GL_MODELVIEW);
|
||||
|
||||
pglGetFloatv(GL_MODELVIEW_MATRIX, modelMatrix); // added for new coronas' code (without depth buffer)
|
||||
}
|
||||
|
||||
|
|
|
@ -1311,7 +1311,7 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
|
|||
{IT_STRING|IT_CVAR, NULL, "Model lighting", &cv_grmodellighting, 32},
|
||||
|
||||
{IT_HEADER, NULL, "General", NULL, 51},
|
||||
{IT_STRING|IT_CVAR, NULL, "Field of view", &cv_grfov, 63},
|
||||
{IT_STRING|IT_CVAR, NULL, "Field of view", &cv_fov, 63},
|
||||
{IT_STRING|IT_CVAR, NULL, "Quality", &cv_scr_depth, 73},
|
||||
{IT_STRING|IT_CVAR, NULL, "Texture Filter", &cv_grfiltermode, 83},
|
||||
{IT_STRING|IT_CVAR, NULL, "Anisotropic", &cv_granisotropicmode,93},
|
||||
|
|
|
@ -8648,7 +8648,7 @@ static void P_MovePlayer(player_t *player)
|
|||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode != render_soft && rendermode != render_none && cv_grfovchange.value)
|
||||
if (rendermode != render_soft && rendermode != render_none && cv_fovchange.value)
|
||||
{
|
||||
fixed_t speed;
|
||||
const fixed_t runnyspeed = 20*FRACUNIT;
|
||||
|
@ -9884,13 +9884,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
{
|
||||
dist = camdist;
|
||||
|
||||
// x1.5 dist for splitscreen
|
||||
if (splitscreen)
|
||||
{
|
||||
dist = FixedMul(dist, 3*FRACUNIT/2);
|
||||
camheight = FixedMul(camheight, 3*FRACUNIT/2);
|
||||
}
|
||||
|
||||
if (sign) // signpost camera has specific placement
|
||||
{
|
||||
camheight = mo->scale << 7;
|
||||
|
|
35
src/r_main.c
35
src/r_main.c
|
@ -57,6 +57,7 @@ INT32 centerx, centery;
|
|||
fixed_t centerxfrac, centeryfrac;
|
||||
fixed_t projection;
|
||||
fixed_t projectiony; // aspect ratio
|
||||
fixed_t fovtan; // field of view
|
||||
|
||||
// just for profiling purposes
|
||||
size_t framecount;
|
||||
|
@ -106,10 +107,12 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = {
|
|||
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
|
||||
{0, "None"}, {0, NULL}};
|
||||
|
||||
static CV_PossibleValue_t fov_cons_t[] = {{60*FRACUNIT, "MIN"}, {179*FRACUNIT, "MAX"}, {0, NULL}};
|
||||
static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
|
||||
static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card
|
||||
static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}};
|
||||
|
||||
static void Fov_OnChange(void);
|
||||
static void ChaseCam_OnChange(void);
|
||||
static void ChaseCam2_OnChange(void);
|
||||
static void FlipCam_OnChange(void);
|
||||
|
@ -139,6 +142,7 @@ consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL,
|
|||
consvar_t cv_drawdist_nights = {"drawdist_nights", "2048", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE, drawdist_precip_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
//consvar_t cv_precipdensity = {"precipdensity", "Moderate", CV_SAVE, precipdensity_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Okay, whoever said homremoval causes a performance hit should be shot.
|
||||
consvar_t cv_homremoval = {"homremoval", "No", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
@ -182,6 +186,14 @@ void SplitScreen_OnChange(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
static void Fov_OnChange(void)
|
||||
{
|
||||
// Shouldn't be needed with render parity?
|
||||
//if ((netgame || multiplayer) && !cv_debug && cv_fov.value != 90*FRACUNIT)
|
||||
// CV_Set(&cv_fov, cv_fov.defaultvalue);
|
||||
|
||||
R_SetViewSize();
|
||||
}
|
||||
|
||||
static void ChaseCam_OnChange(void)
|
||||
{
|
||||
|
@ -446,8 +458,8 @@ static void R_InitTextureMapping(void)
|
|||
//
|
||||
// Calc focallength
|
||||
// so FIELDOFVIEW angles covers SCREENWIDTH.
|
||||
focallength = FixedDiv(centerxfrac,
|
||||
FINETANGENT(FINEANGLES/4+/*cv_fov.value*/ FIELDOFVIEW/2));
|
||||
focallength = FixedDiv(projection,
|
||||
FINETANGENT(FINEANGLES/4+FIELDOFVIEW/2));
|
||||
|
||||
#ifdef ESLOPE
|
||||
focallengthf = FIXED_TO_FLOAT(focallength);
|
||||
|
@ -455,9 +467,9 @@ static void R_InitTextureMapping(void)
|
|||
|
||||
for (i = 0; i < FINEANGLES/2; i++)
|
||||
{
|
||||
if (FINETANGENT(i) > FRACUNIT*2)
|
||||
if (FINETANGENT(i) > fovtan*2)
|
||||
t = -1;
|
||||
else if (FINETANGENT(i) < -FRACUNIT*2)
|
||||
else if (FINETANGENT(i) < -fovtan*2)
|
||||
t = viewwidth+1;
|
||||
else
|
||||
{
|
||||
|
@ -561,6 +573,7 @@ void R_ExecuteSetViewSize(void)
|
|||
INT32 j;
|
||||
INT32 level;
|
||||
INT32 startmapl;
|
||||
angle_t fov;
|
||||
|
||||
setsizeneeded = false;
|
||||
|
||||
|
@ -583,9 +596,12 @@ void R_ExecuteSetViewSize(void)
|
|||
centerxfrac = centerx<<FRACBITS;
|
||||
centeryfrac = centery<<FRACBITS;
|
||||
|
||||
projection = centerxfrac;
|
||||
//projectiony = (((vid.height*centerx*BASEVIDWIDTH)/BASEVIDHEIGHT)/vid.width)<<FRACBITS;
|
||||
projectiony = centerxfrac;
|
||||
fov = FixedAngle(cv_fov.value/2) + ANGLE_90;
|
||||
fovtan = FINETANGENT(fov >> ANGLETOFINESHIFT);
|
||||
if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
|
||||
fovtan = 17*fovtan/10;
|
||||
|
||||
projection = projectiony = FixedDiv(centerxfrac, fovtan);
|
||||
|
||||
R_InitViewBuffer(scaledviewwidth, viewheight);
|
||||
|
||||
|
@ -611,7 +627,7 @@ void R_ExecuteSetViewSize(void)
|
|||
for (i = 0; i < j; i++)
|
||||
{
|
||||
dy = ((i - viewheight*8)<<FRACBITS) + FRACUNIT/2;
|
||||
dy = abs(dy);
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
}
|
||||
|
@ -726,7 +742,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
|
|||
static mobj_t *viewmobj;
|
||||
|
||||
// WARNING: a should be unsigned but to add with 2048, it isn't!
|
||||
#define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS)
|
||||
#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS, fovtan)
|
||||
|
||||
// recalc necessary stuff for mouseaiming
|
||||
// slopes are already calculated for the full possible view (which is 4*viewheight).
|
||||
|
@ -1175,6 +1191,7 @@ void R_RegisterEngineStuff(void)
|
|||
CV_RegisterVar(&cv_drawdist);
|
||||
CV_RegisterVar(&cv_drawdist_nights);
|
||||
CV_RegisterVar(&cv_drawdist_precip);
|
||||
CV_RegisterVar(&cv_fov);
|
||||
|
||||
CV_RegisterVar(&cv_chasecam);
|
||||
CV_RegisterVar(&cv_chasecam2);
|
||||
|
|
|
@ -84,6 +84,7 @@ extern conscar_t cv_shadowoffs;
|
|||
#endif //#ifdef GLBADSHADOWS
|
||||
extern consvar_t cv_translucency;
|
||||
extern consvar_t cv_drawdist, cv_drawdist_nights, cv_drawdist_precip;
|
||||
extern consvar_t cv_fov;
|
||||
extern consvar_t cv_skybox;
|
||||
extern consvar_t cv_tailspickup;
|
||||
|
||||
|
|
Loading…
Reference in a new issue