From 026e1f44e94062e3271abd2f5939a54d6c45c81f Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 17 Oct 2011 18:41:38 +0000 Subject: [PATCH] Make Polymer's FOV depend viewingrange variable in a 'tangent-linear' fashion. Among other things, this makes the FOV widening when shrunk work. User CON code should always check the initial viewingrange value when attempting to do FOV effects like zoom, because it is not guaranteed to be 65536 due to different screen aspect ratios etc. git-svn-id: https://svn.eduke32.com/eduke32@2078 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 4 ++-- polymer/eduke32/build/src/polymer.c | 5 ++++- polymer/eduke32/source/game.c | 14 ++++---------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index cbeba25d2..e2740035f 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -12957,7 +12957,7 @@ restart_grand: void setaspect_new() { - if (r_usenewaspect && newaspect_enable) + if (r_usenewaspect && newaspect_enable && getrendermode()!=4) { // the correction factor 100/107 has been found // out experimentally. squares ftw! @@ -13020,7 +13020,7 @@ void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2) void setaspect(int32_t daxrange, int32_t daaspect) { viewingrange = daxrange; - viewingrangerecip = divscale32(1L,daxrange); + viewingrangerecip = divscale32(1,daxrange); yxaspect = daaspect; xyaspect = divscale32(1,yxaspect); diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index b783def86..10eaea6ef 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -780,6 +780,9 @@ void polymer_uninit(void) void polymer_setaspect(int32_t ang) { float aspect; + float fang = ang; + + fang *= atanf((float)viewingrange/65536.0f)/(PI/4); if (pr_customaspect != 0.0f) aspect = pr_customaspect; @@ -789,7 +792,7 @@ void polymer_setaspect(int32_t ang) bglMatrixMode(GL_PROJECTION); bglLoadIdentity(); - bgluPerspective((float)(ang) / (2048.0f / 360.0f), aspect, 0.01f, 100.0f); + bgluPerspective(fang / (2048.0f / 360.0f), aspect, 0.01f, 100.0f); } void polymer_glinit(void) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 0848e6783..5b3d36adb 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2182,11 +2182,10 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 char col; walltype *wal, *wal2; spritetype *spr; - int32_t oydim=ydim; - ydim = (int32_t)((double)xdim * 0.625f); - setaspect(65536L,(int32_t)divscale16(ydim*320L,xdim*200L)); - ydim = oydim; + int32_t tmpydim = (xdim*5)/8; + + setaspect(65536, divscale16(tmpydim*320, xdim*200)); xvect = sintable[(-cang)&2047] * czoom; yvect = sintable[(1536-cang)&2047] * czoom; @@ -3171,7 +3170,6 @@ void G_DrawBackground(void) static int32_t ror_sprite = -1; -static int32_t oyrepeat=-1; extern float r_ambientlight; char ror_protectedsectors[MAXSECTORS]; @@ -3389,11 +3387,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) if (!r_usenewaspect) { -// if (i != oyrepeat) - { - oyrepeat = i; - setaspect(oyrepeat,yxaspect); - } + setaspect(i, yxaspect); } else {