mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 07:22:28 +00:00
LMAO fisheye
This commit is contained in:
parent
c25e969676
commit
cd957d84f7
1 changed files with 24 additions and 5 deletions
29
src/r_main.c
29
src/r_main.c
|
@ -564,7 +564,7 @@ static struct {
|
||||||
void R_CheckViewMorph(void)
|
void R_CheckViewMorph(void)
|
||||||
{
|
{
|
||||||
float zoomfactor, rollcos, rollsin;
|
float zoomfactor, rollcos, rollsin;
|
||||||
float x1, y1, x2, y2;
|
float x1, y1, x2, y2, fisheyef;
|
||||||
fixed_t temp;
|
fixed_t temp;
|
||||||
size_t end, vx, vy, pos, usedpos;
|
size_t end, vx, vy, pos, usedpos;
|
||||||
INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2;
|
INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2;
|
||||||
|
@ -574,14 +574,14 @@ void R_CheckViewMorph(void)
|
||||||
|
|
||||||
// temp values
|
// temp values
|
||||||
//angle_t rollangle = leveltime << (ANGLETOFINESHIFT);
|
//angle_t rollangle = leveltime << (ANGLETOFINESHIFT);
|
||||||
fixed_t fisheye = 0;
|
fixed_t fisheye = FRACUNIT;
|
||||||
|
|
||||||
rollangle >>= ANGLETOFINESHIFT;
|
rollangle >>= ANGLETOFINESHIFT;
|
||||||
rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot.
|
rollangle = (((rollangle+1)/2)*2) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot.
|
||||||
|
|
||||||
fisheye &= ~0xFF; // Same limiter logic for fisheye
|
fisheye &= ~0xFF; // Same limiter logic for fisheye
|
||||||
|
|
||||||
if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye)
|
if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye && viewmorph.scrmapsize == vid.width*vid.height)
|
||||||
return; // No change
|
return; // No change
|
||||||
|
|
||||||
viewmorph.rollangle = rollangle;
|
viewmorph.rollangle = rollangle;
|
||||||
|
@ -614,6 +614,13 @@ void R_CheckViewMorph(void)
|
||||||
x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width;
|
x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width;
|
||||||
y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height;
|
y1 = (vid.height*fabsf(rollcos) + vid.width*fabsf(rollsin)) / vid.height;
|
||||||
|
|
||||||
|
if (fisheye)
|
||||||
|
{
|
||||||
|
float dist = powf(2, (fisheyef = FIXED_TO_FLOAT(fisheye))/2);
|
||||||
|
x1 *= dist;
|
||||||
|
y1 *= dist;
|
||||||
|
}
|
||||||
|
|
||||||
temp = max(x1, y1)*FRACUNIT;
|
temp = max(x1, y1)*FRACUNIT;
|
||||||
if (temp < FRACUNIT)
|
if (temp < FRACUNIT)
|
||||||
temp = FRACUNIT;
|
temp = FRACUNIT;
|
||||||
|
@ -652,8 +659,20 @@ void R_CheckViewMorph(void)
|
||||||
|
|
||||||
for (vx = 0; vx < vid.width; vx++)
|
for (vx = 0; vx < vid.width; vx++)
|
||||||
{
|
{
|
||||||
usedx = halfwidth+x2;
|
if (fisheye)
|
||||||
usedy = halfheight+y2;
|
{
|
||||||
|
float dist = sqrtf(x2*x2 + y2*y2) * zoomfactor / sqrtf(halfwidth*halfwidth + halfheight*halfheight);
|
||||||
|
dist += (1 - sqrtf(1 - dist*dist)) / dist;
|
||||||
|
dist = powf(dist, fisheyef);
|
||||||
|
usedx = halfwidth+x2*dist;
|
||||||
|
usedy = halfheight+y2*dist;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
usedx = halfwidth+x2;
|
||||||
|
usedy = halfheight+y2;
|
||||||
|
}
|
||||||
|
|
||||||
if (usedx < 0) usedx = 0;
|
if (usedx < 0) usedx = 0;
|
||||||
else if (usedx >= vid.width) usedx = vid.width-1;
|
else if (usedx >= vid.width) usedx = vid.width-1;
|
||||||
|
|
Loading…
Reference in a new issue