SPLITSCREEN FOV

Object tracking is off, but it was off before so I don't know if I actually
broke it. Minor refactoring in HWR_RenderPlayerView and HWR_RenderSkyboxView.
This commit is contained in:
James R 2020-09-23 01:39:05 -07:00
parent a32486b5b9
commit 997d142cb5
20 changed files with 159 additions and 161 deletions

View file

@ -480,7 +480,7 @@ static void D_Display(void)
#ifdef HWRENDER
if (rendermode != render_soft)
HWR_RenderPlayerView(i, &players[displayplayers[i]]);
HWR_RenderPlayerView();
else
#endif
if (rendermode != render_none)
@ -519,7 +519,7 @@ static void D_Display(void)
topleft = screens[0] + viewwindowy*vid.width + viewwindowx;
}
R_RenderPlayerView(&players[displayplayers[i]]);
R_RenderPlayerView();
if (i > 0)
M_Memcpy(ylookup, ylookup1, viewheight*sizeof (ylookup[0]));

View file

@ -331,7 +331,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
// NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function
float render_fov = FIXED_TO_FLOAT(cv_fov.value);
float render_fov = FIXED_TO_FLOAT(cv_fov[viewssnum].value);
float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right?
float render_multiplier = 64.0f / render_fovratio / RMUL;
@ -463,4 +463,4 @@ boolean gld_SphereInFrustum(float x, float y, float z, float radius)
}
return true;
}
#endif
#endif

View file

@ -5405,7 +5405,7 @@ static void HWR_DrawSkyBackground(player_t *player)
if (cv_glskydome.value)
{
FTransform dometransform;
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[0];
SINT8 i;
@ -5633,21 +5633,10 @@ static void HWR_SetTransformAiming(FTransform *trans, player_t *player, boolean
// ==========================================================================
// Same as rendering the player view, but from the skybox object
// ==========================================================================
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
void HWR_RenderSkyboxView(player_t *player)
{
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
postimg_t *type = &postimgtype[0];
SINT8 i;
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
// i is now splitscreen player num
break;
}
}
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[viewssnum];
{
// do we really need to save player (is it not the same)?
@ -5656,7 +5645,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
ST_doPaletteStuff();
stplyr = saved_player;
#ifdef ALAM_LIGHTING
HWR_SetLights(viewnumber);
HWR_SetLights(viewssnum);
#endif
}
@ -5673,7 +5662,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
gl_centery = gl_basecentery;
gl_viewwindowy = gl_baseviewwindowy;
gl_windowcentery = gl_basewindowcentery;
if (r_splitscreen && viewnumber == 1)
if (viewssnum == 1)
{
gl_viewwindowy += (vid.height/2);
gl_windowcentery += (vid.height/2);
@ -5736,7 +5725,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
drawcount = 0;
#ifdef NEWCLIP
if (rendermode == render_opengl)
{
angle_t a1 = gld_FrustumAngle(gl_aimingangle);
gld_clipper_Clear();
@ -5766,10 +5754,10 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
#ifndef NEWCLIP
// Make a viewangle int so we can render things based on mouselook
viewangle = localaiming[i];
viewangle = localaiming[viewssnum];
// Handle stuff when you are looking farther up or down.
if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
if ((gl_aimingangle || fpov > 90.0f))
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();
@ -5830,26 +5818,17 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player)
// ==========================================================================
//
// ==========================================================================
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
void HWR_RenderPlayerView(void)
{
const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd);
postimg_t *type = &postimgtype[0];
SINT8 i;
player_t * player = &players[displayplayers[viewssnum]];
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
postimg_t *type = &postimgtype[viewssnum];
const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on
FRGBAFloat ClearColor;
for (i = r_splitscreen; i >= 0; i--)
{
if (player == &players[displayplayers[i]])
{
type = &postimgtype[i];
// i is now splitscreen player num
break;
}
}
ClearColor.red = 0.0f;
ClearColor.green = 0.0f;
ClearColor.blue = 0.0f;
@ -5858,11 +5837,11 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
if (cv_glshaders.value)
HWD.pfnSetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime.
if (viewnumber == 0) // Only do it if it's the first screen being rendered
if (viewssnum == 0) // Only do it if it's the first screen being rendered
HWD.pfnClearBuffer(true, false, &ClearColor); // Clear the Color Buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs.
if (skybox && drawsky) // If there's a skybox and we should be drawing the sky, draw the skybox
HWR_RenderSkyboxView(viewnumber, player); // This is drawn before everything else so it is placed behind
HWR_RenderSkyboxView(player); // This is drawn before everything else so it is placed behind
{
// do we really need to save player (is it not the same)?
@ -5871,7 +5850,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
ST_doPaletteStuff();
stplyr = saved_player;
#ifdef ALAM_LIGHTING
HWR_SetLights(viewnumber);
HWR_SetLights(viewssnum);
#endif
}
@ -5889,7 +5868,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
gl_centery = gl_basecentery;
gl_viewwindowy = gl_baseviewwindowy;
gl_windowcentery = gl_basewindowcentery;
if (r_splitscreen && viewnumber == 1)
if (viewssnum == 1)
{
gl_viewwindowy += (vid.height/2);
gl_windowcentery += (vid.height/2);
@ -5952,7 +5931,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
drawcount = 0;
#ifdef NEWCLIP
if (rendermode == render_opengl)
{
angle_t a1 = gld_FrustumAngle(gl_aimingangle);
gld_clipper_Clear();
@ -5986,10 +5964,10 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player)
#ifndef NEWCLIP
// Make a viewangle int so we can render things based on mouselook
viewangle = localaiming[i];
viewangle = localaiming[viewssnum];
// Handle stuff when you are looking farther up or down.
if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT))
if ((gl_aimingangle || fpov > 90.0f))
{
dup_viewangle += ANGLE_90;
HWR_ClearClipSegs();

View file

@ -29,8 +29,8 @@ void HWR_drawAMline(const fline_t *fl, INT32 color);
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
void HWR_DrawConsoleBack(UINT32 color, INT32 height);
void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight);
void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player);
void HWR_RenderPlayerView(INT32 viewnumber, player_t *player);
void HWR_RenderSkyboxView(player_t *player);
void HWR_RenderPlayerView(void);
void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void);
void HWR_DrawViewBorder(INT32 clearlines);

