Squashed commit of the following:
commit ec89015662e12dada02877feb9309b565a07b2a4 Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 11:19:59 2020 -0600 Fix loss of aimingtody precision at high FOV commit f6efe19fca206f972ebe567051648b3b11f900c2 Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 11:15:36 2020 -0600 Use generally higher zooms and fix fuzzy edges commit 5757f24342f9dfdebe7bedc226f237bd0aea5cca Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 10:53:45 2020 -0600 Reduce the number of distinct roll angles commit 8679606ebb56975a93b7140184b45170b82bc3fe Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 10:53:23 2020 -0600 Remove a couple adds from each pixel of morph mapping commit af4479924ad616ddf50daee4d1886a59f159607a Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 10:53:00 2020 -0600 Fully clip drawing to roll-used screen bounds commit 8868fc4d8abce1b6393303155e758921f7ef9e4f Author: fickleheart <fickle@tinted.red> Date: Sat Jan 18 00:16:18 2020 -0600 Fix lighting discrepancies between different FOVs commit 1d221a453a183d3933b9176436e91efca9632011 Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 23:21:11 2020 -0600 Avoid rendering unused left/right edges of screen while rolling commit 21ccefe4eb96e3b3f3216025f40d6271faaac206 Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 22:03:16 2020 -0600 Fix sky texture scaling wrong with fov changes commit 7bd9344dd01cf541d86d3e7965e7037fb85ca494 Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 21:55:16 2020 -0600 I think this fixes the compile errors commit 64c4a4c02c6a59264446e9a43593e7397b774baa Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 20:39:38 2020 -0600 Fisheye lens experiments commit 2b7d75126e8e8641a4b413c74b3c65da87e0d309 Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 20:39:15 2020 -0600 Add DBG_VIEWMORPH to view pre-transformed view commit 84329fcd2677a42860f986e06b901434bc44966e Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 19:01:45 2020 -0600 OGL can have little a viewroll commit 7cf563eadd0c2a4e1977c7024ef40975159e5aff Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 18:32:13 2020 -0600 Un/archive viewrollangle in netsaves commit d63aa1031e4c26d0fe6f077e15764aa27c55005b Merge: e23f632cd 9a1cb0e30 Author: fickleheart <fickle@tinted.red> Date: Fri Jan 17 18:27:15 2020 -0600 Merge remote-tracking branch 'upstream/next' into viewroll commit e23f632cdbc687039ec25297ae0105142135e1a1 Author: fickleheart <fickle@tinted.red> Date: Tue Jan 14 23:44:21 2020 -0600 Clean up fisheye and fix crashes commit cdbea0be26067a5774778ba51a18df7aa661ce80 Author: fickleheart <fickle@tinted.red> Date: Tue Jan 14 23:30:39 2020 -0600 Revert "LMAO fisheye" This reverts commit cd957d84f7332fc71ebd1924aaa2b533684cc07d. commit cd957d84f7332fc71ebd1924aaa2b533684cc07d Author: fickleheart <fickle@tinted.red> Date: Tue Jan 14 23:30:19 2020 -0600 LMAO fisheye commit c25e9696760afa898f24acab9ff43378e4156499 Author: fickleheart <fickle@tinted.red> Date: Tue Jan 14 23:29:56 2020 -0600 wip viewroll stuff
This commit is contained in:
1 parent
e2749f8fdc
commit
421d1da205
12 files changed
+501
-24
No files matched your search
@@ -287,6 +287,9 @@ static void D_Display(void)
|
||||
if (vid.recalc)
|
||||
SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc()
|
||||
|
||||
if (rendermode == render_soft && !splitscreen)
|
||||
R_CheckViewMorph();
|
||||
|
||||
// change the view size if needed
|
||||
if (setsizeneeded)
|
||||
{
|
||||
@@ -496,6 +499,9 @@ static void D_Display(void)
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
if (!splitscreen)
|
||||
R_ApplyViewMorph();
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (postimgtype[i])
|
||||
|
||||
@@ -369,6 +369,8 @@ typedef struct player_s
|
||||
// bounded/scaled total momentum.
|
||||
//fixed_t bob;
|
||||
|
||||
angle_t viewrollangle;
|
||||
|
||||
// Mouse aiming, where the guy is looking at!
|
||||
// It is updated with cmd->aiming.
|
||||
angle_t aiming;
|
||||
|
||||
+2
-1
@@ -518,6 +518,7 @@ extern INT32 cv_debug;
|
||||
#define DBG_MEMORY 0x0200
|
||||
#define DBG_SETUP 0x0400
|
||||
#define DBG_LUA 0x0800
|
||||
#define DBG_VIEWMORPH 0x2000
|
||||
|
||||
// =======================
|
||||
// Misc stuff for later...
|
||||
@@ -528,7 +529,7 @@ extern UINT8 shiftdown, ctrldown, altdown;
|
||||
extern boolean capslock;
|
||||
|
||||
// WARNING: a should be unsigned but to add with 2048, it isn't!
|
||||
#define AIMINGTODY(a) (FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)
|
||||
#define AIMINGTODY(a) FixedDiv((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160), fovtan)
|
||||
|
||||
// if we ever make our alloc stuff...
|
||||
#define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL)
|
||||
|
||||
+14
-2
@@ -4471,7 +4471,7 @@ void HWR_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
|
||||
static boolean drewsky = false;
|
||||
|
||||
void HWR_DrawSkyBackground(float fpov)
|
||||
void HWR_DrawSkyBackground(player_t *player, float fpov)
|
||||
{
|
||||
FTransform dometransform;
|
||||
|
||||
@@ -4496,6 +4496,12 @@ void HWR_DrawSkyBackground(float fpov)
|
||||
dometransform.scalez = 1;
|
||||
dometransform.fovxangle = fpov; // Tails
|
||||
dometransform.fovyangle = fpov; // Tails
|
||||
if (player->viewrollangle != 0)
|
||||
{
|
||||
fixed_t rol = AngleFixed(player->viewrollangle);
|
||||
atransform.rollangle = FIXED_TO_FLOAT(rol);
|
||||
atransform.roll = true;
|
||||
}
|
||||
dometransform.splitscreen = splitscreen;
|
||||
|
||||
HWR_GetTexture(texturetranslation[skytexture]);
|
||||
@@ -4617,6 +4623,12 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
||||
|
||||
atransform.fovxangle = fpov; // Tails
|
||||
atransform.fovyangle = fpov; // Tails
|
||||
if (player->viewrollangle != 0)
|
||||
{
|
||||
fixed_t rol = AngleFixed(player->viewrollangle);
|
||||
atransform.rollangle = FIXED_TO_FLOAT(rol);
|
||||
atransform.roll = true;
|
||||
}
|
||||
atransform.splitscreen = splitscreen;
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
@@ -4640,7 +4652,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
|
||||
ST_doPaletteStuff();
|
||||
|
||||
// Draw the sky background.
|
||||
HWR_DrawSkyBackground(fpov);
|
||||
HWR_DrawSkyBackground(player, fpov);
|
||||
if (skybox)
|
||||
drewsky = true;
|
||||
|
||||
|
||||
@@ -3095,7 +3095,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
|
||||
else
|
||||
pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez);
|
||||
|
||||
pglMatrixMode(GL_MODELVIEW);
|
||||
if (stransform->roll)
|
||||
pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f);
|
||||
pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f);
|
||||
pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f);
|
||||
pglTranslatef(-stransform->x, -stransform->z, -stransform->y);
|
||||
|
||||
@@ -5165,6 +5165,8 @@ static void P_NiGHTSMovement(player_t *player)
|
||||
else // AngleFixed(R_PointToAngle2()) results in slight inaccuracy! Don't use it unless movement is on both axises.
|
||||
newangle = (INT16)FixedInt(AngleFixed(R_PointToAngle2(0,0, cmd->sidemove*FRACUNIT, cmd->forwardmove*FRACUNIT)));
|
||||
|
||||
newangle -= player->viewrollangle / ANG1;
|
||||
|
||||
if (newangle < 0 && moved)
|
||||
newangle = (INT16)(360+newangle);
|
||||
}
|
||||
|
||||
+143
-3
@@ -643,6 +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))
|
||||
|
||||
/** \brief The R_DrawTiltedSpan_8 function
|
||||
Draw slopes! Holy sheit!
|
||||
@@ -668,7 +669,7 @@ void R_DrawTiltedSpan_8(void)
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
||||
@@ -804,7 +805,7 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
||||
@@ -915,6 +916,145 @@ void R_DrawTiltedTranslucentSpan_8(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NOWATER
|
||||
/** \brief The R_DrawTiltedTranslucentWaterSpan_8 function
|
||||
Like DrawTiltedTranslucentSpan, but for water
|
||||
*/
|
||||
void R_DrawTiltedTranslucentWaterSpan_8(void)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
int width = ds_x2 - ds_x1;
|
||||
double iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
int i;
|
||||
|
||||
UINT8 *source;
|
||||
UINT8 *colormap;
|
||||
UINT8 *dest;
|
||||
UINT8 *dsrc;
|
||||
|
||||
double startz, startu, startv;
|
||||
double izstep, uzstep, vzstep;
|
||||
double endz, endu, endv;
|
||||
UINT32 stepu, stepv;
|
||||
|
||||
iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx);
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds_szp->x*width) * planelightfloat;
|
||||
lightstart = iz * planelightfloat;
|
||||
|
||||
R_CalcTiltedLighting(FLOAT_TO_FIXED(lightstart), FLOAT_TO_FIXED(lightend));
|
||||
//CONS_Printf("tilted lighting %f to %f (foc %f)\n", lightstart, lightend, focallengthf);
|
||||
}
|
||||
|
||||
uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx);
|
||||
vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx);
|
||||
|
||||
dest = ylookup[ds_y] + columnofs[ds_x1];
|
||||
dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1;
|
||||
source = ds_source;
|
||||
//colormap = ds_colormap;
|
||||
|
||||
#if 0 // The "perfect" reference version of this routine. Pretty slow.
|
||||
// Use it only to see how things are supposed to look.
|
||||
i = 0;
|
||||
do
|
||||
{
|
||||
double z = 1.f/iz;
|
||||
u = (INT64)(uz*z) + viewx;
|
||||
v = (INT64)(vz*z) + viewy;
|
||||
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++);
|
||||
dest++;
|
||||
iz += ds_szp->x;
|
||||
uz += ds_sup->x;
|
||||
vz += ds_svp->x;
|
||||
} while (--width >= 0);
|
||||
#else
|
||||
#define SPANSIZE 16
|
||||
#define INVSPAN 0.0625f
|
||||
|
||||
startz = 1.f/iz;
|
||||
startu = uz*startz;
|
||||
startv = vz*startz;
|
||||
|
||||
izstep = ds_szp->x * SPANSIZE;
|
||||
uzstep = ds_sup->x * SPANSIZE;
|
||||
vzstep = ds_svp->x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
{
|
||||
iz += izstep;
|
||||
uz += uzstep;
|
||||
vz += vzstep;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
stepu = (INT64)((endu - startu) * INVSPAN);
|
||||
stepv = (INT64)((endv - startv) * INVSPAN);
|
||||
u = (INT64)(startu) + viewx;
|
||||
v = (INT64)(startv) + viewy;
|
||||
|
||||
for (i = SPANSIZE-1; i >= 0; i--)
|
||||
{
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++);
|
||||
dest++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
}
|
||||
if (width > 0)
|
||||
{
|
||||
if (width == 1)
|
||||
{
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++);
|
||||
}
|
||||
else
|
||||
{
|
||||
double left = width;
|
||||
iz += ds_szp->x * left;
|
||||
uz += ds_sup->x * left;
|
||||
vz += ds_svp->x * left;
|
||||
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
left = 1.f/left;
|
||||
stepu = (INT64)((endu - startu) * left);
|
||||
stepv = (INT64)((endv - startv) * left);
|
||||
u = (INT64)(startu) + viewx;
|
||||
v = (INT64)(startv) + viewy;
|
||||
|
||||
for (; width != 0; width--)
|
||||
{
|
||||
colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps);
|
||||
*dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++);
|
||||
dest++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // NOWATER
|
||||
|
||||
void R_DrawTiltedSplat_8(void)
|
||||
{
|
||||
// x1, x2 = ds_x1, ds_x2
|
||||
@@ -938,7 +1078,7 @@ void R_DrawTiltedSplat_8(void)
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
{
|
||||
float planelightfloat = BASEVIDWIDTH*BASEVIDWIDTH/vid.width / (zeroheight - FIXED_TO_FLOAT(viewz)) / 21.0f;
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
float lightstart, lightend;
|
||||
|
||||
lightend = (iz + ds_sz.x*width) * planelightfloat;
|
||||
|
||||
+314
-4
@@ -622,6 +622,303 @@ static inline void R_InitLightTables(void)
|
||||
}
|
||||
}
|
||||
|
||||
//#define WOUGHMP_WOUGHMP // I got a fish-eye lens - I'll make a rap video with a couple of friends
|
||||
// it's kinda laggy sometimes
|
||||
|
||||
static struct {
|
||||
angle_t rollangle; // pre-shifted by fineshift
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
fixed_t fisheye;
|
||||
#endif
|
||||
|
||||
fixed_t zoomneeded;
|
||||
INT32 *scrmap;
|
||||
INT32 scrmapsize;
|
||||
|
||||
INT32 x1; // clip rendering horizontally for efficiency
|
||||
INT16 ceilingclip[MAXVIDWIDTH], floorclip[MAXVIDWIDTH];
|
||||
|
||||
boolean use;
|
||||
} viewmorph = {
|
||||
0,
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
0,
|
||||
#endif
|
||||
|
||||
FRACUNIT,
|
||||
NULL,
|
||||
0,
|
||||
|
||||
0,
|
||||
{}, {},
|
||||
|
||||
false
|
||||
};
|
||||
|
||||
void R_CheckViewMorph(void)
|
||||
{
|
||||
float zoomfactor, rollcos, rollsin;
|
||||
float x1, y1, x2, y2;
|
||||
fixed_t temp;
|
||||
INT32 end, vx, vy, pos, usedpos;
|
||||
INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2;
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
float fisheyemap[MAXVIDWIDTH/2 + 1];
|
||||
#endif
|
||||
|
||||
angle_t rollangle = players[displayplayer].viewrollangle;
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value
|
||||
#endif
|
||||
|
||||
rollangle >>= ANGLETOFINESHIFT;
|
||||
rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot.
|
||||
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
fisheye &= ~0x7FF; // Same
|
||||
#endif
|
||||
|
||||
if (rollangle == viewmorph.rollangle &&
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
fisheye == viewmorph.fisheye &&
|
||||
#endif
|
||||
viewmorph.scrmapsize == vid.width*vid.height)
|
||||
return; // No change
|
||||
|
||||
viewmorph.rollangle = rollangle;
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
viewmorph.fisheye = fisheye;
|
||||
#endif
|
||||
|
||||
if (viewmorph.rollangle == 0
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
&& viewmorph.fisheye == 0
|
||||
#endif
|
||||
)
|
||||
{
|
||||
viewmorph.use = false;
|
||||
viewmorph.x1 = 0;
|
||||
if (viewmorph.zoomneeded != FRACUNIT)
|
||||
R_SetViewSize();
|
||||
viewmorph.zoomneeded = FRACUNIT;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (viewmorph.scrmapsize != vid.width*vid.height)
|
||||
{
|
||||
if (viewmorph.scrmap)
|
||||
free(viewmorph.scrmap);
|
||||
viewmorph.scrmap = malloc(vid.width*vid.height * sizeof(INT32));
|
||||
viewmorph.scrmapsize = vid.width*vid.height;
|
||||
}
|
||||
|
||||
temp = FINECOSINE(rollangle);
|
||||
rollcos = FIXED_TO_FLOAT(temp);
|
||||
temp = FINESINE(rollangle);
|
||||
rollsin = FIXED_TO_FLOAT(temp);
|
||||
|
||||
// Calculate maximum zoom needed
|
||||
x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width;
|
||||
y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height;
|
||||
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
if (fisheye)
|
||||
{
|
||||
float f = FIXED_TO_FLOAT(fisheye);
|
||||
for (vx = 0; vx <= halfwidth; vx++)
|
||||
fisheyemap[vx] = 1.0f / cos(atan(vx * f / halfwidth));
|
||||
|
||||
f = cos(atan(f));
|
||||
if (f < 1.0f)
|
||||
{
|
||||
x1 /= f;
|
||||
y1 /= f;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
temp = max(x1, y1)*FRACUNIT;
|
||||
if (temp < FRACUNIT)
|
||||
temp = FRACUNIT;
|
||||
else
|
||||
temp |= 0x3FFF; // Limit how many times the viewport needs to be recalculated
|
||||
|
||||
//CONS_Printf("Setting zoom to %f\n", FIXED_TO_FLOAT(temp));
|
||||
|
||||
if (temp != viewmorph.zoomneeded)
|
||||
{
|
||||
viewmorph.zoomneeded = temp;
|
||||
R_SetViewSize();
|
||||
}
|
||||
|
||||
zoomfactor = FIXED_TO_FLOAT(viewmorph.zoomneeded);
|
||||
|
||||
end = vid.width * vid.height - 1;
|
||||
|
||||
pos = 0;
|
||||
|
||||
// Pre-multiply rollcos and rollsin to use for positional stuff
|
||||
rollcos /= zoomfactor;
|
||||
rollsin /= zoomfactor;
|
||||
|
||||
x1 = -(halfwidth * rollcos - halfheight * rollsin);
|
||||
y1 = -(halfheight * rollcos + halfwidth * rollsin);
|
||||
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
if (fisheye)
|
||||
viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin)) * fisheyemap[halfwidth]);
|
||||
else
|
||||
#endif
|
||||
viewmorph.x1 = (INT32)(halfwidth - (halfwidth * fabsf(rollcos) + halfheight * fabsf(rollsin)));
|
||||
//CONS_Printf("saving %d cols\n", viewmorph.x1);
|
||||
|
||||
// Set ceilingclip and floorclip
|
||||
for (vx = 0; vx < vid.width; vx++)
|
||||
{
|
||||
viewmorph.ceilingclip[vx] = vid.height;
|
||||
viewmorph.floorclip[vx] = -1;
|
||||
}
|
||||
x2 = x1;
|
||||
y2 = y1;
|
||||
for (vx = 0; vx < vid.width; vx++)
|
||||
{
|
||||
INT16 xa, ya, xb, yb;
|
||||
xa = x2+halfwidth;
|
||||
ya = y2+halfheight-1;
|
||||
xb = vid.width-1-xa;
|
||||
yb = vid.height-1-ya;
|
||||
|
||||
viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya);
|
||||
viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya);
|
||||
viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb);
|
||||
viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb);
|
||||
x2 += rollcos;
|
||||
y2 += rollsin;
|
||||
}
|
||||
x2 = x1;
|
||||
y2 = y1;
|
||||
for (vy = 0; vy < vid.height; vy++)
|
||||
{
|
||||
INT16 xa, ya, xb, yb;
|
||||
xa = x2+halfwidth;
|
||||
ya = y2+halfheight;
|
||||
xb = vid.width-1-xa;
|
||||
yb = vid.height-1-ya;
|
||||
|
||||
viewmorph.ceilingclip[xa] = min(viewmorph.ceilingclip[xa], ya);
|
||||
viewmorph.floorclip[xa] = max(viewmorph.floorclip[xa], ya);
|
||||
viewmorph.ceilingclip[xb] = min(viewmorph.ceilingclip[xb], yb);
|
||||
viewmorph.floorclip[xb] = max(viewmorph.floorclip[xb], yb);
|
||||
x2 -= rollsin;
|
||||
y2 += rollcos;
|
||||
}
|
||||
|
||||
//CONS_Printf("Top left corner is %f %f\n", x1, y1);
|
||||
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
if (fisheye)
|
||||
{
|
||||
for (vy = 0; vy < halfheight; vy++)
|
||||
{
|
||||
x2 = x1;
|
||||
y2 = y1;
|
||||
x1 -= rollsin;
|
||||
y1 += rollcos;
|
||||
|
||||
for (vx = 0; vx < vid.width; vx++)
|
||||
{
|
||||
usedx = halfwidth + x2*fisheyemap[(int) floorf(fabsf(y2*zoomfactor))];
|
||||
usedy = halfheight + y2*fisheyemap[(int) floorf(fabsf(x2*zoomfactor))];
|
||||
|
||||
usedpos = usedx + usedy*vid.width;
|
||||
|
||||
viewmorph.scrmap[pos] = usedpos;
|
||||
viewmorph.scrmap[end-pos] = end-usedpos;
|
||||
|
||||
x2 += rollcos;
|
||||
y2 += rollsin;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#endif
|
||||
x1 += halfwidth;
|
||||
y1 += halfheight;
|
||||
|
||||
for (vy = 0; vy < halfheight; vy++)
|
||||
{
|
||||
x2 = x1;
|
||||
y2 = y1;
|
||||
x1 -= rollsin;
|
||||
y1 += rollcos;
|
||||
|
||||
for (vx = 0; vx < vid.width; vx++)
|
||||
{
|
||||
usedx = x2;
|
||||
usedy = y2;
|
||||
|
||||
usedpos = usedx + usedy*vid.width;
|
||||
|
||||
viewmorph.scrmap[pos] = usedpos;
|
||||
viewmorph.scrmap[end-pos] = end-usedpos;
|
||||
|
||||
x2 += rollcos;
|
||||
y2 += rollsin;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
#ifdef WOUGHMP_WOUGHMP
|
||||
}
|
||||
#endif
|
||||
|
||||
viewmorph.use = true;
|
||||
}
|
||||
|
||||
void R_ApplyViewMorph(void)
|
||||
{
|
||||
UINT8 *tmpscr = screens[4];
|
||||
UINT8 *srcscr = screens[0];
|
||||
INT32 p, end = vid.width * vid.height;
|
||||
|
||||
if (!viewmorph.use)
|
||||
return;
|
||||
|
||||
if (cv_debug & DBG_VIEWMORPH)
|
||||
{
|
||||
UINT8 border = 32;
|
||||
UINT8 grid = 160;
|
||||
INT32 ws = vid.width / 4;
|
||||
INT32 hs = vid.width * (vid.height / 4);
|
||||
|
||||
memcpy(tmpscr, srcscr, vid.width*vid.height);
|
||||
for (p = 0; p < vid.width; p++)
|
||||
{
|
||||
tmpscr[viewmorph.scrmap[p]] = border;
|
||||
tmpscr[viewmorph.scrmap[p + hs]] = grid;
|
||||
tmpscr[viewmorph.scrmap[p + hs*2]] = grid;
|
||||
tmpscr[viewmorph.scrmap[p + hs*3]] = grid;
|
||||
tmpscr[viewmorph.scrmap[end - 1 - p]] = border;
|
||||
}
|
||||
for (p = vid.width; p < end; p += vid.width)
|
||||
{
|
||||
tmpscr[viewmorph.scrmap[p]] = border;
|
||||
tmpscr[viewmorph.scrmap[p + ws]] = grid;
|
||||
tmpscr[viewmorph.scrmap[p + ws*2]] = grid;
|
||||
tmpscr[viewmorph.scrmap[p + ws*3]] = grid;
|
||||
tmpscr[viewmorph.scrmap[end - 1 - p]] = border;
|
||||
}
|
||||
}
|
||||
else
|
||||
for (p = 0; p < end; p++)
|
||||
tmpscr[p] = srcscr[viewmorph.scrmap[p]];
|
||||
|
||||
VID_BlitLinearScreen(tmpscr, screens[0],
|
||||
vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// R_SetViewSize
|
||||
@@ -676,7 +973,7 @@ void R_ExecuteSetViewSize(void)
|
||||
centeryfrac = centery<<FRACBITS;
|
||||
|
||||
fov = FixedAngle(cv_fov.value/2) + ANGLE_90;
|
||||
fovtan = FINETANGENT(fov >> ANGLETOFINESHIFT);
|
||||
fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded);
|
||||
if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view
|
||||
fovtan = 17*fovtan/10;
|
||||
|
||||
@@ -833,7 +1130,7 @@ static void R_SetupFreelook(void)
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
dy = (AIMINGTODY(aimingangle)/fovtan) * viewwidth/BASEVIDWIDTH;
|
||||
dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH;
|
||||
yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)];
|
||||
}
|
||||
centery = (viewheight/2) + dy;
|
||||
@@ -1389,9 +1686,22 @@ void R_RenderPlayerView(player_t *player)
|
||||
validcount++;
|
||||
|
||||
// Clear buffers.
|
||||
R_ClearClipSegs();
|
||||
R_ClearDrawSegs();
|
||||
R_ClearPlanes();
|
||||
if (viewmorph.use)
|
||||
{
|
||||
portalclipstart = viewmorph.x1;
|
||||
portalclipend = viewwidth-viewmorph.x1-1;
|
||||
R_PortalClearClipSegs(portalclipstart, portalclipend);
|
||||
memcpy(ceilingclip, viewmorph.ceilingclip, sizeof(INT16)*vid.width);
|
||||
memcpy(floorclip, viewmorph.floorclip, sizeof(INT16)*vid.width);
|
||||
}
|
||||
else
|
||||
{
|
||||
portalclipstart = 0;
|
||||
portalclipend = viewwidth-1;
|
||||
R_ClearClipSegs();
|
||||
}
|
||||
R_ClearDrawSegs();
|
||||
R_ClearSprites();
|
||||
#ifdef FLOORSPLATS
|
||||
R_ClearVisibleFloorSplats();
|
||||
|
||||
@@ -26,6 +26,7 @@ extern INT32 centerx, centery;
|
||||
|
||||
extern fixed_t centerxfrac, centeryfrac;
|
||||
extern fixed_t projection, projectiony;
|
||||
extern fixed_t fovtan; // field of view
|
||||
|
||||
extern size_t validcount, linecount, loopcount, framecount;
|
||||
|
||||
@@ -45,6 +46,8 @@ extern size_t validcount, linecount, loopcount, framecount;
|
||||
#define MAXLIGHTZ 128
|
||||
#define LIGHTZSHIFT 20
|
||||
|
||||
#define LIGHTRESOLUTIONFIX (640*fovtan/vid.width)
|
||||
|
||||
extern lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
|
||||
extern lighttable_t *scalelightfixed[MAXLIGHTSCALE];
|
||||
extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
|
||||
@@ -86,6 +89,9 @@ extern consvar_t cv_tailspickup;
|
||||
// Called by startup code.
|
||||
void R_Init(void);
|
||||
|
||||
void R_CheckViewMorph(void);
|
||||
void R_ApplyViewMorph(void);
|
||||
|
||||
// just sets setsizeneeded true
|
||||
extern boolean setsizeneeded;
|
||||
void R_SetViewSize(void);
|
||||
|
||||
+7
-7
@@ -194,7 +194,7 @@ static void R_DrawWallSplats(void)
|
||||
// draw the columns
|
||||
for (dc_x = x1; dc_x <= x2; dc_x++, spryscale += rw_scalestep)
|
||||
{
|
||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE - 1;
|
||||
dc_colormap = walllights[pindex];
|
||||
@@ -547,7 +547,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
else
|
||||
xwalllights = scalelight[rlight->lightnum];
|
||||
|
||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE - 1;
|
||||
@@ -596,7 +596,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2)
|
||||
}
|
||||
|
||||
// calculate lighting
|
||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE - 1;
|
||||
@@ -1080,7 +1080,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
else
|
||||
xwalllights = scalelight[lightnum];
|
||||
|
||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE-1;
|
||||
@@ -1181,7 +1181,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
|
||||
}
|
||||
|
||||
// calculate lighting
|
||||
pindex = FixedMul(spryscale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(spryscale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE - 1;
|
||||
@@ -1374,7 +1374,7 @@ static void R_RenderSegLoop (void)
|
||||
if (segtextured)
|
||||
{
|
||||
// calculate lighting
|
||||
pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE-1;
|
||||
@@ -1411,7 +1411,7 @@ static void R_RenderSegLoop (void)
|
||||
else
|
||||
xwalllights = scalelight[lightnum];
|
||||
|
||||
pindex = FixedMul(rw_scale, FixedDiv(640, vid.width))>>LIGHTSCALESHIFT;
|
||||
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE-1;
|
||||
|
||||
+1
-4
@@ -80,8 +80,5 @@ void R_SetupSkyDraw(void)
|
||||
void R_SetSkyScale(void)
|
||||
{
|
||||
fixed_t difference = vid.fdupx-(vid.dupx<<FRACBITS);
|
||||
fixed_t scr = FRACUNIT;
|
||||
if (splitscreen > 1)
|
||||
scr *= 2;
|
||||
skyscale = FixedDiv(scr, vid.fdupx+difference);
|
||||
skyscale = FixedDiv(fovtan, vid.fdupx+difference);
|
||||
}
|
||||
+2
-2
@@ -1112,7 +1112,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing)
|
||||
if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW)
|
||||
&& (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1))))
|
||||
{
|
||||
lindex = FixedMul(sprite->xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
|
||||
lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||
|
||||
if (lindex >= MAXLIGHTSCALE)
|
||||
lindex = MAXLIGHTSCALE-1;
|
||||
@@ -1495,7 +1495,7 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
else
|
||||
{
|
||||
// diminished light
|
||||
lindex = FixedMul(xscale, FixedDiv(640, vid.width))>>(LIGHTSCALESHIFT);
|
||||
lindex = FixedMul(xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT);
|
||||
|
||||
if (lindex >= MAXLIGHTSCALE)
|
||||
lindex = MAXLIGHTSCALE-1;
|
||||
|
||||
Reference in new issue
Block a user