This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
fisheye.patch
204 lines (184 loc) · 5.35 KB
/
fisheye.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
diff --git a/Makefile b/Makefile
index 0a6c4d0..143e03e 100644
--- a/Makefile
+++ b/Makefile
@@ -642,6 +642,7 @@ CL_OBJS := \
cl_parse.o \
cl_tent.o \
console.o \
+ fisheye.o \
keys.o \
menu.o \
r_efrag.o \
@@ -814,7 +815,7 @@ COMMON_CPPFLAGS += -DWIN32_LEAN_AND_MEAN
COMMON_OBJS += net_wins.o sys_win.o
CL_OBJS += winquake.res
NQCL_OBJS += conproc.o net_win.o
-COMMON_LIBS += ws2_32 winmm dxguid
+COMMON_LIBS += ws2_32 winmm dxguid lua
GL_LIBS += opengl32
ifeq ($(DEBUG),Y)
CL_LFLAGS += -mconsole
@@ -826,7 +827,7 @@ endif
ifeq ($(TARGET_OS),UNIX)
COMMON_CPPFLAGS += -DELF
COMMON_OBJS += net_udp.o sys_unix.o
-COMMON_LIBS += m
+COMMON_LIBS += m lua
NQCL_OBJS += net_bsd.o
# FIXME - stupid hack
diff --git a/NQ/host.c b/NQ/host.c
index c6c3e06..584ea3a 100644
--- a/NQ/host.c
+++ b/NQ/host.c
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "cmd.h"
#include "console.h"
#include "draw.h"
+#include "fisheye.h"
#include "host.h"
#include "input.h"
#include "keys.h"
@@ -284,6 +285,8 @@ Host_WriteConfiguration(void)
Key_WriteBindings(f);
Cvar_WriteVariables(f);
+ F_WriteConfig(f);
+
fclose(f);
}
}
@@ -846,6 +849,8 @@ Host_Init(quakeparms_t *parms)
CL_Init();
IN_Init();
+
+ F_Init();
}
Mod_InitAliasCache();
@@ -890,6 +895,7 @@ Host_Shutdown(void)
CDAudio_Shutdown();
NET_Shutdown();
S_Shutdown();
+ F_Shutdown();
IN_Shutdown();
if (cls.state != ca_dedicated) {
diff --git a/NQ/sbar.c b/NQ/sbar.c
index 63c03bb..33a69c0 100644
--- a/NQ/sbar.c
+++ b/NQ/sbar.c
@@ -901,8 +901,9 @@ Sbar_Draw(void)
if (scr_con_current == vid.height)
return; // console is full screen
- if (sb_updates >= vid.numpages)
- return;
+ // status bar seems to be disappearing when I pick up items (so I'm commenting this out to force refresh)
+ //if (sb_updates >= vid.numpages)
+ //return;
scr_copyeverything = 1;
diff --git a/NQ/view.c b/NQ/view.c
index c88604b..55b9dce 100644
--- a/NQ/view.c
+++ b/NQ/view.c
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "console.h"
#include "cvar.h"
#include "draw.h"
+#include "fisheye.h"
#include "host.h"
#include "quakedef.h"
#include "screen.h"
@@ -943,8 +944,13 @@ V_RenderView(void)
V_CalcRefdef();
}
- R_PushDlights();
- R_RenderView();
+ if (fisheye_enabled) {
+ F_RenderView();
+ }
+ else {
+ R_PushDlights();
+ R_RenderView();
+ }
#ifndef GLQUAKE
if (crosshair.value)
diff --git a/common/r_main.c b/common/r_main.c
index ec9e1da..a60ba79 100644
--- a/common/r_main.c
+++ b/common/r_main.c
@@ -404,7 +404,23 @@ R_ViewChanged(vrect_t *pvrect, int lineadj, float aspect)
R_SetVrect(pvrect, &r_refdef.vrect, lineadj);
- r_refdef.horizontalFieldOfView = 2.0 * tan(r_refdef.fov_x / 360 * M_PI);
+ extern qboolean fisheye_enabled;
+ if (fisheye_enabled) {
+
+ // Make render size a square
+ int minsize = r_refdef.vrect.width;
+ if (r_refdef.vrect.height < minsize)
+ minsize = r_refdef.vrect.height;
+ r_refdef.vrect.width = r_refdef.vrect.height = minsize;
+
+ // set fov
+ extern double fisheye_plate_fov;
+ r_refdef.horizontalFieldOfView = 2.0 * tan(fisheye_plate_fov / 2);
+ }
+ else {
+ r_refdef.horizontalFieldOfView = 2.0 * tan(r_refdef.fov_x / 360 * M_PI);
+ }
+
r_refdef.fvrectx = (float)r_refdef.vrect.x;
r_refdef.fvrectx_adj = (float)r_refdef.vrect.x - 0.5;
r_refdef.vrect_x_adj_shift20 = (r_refdef.vrect.x << 20) + (1 << 19) - 1;
@@ -430,7 +446,12 @@ R_ViewChanged(vrect_t *pvrect, int lineadj, float aspect)
r_refdef.aliasvrectbottom =
r_refdef.aliasvrect.y + r_refdef.aliasvrect.height;
- pixelAspect = aspect;
+ if (fisheye_enabled) {
+ pixelAspect = (float)r_refdef.vrect.height / r_refdef.vrect.width;
+ }
+ else {
+ pixelAspect = aspect;
+ }
xOrigin = r_refdef.xOrigin;
yOrigin = r_refdef.yOrigin;
diff --git a/common/r_misc.c b/common/r_misc.c
index f052690..30fed3c 100644
--- a/common/r_misc.c
+++ b/common/r_misc.c
@@ -493,14 +493,27 @@ R_SetupFrame(void)
VectorCopy(r_refdef.vieworg, modelorg);
VectorCopy(r_refdef.vieworg, r_origin);
- AngleVectors(r_refdef.viewangles, vpn, vright, vup);
+ extern qboolean fisheye_enabled;
+ if (fisheye_enabled) {
+ VectorCopy(r_refdef.forward, vpn);
+ VectorCopy(r_refdef.right, vright);
+ VectorCopy(r_refdef.up, vup);
+ }
+ else {
+ AngleVectors(r_refdef.viewangles, vpn, vright, vup);
+ }
// current viewleaf
r_oldviewleaf = r_viewleaf;
r_viewleaf = Mod_PointInLeaf(cl.worldmodel, r_origin);
r_dowarpold = r_dowarp;
- r_dowarp = r_waterwarp.value && (r_viewleaf->contents <= CONTENTS_WATER);
+ if (fisheye_enabled) {
+ r_dowarp = 0;
+ }
+ else {
+ r_dowarp = r_waterwarp.value && (r_viewleaf->contents <= CONTENTS_WATER);
+ }
if ((r_dowarp != r_dowarpold) || r_viewchanged) {
if (r_dowarp) {
diff --git a/include/render.h b/include/render.h
index c2b7265..96f9924 100644
--- a/include/render.h
+++ b/include/render.h
@@ -135,6 +135,10 @@ typedef struct {
vec3_t vieworg;
vec3_t viewangles;
+ vec3_t forward;
+ vec3_t right;
+ vec3_t up;
+
float fov_x, fov_y;
int ambientlight;