View file

@ -2196,7 +2196,7 @@ static void K_drawKartWanted(void)
}
}
static void K_ObjectTracking(fixed_t *hud_x, fixed_t *hud_y, vector3_t *campos, angle_t camang, angle_t camaim, vector3_t *point)
static void K_ObjectTracking(fixed_t *hud_x, fixed_t *hud_y, vector3_t *campos, angle_t camang, angle_t camaim, vector3_t *point, UINT8 cnum)
{
const INT32 swhalf = (BASEVIDWIDTH / 2);
const fixed_t swhalffixed = swhalf * FRACUNIT;
@ -2212,7 +2212,7 @@ static void K_ObjectTracking(fixed_t *hud_x, fixed_t *hud_y, vector3_t *campos,
fixed_t distance = R_PointToDist2(campos->x, campos->y, point->x, point->y);
fixed_t factor = INT32_MAX;
const fixed_t fov = cv_fov.value;
const fixed_t fov = cv_fov[cnum].value;
fixed_t intendedfov = 90*FRACUNIT;
fixed_t fovmul = FRACUNIT;
@ -2389,7 +2389,7 @@ static void K_drawKartPlayerCheck(void)
pnum += 2;
}
K_ObjectTracking(&x, NULL, &c, thiscam->angle + ANGLE_180, 0, &v);
K_ObjectTracking(&x, NULL, &c, thiscam->angle + ANGLE_180, 0, &v, cnum);
colormap = R_GetTranslationColormap(TC_DEFAULT, checkplayer->mo->color, GTC_CACHE);
V_DrawFixedPatch(x, CHEK_Y * FRACUNIT, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN|splitflags, kp_check[pnum], colormap);
@ -2614,7 +2614,7 @@ static void K_drawKartNameTags(void)
v.z += ntplayer->mo->height;
}
K_ObjectTracking(&x, &y, &c, thiscam->angle, thiscam->aiming, &v);
K_ObjectTracking(&x, &y, &c, thiscam->angle, thiscam->aiming, &v, cnum);
/*
if ((x < 0 || x > BASEVIDWIDTH * FRACUNIT)

View file

@ -1272,7 +1272,6 @@ static menuitem_t OP_VideoOptionsMenu[] =
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 90},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 100},
{IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 110},
{IT_STRING | IT_CVAR, NULL, "Field of View", &cv_fov, 120},
#ifdef HWRENDER
{IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 140},
@ -1290,7 +1289,6 @@ enum
op_video_wdd,
//op_video_wd,
op_video_skybox,
op_video_fov,
op_video_fps,
op_video_vsync,
#ifdef HWRENDER

View file

@ -446,34 +446,34 @@ static void R_AddLine(seg_t *line)
angle1 -= viewangle;
angle2 -= viewangle;
tspan = angle1 + clipangle;
if (tspan > doubleclipangle)
tspan = angle1 + clipangle[viewssnum];
if (tspan > doubleclipangle[viewssnum])
{
tspan -= doubleclipangle;
tspan -= doubleclipangle[viewssnum];
// Totally off the left edge?
if (tspan >= span)
return;
angle1 = clipangle;
angle1 = clipangle[viewssnum];
}
tspan = clipangle - angle2;
if (tspan > doubleclipangle)
tspan = clipangle[viewssnum] - angle2;
if (tspan > doubleclipangle[viewssnum])
{
tspan -= doubleclipangle;
tspan -= doubleclipangle[viewssnum];
// Totally off the left edge?
if (tspan >= span)
return;
angle2 = -(signed)clipangle;
angle2 = -(signed)clipangle[viewssnum];
}
// The seg is in the view range, but not necessarily visible.
angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT;
angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT;
x1 = viewangletox[angle1];
x2 = viewangletox[angle2];
x1 = viewangletox[viewssnum][angle1];
x2 = viewangletox[viewssnum][angle2];
// Does not cross a pixel?
if (x1 >= x2) // killough 1/31/98 -- change == to >= for robustness
@ -658,16 +658,16 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
angle2 = ANGLE_180;
}
if ((signed)angle2 >= (signed)clipangle) return false;
if ((signed)angle1 <= -(signed)clipangle) return false;
if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle;
if ((signed)angle2 <= -(signed)clipangle) angle2 = 0-clipangle;
if ((signed)angle2 >= (signed)clipangle[viewssnum]) return false;
if ((signed)angle1 <= -(signed)clipangle[viewssnum]) return false;
if ((signed)angle1 >= (signed)clipangle[viewssnum]) angle1 = clipangle[viewssnum];
if ((signed)angle2 <= -(signed)clipangle[viewssnum]) angle2 = 0-clipangle[viewssnum];
// Find the first clippost that touches the source post (adjacent pixels are touching).
angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT;
angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT;
sx1 = viewangletox[angle1];
sx2 = viewangletox[angle2];
sx1 = viewangletox[viewssnum][angle1];
sx2 = viewangletox[viewssnum][angle2];
// Does not cross a pixel.
if (sx1 >= sx2) return false;

View file

@ -117,7 +117,8 @@ UINT8 *ds_transmap; // one of the translucency tables
pslope_t *ds_slope; // Current slope being used
floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff?
floatv3_t *ds_sup, *ds_svp, *ds_szp;
float focallengthf, zeroheight;
float focallengthf[MAXSPLITSCREENPLAYERS];
float zeroheight;
/** \brief Variable flat sizes
*/

