mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
LMAO fisheye
This commit is contained in:
parent
c25e969676
commit
cd957d84f7
1 changed files with 24 additions and 5 deletions
25
src/r_main.c
25
src/r_main.c
|
@ -564,7 +564,7 @@ static struct {
|
|||
void R_CheckViewMorph(void)
|
||||
{
|
||||
float zoomfactor, rollcos, rollsin;
|
||||
float x1, y1, x2, y2;
|
||||
float x1, y1, x2, y2, fisheyef;
|
||||
fixed_t temp;
|
||||
size_t end, vx, vy, pos, usedpos;
|
||||
INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2;
|
||||
|
@ -574,14 +574,14 @@ void R_CheckViewMorph(void)
|
|||
|
||||
// temp values
|
||||
//angle_t rollangle = leveltime << (ANGLETOFINESHIFT);
|
||||
fixed_t fisheye = 0;
|
||||
fixed_t fisheye = FRACUNIT;
|
||||
|
||||
rollangle >>= ANGLETOFINESHIFT;
|
||||
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
|
||||
|
||||
if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye)
|
||||
if (rollangle == viewmorph.rollangle && fisheye == viewmorph.fisheye && viewmorph.scrmapsize == vid.width*vid.height)
|
||||
return; // No change
|
||||
|
||||
viewmorph.rollangle = rollangle;
|
||||
|
@ -614,6 +614,13 @@ void R_CheckViewMorph(void)
|
|||
x1 = (vid.width*fabsf(rollcos) + vid.height*fabsf(rollsin)) / vid.width;
|
||||
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;
|
||||
if (temp < FRACUNIT)
|
||||
temp = FRACUNIT;
|
||||
|
@ -651,9 +658,21 @@ void R_CheckViewMorph(void)
|
|||
y1 += rollcos;
|
||||
|
||||
for (vx = 0; vx < vid.width; vx++)
|
||||
{
|
||||
if (fisheye)
|
||||
{
|
||||
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;
|
||||
else if (usedx >= vid.width) usedx = vid.width-1;
|
||||
|
|
Loading…
Reference in a new issue