View file

@ -71,7 +71,8 @@ typedef struct {
extern pslope_t *ds_slope; // Current slope being used
extern floatv3_t ds_su[MAXVIDHEIGHT], ds_sv[MAXVIDHEIGHT], ds_sz[MAXVIDHEIGHT]; // Vectors for... stuff?
extern floatv3_t *ds_sup, *ds_svp, *ds_szp;
extern float focallengthf, zeroheight;
extern float focallengthf[MAXSPLITSCREENPLAYERS];
extern float zeroheight;
// Variable flat sizes
extern UINT32 nflatxshift;

View file

@ -643,7 +643,7 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end)
}
}
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan[viewssnum]))
/** \brief The R_DrawTiltedSpan_8 function
Draw slopes! Holy sheit!

View file

@ -61,7 +61,7 @@ void R_DrawSpan_NPO2_8 (void)
}
}
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan))
#define PLANELIGHTFLOAT (BASEVIDWIDTH * BASEVIDWIDTH / vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f * FIXED_TO_FLOAT(fovtan[viewssnum]))
/** \brief The R_DrawTiltedSpan_NPO2_8 function
Draw slopes! Holy sheit!

View file

@ -60,9 +60,9 @@ size_t validcount = 1;
INT32 centerx, centery;
fixed_t centerxfrac, centeryfrac;
fixed_t projection;
fixed_t projectiony; // aspect ratio
fixed_t fovtan; // field of view
fixed_t projection[MAXSPLITSCREENPLAYERS];
fixed_t projectiony[MAXSPLITSCREENPLAYERS]; // aspect ratio
fixed_t fovtan[MAXSPLITSCREENPLAYERS]; // field of view
// just for profiling purposes
size_t framecount;
@ -82,19 +82,19 @@ int r_splitscreen;
//
// precalculated math tables
//
angle_t clipangle;
angle_t doubleclipangle;
angle_t clipangle[MAXSPLITSCREENPLAYERS];
angle_t doubleclipangle[MAXSPLITSCREENPLAYERS];
// The viewangletox[viewangle + FINEANGLES/4] lookup
// maps the visible view angles to screen X coordinates,
// flattening the arc to a flat projection plane.
// There will be many angles mapped to the same X.
INT32 viewangletox[FINEANGLES/2];
INT32 viewangletox[MAXSPLITSCREENPLAYERS][FINEANGLES/2];
// The xtoviewangleangle[] table maps a screen pixel
// to the lowest viewangle that maps back to x ranges
// from clipangle to -clipangle.
angle_t xtoviewangle[MAXVIDWIDTH+1];
angle_t xtoviewangle[MAXSPLITSCREENPLAYERS][MAXVIDWIDTH+1];
lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
lighttable_t *scalelightfixed[MAXLIGHTSCALE];
@ -161,7 +161,13 @@ consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_c
consvar_t cv_drawdist = {"drawdist", "8192", 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_fov = {"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fov[MAXSPLITSCREENPLAYERS] = {
{"fov", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"fov2", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"fov3", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"fov4", "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", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -432,7 +438,8 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle)
angle_t angleb = ANGLE_90 + (visangle-rw_normalangle);
fixed_t den = FixedMul(rw_distance, FINESINE(anglea>>ANGLETOFINESHIFT));
// proff 11/06/98: Changed for high-res
fixed_t num = FixedMul(projectiony, FINESINE(angleb>>ANGLETOFINESHIFT));
fixed_t num = FixedMul(projectiony[viewssnum],
FINESINE(angleb>>ANGLETOFINESHIFT));
if (den > num>>16)
{
@ -490,7 +497,7 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
//
// R_InitTextureMapping
//
static void R_InitTextureMapping(void)
static void R_InitTextureMapping(int s)
{
INT32 i;
INT32 x;
@ -503,16 +510,16 @@ static void R_InitTextureMapping(void)
//
// Calc focallength
// so FIELDOFVIEW angles covers SCREENWIDTH.
focallength = FixedDiv(projection,
focallength = FixedDiv(projection[s],
FINETANGENT(FINEANGLES/4+FIELDOFVIEW/2));
focallengthf = FIXED_TO_FLOAT(focallength);
focallengthf[s] = FIXED_TO_FLOAT(focallength);
for (i = 0; i < FINEANGLES/2; i++)
{
if (FINETANGENT(i) > fovtan*2)
if (FINETANGENT(i) > fovtan[s]*2)
t = -1;
else if (FINETANGENT(i) < -fovtan*2)
else if (FINETANGENT(i) < -fovtan[s]*2)
t = viewwidth+1;
else
{
@ -524,7 +531,7 @@ static void R_InitTextureMapping(void)
else if (t > viewwidth+1)
t = viewwidth+1;
}
viewangletox[i] = t;
viewangletox[s][i] = t;
}
// Scan viewangletox[] to generate xtoviewangle[]:
@ -533,22 +540,22 @@ static void R_InitTextureMapping(void)
for (x = 0; x <= viewwidth;x++)
{
i = 0;
while (viewangletox[i] > x)
while (viewangletox[s][i] > x)
i++;
xtoviewangle[x] = (i<<ANGLETOFINESHIFT) - ANGLE_90;
xtoviewangle[s][x] = (i<<ANGLETOFINESHIFT) - ANGLE_90;
}
// Take out the fencepost cases from viewangletox.
for (i = 0; i < FINEANGLES/2; i++)
{
if (viewangletox[i] == -1)
viewangletox[i] = 0;
else if (viewangletox[i] == viewwidth+1)
viewangletox[i] = viewwidth;
if (viewangletox[s][i] == -1)
viewangletox[s][i] = 0;
else if (viewangletox[s][i] == viewwidth+1)
viewangletox[s][i] = viewwidth;
}
clipangle = xtoviewangle[0];
doubleclipangle = clipangle*2;
clipangle[s] = xtoviewangle[s][0];
doubleclipangle[s] = clipangle[s]*2;
}
@ -914,6 +921,7 @@ void R_ExecuteSetViewSize(void)
INT32 level;
INT32 startmapl;
angle_t fov;
int s;
setsizeneeded = false;
@ -942,17 +950,33 @@ void R_ExecuteSetViewSize(void)
centerxfrac = centerx<<FRACBITS;
centeryfrac = centery<<FRACBITS;
fov = FixedAngle(cv_fov.value/2) + ANGLE_90;
fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded);
if (r_splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
fovtan = 17*fovtan/10;
for (s = 0; s <= r_splitscreen; ++s)
{
fov = FixedAngle(cv_fov[s].value/2) + ANGLE_90;
fovtan[s] = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded);
if (r_splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
fovtan[s] = 17*fovtan[s]/10;
projection = projectiony = FixedDiv(centerxfrac, fovtan);
projection[s] = projectiony[s] = FixedDiv(centerxfrac, fovtan[s]);
R_InitTextureMapping(s);
// planes
if (rendermode == render_soft)
{
// this is only used for planes rendering in software mode
j = viewheight*16;
for (i = 0; i < j; i++)
{
dy = ((i - viewheight*8)<<FRACBITS) + FRACUNIT/2;
dy = FixedMul(abs(dy), fovtan[s]);
yslopetab[s][i] = FixedDiv(centerx*FRACUNIT, dy);
}
}
}
R_InitViewBuffer(scaledviewwidth, viewheight);
R_InitTextureMapping();
// thing clipping
for (i = 0; i < viewwidth; i++)
screenheightarray[i] = (INT16)viewheight;
@ -960,19 +984,6 @@ void R_ExecuteSetViewSize(void)
// setup sky scaling
R_SetSkyScale();
// planes
if (rendermode == render_soft)
{
// this is only used for planes rendering in software mode
j = viewheight*16;
for (i = 0; i < j; i++)
{
dy = ((i - viewheight*8)<<FRACBITS) + FRACUNIT/2;
dy = FixedMul(abs(dy), fovtan);
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
}
}
memset(scalelight, 0xFF, sizeof(scalelight));
// Calculate the light levels to use for each level/scale combination.
@ -1107,7 +1118,7 @@ static void R_SetupFreelook(void)
if (rendermode == render_soft)
{
dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH;
yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)];
yslope = &yslopetab[viewssnum][viewheight*8 - (viewheight/2 + dy)];
}
centery = (viewheight/2) + dy;
@ -1446,8 +1457,10 @@ static void Mask_Post (maskcount_t* m)
// I mean, there is a win16lock() or something that lasts all the rendering,
// so maybe we should release screen lock before each netupdate below..?
void R_RenderPlayerView(player_t *player)
void R_RenderPlayerView(void)
{
player_t * player = &players[displayplayers[viewssnum]];
UINT8 nummasks = 1;
maskcount_t* masks = malloc(sizeof(maskcount_t));
@ -1622,13 +1635,13 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_drawdist);
CV_RegisterVar(&cv_drawdist_precip);
CV_RegisterVar(&cv_fov);
CV_RegisterVar(&cv_shadow);
CV_RegisterVar(&cv_skybox);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_fov[i]);
CV_RegisterVar(&cv_chasecam[i]);
CV_RegisterVar(&cv_cam_dist[i]);
CV_RegisterVar(&cv_cam_still[i]);

View file

@ -24,9 +24,11 @@ extern fixed_t viewcos, viewsin;
extern INT32 viewheight;
extern INT32 centerx, centery;
extern fixed_t centerxfrac, centeryfrac;
extern fixed_t projection, projectiony;
extern fixed_t fovtan;
extern fixed_t centerxfrac;
extern fixed_t centeryfrac;
extern fixed_t projection[MAXSPLITSCREENPLAYERS];
extern fixed_t projectiony[MAXSPLITSCREENPLAYERS];
extern fixed_t fovtan[MAXSPLITSCREENPLAYERS];
extern size_t validcount, linecount, loopcount, framecount;
@ -46,7 +48,7 @@ extern size_t validcount, linecount, loopcount, framecount;
#define MAXLIGHTZ 128
#define LIGHTZSHIFT 20
#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width)
#define LIGHTRESOLUTIONFIX (640*fovtan[viewssnum]/vid.width)
extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
extern lighttable_t *scalelightfixed[MAXLIGHTSCALE];
@ -102,7 +104,7 @@ extern consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_shadow;
extern consvar_t cv_drawdist, cv_drawdist_precip;
extern consvar_t cv_fov;
extern consvar_t cv_fov[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup;
@ -130,7 +132,7 @@ boolean R_ViewpointHasChasecam(player_t *player);
boolean R_IsViewpointThirdPerson(player_t *player, boolean skybox);
// Called by D_Display.
void R_RenderPlayerView(player_t *player);
void R_RenderPlayerView(void);
// add commands related to engine, at game startup
void R_RegisterEngineStuff(void);

View file

@ -92,7 +92,7 @@ static fixed_t planeheight;
// (this is to calculate yslopes only when really needed)
// (when mouselookin', yslope is moving into yslopetab)
// Check R_SetupFrame, R_SetViewSize for more...
fixed_t yslopetab[MAXVIDHEIGHT*16];
fixed_t yslopetab[MAXSPLITSCREENPLAYERS][MAXVIDHEIGHT*16];
fixed_t *yslope;
fixed_t basexscale, baseyscale;
@ -622,7 +622,7 @@ static void R_DrawSkyPlane(visplane_t *pl)
colfunc = colfuncs[BASEDRAWFUNC];
// use correct aspect ratio scale
dc_iscale = skyscale;
dc_iscale = skyscale[viewssnum];
// Sky is always drawn full bright,
// i.e. colormaps[0] is used.
@ -639,8 +639,8 @@ static void R_DrawSkyPlane(visplane_t *pl)
if (dc_yl <= dc_yh)
{
angle = (pl->viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT;
dc_iscale = FixedMul(skyscale, FINECOSINE(xtoviewangle[x]>>ANGLETOFINESHIFT));
angle = (pl->viewangle + xtoviewangle[viewssnum][x])>>ANGLETOSKYSHIFT;
dc_iscale = FixedMul(skyscale[viewssnum], FINECOSINE(xtoviewangle[viewssnum][x]>>ANGLETOFINESHIFT));
dc_x = x;
dc_source =
R_GetColumn(texturetranslation[skytexture],
@ -895,9 +895,9 @@ d.z = (v1.x * v2.y) - (v1.y * v2.x)
CROSS(ds_sz[i], m, n);
#undef CROSS
ds_su[i].z *= focallengthf;
ds_sv[i].z *= focallengthf;
ds_sz[i].z *= focallengthf;
ds_su[i].z *= focallengthf[viewssnum];
ds_sv[i].z *= focallengthf[viewssnum];
ds_sz[i].z *= focallengthf[viewssnum];
// Premultiply the texture vectors with the scale factors
#define SFMULT 65536.f

View file

@ -62,7 +62,8 @@ extern INT16 *lastopening, *openings;
extern size_t maxopenings;
extern INT16 floorclip[MAXVIDWIDTH], ceilingclip[MAXVIDWIDTH];
extern fixed_t frontscale[MAXVIDWIDTH], yslopetab[MAXVIDHEIGHT*16];
extern fixed_t frontscale[MAXVIDWIDTH];
extern fixed_t yslopetab[MAXSPLITSCREENPLAYERS][MAXVIDHEIGHT*16];
extern fixed_t cachedheight[MAXVIDHEIGHT];
extern fixed_t cacheddistance[MAXVIDHEIGHT];
extern fixed_t cachedxstep[MAXVIDHEIGHT];

View file

@ -203,7 +203,7 @@ static void R_DrawWallSplats(void)
dc_iscale = 0xffffffffu / (unsigned)spryscale;
// find column of patch, from perspective
angle = (rw_centerangle + xtoviewangle[dc_x])>>ANGLETOFINESHIFT;
angle = (rw_centerangle + xtoviewangle[viewssnum][dc_x])>>ANGLETOFINESHIFT;
texturecolumn = rw_offset2 - splat->offset
- FixedMul(FINETANGENT(angle), rw_distance);
@ -1353,7 +1353,7 @@ static void R_RenderSegLoop (void)
//SoM: Calculate offsets for Thick fake floors.
// calculate texture offset
angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
angle = (rw_centerangle + xtoviewangle[viewssnum][rw_x])>>ANGLETOFINESHIFT;
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle),rw_distance);
if (oldtexturecolumn != -1) {
@ -1687,11 +1687,11 @@ void R_StoreWallRange(INT32 start, INT32 stop)
} // end of code to remove limits on openings
// calculate scale at both ends and step
ds_p->scale1 = rw_scale = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[start]);
ds_p->scale1 = rw_scale = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[viewssnum][start]);
if (stop > start)
{
ds_p->scale2 = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[stop]);
ds_p->scale2 = R_ScaleFromGlobalAngle(viewangle + xtoviewangle[viewssnum][stop]);
range = stop-start;
}
else
@ -1726,7 +1726,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
angle_t temp;
// left
temp = xtoviewangle[start]+viewangle;
temp = xtoviewangle[viewssnum][start]+viewangle;
{
// Both lines can be written in slope-intercept form, so figure out line intersection
@ -1748,7 +1748,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
}
// right
temp = xtoviewangle[stop]+viewangle;
temp = xtoviewangle[viewssnum][stop]+viewangle;
{
// Both lines can be written in slope-intercept form, so figure out line intersection

View file

@ -43,7 +43,7 @@ INT32 skytexturemid;
/** \brief the scale of the sky
*/
fixed_t skyscale;
fixed_t skyscale[MAXSPLITSCREENPLAYERS];
/** \brief used for keeping track of the current sky
*/
@ -76,5 +76,9 @@ void R_SetupSkyDraw(void)
void R_SetSkyScale(void)
{
fixed_t difference = vid.fdupx-(vid.dupx<<FRACBITS);
skyscale = FixedDiv(fovtan, vid.fdupx+difference);
int i;
for (i = 0; i <= r_splitscreen; ++i)
{
skyscale[i] = FixedDiv(fovtan[i], vid.fdupx+difference);
}
}

View file

@ -27,7 +27,7 @@
#define ANGLETOSKYSHIFT 22
extern INT32 skytexture, skytexturemid;
extern fixed_t skyscale;
extern fixed_t skyscale[MAXSPLITSCREENPLAYERS];
extern INT32 skyflatnum;
extern char levelskytexture[9];

View file

@ -100,11 +100,11 @@ extern mobj_t *r_viewmobj;
extern consvar_t cv_allowmlook;
extern consvar_t cv_maxportals;
extern angle_t clipangle;
extern angle_t doubleclipangle;
extern angle_t clipangle[MAXSPLITSCREENPLAYERS];
extern angle_t doubleclipangle[MAXSPLITSCREENPLAYERS];
extern INT32 viewangletox[FINEANGLES/2];
extern angle_t xtoviewangle[MAXVIDWIDTH+1];
extern INT32 viewangletox[MAXSPLITSCREENPLAYERS][FINEANGLES/2];
extern angle_t xtoviewangle[MAXSPLITSCREENPLAYERS][MAXVIDWIDTH+1];
extern fixed_t rw_distance;
extern angle_t rw_normalangle;

View file

@ -902,7 +902,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
// Papersprite drawing loop
for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += vis->scalestep)
{
angle_t angle = ((vis->centerangle + xtoviewangle[dc_x]) >> ANGLETOFINESHIFT) & 0xFFF;
angle_t angle = ((vis->centerangle + xtoviewangle[viewssnum][dc_x]) >> ANGLETOFINESHIFT) & 0xFFF;
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / this_scale;
if (texturecolumn < 0 || texturecolumn >= pwidth)
@ -1245,8 +1245,8 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
scalemul = FixedMul(FRACUNIT - floordiff/640, scale);
patch = W_CachePatchName((thing->whiteshadow == true ? "LSHADOW" : "DSHADOW"), PU_CACHE);
xscale = FixedDiv(projection, tz);
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection[viewssnum], tz);
yscale = FixedDiv(projectiony[viewssnum], tz);
shadowxscale = FixedMul(thing->radius*2, scalemul);
shadowyscale = FixedMul(FixedMul(thing->radius*2, scalemul), FixedDiv(abs(groundz - viewz), tz));
shadowyscale = min(shadowyscale, shadowxscale) / SHORT(patch->height);
@ -1444,12 +1444,12 @@ static void R_ProjectSprite(mobj_t *thing)
basetx = tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
// too far off the side?
if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later
if (!papersprite && abs(tx) > FixedMul(tz, fovtan[viewssnum])<<2) // papersprite clipping is handled later
return;
// aspect ratio stuff
xscale = FixedDiv(projection, tz);
sortscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection[viewssnum], tz);
sortscale = FixedDiv(projectiony[viewssnum], tz);
// decide which patch to use for sprite relative to player
#ifdef RANGECHECK
@ -1635,11 +1635,11 @@ static void R_ProjectSprite(mobj_t *thing)
tz2 = FixedMul(MINZ, this_scale);
}
if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side?
if (tx2 < -(FixedMul(tz2, fovtan[viewssnum])<<2) || tx > FixedMul(tz, fovtan[viewssnum])<<2) // too far off the side?
return;
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection, tz);
yscale = FixedDiv(projectiony[viewssnum], tz);
xscale = FixedDiv(projection[viewssnum], tz);
x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS;
@ -1647,8 +1647,8 @@ static void R_ProjectSprite(mobj_t *thing)
if (x1 > viewwidth)
return;
yscale2 = FixedDiv(projectiony, tz2);
xscale2 = FixedDiv(projection, tz2);
yscale2 = FixedDiv(projectiony[viewssnum], tz2);
xscale2 = FixedDiv(projection[viewssnum], tz2);
x2 = (centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS;
@ -1699,7 +1699,7 @@ static void R_ProjectSprite(mobj_t *thing)
tr_x = thingxpos - viewx;
tr_y = thingypos - viewy;
tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin);
linkscale = FixedDiv(projectiony, tz);
linkscale = FixedDiv(projectiony[viewssnum], tz);
if (tz < FixedMul(MINZ, this_scale))
return;
@ -1940,12 +1940,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance
// too far off the side?
if (abs(tx) > FixedMul(tz, fovtan)<<2)
if (abs(tx) > FixedMul(tz, fovtan[viewssnum])<<2)
return;
// aspect ratio stuff :
xscale = FixedDiv(projection, tz);
yscale = FixedDiv(projectiony, tz);
xscale = FixedDiv(projection[viewssnum], tz);
yscale = FixedDiv(projectiony[viewssnum], tz);
// decide which patch to use for sprite relative to player
#ifdef RANGECHECK