Debian Codegraph @

Descent3/render.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/render.cpp $
21 * $Revision: 325 $
22 * $Date: 9/10/01 5:16p $
23 * $Author: Matt $
24 *
25 * Code to render the mine
26 *
27 * $Log: /DescentIII/Main/render.cpp $
28 *
29 * $NoKeywords: $
30 */
31 #include "render.h"cxx . . $ `<file>/Descent3/render.h`/
32 #include <stdlib.h>
33 #include <string.h>
34 #include "3d.h"cxx . . $ `<file>/lib/3d.h`/
35 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
36 #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/
37 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
38 #include "renderobject.h"cxx . . $ `<file>/Descent3/renderobject.h`/
39 #include "door.h"cxx . . $ `<file>/Descent3/door.h`/
40 #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/
41 #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/
42 #include "room.h"cxx . . $ `<file>/Descent3/room.h`/
43 #include "lighting.h"cxx . . $ `<file>/Descent3/lighting.h`/
44 #include "lightmap.h"cxx . . $ `<file>/lib/lightmap.h`/
45 #include "limits.h"
46 #include "lightmap_info.h"cxx . . $ `<file>/Descent3/lightmap_info.h`/
47 #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/
48 #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/
49 #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/
50 #include "scorch.h"cxx . . $ `<file>/Descent3/scorch.h`/
51 #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/
52 #include "special_face.h"cxx . . $ `<file>/Descent3/special_face.h`/
53 #include "config.h"cxx . . $ `<file>/Descent3/config.h`/
54 #include "gameloop.h"cxx . . $ `<file>/Descent3/gameloop.h`/
55 #include "doorway.h"cxx . . $ `<file>/Descent3/doorway.h`/
56 #include "TelComAutoMap.h"cxx . . $ `<file>/Descent3/TelComAutoMap.h`/
57 #include "postrender.h"cxx . . $ `<file>/Descent3/postrender.h`/
58 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
59 #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/
60 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
61 #include "args.h"cxx . . $ `<file>/Descent3/args.h`/
62 #ifdef EDITOR
63 #include "editor\d3edit.h"
64 #endif
65
66 #include <algorithm>
67
68 // #define KATMAI
69
70 // Katmai enhanced rotate only in a release build, because not
71 // everyone has the intel compiler!
72 #if (defined(RELEASE) && defined(KATMAI))
73 // Katmai version -- Rotates all the points in a room
74 void RotateRoomPoints(room *rp, vector4 *world_vecs);
75 #endif
76
77
78 static int Faces_renderedcxx . . $ Faces_rendered. = 0;
79 extern float GetFPScxx . . $ GetFPS(9b8c9e39889c762c).();
80 extern uint8_tcxx . . $ uint8_t# Outline_release_modecxx . . $ Outline_release_mode.;
81 // 3d point for each vertex for use during rendering a room
82 uint8_tcxx . . $ uint8_t# Room_clipscxx . . $ Room_clips.[MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!]; // used for face culling
83 // default face reflectivity
84 float Face_reflectivitycxx . . $ Face_reflectivity. = 0.5;
85 // the position of the viewer - valid while a frame is being rendered
86 static vectorcxx . . $ vector# Viewer_eyecxx . . $ Viewer_eye.;
87 static matrixcxx . . $ matrix# Viewer_orientcxx . . $ Viewer_orient.;
88 int Viewer_roomnumcxx . . $ Viewer_roomnum.;
89 int Flag_automapcxx . . $ Flag_automap., Called_from_terraincxx . . $ Called_from_terrain.;
90 // Fog zone variables
91 float Fog_zone_startcxx . . $ Fog_zone_start. = FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!, Fog_zone_endcxx . . $ Fog_zone_end. = FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!;
92 int Must_render_terraincxx . . $ Must_render_terrain.;
93 int Global_buffer_indexcxx . . $ Global_buffer_index.;
94 int No_render_windows_hackcxx . . $ No_render_windows_hack. = -1;
95 #define WALL_PULSE_INCREMENTcxx . . $ `Descent3/render.cpp:95:9`! .01
96 // Variables for various debugging features
97 #if (defined(_DEBUGcxx . . $ `<built-in>:482:9`!) || defined(NEWEDITOR) || defined(EDITOR))
98 // If true, draw white outline for each polygon
99 int Render_portalscxx . . $ Render_portals. = 0;
100 uint8_tcxx . . $ uint8_t# Outline_modecxx . . $ Outline_mode. = 0;
101 uint8_tcxx . . $ uint8_t# Shell_render_flagcxx . . $ Shell_render_flag. = 0;
102 bool Outline_alphacxx . . $ Outline_alpha. = 0;
103 bool Outline_lightmapscxx . . $ Outline_lightmaps. = 0;
104 bool Render_floating_triggerscxx . . $ Render_floating_triggers. = 0;
105 bool Use_software_zbuffercxx . . $ Use_software_zbuffer. = 0;
106 bool Lighting_oncxx . . $ Lighting_on. = 1;
107 bool Render_all_external_roomscxx . . $ Render_all_external_rooms. = 0;
108 bool In_editor_modecxx . . $ In_editor_mode. = 0;
109 bool Render_one_room_onlycxx . . $ Render_one_room_only. = 0;
110 bool Render_inside_onlycxx . . $ Render_inside_only. = 0;
111 #else
112 #define In_editor_mode 0
113 #define Outline_lightmaps 0
114 #define Outline_alpha 0
115 #define Render_floating_triggers 0
116 #define Use_software_zbuffer 0
117 #define Render_all_external_rooms 0
118 #define Render_portals 0
119 #define Render_one_room_only 0
120 #define Render_inside_only 0
121 #define Shell_render_flag 0
122 #endif
123
124 #ifndef RELEASE
125 int Mine_depthcxx . . $ Mine_depth.;
126 #endif
127 #ifndef EDITOR
128 #define Search_lightmapscxx . . $ `Descent3/render.cpp:128:9`! 0
129 #else // ifndef EDITOR
130 // Vars for find_seg_side_face()
131 static int Search_lightmaps = 0; // true if searching for a lightmap
132 int found_lightmap;
133 #endif // ifndef EDITOR
134 bool Vsync_enabledcxx . . $ Vsync_enabled. = true;
135 // Prototypes
136 void RenderRoomObjectscxx . . $ RenderRoomObjects(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp);
137 // The current window width & height (valid while rendering)
138 static int Render_widthcxx . . $ Render_width., Render_heightcxx . . $ Render_height.;
139 int Clear_window_colorcxx . . $ Clear_window_color. = -1;
140 int Clear_windowcxx . . $ Clear_window. = 2; // 1 = Clear whole background window, 2 = clear view portals into rest of world, 0 = no clear
141 #define MAX_RENDER_ROOMScxx . . $ `Descent3/render.cpp:141:9`! 100
142 char Rooms_visitedcxx . . $ Rooms_visited.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_PALETTE_ROOMScxx . . $ `Descent3/room.h:384:9`!];
143 int Facing_visitedcxx . . $ Facing_visited.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_PALETTE_ROOMScxx . . $ `Descent3/room.h:384:9`!];
144 // For keeping track of portal recursion
145 uint8_tcxx . . $ uint8_t# Room_depth_listcxx . . $ Room_depth_list.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_PALETTE_ROOMScxx . . $ `Descent3/room.h:384:9`!];
146 int16_t Render_listcxx . . $ Render_list.[MAX_RENDER_ROOMScxx . . $ `Descent3/render.cpp:141:9`!];
147 int16_t External_room_listcxx . . $ External_room_list.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!];
148 int N_external_roomscxx . . $ N_external_rooms.;
149 // For rendering specular faces
150 #define MAX_SPECULAR_FACEScxx . . $ `Descent3/render.cpp:150:9`! 2500
151 int16_t Specular_facescxx . . $ Specular_faces.[MAX_SPECULAR_FACEScxx . . $ `Descent3/render.cpp:150:9`!];
152 int Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render. = 0;
153 int Num_real_specular_faces_to_rendercxx . . $ Num_real_specular_faces_to_render. = 0; // Non-invisible specular faces
154 struct smooth_spec_vertcxx . . $ smooth_spec_vert# {
155 float rcxx . . $ smooth_spec_vert#r., gcxx . . $ smooth_spec_vert#g., bcxx . . $ smooth_spec_vert#b.;
156 int usedcxx . . $ smooth_spec_vert#used.;
157 };
158 smooth_spec_vertcxx . . $ smooth_spec_vert# Smooth_vertscxx . . $ Smooth_verts.[MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!];
159 // For scorch rendering
160 uint16_tcxx . . $ uint16_t# Scorches_to_rendercxx . . $ Scorches_to_render.[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
161 int Num_scorches_to_rendercxx . . $ Num_scorches_to_render. = 0;
162 // For rendering volumetric fog
163 #define MAX_FOGGED_ROOMS_PER_FRAMEcxx . . $ `Descent3/render.cpp:163:9`! 8
164 fog_portal_datacxx . . $ fog_portal_data# Fog_portal_datacxx . . $ Fog_portal_data.[MAX_FOGGED_ROOMS_PER_FRAMEcxx . . $ `Descent3/render.cpp:163:9`!];
165 int Num_fogged_rooms_this_framecxx . . $ Num_fogged_rooms_this_frame. = 0;
166 float Room_light_valcxx . . $ Room_light_val. = 0;
167 int Room_fog_plane_checkcxx . . $ Room_fog_plane_check. = 0;
168 float Room_fog_distancecxx . . $ Room_fog_distance. = 0;
169 float Room_fog_eye_distancecxx . . $ Room_fog_eye_distance. = 0;
170 vectorcxx . . $ vector# Room_fog_planecxx . . $ Room_fog_plane., Room_fog_portal_vertcxx . . $ Room_fog_portal_vert.;
171 int16_t Fog_facescxx . . $ Fog_faces.[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
172 int Num_fog_faces_to_rendercxx . . $ Num_fog_faces_to_render. = 0;
173 #define MAX_EXTERNAL_ROOMScxx . . $ `Descent3/render.cpp:173:9`! 100
174 vectorcxx . . $ vector# External_room_cornerscxx . . $ External_room_corners.[MAX_EXTERNAL_ROOMScxx . . $ `Descent3/render.cpp:173:9`!][8];
175 uint8_tcxx . . $ uint8_t# External_room_codescxx . . $ External_room_codes.[MAX_EXTERNAL_ROOMScxx . . $ `Descent3/render.cpp:173:9`!];
176 uint8_tcxx . . $ uint8_t# External_room_project_netcxx . . $ External_room_project_net.[MAX_EXTERNAL_ROOMScxx . . $ `Descent3/render.cpp:173:9`!];
177 // For light glows
178 #define MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! 100
179 #define LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`! 1
180 #define LGF_INCREASINGcxx . . $ `Descent3/render.cpp:180:9`! 2
181 #define LGF_FASTcxx . . $ `Descent3/render.cpp:181:9`! 4
182 struct light_glowcxx . . $ light_glow# {
183 int16_t roomnumcxx . . $ light_glow#roomnum.;
184 int16_t facenumcxx . . $ light_glow#facenum.;
185 float sizecxx . . $ light_glow#size.;
186 vectorcxx . . $ vector# centercxx . . $ light_glow#center.;
187 float scalarcxx . . $ light_glow#scalar.;
188 uint8_tcxx . . $ uint8_t# flagscxx . . $ light_glow#flags.;
189 };
190 light_glowcxx . . $ light_glow# LightGlowscxx . . $ LightGlows.[MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`!];
191 light_glowcxx . . $ light_glow# LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`!];
192 int FastCoronascxx . . $ FastCoronas. = 0;
193 int Num_glowscxx . . $ Num_glows. = 0, Num_glows_this_framecxx . . $ Num_glows_this_frame. = 0;
194 // For sorting our textures in state limited environments
195 state_limited_elementcxx . . $ state_limited_element# State_elementscxx . . $ State_elements.[MAX_STATE_ELEMENTScxx . . $ `Descent3/render.h:242:9`!];
196 // For terrain portals
197 int Terrain_portal_leftcxx . . $ Terrain_portal_left., Terrain_portal_rightcxx . . $ Terrain_portal_right., Terrain_portal_topcxx . . $ Terrain_portal_top., Terrain_portal_bottomcxx . . $ Terrain_portal_bottom.;
198 // For deformation effect
199 vectorcxx . . $ vector# Global_alter_veccxx . . $ Global_alter_vec. = {19, -19, 19};
200 // For detail stuff (mirrors, specular,etc)
201 bool Render_mirror_for_roomcxx . . $ Render_mirror_for_room. = false;
202 int Mirror_roomcxx . . $ Mirror_room.;
203 int Num_mirrored_roomscxx . . $ Num_mirrored_rooms.;
204 int16_t Mirrored_room_listcxx . . $ Mirrored_room_list.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!];
205 uint8_tcxx . . $ uint8_t# Mirrored_room_checkedcxx . . $ Mirrored_room_checked.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!];
206 int16_t Mirror_roomscxx . . $ Mirror_rooms.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!];
207 int Num_mirror_roomscxx . . $ Num_mirror_rooms. = 0;
208 //
209 // UTILITY FUNCS
210 //
211 // Determines if a face renders
212 // Parameters: rp - pointer to room that contains the face
213 // fp - pointer to the face in question
214 static inline bool FaceIsRenderablecxx . . $ FaceIsRenderable(64b515d199dd040c).(roomcxx . . $ room# *rp, facecxx . . $ face# *fp) {
215 // Check for a floating trigger, which doesn't get rendered
216 if ((fp->flagscxx . . $ face#flags. & FF_FLOATING_TRIGcxx . . $ `Descent3/room_external.h:118:9`!) && (!In_editor_modecxx . . $ In_editor_mode. || !Render_floating_triggerscxx . . $ Render_floating_triggers.))
217 return 0;
218 // Check for face that's part of a portal
219 if (fp->portal_numcxx . . $ face#portal_num. != -1) {
220 if (rp->portalscxx . . $ room#portals.[fp->portal_numcxx . . $ face#portal_num.].flagscxx . . $ portal#flags. & PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!)
221 return 1;
222 if (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`! && !In_editor_modecxx . . $ In_editor_mode.)
223 return 1;
224 return 0;
225 }
226
227 // Nothing special, so face renders
228 return 1;
229 }
230 // Flags for GetFaceAlpha()
231 #define FA_CONSTANTcxx . . $ `Descent3/render.cpp:231:9`! 1 // face has a constant alpha for the whole face
232 #define FA_VERTEXcxx . . $ `Descent3/render.cpp:232:9`! 2 // face has different alpha per vertex
233 #define FA_TRANSPARENTcxx . . $ `Descent3/render.cpp:233:9`! 4 // face has transparency (i.e. per pixel 1-bit alpha)
234 // Determines if a face draws with alpha blending
235 // Parameters: fp - pointer to the face in question
236 // bm_handle - the handle for the bitmap for this frame, or -1 if don't care about
237 // transparence Returns: bitmask describing the alpha blending for the face
238 // the return bits are the ATF_ flags in renderer.h
239 static inline int GetFaceAlphacxx . . $ GetFaceAlpha(1ba15edd17ae1010).(facecxx . . $ face# *fp, int bm_handle) {
240 int ret = AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!;
241 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SATURATEcxx . . $ `Descent3/gametexture.h:222:9`!) {
242 ret = AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!;
243 } else {
244 // Check the face's texture for an alpha value
245 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].alphacxx . . $ texture#alpha. < 1.0)
246 ret |= ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`!;
247
248 // Check for transparency
249 if (GameBitmapscxx . . $ GameBitmaps.[bm_handle].formatcxx . . $ bms_bitmap#format. != BITMAP_FORMAT_4444cxx . . $ `lib/bitmap.h:57:9`! && GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_TMAP2cxx . . $ `Descent3/gametexture.h:215:9`!)
250 ret |= ATF_TEXTUREcxx . . $ `lib/renderer.h:395:9`!;
251 }
252 return ret;
253 }
254 // Determine if you should render through a portal
255 // Parameters: rp - the room the portal is in
256 // pp - the portal we're checking
257 // Returns: true if you should render the room to which the portal connects
258 static inline bool RenderPastPortalcxx . . $ RenderPastPortal(5714109361f3d17d).(roomcxx . . $ room# *rp, portalcxx . . $ portal# *pp) {
259 // If we don't render the portal's faces, then we see through it
260 if (!(pp->flagscxx . . $ portal#flags. & PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!))
261 return 1;
262 if (!UseHardwarecxx . . $ UseHardware.) // Don't render alpha stuff in software
263 return 0;
264 // Check if the face's texture has transparency
265 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[pp->portal_facecxx . . $ portal#portal_face.];
266 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_PROCEDURALcxx . . $ `Descent3/gametexture.h:225:9`!)
267 return 1;
268 int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(fp->tmapcxx . . $ face#tmap., 0);
269 if (GetFaceAlphacxx . . $ GetFaceAlpha(1ba15edd17ae1010).(fp, bm_handle))
270 return 1; // Face has alpha or transparency, so we can see through it
271 else
272 return 0; // Not transparent, so no render past
273 }
274
275 // used during rendering as count of items in render_list[]
276 int N_render_roomscxx . . $ N_render_rooms.;
277 int first_terminal_roomcxx . . $ first_terminal_room.;
278 #define roundcxx . . $ `Descent3/render.cpp:278:9`!(a) (int((a) + 0.5f))
279
280 #ifdef EDITOR
281 #define CROSS_WIDTH 8.0
282 #define CROSS_HEIGHT 8.0
283 #define CURFACE_COLOR GR_RGB(255, 255, 0)
284 #define CUREDGE_COLOR GR_RGB(0, 255, 0)
285 #define MARKEDFACE_COLOR GR_RGB(0, 255, 255)
286 #define MARKEDEDGE_COLOR GR_RGB(0, 150, 150)
287 #define PLACED_COLOR GR_RGB(255, 0, 255)
288 // Draw outline for current edge & vertex
289 void OutlineCurrentFace(room *rp, int facenum, int edgenum, int vertnum, ddgr_color face_color, ddgr_color edge_color) {
290 face *fp = &rp->faces[facenum];
291 g3Point p0, p1;
292 uint8_t c0, c1;
293 int v;
294 for (v = 0; v < fp->num_verts; v++) {
295 c0 = g3_RotatePoint(&p0, &rp->verts[fp->face_verts[v]]);
296 c1 = g3_RotatePoint(&p1, &rp->verts[fp->face_verts[(v + 1) % fp->num_verts]]);
297 if (!(c0 & c1)) { // both not off screen?
298 // Draw current edge in green
299 g3_DrawLine((v == edgenum) ? edge_color : face_color, &p0, &p1);
300 }
301 if ((v == vertnum) && (c0 == 0)) {
302 // Draw a little cross at the current vert
303 g3_ProjectPoint(&p0); // make sure projected
304 rend_SetFlatColor(edge_color);
305 rend_DrawLine(p0.p3_sx - CROSS_WIDTH, p0.p3_sy, p0.p3_sx, p0.p3_sy - CROSS_HEIGHT);
306 rend_DrawLine(p0.p3_sx, p0.p3_sy - CROSS_HEIGHT, p0.p3_sx + CROSS_WIDTH, p0.p3_sy);
307 rend_DrawLine(p0.p3_sx + CROSS_WIDTH, p0.p3_sy, p0.p3_sx, p0.p3_sy + CROSS_HEIGHT);
308 rend_DrawLine(p0.p3_sx, p0.p3_sy + CROSS_HEIGHT, p0.p3_sx - CROSS_WIDTH, p0.p3_sy);
309 }
310 }
311 // Draw upper left cross
312 if (Outline_lightmaps && (rp->faces[facenum].flags & FF_LIGHTMAP)) {
313 ASSERT(rp->faces[facenum].lmi_handle != BAD_LMI_INDEX);
314
315 p0.p3_flags = 0;
316 c0 = g3_RotatePoint(&p0, &LightmapInfo[rp->faces[facenum].lmi_handle].upper_left);
317 if (!c0) {
318 // Draw a little cross at the current vert
319 g3_ProjectPoint(&p0); // make sure projected
320 rend_SetFlatColor(GR_RGB(255, 0, 0));
321 rend_DrawLine(p0.p3_sx - CROSS_WIDTH, p0.p3_sy, p0.p3_sx, p0.p3_sy - CROSS_HEIGHT);
322 rend_DrawLine(p0.p3_sx, p0.p3_sy - CROSS_HEIGHT, p0.p3_sx + CROSS_WIDTH, p0.p3_sy);
323 rend_DrawLine(p0.p3_sx + CROSS_WIDTH, p0.p3_sy, p0.p3_sx, p0.p3_sy + CROSS_HEIGHT);
324 rend_DrawLine(p0.p3_sx, p0.p3_sy + CROSS_HEIGHT, p0.p3_sx - CROSS_WIDTH, p0.p3_sy);
325 }
326 }
327 }
328
329 // Draw a room rotated and placed in space
330 static void DrawPlacedRoomFace(room *rp, vector *rotpoint, matrix *rotmat, vector *placepoint, int facenum, int color) {
331 face *fp = &rp->faces[facenum];
332
333 g3Point p0, p1;
334 uint8_t c0, c1;
335 int v;
336 for (v = 0; v < fp->num_verts; v++) {
337 vector tv;
338
339 tv = (rp->verts[fp->face_verts[v]] - *rotpoint) * *rotmat + *placepoint;
340 c0 = g3_RotatePoint(&p0, &tv);
341
342 tv = (rp->verts[fp->face_verts[(v + 1) % fp->num_verts]] - *rotpoint) * *rotmat + *placepoint;
343 c1 = g3_RotatePoint(&p1, &tv);
344
345 if (!(c0 & c1)) // both not off screen?
346 g3_DrawLine(color, &p0, &p1);
347 }
348 }
349 #endif // ifdef EDITOR
350
351 struct clip_wndcxx . . $ clip_wnd# {
352 float leftcxx . . $ clip_wnd#left., topcxx . . $ clip_wnd#top., rightcxx . . $ clip_wnd#right., botcxx . . $ clip_wnd#bot.;
353 };
354
355 static inline int clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(g3Pointcxx . . $ g3Point# *pnt, clip_wndcxx . . $ clip_wnd# *wnd) {
356 int ret = 0;
357 if (pnt->p3_codescxx . . $ g3Point#p3_codes. & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!)
358 return CC_BEHINDcxx . . $ `lib/3d.h:230:9`!;
359
360 if (pnt->p3_sxcxx . . $ g3Point#p3_sx. < wnd->leftcxx . . $ clip_wnd#left.)
361 ret |= CC_OFF_LEFTcxx . . $ `lib/3d.h:224:9`!;
362 if (pnt->p3_sxcxx . . $ g3Point#p3_sx. > wnd->rightcxx . . $ clip_wnd#right.)
363 ret |= CC_OFF_RIGHTcxx . . $ `lib/3d.h:225:9`!;
364 if (pnt->p3_sycxx . . $ g3Point#p3_sy. < wnd->topcxx . . $ clip_wnd#top.)
365 ret |= CC_OFF_TOPcxx . . $ `lib/3d.h:227:9`!;
366 if (pnt->p3_sycxx . . $ g3Point#p3_sy. > wnd->botcxx . . $ clip_wnd#bot.)
367 ret |= CC_OFF_BOTcxx . . $ `lib/3d.h:226:9`!;
368 return ret;
369 }
370
371 // Returns true if a line intersects another line
372 static inline bool LineIntersectsLinecxx . . $ LineIntersectsLine(336298da2d87c39d).(g3Pointcxx . . $ g3Point# *ls, g3Pointcxx . . $ g3Point# *le, float x1, float y1, float x2, float y2) {
373 float num, denom;
374 num = ((ls->p3_sycxx . . $ g3Point#p3_sy. - y1) * (x2 - x1)) - ((ls->p3_sxcxx . . $ g3Point#p3_sx. - x1) * (y2 - y1));
375 denom = ((le->p3_sxcxx . . $ g3Point#p3_sx. - ls->p3_sxcxx . . $ g3Point#p3_sx.) * (y2 - y1)) - ((le->p3_sycxx . . $ g3Point#p3_sy. - ls->p3_sycxx . . $ g3Point#p3_sy.) * (x2 - x1));
376 float r = num / denom;
377 if (r >= 0.0 && r <= 1.0)
378 return true;
379 num = ((ls->p3_sycxx . . $ g3Point#p3_sy. - y1) * (le->p3_sxcxx . . $ g3Point#p3_sx. - ls->p3_sxcxx . . $ g3Point#p3_sx.)) - ((ls->p3_sxcxx . . $ g3Point#p3_sx. - x1) * (le->p3_sycxx . . $ g3Point#p3_sy. - ls->p3_sycxx . . $ g3Point#p3_sy.));
380 denom = ((le->p3_sxcxx . . $ g3Point#p3_sx. - ls->p3_sxcxx . . $ g3Point#p3_sx.) * (y2 - y1)) - ((le->p3_sycxx . . $ g3Point#p3_sy. - ls->p3_sycxx . . $ g3Point#p3_sy.) * (x2 - x1));
381 float s = num / denom;
382 if (s >= 0.0 && s <= 1.0)
383 return true;
384 return false;
385 }
386 // Returns true if a face intersects the passed in portal in any way
387 static inline bool FaceIntersectsPortalcxx . . $ FaceIntersectsPortal(1ceef1629d0b9542).(roomcxx . . $ room# *rp, facecxx . . $ face# *fp, clip_wndcxx . . $ clip_wnd# *wnd) {
388 g3Codescxx . . $ g3Codes# cc;
389 int i;
390
391 cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
392 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
393 for (i = 0; i < fp->num_vertscxx . . $ face#num_verts.; i++) {
394 cc.cc_orcxx . . $ g3Codes#cc_or. |= Room_clipscxx . . $ Room_clips.[fp->face_vertscxx . . $ face#face_verts.[i]];
395 cc.cc_andcxx . . $ g3Codes#cc_and. &= Room_clipscxx . . $ Room_clips.[fp->face_vertscxx . . $ face#face_verts.[i]];
396 }
397 if (cc.cc_andcxx . . $ g3Codes#cc_and.)
398 return false; // completely outside
399 if (!cc.cc_orcxx . . $ g3Codes#cc_or.)
400 return true; // completely inside
401
402 // Now we must do a check
403 for (i = 0; i < fp->num_vertscxx . . $ face#num_verts.; i++) {
404 g3Pointcxx . . $ g3Point# *p1 = &World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[i]];
405 g3Pointcxx . . $ g3Point# *p2 = &World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[(i + 1) % fp->num_vertscxx . . $ face#num_verts.]];
406 if (LineIntersectsLinecxx . . $ LineIntersectsLine(336298da2d87c39d).(p1, p2, wnd->leftcxx . . $ clip_wnd#left., wnd->topcxx . . $ clip_wnd#top., wnd->rightcxx . . $ clip_wnd#right., wnd->topcxx . . $ clip_wnd#top.))
407 return true;
408 if (LineIntersectsLinecxx . . $ LineIntersectsLine(336298da2d87c39d).(p1, p2, wnd->rightcxx . . $ clip_wnd#right., wnd->topcxx . . $ clip_wnd#top., wnd->rightcxx . . $ clip_wnd#right., wnd->botcxx . . $ clip_wnd#bot.))
409 return true;
410 if (LineIntersectsLinecxx . . $ LineIntersectsLine(336298da2d87c39d).(p1, p2, wnd->rightcxx . . $ clip_wnd#right., wnd->botcxx . . $ clip_wnd#bot., wnd->leftcxx . . $ clip_wnd#left., wnd->botcxx . . $ clip_wnd#bot.))
411 return true;
412 if (LineIntersectsLinecxx . . $ LineIntersectsLine(336298da2d87c39d).(p1, p2, wnd->leftcxx . . $ clip_wnd#left., wnd->botcxx . . $ clip_wnd#bot., wnd->leftcxx . . $ clip_wnd#left., wnd->topcxx . . $ clip_wnd#top.))
413 return true;
414 }
415 return false;
416 }
417 // Sets the status of a glow light
418 void SetGlowStatuscxx . . $ SetGlowStatus(abfd27cce48f162c).(int roomnum, int facenum, vectorcxx . . $ vector# *center, float size, int fast) {
419 int i;
420 int first = 1;
421 int first_free = -1;
422 int done = 0;
423 int count = 0;
424 int found = 0;
425 for (i = 0; i < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! && !done; i++) {
426 if (count >= Num_glowscxx . . $ Num_glows.) {
427 if (first_free == -1)
428 first_free = i;
429 done = 1;
430 continue;
431 }
432 if (LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. & LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`!) {
433 count++;
434 if (LightGlowscxx . . $ LightGlows.[i].roomnumcxx . . $ light_glow#roomnum. == roomnum && LightGlowscxx . . $ LightGlows.[i].facenumcxx . . $ light_glow#facenum. == facenum) {
435 found = 1;
436 LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. |= LGF_INCREASINGcxx . . $ `Descent3/render.cpp:180:9`!;
437 done = 1;
438 }
439 } else {
440 if (first) {
441 first_free = i;
442 first = 0;
443 }
444 }
445 }
446 if (!found) // couldn't find it - is it a new one?
447 {
448 if (first_free == -1) // no free slots
449 return;
450 LightGlowscxx . . $ LightGlows.[first_free].flagscxx . . $ light_glow#flags. = LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`! | LGF_INCREASINGcxx . . $ `Descent3/render.cpp:180:9`!;
451 if (fast)
452 LightGlowscxx . . $ LightGlows.[first_free].flagscxx . . $ light_glow#flags. |= LGF_FASTcxx . . $ `Descent3/render.cpp:181:9`!;
453 LightGlowscxx . . $ LightGlows.[first_free].roomnumcxx . . $ light_glow#roomnum. = roomnum;
454 LightGlowscxx . . $ LightGlows.[first_free].facenumcxx . . $ light_glow#facenum. = facenum;
455 LightGlowscxx . . $ LightGlows.[first_free].scalarcxx . . $ light_glow#scalar. = 0;
456 LightGlowscxx . . $ LightGlows.[first_free].sizecxx . . $ light_glow#size. = size;
457 LightGlowscxx . . $ LightGlows.[first_free].centercxx . . $ light_glow#center. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *center;
458 Num_glowscxx . . $ Num_glows.++;
459 }
460 }
461 // Takes a min,max vector and makes a surrounding cube from it
462 void MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(vectorcxx . . $ vector# *corners, vectorcxx . . $ vector# *minp, vectorcxx . . $ vector# *maxp) {
463 corners[0].xcxx . . $ vector#x. = minp->xcxx . . $ vector#x.;
464 corners[0].ycxx . . $ vector#y. = maxp->ycxx . . $ vector#y.;
465 corners[0].zcxx . . $ vector#z. = minp->zcxx . . $ vector#z.;
466 corners[1].xcxx . . $ vector#x. = maxp->xcxx . . $ vector#x.;
467 corners[1].ycxx . . $ vector#y. = maxp->ycxx . . $ vector#y.;
468 corners[1].zcxx . . $ vector#z. = minp->zcxx . . $ vector#z.;
469 corners[2].xcxx . . $ vector#x. = maxp->xcxx . . $ vector#x.;
470 corners[2].ycxx . . $ vector#y. = minp->ycxx . . $ vector#y.;
471 corners[2].zcxx . . $ vector#z. = minp->zcxx . . $ vector#z.;
472 corners[3].xcxx . . $ vector#x. = minp->xcxx . . $ vector#x.;
473 corners[3].ycxx . . $ vector#y. = minp->ycxx . . $ vector#y.;
474 corners[3].zcxx . . $ vector#z. = minp->zcxx . . $ vector#z.;
475 corners[4].xcxx . . $ vector#x. = minp->xcxx . . $ vector#x.;
476 corners[4].ycxx . . $ vector#y. = maxp->ycxx . . $ vector#y.;
477 corners[4].zcxx . . $ vector#z. = maxp->zcxx . . $ vector#z.;
478 corners[5].xcxx . . $ vector#x. = maxp->xcxx . . $ vector#x.;
479 corners[5].ycxx . . $ vector#y. = maxp->ycxx . . $ vector#y.;
480 corners[5].zcxx . . $ vector#z. = maxp->zcxx . . $ vector#z.;
481 corners[6].xcxx . . $ vector#x. = maxp->xcxx . . $ vector#x.;
482 corners[6].ycxx . . $ vector#y. = minp->ycxx . . $ vector#y.;
483 corners[6].zcxx . . $ vector#z. = maxp->zcxx . . $ vector#z.;
484 corners[7].xcxx . . $ vector#x. = minp->xcxx . . $ vector#x.;
485 corners[7].ycxx . . $ vector#y. = minp->ycxx . . $ vector#y.;
486 corners[7].zcxx . . $ vector#z. = maxp->zcxx . . $ vector#z.;
487 }
488
489 // Rotates all the points in a room
490 void RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(roomcxx . . $ room# *rp, vectorcxx . . $ vector# *world_vecs) {
491 int i;
492 // Jig the vertices a bit if being deformed
493 if (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info. && (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. & EF_DEFORMcxx . . $ `Descent3/object_external.h:198:9`!)) {
494 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++) {
495 vectorcxx . . $ vector# vec = world_vecs[i];
496 float val = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 1000) - 500.0) / 500.0;
497 val *= Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->deform_timecxx . . $ effect_info_s#deform_time.;
498 vec +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). Global_alter_veccxx . . $ Global_alter_vec. *cxx . . $ `operator*`(252247219a31502c). (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->deform_rangecxx . . $ effect_info_s#deform_range. * val);
499
500 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i], &vec);
501 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i]);
502 }
503 } else {
504 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++) {
505 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i], &world_vecs[i]);
506 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i]);
507 }
508 }
509 }
510
511 // Given a vector, reflects that vector off of a mirror vector
512 // Useful for specular and other reflective surfaces
513 void ReflectRaycxx . . $ ReflectRay(af83aca25ba5b41c).(vectorcxx . . $ vector# *dest, vectorcxx . . $ vector# *src, vectorcxx . . $ vector# *mirror_norm) {
514 *dest =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *src;
515 float d = *dest *cxx . . $ `operator*`(4a721543d64e126a). *mirror_norm;
516 vectorcxx . . $ vector# upvec = d *cxx . . $ `operator*`(9d6577ff3e9faa29). *mirror_norm;
517 *dest -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (2.0f *cxx . . $ `operator*`(9d6577ff3e9faa29). upvec);
518 }
519
520 // This is needed for small view cameras
521 // It clears the facing array so that it is recomputed
522 void ResetFacingscxx . . $ ResetFacings(49f6e7a06ebc5aa8).() { memset(Facing_visitedcxx . . $ Facing_visited., 0, sizeof(int) * (Highest_room_indexcxx . . $ Highest_room_index. + 1)); }
523
524 // Marks all the faces facing us as drawable
525 void MarkFacingFacescxx . . $ MarkFacingFaces(6819790def3fd1d2).(int roomnum, vectorcxx . . $ vector# *world_verts) {
526 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[roomnum];
527 facecxx . . $ face# *fp;
528 vectorcxx . . $ vector# tvec;
529 if (Facing_visitedcxx . . $ Facing_visited.[roomnum] == FrameCountcxx . . $ FrameCount.)
530 return;
531 Facing_visitedcxx . . $ Facing_visited.[roomnum] = FrameCountcxx . . $ FrameCount.;
532
533 fp = &rp->facescxx . . $ room#faces.[0];
534 // Go through and mark all non facing faces
535 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room.) {
536 roomcxx . . $ room# *mirror_rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
537 facecxx . . $ face# *mirror_fp = &mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.];
538 for (int t = 0; t < rp->num_facescxx . . $ room#num_faces.; t++, fp++) {
539 vectorcxx . . $ vector# incident_norm;
540 ReflectRaycxx . . $ ReflectRay(af83aca25ba5b41c).(&incident_norm, &fp->normalcxx . . $ face#normal., &mirror_fp->normalcxx . . $ face#normal.);
541
542 tvec =cxx . . $ vector#`operator=`(c0842353a20857d). Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). world_verts[fp->face_vertscxx . . $ face#face_verts.[0]];
543 if ((tvec *cxx . . $ `operator*`(4a721543d64e126a). incident_norm) <= 0)
544 fp->flagscxx . . $ face#flags. |= FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!;
545 }
546 } else {
547 for (int i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++) {
548 tvec =cxx . . $ vector#`operator=`(c0842353a20857d). Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). world_verts[fp->face_vertscxx . . $ face#face_verts.[0]];
549 if ((tvec *cxx . . $ `operator*`(4a721543d64e126a). fp->normalcxx . . $ face#normal.) <= 0)
550 fp->flagscxx . . $ face#flags. |= FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!;
551 }
552 }
553 }
554
555 // Returns true if the external room is visible from the passed in portal
556 int ExternalRoomVisibleFromPortalcxx . . $ ExternalRoomVisibleFromPortal(f8590bd56d296b2b).(int index, clip_wndcxx . . $ clip_wnd# *wnd) {
557 int i;
558 uint8_tcxx . . $ uint8_t# code = 0xff;
559 g3Pointcxx . . $ g3Point# pnt;
560 // This is a stupid hack to prevent really large buildings from popping in and out of view
561 if (External_room_project_netcxx . . $ External_room_project_net.[index])
562 return 1;
563 for (i = 0; i < 8; i++) {
564 pnt.p3_sxcxx . . $ g3Point#p3_sx. = External_room_cornerscxx . . $ External_room_corners.[index][i].xcxx . . $ vector#x.;
565 pnt.p3_sycxx . . $ g3Point#p3_sy. = External_room_cornerscxx . . $ External_room_corners.[index][i].ycxx . . $ vector#y.;
566 pnt.p3_codescxx . . $ g3Point#p3_codes. = 0;
567 code &= clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(&pnt, wnd);
568 }
569 if (code)
570 return 0; // building can't be seen from this portal
571 return 1;
572 }
573
574 // Checks to see what faces intersect the passed in portal
575 void MarkFacesForRenderingcxx . . $ MarkFacesForRendering(242c595644197048).(int roomnum, clip_wndcxx . . $ clip_wnd# *wnd) {
576 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[roomnum];
577 int i;
578 MarkFacingFacescxx . . $ MarkFacingFaces(6819790def3fd1d2).(roomnum, rp->vertscxx . . $ room#verts.);
579
580 // Rotate all the points in this room
581 if (rp->wpb_indexcxx . . $ room#wpb_index. == -1) {
582 rp->wpb_indexcxx . . $ room#wpb_index. = Global_buffer_indexcxx . . $ Global_buffer_index.;
583
584 // Katmai enhanced rotate only in a release build, because not
585 // everyone has the intel compiler!
586 #if (defined(RELEASE) && defined(KATMAI))
587 if (Katmai)
588 RotateRoomPoints(rp, rp->verts4);
589 else
590 #endif
591 RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(rp, rp->vertscxx . . $ room#verts.);
592
593 Global_buffer_indexcxx . . $ Global_buffer_index. += rp->num_vertscxx . . $ room#num_verts.;
594 }
595 if (rp->flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!) {
596 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++)
597 rp->facescxx . . $ room#faces.[i].flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
598 } else {
599 // If this room contains a mirror, just mark all faces as visible
600 // Else go through and figure out which ones are visible from the current portal
601 if (rp->mirror_facecxx . . $ room#mirror_face. == -1 || !Detail_settingscxx . . $ Detail_settings..Mirrored_surfacescxx . . $ tDetailSettings#Mirrored_surfaces.) {
602 // Do pointer dereferencing instead of array lookup for speed reasons
603 g3Pointcxx . . $ g3Point# *pnt = &World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index.];
604 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++, pnt++) {
605 Room_clipscxx . . $ Room_clips.[i] = clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(pnt, wnd);
606 }
607 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[0];
608 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++) {
609 if (fp->flagscxx . . $ face#flags. & (FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`! | FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!))
610 continue; // this face is a backface
611
612 if (FaceIntersectsPortalcxx . . $ FaceIntersectsPortal(1ceef1629d0b9542).(rp, fp, wnd))
613 fp->flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
614 }
615 } else {
616 if (rp->flagscxx . . $ room#flags. & RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!) // If this room is already mirror, just return
617 return;
618 g3Pointcxx . . $ g3Point# *pnt = &World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index.];
619 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++, pnt++) {
620 Room_clipscxx . . $ Room_clips.[i] = clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(pnt, wnd);
621 }
622 int done = 0;
623 facecxx . . $ face# *fp;
624 for (i = 0; i < rp->num_mirror_facescxx . . $ room#num_mirror_faces. && !done; i++) {
625 fp = &rp->facescxx . . $ room#faces.[rp->mirror_faces_listcxx . . $ room#mirror_faces_list.[i]];
626 if (FaceIntersectsPortalcxx . . $ FaceIntersectsPortal(1ceef1629d0b9542).(rp, fp, wnd)) {
627 rp->flagscxx . . $ room#flags. |= RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!;
628 Mirror_roomscxx . . $ Mirror_rooms.[Num_mirror_roomscxx . . $ Num_mirror_rooms.++] = roomnum;
629 done = 1;
630 }
631 }
632
633 if (rp->flagscxx . . $ room#flags. & RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!) // Mirror is visible, just mark all faces as visible
634 {
635 fp = &rp->facescxx . . $ room#faces.[0];
636 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++) {
637 fp->flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
638 }
639 } else {
640 fp = &rp->facescxx . . $ room#faces.[0];
641 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++) {
642 if (fp->flagscxx . . $ face#flags. & (FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`! | FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!))
643 continue; // this face is a backface
644
645 if (FaceIntersectsPortalcxx . . $ FaceIntersectsPortal(1ceef1629d0b9542).(rp, fp, wnd))
646 fp->flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
647 }
648 }
649 }
650 }
651
652 // Mark objects for rendering
653 int objnum;
654 for (objnum = rp->objectscxx . . $ room#objects.; (objnum != -1); objnum = Objectscxx . . $ Objects.[objnum].nextcxx . . $ object#next.) {
655 objectcxx . . $ object# *obj = &Objectscxx . . $ Objects.[objnum];
656 uint8_tcxx . . $ uint8_t# anded = 0xff;
657 g3Pointcxx . . $ g3Point# pnts[8];
658 vectorcxx . . $ vector# vecs[8];
659 uint8_tcxx . . $ uint8_t# code;
660 if (rp->flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!) // Render all objects in a door room
661 {
662 obj->flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
663 continue;
664 }
665 if (rp->flagscxx . . $ room#flags. & RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!) // Render all objects if this mirror is visible
666 {
667 obj->flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
668 continue;
669 }
670
671 MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(vecs, &obj->min_xyzcxx . . $ object#min_xyz., &obj->max_xyzcxx . . $ object#max_xyz.);
672 for (i = 0; i < 8; i++) {
673 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnts[i], &vecs[i]);
674 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&pnts[i]);
675 code = clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(&pnts[i], wnd);
676 anded &= code;
677 if (pnts[i].p3_codescxx . . $ g3Point#p3_codes. & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!)
678 anded = 0;
679 }
680
681 if (!anded) {
682 // Object is visible
683 obj->flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
684 }
685 }
686 }
687 // Prerotates all external room points and caches them
688 void RotateAllExternalRoomscxx . . $ RotateAllExternalRooms(49f6e7a06ebc5aa8).() {
689 // Build the external room list if needed
690 if (N_external_roomscxx . . $ N_external_rooms. == -1) {
691 // Set up our z wall
692 float zclip = (Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance.) * Matrix_scalecxx . . $ Matrix_scale..zcxx . . $ vector#z.;
693 g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(zclip);
694 N_external_roomscxx . . $ N_external_rooms. = 0;
695
696 int i;
697 for (i = 0; i <= Highest_room_indexcxx . . $ Highest_room_index.; i++) {
698 if ((Roomscxx . . $ Rooms.[i].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) && Roomscxx . . $ Rooms.[i].usedcxx . . $ room#used.) {
699 External_room_listcxx . . $ External_room_list.[N_external_roomscxx . . $ N_external_rooms.++] = i;
700 }
701 }
702 ASSERTcxx . . $ `misc/pserror.h:246:9`!(N_external_rooms < MAX_EXTERNAL_ROOMScxx . . $ `Descent3/render.cpp:173:9`!); // Get Jason if hit this
703 // Rotate all the points
704 vectorcxx . . $ vector# corners[8];
705 for (i = 0; i < N_external_roomscxx . . $ N_external_rooms.; i++) {
706 int roomnum = External_room_listcxx . . $ External_room_list.[i];
707 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[roomnum];
708 MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(corners, &rp->min_xyzcxx . . $ room#min_xyz., &rp->max_xyzcxx . . $ room#max_xyz.);
709
710 uint8_tcxx . . $ uint8_t# andbyte = 0xff;
711 g3Pointcxx . . $ g3Point# pnt;
712 External_room_codescxx . . $ External_room_codes.[i] = 0xff;
713 External_room_project_netcxx . . $ External_room_project_net.[i] = 0;
714 bool behind = 0;
715 bool infront = 0;
716 for (int t = 0; t < 8; t++) {
717 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt, &corners[t]);
718 External_room_codescxx . . $ External_room_codes.[i] &= pnt.p3_codescxx . . $ g3Point#p3_codes.;
719 if (pnt.p3_codescxx . . $ g3Point#p3_codes. & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!)
720 behind = true;
721 else
722 infront = true;
723 pnt.p3_codescxx . . $ g3Point#p3_codes. &= ~CC_BEHINDcxx . . $ `lib/3d.h:230:9`!;
724 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&pnt);
725 External_room_cornerscxx . . $ External_room_corners.[i][t].xcxx . . $ vector#x. = pnt.p3_sxcxx . . $ g3Point#p3_sx.;
726 External_room_cornerscxx . . $ External_room_corners.[i][t].ycxx . . $ vector#y. = pnt.p3_sycxx . . $ g3Point#p3_sy.;
727 }
728 if (infront && behind) {
729 External_room_codescxx . . $ External_room_codes.[i] = 0;
730 External_room_project_netcxx . . $ External_room_project_net.[i] = 1;
731 } else {
732 if (behind) {
733 External_room_codescxx . . $ External_room_codes.[i] = CC_BEHINDcxx . . $ `lib/3d.h:230:9`!;
734 }
735 }
736 }
737 }
738 }
739
740 void CheckFogPortalExtentscxx . . $ CheckFogPortalExtents(3e454b8ccf442868).(int roomnum, int portalnum) {
741 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[roomnum];
742 ASSERTcxx . . $ `misc/pserror.h:246:9`!(rp->flags & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!);
743
744 int i, found_room = -1;
745 for (i = 0; i < Num_fogged_rooms_this_framecxx . . $ Num_fogged_rooms_this_frame.; ++i) {
746 if (Fog_portal_datacxx . . $ Fog_portal_data.[i].roomnumcxx . . $ fog_portal_data#roomnum. != roomnum)
747 continue;
748
749 found_room = i;
750 break;
751 }
752
753 if (found_room == -1) {
754 // Couldn't find this room in our list, so make a new one
755 if (Num_fogged_rooms_this_framecxx . . $ Num_fogged_rooms_this_frame. >= MAX_FOGGED_ROOMS_PER_FRAMEcxx . . $ `Descent3/render.cpp:163:9`!) {
756 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Too many fogged rooms in view cone!\n");
757 return;
758 }
759
760 found_room = Num_fogged_rooms_this_framecxx . . $ Num_fogged_rooms_this_frame.++;
761 Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_facecxx . . $ fog_portal_data#close_face. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
762 Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_distcxx . . $ fog_portal_data#close_dist. = 10000000.0f;
763 Fog_portal_datacxx . . $ Fog_portal_data.[found_room].roomnumcxx . . $ fog_portal_data#roomnum. = roomnum;
764 }
765
766 // get the portal face
767 int fn = rp->portalscxx . . $ room#portals.[portalnum].portal_facecxx . . $ portal#portal_face.;
768 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[fn];
769
770 // calculate the plane equation for the portal
771 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[0]];
772 float distance = -vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&fp->normalcxx . . $ face#normal., vec);
773
774 // calculate the distance from the camera to the portal
775 distance = vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&fp->normalcxx . . $ face#normal., &Viewer_eyecxx . . $ Viewer_eye.) + distance;
776 if (distance < Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_distcxx . . $ fog_portal_data#close_dist.) {
777 // this portal is closer to the camera than the previous
778 Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_distcxx . . $ fog_portal_data#close_dist. = distance;
779 Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_facecxx . . $ fog_portal_data#close_face. = fp;
780 }
781 }
782
783 g3Pointcxx . . $ g3Point# Combined_portal_pointscxx . . $ Combined_portal_points.[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`! * 5];
784 void BuildRoomListSubcxx . . $ BuildRoomListSub(f16fb5ada6908fa3).(int start_room_num, clip_wndcxx . . $ clip_wnd# *wnd, int depth) {
785 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[start_room_num];
786 int i, t;
787 if (Render_portalscxx . . $ Render_portals.) {
788 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.);
789 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!);
790 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
791 rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 255));
792
793 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(wnd->leftcxx . . $ clip_wnd#left., wnd->topcxx . . $ clip_wnd#top., wnd->rightcxx . . $ clip_wnd#right., wnd->topcxx . . $ clip_wnd#top.);
794 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(wnd->rightcxx . . $ clip_wnd#right., wnd->topcxx . . $ clip_wnd#top., wnd->rightcxx . . $ clip_wnd#right., wnd->botcxx . . $ clip_wnd#bot.);
795 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(wnd->rightcxx . . $ clip_wnd#right., wnd->botcxx . . $ clip_wnd#bot., wnd->leftcxx . . $ clip_wnd#left., wnd->botcxx . . $ clip_wnd#bot.);
796 rend_DrawLinecxx . . $ rend_DrawLine(748afa4755bc9595).(wnd->leftcxx . . $ clip_wnd#left., wnd->botcxx . . $ clip_wnd#bot., wnd->leftcxx . . $ clip_wnd#left., wnd->topcxx . . $ clip_wnd#top.);
797 }
798 if (!Rooms_visitedcxx . . $ Rooms_visited.[start_room_num]) {
799 Render_listcxx . . $ Render_list.[N_render_roomscxx . . $ N_render_rooms.++] = start_room_num;
800 }
801
802 ASSERTcxx . . $ `misc/pserror.h:246:9`!(N_render_rooms < MAX_RENDER_ROOMScxx . . $ `Descent3/render.cpp:141:9`!);
803 #ifndef RELEASE
804 Mine_depthcxx . . $ Mine_depth.++;
805 #endif
806 Rooms_visitedcxx . . $ Rooms_visited.[start_room_num] = 1;
807 Room_depth_listcxx . . $ Room_depth_list.[start_room_num] = depth;
808 // If this room is a closed (non-seethrough) door, don't check any of its portals,
809 //...UNLESS this is the first room we're looking at (meaning the viewer is in this room)
810 if ((rp->flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!) && (DoorwayGetPositioncxx . . $ `Descent3/doorway.h:215:9`!(rp) == 0.0) &&
811 !(Doorscxx . . $ Doors.[rp->doorway_datacxx . . $ room#doorway_data.->doornumcxx . . $ doorway#doornum.].flagscxx . . $ door#flags. & DF_SEETHROUGHcxx . . $ `Descent3/door.h:120:9`!))
812 if (depth != 0)
813 return;
814
815 // Check all the portals for this room
816 for (t = 0; t < rp->num_portalscxx . . $ room#num_portals.; t++) {
817 portalcxx . . $ portal# *pp = &rp->portalscxx . . $ room#portals.[t];
818 int croom = pp->croomcxx . . $ portal#croom.;
819 ASSERTcxx . . $ `misc/pserror.h:246:9`!(croom >= 0);
820
821 // If we are an external room portalizing into another external room, then skip!
822 if ((rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) && (Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!))
823 continue;
824
825 // Check if we can see through this portal, and if not, skip it
826 if (!RenderPastPortalcxx . . $ RenderPastPortal(5714109361f3d17d).(rp, pp))
827 continue;
828
829 // If this portal has been visited, skip it
830 if (Room_depth_listcxx . . $ Room_depth_list.[croom] < Room_depth_listcxx . . $ Room_depth_list.[start_room_num])
831 continue;
832
833 // Deal with external portals differently
834 int external_door_hack = 0;
835 if (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`! && Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!)
836 external_door_hack = 1;
837
838 // Get pointer to this portal's face
839 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[pp->portal_facecxx . . $ portal#portal_face.];
840
841 // See if portal is facing toward us
842 if (!external_door_hack && !(pp->flagscxx . . $ portal#flags. & PF_COMBINEDcxx . . $ `Descent3/room_external.h:158:9`!)) {
843 vectorcxx . . $ vector# check_v = Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[0]];
844 if (check_v *cxx . . $ `operator*`(4a721543d64e126a). fp->normalcxx . . $ face#normal. <= 0) {
845 // not facing us
846 continue;
847 }
848 }
849
850 g3Codescxx . . $ g3Codes# cc;
851 cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
852 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
853 int nv = fp->num_vertscxx . . $ face#num_verts.;
854
855 // Code the face points
856 // If this is a combined portal, then do that
857 if ((pp->flagscxx . . $ portal#flags. & PF_COMBINEDcxx . . $ `Descent3/room_external.h:158:9`!) && !(Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!)) {
858 // If this isn't the portal-combine master, then skip it
859 if (pp->combine_mastercxx . . $ portal#combine_master. != t)
860 continue;
861 int num_points = 0;
862 for (i = 0; i < rp->num_portalscxx . . $ room#num_portals.; i++) {
863 if (((rp->portalscxx . . $ room#portals.[i].flagscxx . . $ portal#flags. & PF_COMBINEDcxx . . $ `Descent3/room_external.h:158:9`!) == 0) || rp->portalscxx . . $ room#portals.[i].combine_mastercxx . . $ portal#combine_master. != t)
864 continue;
865
866 int k;
867
868 facecxx . . $ face# *this_fp = &rp->facescxx . . $ room#faces.[rp->portalscxx . . $ room#portals.[i].portal_facecxx . . $ portal#portal_face.];
869 vectorcxx . . $ vector# check_v;
870 check_v =cxx . . $ vector#`operator=`(c0842353a20857d). Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). rp->vertscxx . . $ room#verts.[this_fp->face_vertscxx . . $ face#face_verts.[0]];
871 if (check_v *cxx . . $ `operator*`(4a721543d64e126a). this_fp->normalcxx . . $ face#normal. <= 0) // not facing us
872 continue;
873
874 g3Codescxx . . $ g3Codes# combine_cc;
875 combine_cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
876 combine_cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
877 ASSERTcxx . . $ `misc/pserror.h:246:9`!((num_points + this_fp->num_verts) < (MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`! * 5));
878
879 // First we must rotate and clip this polygon
880 for (k = 0; k < this_fp->num_vertscxx . . $ face#num_verts.; k++) {
881 uint8_tcxx . . $ uint8_t# c = g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&Combined_portal_pointscxx . . $ Combined_portal_points.[num_points + k], &rp->vertscxx . . $ room#verts.[this_fp->face_vertscxx . . $ face#face_verts.[k]]);
882 combine_cc.cc_orcxx . . $ g3Codes#cc_or. |= c;
883 combine_cc.cc_andcxx . . $ g3Codes#cc_and. &= c;
884 }
885 if (combine_cc.cc_andcxx . . $ g3Codes#cc_and.) {
886 continue; // clipped away!
887 } else if (combine_cc.cc_orcxx . . $ g3Codes#cc_or.) {
888 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
889 for (k = 0; k < this_fp->num_vertscxx . . $ face#num_verts.; k++) {
890 pointlist[k] = &Combined_portal_pointscxx . . $ Combined_portal_points.[num_points + k];
891 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pointlist[k]->p3_flags & PF_TEMP_POINTcxx . . $ `lib/3d.h:216:9`!));
892 }
893
894 // If portal not all on screen, must clip it
895 int combine_nv = this_fp->num_vertscxx . . $ face#num_verts.;
896 g3Pointcxx . . $ g3Point# **pl = g3_ClipPolygoncxx . . $ g3_ClipPolygon(729f60102f660017).(pointlist, &combine_nv, &combine_cc);
897 if (combine_cc.cc_andcxx . . $ g3Codes#cc_and.) {
898 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, combine_nv);
899 } else {
900 // save the clipped points
901 g3Pointcxx . . $ g3Point# temp_points[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
902 for (k = 0; k < combine_nv; k++) {
903 temp_points[k] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). *pl[k];
904 temp_points[k].p3_flagscxx . . $ g3Point#p3_flags. &= ~PF_TEMP_POINTcxx . . $ `lib/3d.h:216:9`!;
905 }
906
907 // release the temp points
908 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, combine_nv);
909
910 // put the points back in the buffer
911 // NOTE: we have to do it like this because pl points to
912 // Combined_portal_points pointers
913 for (k = 0; k < combine_nv; k++) {
914 Combined_portal_pointscxx . . $ Combined_portal_points.[k + num_points] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). temp_points[k];
915 }
916
917 num_points += combine_nv;
918 }
919 } else {
920 // No clipping needed, face is fully on screen
921 num_points += this_fp->num_vertscxx . . $ face#num_verts.;
922 }
923 }
924 if (num_points == 0)
925 continue;
926
927 // Now, figure out a min/max for these points
928 g3Pointcxx . . $ g3Point# four_points[4];
929 for (i = 0; i < num_points; i++) {
930 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&Combined_portal_pointscxx . . $ Combined_portal_points.[i]);
931 }
932 int left = 0, top = 0, right = 0, bottom = 0;
933 clip_wndcxx . . $ clip_wnd# combine_wnd;
934 combine_wnd.rightcxx . . $ clip_wnd#right. = combine_wnd.botcxx . . $ clip_wnd#bot. = 0.0;
935 combine_wnd.leftcxx . . $ clip_wnd#left. = Render_widthcxx . . $ Render_width.;
936 combine_wnd.topcxx . . $ clip_wnd#top. = Render_heightcxx . . $ Render_height.;
937 // make new clip window
938 for (i = 0; i < num_points; i++) {
939 float x = Combined_portal_pointscxx . . $ Combined_portal_points.[i].p3_sxcxx . . $ g3Point#p3_sx., y = Combined_portal_pointscxx . . $ Combined_portal_points.[i].p3_sycxx . . $ g3Point#p3_sy.;
940 if (x < combine_wnd.leftcxx . . $ clip_wnd#left.) {
941 combine_wnd.leftcxx . . $ clip_wnd#left. = x;
942 left = i;
943 }
944 if (x > combine_wnd.rightcxx . . $ clip_wnd#right.) {
945 combine_wnd.rightcxx . . $ clip_wnd#right. = x;
946 right = i;
947 }
948 if (y < combine_wnd.topcxx . . $ clip_wnd#top.) {
949 combine_wnd.topcxx . . $ clip_wnd#top. = y;
950 top = i;
951 }
952 if (y > combine_wnd.botcxx . . $ clip_wnd#bot.) {
953 combine_wnd.botcxx . . $ clip_wnd#bot. = y;
954 bottom = i;
955 }
956 }
957 // Now harvest these points
958 four_points[0] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). Combined_portal_pointscxx . . $ Combined_portal_points.[left];
959 four_points[1] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). Combined_portal_pointscxx . . $ Combined_portal_points.[top];
960 four_points[2] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). Combined_portal_pointscxx . . $ Combined_portal_points.[right];
961 four_points[3] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). Combined_portal_pointscxx . . $ Combined_portal_points.[bottom];
962 for (i = 0; i < 4; i++) {
963 Combined_portal_pointscxx . . $ Combined_portal_points.[i] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). four_points[i];
964 Combined_portal_pointscxx . . $ Combined_portal_points.[i].p3_flagscxx . . $ g3Point#p3_flags. &= ~(PF_PROJECTEDcxx . . $ `lib/3d.h:214:9`! | PF_TEMP_POINTcxx . . $ `lib/3d.h:216:9`!);
965 uint8_tcxx . . $ uint8_t# c = Combined_portal_pointscxx . . $ Combined_portal_points.[i].p3_codescxx . . $ g3Point#p3_codes.;
966 cc.cc_andcxx . . $ g3Codes#cc_and. &= c;
967 cc.cc_orcxx . . $ g3Codes#cc_or. |= c;
968 }
969 nv = 4;
970 } else {
971 for (i = 0; i < nv; i++) {
972 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&Combined_portal_pointscxx . . $ Combined_portal_points.[i], &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[i]]);
973
974 uint8_tcxx . . $ uint8_t# c = Combined_portal_pointscxx . . $ Combined_portal_points.[i].p3_codescxx . . $ g3Point#p3_codes.;
975 cc.cc_andcxx . . $ g3Codes#cc_and. &= c;
976 cc.cc_orcxx . . $ g3Codes#cc_or. |= c;
977 }
978 }
979 // If points are on screen, see if they're in the clip window
980 if (cc.cc_andcxx . . $ g3Codes#cc_and. == 0 || external_door_hack) {
981 bool clipped = 0;
982 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!], **pl = pointlist;
983 for (i = 0; i < nv; i++)
984 pointlist[i] = &Combined_portal_pointscxx . . $ Combined_portal_points.[i];
985 // If portal not all on screen, must clip it
986 if (cc.cc_orcxx . . $ g3Codes#cc_or.) {
987 pl = g3_ClipPolygoncxx . . $ g3_ClipPolygon(729f60102f660017).(pl, &nv, &cc);
988 clipped = 1;
989 }
990 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
991 for (i = 0; i < nv; i++) {
992 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(pl[i]);
993 cc.cc_andcxx . . $ g3Codes#cc_and. &= clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(pl[i], wnd);
994 }
995 // Make sure it didn't get clipped away
996 if (cc.cc_andcxx . . $ g3Codes#cc_and. == 0 || external_door_hack) {
997 clip_wndcxx . . $ clip_wnd# new_wnd;
998 new_wnd.rightcxx . . $ clip_wnd#right. = new_wnd.botcxx . . $ clip_wnd#bot. = 0.0;
999 new_wnd.leftcxx . . $ clip_wnd#left. = Render_widthcxx . . $ Render_width.;
1000 new_wnd.topcxx . . $ clip_wnd#top. = Render_heightcxx . . $ Render_height.;
1001 // make new clip window
1002 for (i = 0; i < nv; i++) {
1003 float x = pl[i]->p3_sxcxx . . $ g3Point#p3_sx., y = pl[i]->p3_sycxx . . $ g3Point#p3_sy.;
1004 if (x < new_wnd.leftcxx . . $ clip_wnd#left.)
1005 new_wnd.leftcxx . . $ clip_wnd#left. = x;
1006 if (x > new_wnd.rightcxx . . $ clip_wnd#right.)
1007 new_wnd.rightcxx . . $ clip_wnd#right. = x;
1008 if (y < new_wnd.topcxx . . $ clip_wnd#top.)
1009 new_wnd.topcxx . . $ clip_wnd#top. = y;
1010 if (y > new_wnd.botcxx . . $ clip_wnd#bot.)
1011 new_wnd.botcxx . . $ clip_wnd#bot. = y;
1012 }
1013 // If this room is fogged, see if this portal is closest
1014 if (Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!) {
1015 CheckFogPortalExtentscxx . . $ CheckFogPortalExtents(3e454b8ccf442868).(croom, pp->cportalcxx . . $ portal#cportal.);
1016 }
1017 // Combine the two windows
1018 new_wnd.leftcxx . . $ clip_wnd#left. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd->leftcxx . . $ clip_wnd#left., new_wnd.leftcxx . . $ clip_wnd#left.);
1019 new_wnd.rightcxx . . $ clip_wnd#right. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd->rightcxx . . $ clip_wnd#right., new_wnd.rightcxx . . $ clip_wnd#right.);
1020 new_wnd.topcxx . . $ clip_wnd#top. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd->topcxx . . $ clip_wnd#top., new_wnd.topcxx . . $ clip_wnd#top.);
1021 new_wnd.botcxx . . $ clip_wnd#bot. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd->botcxx . . $ clip_wnd#bot., new_wnd.botcxx . . $ clip_wnd#bot.);
1022 if (clipped) { // Free up temp points
1023 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
1024 clipped = 0;
1025 }
1026 if (Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) {
1027 if (!Called_from_terraincxx . . $ Called_from_terrain.) {
1028 Must_render_terraincxx . . $ Must_render_terrain. = 1;
1029 RotateAllExternalRoomscxx . . $ RotateAllExternalRooms(49f6e7a06ebc5aa8).();
1030 // For this external portal, we must check to see what external
1031 // rooms are visible from here
1032 for (i = 0; i < N_external_roomscxx . . $ N_external_rooms.; i++) {
1033 if (External_room_codescxx . . $ External_room_codes.[i]) {
1034 continue;
1035 }
1036 if (External_room_listcxx . . $ External_room_list.[i] != croom) {
1037 // If this portal has been visited, skip it
1038 if (Room_depth_listcxx . . $ Room_depth_list.[External_room_listcxx . . $ External_room_list.[i]] < Room_depth_listcxx . . $ Room_depth_list.[start_room_num]) {
1039 continue;
1040 }
1041 if (!ExternalRoomVisibleFromPortalcxx . . $ ExternalRoomVisibleFromPortal(f8590bd56d296b2b).(i, &new_wnd)) {
1042 continue;
1043 }
1044 }
1045 MarkFacesForRenderingcxx . . $ MarkFacesForRendering(242c595644197048).(External_room_listcxx . . $ External_room_list.[i], &new_wnd);
1046 BuildRoomListSubcxx . . $ BuildRoomListSub(f16fb5ada6908fa3).(External_room_listcxx . . $ External_room_list.[i], &new_wnd, depth + 1);
1047 Room_depth_listcxx . . $ Room_depth_list.[External_room_listcxx . . $ External_room_list.[i]] = 255;
1048 }
1049 // Combine the two windows
1050 Terrain_portal_leftcxx . . $ Terrain_portal_left. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(new_wnd.leftcxx . . $ clip_wnd#left., Terrain_portal_leftcxx . . $ Terrain_portal_left.);
1051 Terrain_portal_rightcxx . . $ Terrain_portal_right. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<float>(new_wnd.rightcxx . . $ clip_wnd#right., Terrain_portal_rightcxx . . $ Terrain_portal_right.);
1052 Terrain_portal_topcxx . . $ Terrain_portal_top. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(new_wnd.topcxx . . $ clip_wnd#top., Terrain_portal_topcxx . . $ Terrain_portal_top.);
1053 Terrain_portal_bottomcxx . . $ Terrain_portal_bottom. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<float>(new_wnd.botcxx . . $ clip_wnd#bot., Terrain_portal_bottomcxx . . $ Terrain_portal_bottom.);
1054 }
1055 } else {
1056 MarkFacesForRenderingcxx . . $ MarkFacesForRendering(242c595644197048).(croom, &new_wnd);
1057 BuildRoomListSubcxx . . $ BuildRoomListSub(f16fb5ada6908fa3).(croom, &new_wnd, depth + 1);
1058 Room_depth_listcxx . . $ Room_depth_list.[croom] = 255;
1059 }
1060 }
1061 if (clipped) // Free up temp points
1062 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
1063 }
1064 }
1065 }
1066 // compare function for room z sort
1067 float Room_z_depthcxx . . $ Room_z_depth.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`! + MAX_PALETTE_ROOMScxx . . $ `Descent3/room.h:384:9`!];
1068 static int Room_z_sort_funccxx . . $ Room_z_sort_func(cc1caa6a32f99af5).(const int16_t *a, const int16_t *b) {
1069 float az, bz;
1070 az = Room_z_depthcxx . . $ Room_z_depth.[*a];
1071 bz = Room_z_depthcxx . . $ Room_z_depth.[*b];
1072 if (az < bz)
1073 return 1;
1074 else if (az > bz)
1075 return -1;
1076 else
1077 return 0;
1078 }
1079 // build a list of rooms to be rendered
1080 // fills in Render_list & N_render_rooms
1081 void BuildRoomListcxx . . $ BuildRoomList(d4f767463ce0a6b3).(int start_room_num) {
1082 clip_wndcxx . . $ clip_wnd# wnd;
1083 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[start_room_num];
1084 int i;
1085 // For now, render all connected rooms
1086 for (i = 0; i <= Highest_room_indexcxx . . $ Highest_room_index.; i++) {
1087 Rooms_visitedcxx . . $ Rooms_visited.[i] = 0;
1088 Room_depth_listcxx . . $ Room_depth_list.[i] = 255;
1089 Roomscxx . . $ Rooms.[i].wpb_indexcxx . . $ room#wpb_index. = -1;
1090 }
1091 #ifdef EDITOR
1092 Rooms_visited[start_room_num] = 0; // take care of rooms in the room palette
1093 Room_depth_list[start_room_num] = 0;
1094 #endif
1095 N_external_roomscxx . . $ N_external_rooms. = -1;
1096 N_render_roomscxx . . $ N_render_rooms. = 0;
1097 Global_buffer_indexcxx . . $ Global_buffer_index. = 0;
1098 // Mark all the faces in our start room as renderable
1099 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++)
1100 rp->facescxx . . $ room#faces.[i].flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
1101
1102 MarkFacingFacescxx . . $ MarkFacingFaces(6819790def3fd1d2).(start_room_num, rp->vertscxx . . $ room#verts.);
1103 // Enable mirror if there is one
1104 if (rp->mirror_facecxx . . $ room#mirror_face. != -1 && Detail_settingscxx . . $ Detail_settings..Mirrored_surfacescxx . . $ tDetailSettings#Mirrored_surfaces. &&
1105 !(rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].flagscxx . . $ face#flags. & FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!)) {
1106 rp->flagscxx . . $ room#flags. |= RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!;
1107 Mirror_roomscxx . . $ Mirror_rooms.[Num_mirror_roomscxx . . $ Num_mirror_rooms.++] = start_room_num;
1108 }
1109
1110 // Get our points rotated, and update the global point list
1111 rp->wpb_indexcxx . . $ room#wpb_index. = Global_buffer_indexcxx . . $ Global_buffer_index.;
1112
1113 // Katmai enhanced rotate only in a release build, because not
1114 // everyone has the intel compiler!
1115 #if (defined(RELEASE) && defined(KATMAI))
1116 if (Katmai)
1117
1118 RotateRoomPoints(rp, rp->verts4);
1119 else
1120 #endif
1121 RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(rp, rp->vertscxx . . $ room#verts.);
1122
1123 Global_buffer_indexcxx . . $ Global_buffer_index. += rp->num_vertscxx . . $ room#num_verts.;
1124
1125 // Mark all objects in this room as visible
1126 for (int objnum = rp->objectscxx . . $ room#objects.; (objnum != -1); objnum = Objectscxx . . $ Objects.[objnum].nextcxx . . $ object#next.)
1127 Objectscxx . . $ Objects.[objnum].flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
1128
1129 // Initial clip window is whole screen
1130 wnd.leftcxx . . $ clip_wnd#left. = wnd.topcxx . . $ clip_wnd#top. = 0.0;
1131 wnd.rightcxx . . $ clip_wnd#right. = Render_widthcxx . . $ Render_width.;
1132 wnd.botcxx . . $ clip_wnd#bot. = Render_heightcxx . . $ Render_height.;
1133 BuildRoomListSubcxx . . $ BuildRoomListSub(f16fb5ada6908fa3).(start_room_num, &wnd, 0);
1134 // mprintf(0,"N_render_rooms = %d ",N_render_rooms);
1135 #ifdef EDITOR
1136 // Add all external rooms to render list if that flag set
1137 if (Editor_view_mode == VM_MINE && In_editor_mode) {
1138 if (Render_all_external_rooms) {
1139 int i;
1140 room *rp;
1141 for (i = 0, rp = Rooms; i <= Highest_room_index; i++, rp++) {
1142 if (rp->used && (rp->flags & RF_EXTERNAL)) {
1143 for (int t = 0; t < rp->num_faces; t++)
1144 rp->faces[t].flags |= FF_VISIBLE;
1145 MarkFacingFaces(i, rp->verts);
1146
1147 if (!Rooms_visited[i])
1148 Render_list[N_render_rooms++] = i;
1149 Rooms_visited[i] = 1;
1150 }
1151 }
1152 }
1153 }
1154 #endif
1155 }
1156 #ifdef EDITOR
1157 // Returns 1 if x,y is inside the given polygon, else 0
1158 int point_in_poly(int nv, g3Point *p, float x, float y) {
1159 int i, j, c = 0;
1160 for (i = 0, j = nv - 1; i < nv; j = i++) {
1161 if ((((p[i].p3_sy <= y) && (y < p[j].p3_sy)) || ((p[j].p3_sy <= y) && (y < p[i].p3_sy))) &&
1162 (x < (p[j].p3_sx - p[i].p3_sx) * (y - p[i].p3_sy) / (p[j].p3_sy - p[i].p3_sy) + p[i].p3_sx))
1163 c = !c;
1164 }
1165
1166 return c;
1167 }
1168 /*
1169 // Only called if editor active.
1170 // Used to determine which face was clicked on.
1171 void CheckFace(room *rp,int facenum, int nv, int bm,g3Point **pointlist)
1172 {
1173 ddgr_color oldcolor;
1174 //draw search pixel in bright green
1175 rend_SetPixel(GR_RGB(0,255,10),search_x,search_y);
1176 oldcolor = rend_GetPixel(search_x,search_y); //will be different in 15/16-bit color
1177 // Based on distance, draw in perspective or linear
1178 // This is gonna be ripped out
1179 rend_SetTextureType (TT_LINEAR_SPECIAL);
1180 for (int i=0;i<nv;i++)
1181 {
1182 g3Point *t;
1183 t=pointlist[i];
1184 if (t[i].p3_vec.z<35)
1185 rend_SetTextureType (TT_PERSPECTIVE_SPECIAL);
1186 }
1187 g3_DrawPoly(nv,pointlist,bm);
1188 if (rend_GetPixel(search_x,search_y) != oldcolor) {
1189 found_room = ROOMNUM(rp);
1190 found_face = facenum;
1191 }
1192 }
1193 */
1194 #endif
1195 #ifdef EDITOR
1196 #define STEPSIZE .01f
1197 #define STEPSIZE_MIN .1f
1198 void RenderFloatingTrig(room *rp, face *fp) {
1199 if (!Render_floating_triggers)
1200 return;
1201 vector leftvec, rightvec;
1202 vector left, right;
1203 vector left_step, right_step;
1204 int n_steps, i, j;
1205 g3Point p3;
1206 float stepsize;
1207 left = rp->verts[fp->face_verts[0]];
1208 right = rp->verts[fp->face_verts[1]];
1209 g3_RotatePoint(&p3, &left);
1210 stepsize = STEPSIZE * p3.p3_z;
1211 if (stepsize < STEPSIZE_MIN)
1212 stepsize = STEPSIZE_MIN;
1213 leftvec = rp->verts[fp->face_verts[3]] - rp->verts[fp->face_verts[0]];
1214 rightvec = rp->verts[fp->face_verts[2]] - rp->verts[fp->face_verts[1]];
1215 n_steps = (vm_GetMagnitude(&leftvec) / stepsize + 0.5) + 1;
1216 left_step = leftvec / n_steps;
1217 right_step = rightvec / n_steps;
1218 for (i = 0; i < n_steps; i++) {
1219 vector p;
1220 g3Point p3;
1221 vector crossvec, cross_step;
1222 int n_crosssteps;
1223
1224 crossvec = right - left;
1225 n_crosssteps = (vm_GetMagnitude(&crossvec) / stepsize + 0.5) + 1;
1226 cross_step = crossvec / n_steps;
1227 p = left;
1228 for (j = 0; j < n_crosssteps; j++) {
1229 if (g3_RotatePoint(&p3, &p) == 0) { // on screen
1230 g3_ProjectPoint(&p3);
1231 rend_SetPixel(GR_RGB(255, 100, 100), p3.p3_sx, p3.p3_sy);
1232 }
1233 p += cross_step;
1234 }
1235 left += left_step;
1236 right += right_step;
1237 }
1238 }
1239 #endif // ifdef EDITOR
1240 void RenderSpecularFacescxx . . $ RenderSpecularFaces(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
1241 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_specular_faces_to_render > 0);
1242 int i, vn;
1243 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1244 g3Pointcxx . . $ g3Point# pointbuffer[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1245 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.);
1246 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1247 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.);
1248 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
1249 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
1250 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!);
1251 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
1252
1253 for (i = 0; i < Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render.; i++) {
1254 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[Specular_facescxx . . $ Specular_faces.[i]];
1255 int lm_handle = LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].spec_mapcxx . . $ lightmap_info#spec_map.;
1256 ASSERTcxx . . $ `misc/pserror.h:246:9`!(lm_handle != -1);
1257 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1258 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1259 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1260 pointlist[vn] = p;
1261 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2.;
1262 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2.;
1263
1264 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`!;
1265 }
1266
1267 int save_w = lm_wcxx . . $ lm_w(7864480464b09eea).(lm_handle);
1268 int save_h = lm_hcxx . . $ lm_h(7864480464b09eea).(lm_handle);
1269 GameLightmapscxx . . $ GameLightmaps.[lm_handle].widthcxx . . $ bms_lightmap#width. = lm_wcxx . . $ lm_w(7864480464b09eea).(LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.);
1270 GameLightmapscxx . . $ GameLightmaps.[lm_handle].heightcxx . . $ bms_lightmap#height. = lm_hcxx . . $ lm_h(7864480464b09eea).(LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.);
1271 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, lm_handle, MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!);
1272 GameLightmapscxx . . $ GameLightmaps.[lm_handle].widthcxx . . $ bms_lightmap#width. = save_w;
1273 GameLightmapscxx . . $ GameLightmaps.[lm_handle].heightcxx . . $ bms_lightmap#height. = save_h;
1274 }
1275 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.);
1276 }
1277
1278 float Specular_scalarscxx . . $ Specular_scalars.[4][4] = {{1.0f}, {1.0f, .66f}, {1.0f, .66f, .33f}, {1.0f, .66f, .33f, .25f}};
1279 void RenderSpecularFacesFlatcxx . . $ RenderSpecularFacesFlat(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
1280 static int first = 1;
1281 static float lm_red[32], lm_green[32], lm_blue[32];
1282 int num_smooth_faces = 0;
1283 int num_smooth_used = 0;
1284 uint16_tcxx . . $ uint16_t# smooth_faces[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
1285 uint16_tcxx . . $ uint16_t# smooth_used[MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!];
1286 int i;
1287 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_specular_faces_to_render > 0);
1288 if (!UseHardwarecxx . . $ UseHardware.)
1289 return;
1290 if (Num_real_specular_faces_to_rendercxx . . $ Num_real_specular_faces_to_render. == 0) {
1291 for (i = 0; i < Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render.; i++) {
1292 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[Specular_facescxx . . $ Specular_faces.[i]];
1293 fp->flagscxx . . $ face#flags. &= ~FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!;
1294 }
1295 return;
1296 }
1297 if (first) {
1298 first = 0;
1299 int i;
1300 for (i = 0; i < 32; i++) {
1301 lm_red[i] = (float)i / 31.0;
1302 lm_green[i] = (float)i / 31.0;
1303 lm_blue[i] = (float)i / 31.0;
1304 }
1305 for (i = 0; i < MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!; i++) {
1306 Smooth_vertscxx . . $ Smooth_verts.[i].usedcxx . . $ smooth_spec_vert#used. = 0;
1307 }
1308 }
1309
1310 int t, vn;
1311 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1312 g3Pointcxx . . $ g3Point# pointbuffer[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1313 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1314 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.);
1315 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
1316 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.);
1317 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SPECULARcxx . . $ `lib/renderer.h:416:9`!);
1318 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0);
1319
1320 for (i = 0; i < Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render.; i++) {
1321 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[Specular_facescxx . . $ Specular_faces.[i]];
1322
1323 int material_type = 0;
1324 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_PLASTICcxx . . $ `Descent3/gametexture.h:205:9`!)
1325 material_type = 1;
1326 else if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_MARBLEcxx . . $ `Descent3/gametexture.h:204:9`!)
1327 material_type = 2;
1328 int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(fp->tmapcxx . . $ face#tmap., 0);
1329 if ((fp->flagscxx . . $ face#flags. & FF_DESTROYEDcxx . . $ `Descent3/room_external.h:119:9`!) && (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_DESTROYABLEcxx . . $ `Descent3/gametexture.h:208:9`!))
1330 bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].destroy_handlecxx . . $ texture#destroy_handle., 0);
1331 if (bm_formatcxx . . $ bm_format(7864480464b09eea).(bm_handle) != BITMAP_FORMAT_4444cxx . . $ `lib/bitmap.h:57:9`!)
1332 continue;
1333
1334 int lm_handle;
1335 uint16_tcxx . . $ uint16_t# *data;
1336 int w, h;
1337
1338 if (fp->lmi_handlecxx . . $ face#lmi_handle. == 65535) {
1339 // this face shouldn't be rendered during the specular pass...skip it
1340 continue;
1341 }
1342
1343 lm_handle = LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.;
1344 data = (uint16_tcxx . . $ uint16_t# *)lm_datacxx . . $ lm_data(2fbd6a760478ca0f).(lm_handle);
1345 w = lm_wcxx . . $ lm_w(7864480464b09eea).(lm_handle);
1346 h = lm_hcxx . . $ lm_h(7864480464b09eea).(lm_handle);
1347
1348 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1349
1350 float rv = 0, gv = 0, bv = 0;
1351 float scalar = 0;
1352 float u, v;
1353 int int_u, int_v;
1354 uint16_tcxx . . $ uint16_t# texel;
1355 int r, g, b;
1356 float vr, vg, vb;
1357
1358 u = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2. * w;
1359 v = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2. * h;
1360 int_u = u;
1361 int_v = v;
1362 texel = data[int_v * w + int_u];
1363 r = (texel >> 10) & 0x1f;
1364 g = (texel >> 5) & 0x1f;
1365 b = (texel) & 0x1f;
1366 vr = lm_red[r];
1367 vg = lm_green[g];
1368 vb = lm_blue[b];
1369
1370 vectorcxx . . $ vector# subvec = Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vn]];
1371 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&subvec);
1372 if (!(rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)) {
1373 int limit = SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].numcxx . . $ special_face#num.;
1374 int spec_index = limit - 1;
1375 /*if (GameTextures[fp->tmap].flags & TF_SMOOTH_SPECULAR)
1376 {
1377 limit/=2;
1378 }*/
1379
1380 for (t = 0; t < limit; t++) {
1381 uint16_tcxx . . $ uint16_t# color;
1382 vectorcxx . . $ vector# incident_norm;
1383 float spec_scalar;
1384
1385 // Use regular static lighting
1386 color = SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].spec_instancecxx . . $ special_face#spec_instance.[t].bright_colorcxx . . $ specular_instance#bright_color.;
1387 if (color == 0)
1388 continue;
1389 incident_norm =cxx . . $ vector#`operator=`(c0842353a20857d).
1390 rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vn]] -cxx . . $ operator-(b77b703cd1e43e33). SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].spec_instancecxx . . $ special_face#spec_instance.[t].bright_centercxx . . $ specular_instance#bright_center.;
1391 spec_scalar = Specular_scalarscxx . . $ Specular_scalars.[spec_index][t];
1392
1393 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&incident_norm);
1394 float d;
1395 vectorcxx . . $ vector# upvec;
1396 if ((GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) &&
1397 (SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].flagscxx . . $ special_face#flags. & SFF_SPEC_SMOOTHcxx . . $ `Descent3/special_face.h:38:9`!)) {
1398 d = incident_norm *cxx . . $ `operator*`(4a721543d64e126a). SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].vertnormscxx . . $ special_face#vertnorms.[vn];
1399 upvec =cxx . . $ vector#`operator=`(c0842353a20857d). d *cxx . . $ `operator*`(9d6577ff3e9faa29). SpecialFacescxx . . $ SpecialFaces.[fp->special_handlecxx . . $ face#special_handle.].vertnormscxx . . $ special_face#vertnorms.[vn];
1400 } else {
1401 d = incident_norm *cxx . . $ `operator*`(4a721543d64e126a). fp->normalcxx . . $ face#normal.;
1402 upvec =cxx . . $ vector#`operator=`(c0842353a20857d). d *cxx . . $ `operator*`(9d6577ff3e9faa29). fp->normalcxx . . $ face#normal.;
1403 }
1404 incident_norm -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (2 *cxx . . $ `operator*`(9d6577ff3e9faa29). upvec);
1405 float dotp = subvec *cxx . . $ `operator*`(4a721543d64e126a). incident_norm;
1406 if (dotp > 1)
1407 dotp = 1;
1408
1409 if (dotp > 0) {
1410 int index = ((float)(MAX_SPECULAR_INCREMENTScxx . . $ `Descent3/lighting.h:38:9`! - 1) * dotp);
1411 scalar = Specular_tablescxx . . $ Specular_tables.[material_type][index] * spec_scalar;
1412
1413 float cr = (float)((color >> 10) & 0x1f) / 31.0;
1414 float cg = (float)((color >> 5) & 0x1f) / 31.0;
1415 float cb = (float)(color & 0x1f) / 31.0;
1416 rv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, (rv + (scalar * cr)));
1417 gv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, (gv + (scalar * cg)));
1418 bv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, (bv + (scalar * cb)));
1419 }
1420 }
1421 } else {
1422 vectorcxx . . $ vector# incident_norm = rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vn]] -cxx . . $ operator-(b77b703cd1e43e33). Terrain_skycxx . . $ Terrain_sky..satellite_vectorscxx . . $ terrain_sky#satellite_vectors.[0];
1423 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&incident_norm);
1424
1425 float d = incident_norm *cxx . . $ `operator*`(4a721543d64e126a). fp->normalcxx . . $ face#normal.;
1426 vectorcxx . . $ vector# upvec = d *cxx . . $ `operator*`(9d6577ff3e9faa29). fp->normalcxx . . $ face#normal.;
1427 incident_norm -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (2 *cxx . . $ `operator*`(9d6577ff3e9faa29). upvec);
1428 float dotp = subvec *cxx . . $ `operator*`(4a721543d64e126a). incident_norm;
1429 if (dotp > 1)
1430 dotp = 1;
1431
1432 if (dotp > 0) {
1433 int index = ((float)(MAX_SPECULAR_INCREMENTScxx . . $ `Descent3/lighting.h:38:9`! - 1) * dotp);
1434 scalar = Specular_tablescxx . . $ Specular_tables.[material_type][index];
1435 rv = scalar;
1436 gv = scalar;
1437 bv = scalar;
1438 }
1439 }
1440 // Finally, brighten these value up a bit
1441 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) {
1442 rv = rv * vr;
1443 gv = gv * vg;
1444 bv = bv * vb;
1445 if (Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].usedcxx . . $ smooth_spec_vert#used. == 0) {
1446 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].usedcxx . . $ smooth_spec_vert#used. = 1;
1447 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].rcxx . . $ smooth_spec_vert#r. = rv;
1448 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].gcxx . . $ smooth_spec_vert#g. = gv;
1449 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].bcxx . . $ smooth_spec_vert#b. = bv;
1450 smooth_used[num_smooth_used++] = fp->face_vertscxx . . $ face#face_verts.[vn];
1451 } else {
1452 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].rcxx . . $ smooth_spec_vert#r. += rv;
1453 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].gcxx . . $ smooth_spec_vert#g. += gv;
1454 Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].bcxx . . $ smooth_spec_vert#b. += bv;
1455 }
1456 } else {
1457 rv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(1.0, rv * vr * 4.0);
1458 gv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(1.0, gv * vg * 4.0);
1459 bv = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(1.0, bv * vb * 4.0);
1460 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1461 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1462 pointlist[vn] = p;
1463 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].ucxx . . $ roomUVL#u.;
1464 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].vcxx . . $ roomUVL#v.;
1465 p->p3_acxx . . $ `lib/3d.h:256:9`! = 1.0;
1466 p->p3_rcxx . . $ `lib/3d.h:253:9`! = rv;
1467 p->p3_gcxx . . $ `lib/3d.h:254:9`! = gv;
1468 p->p3_bcxx . . $ `lib/3d.h:255:9`! = bv;
1469 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_UVcxx . . $ `lib/3d.h:217:9`!;
1470 }
1471 }
1472 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) {
1473 smooth_faces[num_smooth_faces] = fp - rp->facescxx . . $ room#faces.;
1474 num_smooth_faces++;
1475 } else {
1476 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1477 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1);
1478
1479 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, bm_handle);
1480
1481 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1482 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0);
1483 }
1484 }
1485 // Now draw smooth specular faces
1486 for (i = 0; i < num_smooth_faces; i++) {
1487 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[smooth_faces[i]];
1488 if (fp->flagscxx . . $ face#flags. & FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!) {
1489 fp->flagscxx . . $ face#flags. &= ~(FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!);
1490 continue;
1491 }
1492 int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(fp->tmapcxx . . $ face#tmap., 0);
1493 if ((fp->flagscxx . . $ face#flags. & FF_DESTROYEDcxx . . $ `Descent3/room_external.h:119:9`!) && (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_DESTROYABLEcxx . . $ `Descent3/gametexture.h:208:9`!))
1494 bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].destroy_handlecxx . . $ texture#destroy_handle., 0);
1495 if (bm_formatcxx . . $ bm_format(7864480464b09eea).(bm_handle) != BITMAP_FORMAT_4444cxx . . $ `lib/bitmap.h:57:9`!)
1496 continue;
1497 float reflect = GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].reflectivitycxx . . $ texture#reflectivity. * 1.5;
1498 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1499 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1500 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1501 pointlist[vn] = p;
1502 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].ucxx . . $ roomUVL#u.;
1503 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].vcxx . . $ roomUVL#v.;
1504 p->p3_acxx . . $ `lib/3d.h:256:9`! = 1.0;
1505 p->p3_rcxx . . $ `lib/3d.h:253:9`! = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].rcxx . . $ smooth_spec_vert#r. * reflect);
1506 p->p3_gcxx . . $ `lib/3d.h:254:9`! = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].gcxx . . $ smooth_spec_vert#g. * reflect);
1507 p->p3_bcxx . . $ `lib/3d.h:255:9`! = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(1.0, Smooth_vertscxx . . $ Smooth_verts.[fp->face_vertscxx . . $ face#face_verts.[vn]].bcxx . . $ smooth_spec_vert#b. * reflect);
1508 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_UVcxx . . $ `lib/3d.h:217:9`!;
1509 }
1510
1511 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1512 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1);
1513
1514 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, bm_handle);
1515
1516 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1517 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0);
1518 }
1519 for (i = 0; i < num_smooth_used; i++) {
1520 Smooth_vertscxx . . $ Smooth_verts.[smooth_used[i]].usedcxx . . $ smooth_spec_vert#used. = 0;
1521 }
1522 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
1523 }
1524
1525 // Adds a specular face to draw after the mine has been drawn
1526 void UpdateSpecularFacecxx . . $ UpdateSpecularFace(7ae16100a71bcfc5).(roomcxx . . $ room# *rp, facecxx . . $ face# *fp) {
1527 /*if (!(rp->flags & RF_EXTERNAL)
1528 {
1529 int handle=GetSpecularLightmapForFace (&Viewer_eye,rp,fp);
1530 if (handle<0)
1531 return;
1532 }*/
1533 if (Renderer_typecxx . . $ Renderer_type. == RENDERER_OPENGLcxx . . $ RENDERER_OPENGL.)
1534 return;
1535 int n = Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render.;
1536 if (n >= MAX_SPECULAR_FACEScxx . . $ `Descent3/render.cpp:150:9`!)
1537 return;
1538 Specular_facescxx . . $ Specular_faces.[n] = fp - rp->facescxx . . $ room#faces.;
1539 Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render.++;
1540 if (!(fp->flagscxx . . $ face#flags. & FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!))
1541 Num_real_specular_faces_to_rendercxx . . $ Num_real_specular_faces_to_render.++;
1542 }
1543
1544 #if _DEBUGcxx . . $ `<built-in>:482:9`!
1545 bool Fog_disabledcxx . . $ Fog_disabled. = 0;
1546 #else
1547 #define Fog_disabled 0
1548 #endif
1549
1550 // Adds a specular face to draw after the mine has been drawn
1551 void UpdateFogFacecxx . . $ UpdateFogFace(7ae16100a71bcfc5).(roomcxx . . $ room# *rp, facecxx . . $ face# *fp) {
1552 if (Fog_disabledcxx . . $ Fog_disabled. || !Detail_settingscxx . . $ Detail_settings..Fog_enabledcxx . . $ tDetailSettings#Fog_enabled.)
1553 return;
1554 Fog_facescxx . . $ Fog_faces.[Num_fog_faces_to_rendercxx . . $ Num_fog_faces_to_render.++] = fp - rp->facescxx . . $ room#faces.;
1555 }
1556
1557 // Render a fog layer on top of a face
1558 void RenderFogFacescxx . . $ RenderFogFaces(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
1559 int vn;
1560 float eye_distance;
1561 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1562 g3Pointcxx . . $ g3Point# pointbuffer[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1563 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1564 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.);
1565 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
1566 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
1567 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_VERTEXcxx . . $ `lib/renderer.h:403:9`!);
1568 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
1569 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0);
1570 rend_SetCoplanarPolygonOffsetcxx . . $ rend_SetCoplanarPolygonOffset(9364e6e7bff7660).(1);
1571
1572 rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).((int)(rp->fog_rcxx . . $ room#fog_r. * 255.0), (int)(rp->fog_gcxx . . $ room#fog_g. * 255.0), (int)(rp->fog_bcxx . . $ room#fog_b. * 255.0)));
1573 for (int i = 0; i < Num_fog_faces_to_rendercxx . . $ Num_fog_faces_to_render.; i++) {
1574 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[Fog_facescxx . . $ Fog_faces.[i]];
1575 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1576 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1577 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1578 pointlist[vn] = p;
1579
1580 float mag = 0;
1581
1582 if (Room_fog_plane_checkcxx . . $ Room_fog_plane_check. == 0) {
1583 // Outside of the room
1584 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vn]];
1585 // Now we must generate the split point. This is simply
1586 // an equation in the form Origin + t*Direction
1587
1588 float dist = (*vec *cxx . . $ `operator*`(4a721543d64e126a). Room_fog_planecxx . . $ Room_fog_plane.) + Room_fog_distancecxx . . $ Room_fog_distance.;
1589
1590 vectorcxx . . $ vector# subvec = *vec -cxx . . $ operator-(b77b703cd1e43e33). Viewer_eyecxx . . $ Viewer_eye.;
1591 float t = Room_fog_eye_distancecxx . . $ Room_fog_eye_distance. / (Room_fog_eye_distancecxx . . $ Room_fog_eye_distance. - dist);
1592 vectorcxx . . $ vector# portal_point = Viewer_eyecxx . . $ Viewer_eye. +cxx . . $ operator+(b77b703cd1e43e33). (t *cxx . . $ `operator*`(9d6577ff3e9faa29). subvec);
1593
1594 eye_distance = -(vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&Viewer_orientcxx . . $ Viewer_orient..fveccxx . . $ matrix#fvec., &portal_point));
1595 mag = vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&Viewer_orientcxx . . $ Viewer_orient..fveccxx . . $ matrix#fvec., vec) + eye_distance;
1596 } else if (Room_fog_plane_checkcxx . . $ Room_fog_plane_check. == 1) {
1597 // In the room, distance from
1598 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[vn]];
1599 mag = vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&Room_fog_planecxx . . $ Room_fog_plane., vec) + Room_fog_distancecxx . . $ Room_fog_distance.;
1600 }
1601 float scalar = mag / rp->fog_depthcxx . . $ room#fog_depth.;
1602 if (scalar > 1)
1603 scalar = 1;
1604 if (scalar < 0)
1605 scalar = 0;
1606 p->p3_acxx . . $ `lib/3d.h:256:9`! = scalar * Room_light_valcxx . . $ Room_light_val.;
1607
1608 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`!;
1609 }
1610 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1611 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1);
1612 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, 0);
1613 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1614 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0);
1615 }
1616
1617 rend_SetCoplanarPolygonOffsetcxx . . $ rend_SetCoplanarPolygonOffset(9364e6e7bff7660).(0);
1618 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
1619 }
1620 // MATT! Change this function to sort by state once you change the scorch system!
1621 void RenderScorchesForRoomcxx . . $ RenderScorchesForRoom(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
1622 int i;
1623 if (!Detail_settingscxx . . $ Detail_settings..Scorches_enabledcxx . . $ tDetailSettings#Scorches_enabled.)
1624 return;
1625 // Set alpha, transparency, & lighting for this face
1626 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!);
1627 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
1628 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
1629 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
1630 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1631 rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(-.5);
1632 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0);
1633
1634 // Select texture type
1635 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.);
1636
1637 for (i = 0; i < Num_scorches_to_rendercxx . . $ Num_scorches_to_render.; i++) {
1638 DrawScorchescxx . . $ DrawScorches(3e454b8ccf442868).(ROOMNUMcxx . . $ `Descent3/room.h:411:9`!(rp), Scorches_to_rendercxx . . $ Scorches_to_render.[i]);
1639 }
1640 // Reset rendering states
1641 rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(0);
1642 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
1643 }
1644 // Draw the specified face
1645 // Parameters: rp - pointer to the room the face is un
1646 // facenum - which face in the specified room
1647 void RenderLightmapFacecxx . . $ RenderLightmapFace(5c94b6ab436d91cf).(roomcxx . . $ room# *rp, int facenum) {
1648 int vn, drawn = 0;
1649 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[facenum];
1650 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1651 g3Pointcxx . . $ g3Point# pointbuffer[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1652 uint8_tcxx . . $ uint8_t# face_code = 255;
1653 if (NoLightmapscxx . . $ NoLightmaps.)
1654 return;
1655 if (fp->lmi_handlecxx . . $ face#lmi_handle. == BAD_LMI_INDEXcxx . . $ `Descent3/lightmap_info.h:46:9`!)
1656 return;
1657 if (!(fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!))
1658 return;
1659 // check for render windows hack
1660 if (No_render_windows_hackcxx . . $ No_render_windows_hack. == 1) {
1661 if (fp->portal_numcxx . . $ face#portal_num. != -1)
1662 return;
1663 }
1664 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SATURATEcxx . . $ `Descent3/gametexture.h:222:9`!)
1665 return;
1666 #ifdef EDITOR
1667 if (In_editor_mode && !Lighting_on)
1668 return;
1669 #endif
1670 int lm_handle = LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.;
1671 // Setup saturation if needed
1672 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SATURATE_LIGHTMAPcxx . . $ `Descent3/gametexture.h:228:9`!)
1673 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLEND_SATURATEcxx . . $ `lib/renderer.h:417:9`!);
1674 // Our lightmaps aren't square, but our destination texture surfaces are
1675 // Use these scalars to get them into the correct coordinates
1676 float xscalar = (float)GameLightmapscxx . . $ GameLightmaps.[lm_handle].widthcxx . . $ bms_lightmap#width. / (float)GameLightmapscxx . . $ GameLightmaps.[lm_handle].square_rescxx . . $ bms_lightmap#square_res.;
1677 float yscalar = (float)GameLightmapscxx . . $ GameLightmaps.[lm_handle].heightcxx . . $ bms_lightmap#height. / (float)GameLightmapscxx . . $ GameLightmaps.[lm_handle].square_rescxx . . $ bms_lightmap#square_res.;
1678 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room.) {
1679 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1680 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1681 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1682 pointlist[vn] = p;
1683 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2. * xscalar;
1684 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2. * yscalar;
1685
1686 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! + PF_Lcxx . . $ `lib/3d.h:218:9`! + PF_RGBAcxx . . $ `lib/3d.h:219:9`!; // has uv and l set
1687 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = 1.0;
1688
1689 face_code &= p->p3_codescxx . . $ g3Point#p3_codes.;
1690 }
1691 } else {
1692 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1693 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1694 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1695 pointlist[(fp->num_vertscxx . . $ face#num_verts. - 1) - vn] = p;
1696 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2. * xscalar;
1697 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2. * yscalar;
1698
1699 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! + PF_Lcxx . . $ `lib/3d.h:218:9`! + PF_RGBAcxx . . $ `lib/3d.h:219:9`!; // has uv and l set
1700 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = 1.0;
1701
1702 face_code &= p->p3_codescxx . . $ g3Point#p3_codes.;
1703 }
1704 }
1705
1706 if (face_code) // This entire face is off the scren
1707 return;
1708 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].alphacxx . . $ texture#alpha. * 255);
1709 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1710 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1);
1711 // Draw the damn thing
1712 drawn = g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, lm_handle, MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!);
1713 if (fp->flagscxx . . $ face#flags. & FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!)
1714 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0);
1715 // Restore if using saturated blending
1716 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SATURATE_LIGHTMAPcxx . . $ `Descent3/gametexture.h:228:9`!)
1717 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!);
1718 }
1719 // Draw the specified face
1720 // Parameters: rp - pointer to the room the face is un
1721 // facenum - which face in the specified room
1722 void RenderFacecxx . . $ RenderFace(5c94b6ab436d91cf).(roomcxx . . $ room# *rp, int facenum) {
1723 int vn, drawn = 0;
1724 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[facenum];
1725 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1726 g3Pointcxx . . $ g3Point# pointbuffer[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
1727 int bm_handle;
1728 float uchange = 0, vchange = 0;
1729 texture_typecxx . . $ texture_type# tt;
1730 uint8_tcxx . . $ uint8_t# do_triangle_test = 0;
1731 g3Codescxx . . $ g3Codes# face_cc;
1732 static int first = 1;
1733 static float lm_red[32], lm_green[32], lm_blue[32];
1734 bool spec_face = 0;
1735 face_cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
1736 face_cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
1737 #ifdef EDITOR
1738 if (fp->flags & FF_FLOATING_TRIG) {
1739 RenderFloatingTrig(rp, fp);
1740 return;
1741 }
1742 #endif
1743 // Clear triangulation flag
1744 fp->flagscxx . . $ face#flags. &= ~FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!;
1745 // check for render windows hack
1746 if (No_render_windows_hackcxx . . $ No_render_windows_hack. == 1) {
1747 if (fp->portal_numcxx . . $ face#portal_num. != -1)
1748 return;
1749 }
1750 if (rp->flagscxx . . $ room#flags. & RF_TRIANGULATEcxx . . $ `Descent3/room_external.h:192:9`!)
1751 do_triangle_test = 1;
1752 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && Detail_settingscxx . . $ Detail_settings..Specular_lightingcxx . . $ tDetailSettings#Specular_lighting. && (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SPECULARcxx . . $ `Descent3/gametexture.h:236:9`!) &&
1753 ((fp->special_handlecxx . . $ face#special_handle. != BAD_SPECIAL_FACE_INDEXcxx . . $ `Descent3/special_face.h:26:9`!) || (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!)))
1754 spec_face = 1;
1755 // Figure out if there is any texture sliding
1756 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_ucxx . . $ texture#slide_u. != 0) {
1757 int int_time = Gametimecxx . . $ Gametime. / GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_ucxx . . $ texture#slide_u.;
1758 float norm_time = Gametimecxx . . $ Gametime. - (int_time * GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_ucxx . . $ texture#slide_u.);
1759 norm_time /= GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_ucxx . . $ texture#slide_u.;
1760 uchange = norm_time;
1761 }
1762 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_vcxx . . $ texture#slide_v. != 0) {
1763 int int_time = Gametimecxx . . $ Gametime. / GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_vcxx . . $ texture#slide_v.;
1764 float norm_time = Gametimecxx . . $ Gametime. - (int_time * GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_vcxx . . $ texture#slide_v.);
1765 norm_time /= GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].slide_vcxx . . $ texture#slide_v.;
1766 vchange = norm_time;
1767 }
1768 // Build list of points and UVLs for this face
1769 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room.) // If mirror room, order the vertices counter clockwise
1770 {
1771 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1772 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1773 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1774 pointlist[(fp->num_vertscxx . . $ face#num_verts. - 1) - vn] = p;
1775 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].ucxx . . $ roomUVL#u.;
1776 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].vcxx . . $ roomUVL#v.;
1777 p->p3_uvlcxx . . $ g3Point#p3_uvl..u2cxx . . $ g3UVL#u2. = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2.;
1778 p->p3_uvlcxx . . $ g3Point#p3_uvl..v2cxx . . $ g3UVL#v2. = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2.;
1779
1780 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! + PF_Lcxx . . $ `lib/3d.h:218:9`! + PF_UV2cxx . . $ `lib/3d.h:220:9`!; // has uv and l set
1781 #ifndef RELEASE
1782 if ((fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!) && UseHardwarecxx . . $ UseHardware.)
1783 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = Room_light_valcxx . . $ Room_light_val.;
1784 else
1785 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = 1.0;
1786 #else
1787 p->p3_uvl.l = Room_light_val;
1788 #endif
1789
1790 // do texture sliding
1791 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. += uchange;
1792 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. += vchange;
1793 face_cc.cc_andcxx . . $ g3Codes#cc_and. &= p->p3_codescxx . . $ g3Point#p3_codes.;
1794 face_cc.cc_orcxx . . $ g3Codes#cc_or. |= p->p3_codescxx . . $ g3Point#p3_codes.;
1795 }
1796 } else {
1797
1798 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
1799 pointbuffer[vn] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]];
1800 g3Pointcxx . . $ g3Point# *p = &pointbuffer[vn];
1801 pointlist[vn] = p;
1802 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = fp->face_uvlscxx . . $ face#face_uvls.[vn].ucxx . . $ roomUVL#u.;
1803 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = fp->face_uvlscxx . . $ face#face_uvls.[vn].vcxx . . $ roomUVL#v.;
1804 p->p3_uvlcxx . . $ g3Point#p3_uvl..u2cxx . . $ g3UVL#u2. = fp->face_uvlscxx . . $ face#face_uvls.[vn].u2cxx . . $ roomUVL#u2.;
1805 p->p3_uvlcxx . . $ g3Point#p3_uvl..v2cxx . . $ g3UVL#v2. = fp->face_uvlscxx . . $ face#face_uvls.[vn].v2cxx . . $ roomUVL#v2.;
1806
1807 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! + PF_Lcxx . . $ `lib/3d.h:218:9`! + PF_UV2cxx . . $ `lib/3d.h:220:9`!; // has uv and l set
1808 #ifndef RELEASE
1809 if ((fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!) && UseHardwarecxx . . $ UseHardware.)
1810 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = Room_light_valcxx . . $ Room_light_val.;
1811 else
1812 p->p3_uvlcxx . . $ g3Point#p3_uvl..lcxx . . $ g3UVL#$anonymous_type_0#l. = 1.0;
1813 #else
1814 p->p3_uvl.l = Room_light_val;
1815 #endif
1816
1817 // do texture sliding
1818 p->p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. += uchange;
1819 p->p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. += vchange;
1820 face_cc.cc_andcxx . . $ g3Codes#cc_and. &= p->p3_codescxx . . $ g3Point#p3_codes.;
1821 face_cc.cc_orcxx . . $ g3Codes#cc_or. |= p->p3_codescxx . . $ g3Point#p3_codes.;
1822 }
1823 }
1824 if (face_cc.cc_andcxx . . $ g3Codes#cc_and.) // This entire face is off the screen
1825 {
1826 if (spec_face && GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) {
1827 fp->flagscxx . . $ face#flags. |= FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!;
1828 UpdateSpecularFacecxx . . $ UpdateSpecularFace(7ae16100a71bcfc5).(rp, fp);
1829 }
1830 return;
1831 }
1832 // Do stupid gouraud shading for lightmap
1833 if (NoLightmapscxx . . $ NoLightmaps.) {
1834 if (first) {
1835 first = 0;
1836 for (int i = 0; i < 32; i++) {
1837 lm_red[i] = (float)i / 31.0;
1838 lm_green[i] = (float)i / 31.0;
1839 lm_blue[i] = (float)i / 31.0;
1840 }
1841 }
1842
1843 if (fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!) {
1844 int lm_handle = LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.;
1845 uint16_tcxx . . $ uint16_t# *data = (uint16_tcxx . . $ uint16_t# *)lm_datacxx . . $ lm_data(2fbd6a760478ca0f).(lm_handle);
1846 int w = lm_wcxx . . $ lm_w(7864480464b09eea).(lm_handle);
1847 int h = lm_hcxx . . $ lm_h(7864480464b09eea).(lm_handle);
1848
1849 for (int i = 0; i < fp->num_vertscxx . . $ face#num_verts.; i++) {
1850 float u = fp->face_uvlscxx . . $ face#face_uvls.[i].u2cxx . . $ roomUVL#u2. * (w - 1);
1851 float v = fp->face_uvlscxx . . $ face#face_uvls.[i].v2cxx . . $ roomUVL#v2. * (h - 1);
1852 g3Pointcxx . . $ g3Point# *p = &pointbuffer[i];
1853 int int_u = u;
1854 int int_v = v;
1855 uint16_tcxx . . $ uint16_t# texel = data[int_v * w + int_u];
1856 int r = (texel >> 10) & 0x1f;
1857 int g = (texel >> 5) & 0x1f;
1858 int b = (texel) & 0x1f;
1859 p->p3_rcxx . . $ `lib/3d.h:253:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`! * lm_red[r];
1860 p->p3_gcxx . . $ `lib/3d.h:254:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`! * lm_green[g];
1861 p->p3_bcxx . . $ `lib/3d.h:255:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`! * lm_blue[b];
1862 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`!;
1863 }
1864 } else {
1865 for (int i = 0; i < fp->num_vertscxx . . $ face#num_verts.; i++) {
1866 g3Pointcxx . . $ g3Point# *p = &pointbuffer[i];
1867 p->p3_rcxx . . $ `lib/3d.h:253:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`!;
1868 p->p3_gcxx . . $ `lib/3d.h:254:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`!;
1869 p->p3_bcxx . . $ `lib/3d.h:255:9`! = p->p3_lcxx . . $ `lib/3d.h:252:9`!;
1870 p->p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`!;
1871 }
1872 }
1873 }
1874 // Get bitmap handle
1875 if ((fp->flagscxx . . $ face#flags. & FF_DESTROYEDcxx . . $ `Descent3/room_external.h:119:9`!) && (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_DESTROYABLEcxx . . $ `Descent3/gametexture.h:208:9`!)) {
1876 bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].destroy_handlecxx . . $ texture#destroy_handle., 0);
1877 ASSERTcxx . . $ `misc/pserror.h:246:9`!(bm_handle != -1);
1878 } else
1879 bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(fp->tmapcxx . . $ face#tmap., 0);
1880 // If searching,
1881 #ifdef EDITOR
1882 ddgr_color oldcolor;
1883 if (TSearch_on) {
1884 rend_SetPixel(GR_RGB(16, 255, 16), TSearch_x, TSearch_y);
1885 oldcolor = rend_GetPixel(TSearch_x, TSearch_y);
1886 }
1887 #endif
1888 // Set alpha, transparency, & lighting for this face
1889 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(GetFaceAlphacxx . . $ GetFaceAlpha(1ba15edd17ae1010).(fp, bm_handle));
1890
1891 // If this is a mirror face, and mirrors are turned off, then just make opaque
1892 if (!Detail_settingscxx . . $ Detail_settings..Mirrored_surfacescxx . . $ tDetailSettings#Mirrored_surfaces. && rp->mirror_facecxx . . $ room#mirror_face. != -1 && rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap. == fp->tmapcxx . . $ face#tmap.)
1893 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255);
1894 else if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && rp->mirror_facecxx . . $ room#mirror_face. != -1 && fp->tmapcxx . . $ face#tmap. == rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap. &&
1895 rp != &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.])
1896 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); // This prevents mirrors from rendering each other
1897 else
1898 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].alphacxx . . $ texture#alpha. * 255);
1899 if (!UseHardwarecxx . . $ UseHardware.)
1900 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(Lighting_oncxx . . $ Lighting_on. ? LS_GOURAUDcxx . . $ LS_GOURAUD. : LS_NONEcxx . . $ LS_NONE.);
1901 else
1902 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
1903 if (!NoLightmapscxx . . $ NoLightmaps.)
1904 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
1905 else
1906 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.);
1907 // Set lighting map
1908 if ((fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!) && (!StateLimitedcxx . . $ StateLimited. || UseMultitexturecxx . . $ UseMultitexture.)) {
1909 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SATURATEcxx . . $ `Descent3/gametexture.h:222:9`!)
1910 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1911 else
1912 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_BLENDcxx . . $ `lib/renderer.h:334:9`!);
1913 rend_SetOverlayMapcxx . . $ rend_SetOverlayMap(d4f767463ce0a6b3).(LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle.);
1914 } else
1915 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
1916 // Select texture type
1917 if (!UseHardwarecxx . . $ UseHardware.) {
1918 tt = TT_LINEARcxx . . $ TT_LINEAR.; // default to linear
1919 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) // select perspective if close
1920 if (pointlist[vn]->p3_veccxx . . $ g3Point#p3_vec..zcxx . . $ vector#z. < 35) {
1921 tt = TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.;
1922 break;
1923 }
1924 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(tt);
1925 } else
1926 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.);
1927 if (face_cc.cc_orcxx . . $ g3Codes#cc_or.) // Possible triangulate this face cuz its off screen somewhat
1928 {
1929 if (Room_light_valcxx . . $ Room_light_val. < 1.0)
1930 do_triangle_test = 1;
1931 if (Detail_settingscxx . . $ Detail_settings..Fog_enabledcxx . . $ tDetailSettings#Fog_enabled. && (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!))
1932 do_triangle_test = 1;
1933 if (spec_face)
1934 do_triangle_test = 1;
1935 }
1936 if (do_triangle_test) {
1937 fp->flagscxx . . $ face#flags. |= FF_TRIANGULATEDcxx . . $ `Descent3/room_external.h:121:9`!;
1938 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1);
1939 }
1940 // Do special fog stuff for portal faces
1941 if (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`! && !In_editor_modecxx . . $ In_editor_mode.) {
1942 if (fp->portal_numcxx . . $ face#portal_num. != -1 && !(rp->portalscxx . . $ room#portals.[fp->portal_numcxx . . $ face#portal_num.].flagscxx . . $ portal#flags. & PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!)) {
1943 drawn = 1;
1944 goto draw_fog;
1945 }
1946 }
1947 // Draw the damn thing
1948 drawn = g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(fp->num_vertscxx . . $ face#num_verts., pointlist, bm_handle, MAP_TYPE_BITMAPcxx . . $ `lib/renderer.h:362:9`!, &face_cc);
1949 #ifdef EDITOR
1950 if (TSearch_on) {
1951 if (rend_GetPixel(TSearch_x, TSearch_y) != oldcolor) {
1952 TSearch_found_type = TSEARCH_FOUND_MINE;
1953 TSearch_seg = rp - Rooms;
1954 TSearch_face = facenum;
1955 }
1956 }
1957 #endif
1958
1959 // Do light saturation
1960 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && Rendering_main_viewcxx . . $ Rendering_main_view. && drawn && fp->portal_numcxx . . $ face#portal_num. == -1 &&
1961 ((fp->flagscxx . . $ face#flags. & FF_CORONAcxx . . $ `Descent3/room_external.h:114:9`!) || FastCoronascxx . . $ FastCoronas.) && (fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!) && UseHardwarecxx . . $ UseHardware. &&
1962 (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_LIGHTcxx . . $ `Descent3/gametexture.h:220:9`!)) {
1963 if (Num_glows_this_framecxx . . $ Num_glows_this_frame. < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! && Detail_settingscxx . . $ Detail_settings..Coronas_enabledcxx . . $ tDetailSettings#Coronas_enabled.) {
1964 LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[Num_glows_this_framecxx . . $ Num_glows_this_frame.].roomnumcxx . . $ light_glow#roomnum. = rp - Roomscxx . . $ Rooms.;
1965 LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[Num_glows_this_framecxx . . $ Num_glows_this_frame.].facenumcxx . . $ light_glow#facenum. = facenum;
1966 Num_glows_this_framecxx . . $ Num_glows_this_frame.++;
1967 }
1968 }
1969 // Draw a specular face
1970 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && spec_face) {
1971 if (drawn)
1972 UpdateSpecularFacecxx . . $ UpdateSpecularFace(7ae16100a71bcfc5).(rp, fp);
1973 else {
1974 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) {
1975 fp->flagscxx . . $ face#flags. |= FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!;
1976 UpdateSpecularFacecxx . . $ UpdateSpecularFace(7ae16100a71bcfc5).(rp, fp);
1977 }
1978 }
1979 }
1980
1981 // Draw scorches, if any
1982 if (drawn && fp->flagscxx . . $ face#flags. & FF_SCORCHEDcxx . . $ `Descent3/room_external.h:127:9`! && !Render_mirror_for_roomcxx . . $ Render_mirror_for_room.) {
1983 if (!StateLimitedcxx . . $ StateLimited.)
1984 DrawScorchescxx . . $ DrawScorches(3e454b8ccf442868).(ROOMNUMcxx . . $ `Descent3/room.h:411:9`!(rp), facenum);
1985 else {
1986 Scorches_to_rendercxx . . $ Scorches_to_render.[Num_scorches_to_rendercxx . . $ Num_scorches_to_render.] = facenum;
1987 Num_scorches_to_rendercxx . . $ Num_scorches_to_render.++;
1988 }
1989 }
1990
1991 draw_fog:
1992 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && !In_editor_modecxx . . $ In_editor_mode. && drawn && (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!) && UseHardwarecxx . . $ UseHardware.) {
1993 UpdateFogFacecxx . . $ UpdateFogFace(7ae16100a71bcfc5).(rp, fp);
1994 }
1995
1996 if (do_triangle_test)
1997 g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0);
1998 // Mark it as rendered
1999 if (drawn)
2000 fp->renderframecxx . . $ face#renderframe. = FrameCountcxx . . $ FrameCount. % 256;
2001 // if (Render_mirror_for_room && (GameTextures[fp->tmap].flags & TF_ALPHA))
2002 // rend_SetZBufferWriteMask (1);
2003 #ifdef EDITOR
2004 if (OUTLINE_ON(OM_MINE)) // Outline the face
2005 {
2006 rend_SetTextureType(TT_FLAT);
2007 rend_SetAlphaType(AT_ALWAYS);
2008 rend_SetFlatColor(GR_RGB(255, 255, 255));
2009
2010 if (UseHardware) {
2011 rend_SetZBias(-.1f);
2012 for (int i = 0; i < fp->num_verts; i++) {
2013 g3_DrawSpecialLine(pointlist[i], pointlist[(i + 1) % fp->num_verts]);
2014 }
2015 rend_SetZBias(0);
2016 } else {
2017 for (int i = 0; i < fp->num_verts; i++) {
2018 g3_DrawLine(GR_RGB(255, 255, 255), pointlist[i], pointlist[(i + 1) % fp->num_verts]);
2019 }
2020 }
2021 if ((fp->flags & FF_HAS_TRIGGER) && (fp->num_verts > 3)) {
2022 g3_DrawLine(CUREDGE_COLOR, pointlist[0], pointlist[2]);
2023 g3_DrawLine(CUREDGE_COLOR, pointlist[1], pointlist[3]);
2024 }
2025 if (fp->special_handle != BAD_SPECIAL_FACE_INDEX) {
2026 g3Point p1, p2;
2027 vector verts[MAX_VERTS_PER_FACE];
2028 vector center, end;
2029 for (int t = 0; t < fp->num_verts; t++)
2030 verts[t] = rp->verts[fp->face_verts[t]];
2031 vm_GetCentroid(&center, verts, fp->num_verts);
2032 vector subvec = SpecialFaces[fp->special_handle].spec_instance[0].bright_center - center;
2033 vm_NormalizeVectorFast(&subvec);
2034 end = center + subvec;
2035 g3_RotatePoint(&p1, &center);
2036 g3_RotatePoint(&p2, &end);
2037 g3_DrawLine(GR_RGB(255, 255, 255), &p1, &p2);
2038 /*for (t=0;t<fp->num_verts;t++)
2039 {
2040 end=rp->verts[fp->face_verts[t]]+SpecialFaces[fp->special_handle].vertnorms[t];
2041 g3_RotatePoint (&p1,&rp->verts[fp->face_verts[t]]);
2042 g3_RotatePoint (&p2,&end);
2043 g3_DrawLine(GR_RGB(255,255,255),&p1,&p2);
2044 }*/
2045 }
2046 }
2047 if (Outline_lightmaps) {
2048 rend_SetTextureType(TT_FLAT);
2049 rend_SetAlphaType(AT_ALWAYS);
2050 if (fp == &Curroomp->faces[Curface] && (fp->flags & FF_LIGHTMAP)) {
2051 ASSERT(fp->lmi_handle != BAD_LMI_INDEX);
2052
2053 lightmap_info *lmi = &LightmapInfo[fp->lmi_handle];
2054 uint16_t *src_data = (uint16_t *)lm_data(lmi->lm_handle);
2055 matrix facematrix;
2056 vector fvec = -lmi->normal;
2057 vm_VectorToMatrix(&facematrix, &fvec, NULL, NULL);
2058 vector rvec = facematrix.rvec * lmi->xspacing;
2059 vector uvec = facematrix.uvec * lmi->yspacing;
2060 vm_TransposeMatrix(&facematrix);
2061 int w = lm_w(lmi->lm_handle);
2062 int h = lm_h(lmi->lm_handle);
2063 for (int i = 0; i < w * h; i++) {
2064 int t;
2065 g3Point epoints[20];
2066 vector evec[20];
2067 int y = i / w;
2068 int x = i % w;
2069 evec[0] = lmi->upper_left - (y * uvec) + (x * rvec);
2070 g3_RotatePoint(&epoints[0], &evec[0]);
2071 pointlist[0] = &epoints[0];
2072 evec[1] = lmi->upper_left - (y * uvec) + ((x + 1) * rvec);
2073 g3_RotatePoint(&epoints[1], &evec[1]);
2074 pointlist[1] = &epoints[1];
2075 evec[2] = lmi->upper_left - ((y + 1) * uvec) + ((x + 1) * rvec);
2076 g3_RotatePoint(&epoints[2], &evec[2]);
2077 pointlist[2] = &epoints[2];
2078 evec[3] = lmi->upper_left - ((y + 1) * uvec) + (x * rvec);
2079 g3_RotatePoint(&epoints[3], &evec[3]);
2080 pointlist[3] = &epoints[3];
2081
2082 if (!(src_data[y * w + x] & OPAQUE_FLAG)) {
2083 for (t = 0; t < 4; t++)
2084 g3_DrawLine(GR_RGB(255, 0, 255), pointlist[t], pointlist[(t + 1) % 4]);
2085 } else {
2086 for (t = 0; t < 4; t++)
2087 g3_DrawLine(GR_RGB(255, 255, 255), pointlist[t], pointlist[(t + 1) % 4]);
2088 }
2089 // Draw interpolated normals
2090 /*if (fp->special_handle!=BAD_SPECIAL_FACE_INDEX && SpecialFaces[fp->special_handle].normal_map!=NULL)
2091 {
2092 vector norm,from,to,temp;
2093 g3Point p1,p2;
2094 vm_MakeZero (&from);
2095 norm.x=Normal_table[SpecialFaces[fp->special_handle].normal_map[i*3+0]];
2096 norm.y=Normal_table[SpecialFaces[fp->special_handle].normal_map[i*3+1]];
2097 norm.z=Normal_table[SpecialFaces[fp->special_handle].normal_map[i*3+2]];
2098 vm_MatrixMulVector (&temp,&norm,&facematrix);
2099 norm=temp;
2100 for (t=0;t<4;t++)
2101 from+=evec[t];
2102 from/=4;
2103 to=from+norm;
2104 g3_RotatePoint (&p1,&from);
2105 g3_RotatePoint (&p2,&to);
2106 g3_DrawLine(GR_RGB(255,255,255),&p1,&p2);
2107 }*/
2108
2109 if (Search_lightmaps) {
2110 for (t = 0; t < 4; t++)
2111 g3_ProjectPoint(&epoints[t]);
2112
2113 if (point_in_poly(4, epoints, TSearch_x, TSearch_y)) {
2114 found_lightmap = i;
2115 TSearch_found_type = TSEARCH_FOUND_MINE;
2116 TSearch_seg = ROOMNUM(rp);
2117 TSearch_face = facenum;
2118 }
2119 }
2120 }
2121 }
2122 }
2123 #endif
2124 }
2125 static float face_depthcxx . . $ face_depth.[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
2126 // compare function for room face sort
2127 static int room_face_sort_funccxx . . $ room_face_sort_func(cc1caa6a32f99af5).(const int16_t *a, const int16_t *b) {
2128 float az, bz;
2129 az = face_depthcxx . . $ face_depth.[*a];
2130 bz = face_depthcxx . . $ face_depth.[*b];
2131 if (az < bz)
2132 return -1;
2133 else if (az > bz)
2134 return 1;
2135 else
2136 return 0;
2137 }
2138 // Sorts the faces of a room before rendering. Used for rendering in the editor.
2139 // Parameters: rp - pointer to the room to be rendered
2140 void RenderRoomSortedcxx . . $ RenderRoomSorted(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2141 int vn, fn, i, rcount;
2142 int render_order[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
2143 ASSERTcxx . . $ `misc/pserror.h:246:9`!(rp->num_faces <= MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!);
2144 // Rotate all the points
2145 if (rp->wpb_indexcxx . . $ room#wpb_index. == -1) {
2146 rp->wpb_indexcxx . . $ room#wpb_index. = Global_buffer_indexcxx . . $ Global_buffer_index.;
2147 // Katmai enhanced rotate only in a release build, because not
2148 // everyone has the intel compiler!
2149 #if (defined(RELEASE) && defined(KATMAI))
2150 if (Katmai)
2151 RotateRoomPoints(rp, rp->verts4);
2152 else
2153 #endif
2154 RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(rp, rp->vertscxx . . $ room#verts.);
2155
2156 Global_buffer_indexcxx . . $ Global_buffer_index. += rp->num_vertscxx . . $ room#num_verts.;
2157 }
2158 // Build list of visible (non-backfacing) faces, & compute average face depths
2159 for (fn = rcount = 0; fn < rp->num_facescxx . . $ room#num_faces.; fn++) {
2160 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[fn];
2161
2162 if ((!(fp->flagscxx . . $ face#flags. & FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!)) || ((fp->flagscxx . . $ face#flags. & FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!))) {
2163 fp->flagscxx . . $ face#flags. &= ~(FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`! | FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!);
2164 continue; // this guy shouldn't be rendered
2165 }
2166 // Clear visibility flags
2167 fp->flagscxx . . $ face#flags. &= ~(FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`! | FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!);
2168
2169 if (!FaceIsRenderablecxx . . $ FaceIsRenderable(64b515d199dd040c).(rp, fp))
2170 continue; // skip this face
2171 #ifdef EDITOR
2172 if (In_editor_mode) {
2173 if ((Shell_render_flag & SRF_NO_NON_SHELL) && (fp->flags & FF_NOT_SHELL))
2174 continue;
2175 if ((Shell_render_flag & SRF_NO_SHELL) && !(fp->flags & FF_NOT_SHELL))
2176 continue;
2177 }
2178 #endif
2179 face_depthcxx . . $ face_depth.[fn] = 0;
2180 for (vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++)
2181 face_depthcxx . . $ face_depth.[fn] += World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]].p3_zcxx . . $ `lib/3d.h:247:9`!;
2182 face_depthcxx . . $ face_depth.[fn] /= fp->num_vertscxx . . $ face#num_verts.;
2183 // initialize order list
2184 render_order[rcount] = fn;
2185 rcount++;
2186 }
2187 // Sort the faces
2188 qsortcxx . . $ qsort(ebb60b13a65e77d7).(render_order, rcount, sizeof(*render_order), (int (*)(const void *, const void *))room_face_sort_funccxx . . $ room_face_sort_func(cc1caa6a32f99af5).);
2189 // Render the faces
2190 for (i = rcount - 1; i >= 0; i--)
2191 RenderFacecxx . . $ RenderFace(5c94b6ab436d91cf).(rp, render_order[i]);
2192 }
2193
2194 // Sets up fog if this room is fogged
2195 void SetupRoomFogcxx . . $ SetupRoomFog(2babcc7ca594dc16).(roomcxx . . $ room# *rp, vectorcxx . . $ vector# *eye, matrixcxx . . $ matrix# *orient, int viewer_room) {
2196 if ((rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!) == 0)
2197 return;
2198
2199 if (!Detail_settingscxx . . $ Detail_settings..Fog_enabledcxx . . $ tDetailSettings#Fog_enabled.) {
2200 // fog is disabled
2201 Room_fog_plane_checkcxx . . $ Room_fog_plane_check. = -1;
2202 return;
2203 }
2204
2205 if (viewer_room == (rp - Roomscxx . . $ Rooms.)) {
2206 // viewer is in the room
2207 vectorcxx . . $ vector# *vec = eye;
2208 Room_fog_plane_checkcxx . . $ Room_fog_plane_check. = 1;
2209 Room_fog_distancecxx . . $ Room_fog_distance. = -vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&orient->fveccxx . . $ matrix#fvec., vec);
2210 Room_fog_planecxx . . $ Room_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). orient->fveccxx . . $ matrix#fvec.;
2211 return;
2212 }
2213
2214 // find the 'fogroom' number (we should have put it in here if we will render the room)
2215 int found_room = -1;
2216 for (int i = 0; i < Num_fogged_rooms_this_framecxx . . $ Num_fogged_rooms_this_frame. && found_room == -1; i++) {
2217 if (Fog_portal_datacxx . . $ Fog_portal_data.[i].roomnumcxx . . $ fog_portal_data#roomnum. == rp - Roomscxx . . $ Rooms.) {
2218 found_room = i;
2219 break;
2220 }
2221 }
2222
2223 if (found_room == -1 || Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_facecxx . . $ fog_portal_data#close_face. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
2224 // we won't be rendering this room
2225 Room_fog_plane_checkcxx . . $ Room_fog_plane_check. = -1;
2226 return;
2227 }
2228
2229 // Use the closest face
2230 facecxx . . $ face# *close_face = Fog_portal_datacxx . . $ Fog_portal_data.[found_room].close_facecxx . . $ fog_portal_data#close_face.;
2231 Room_fog_plane_checkcxx . . $ Room_fog_plane_check. = 0;
2232 Room_fog_planecxx . . $ Room_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). close_face->normalcxx . . $ face#normal.;
2233 Room_fog_portal_vertcxx . . $ Room_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). rp->vertscxx . . $ room#verts.[close_face->face_vertscxx . . $ face#face_verts.[0]];
2234 Room_fog_distancecxx . . $ Room_fog_distance. = -vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&Room_fog_planecxx . . $ Room_fog_plane., &Room_fog_portal_vertcxx . . $ Room_fog_portal_vert.);
2235 Room_fog_eye_distancecxx . . $ Room_fog_eye_distance. = (*eye *cxx . . $ `operator*`(4a721543d64e126a). Room_fog_planecxx . . $ Room_fog_plane.) + Room_fog_distancecxx . . $ Room_fog_distance.;
2236 }
2237
2238 // Renders the faces in a room without worrying about sorting. Used in the game when Z-buffering is active
2239 void RenderRoomUnsortedcxx . . $ RenderRoomUnsorted(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2240 int fn;
2241 int rcount = 0;
2242 ASSERTcxx . . $ `misc/pserror.h:246:9`!(rp->num_faces <= MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!);
2243
2244 // Rotate points in this room if need be
2245 if (rp->wpb_indexcxx . . $ room#wpb_index. == -1) {
2246 rp->wpb_indexcxx . . $ room#wpb_index. = Global_buffer_indexcxx . . $ Global_buffer_index.;
2247
2248 // Katmai enhanced rotate only in a release build, because not
2249 // everyone has the intel compiler!
2250 #if (defined(RELEASE) && defined(KATMAI))
2251 if (Katmai) {
2252 RotateRoomPoints(rp, rp->verts4);
2253 } else
2254 #endif
2255 {
2256 RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(rp, rp->vertscxx . . $ room#verts.);
2257 }
2258
2259 Global_buffer_indexcxx . . $ Global_buffer_index. += rp->num_vertscxx . . $ room#num_verts.;
2260 }
2261
2262 // Sort portal faces if this is a fogged room
2263 if (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!) {
2264 SetupRoomFogcxx . . $ SetupRoomFog(2babcc7ca594dc16).(rp, &Viewer_eyecxx . . $ Viewer_eye., &Viewer_orientcxx . . $ Viewer_orient., Viewer_roomnumcxx . . $ Viewer_roomnum.);
2265 }
2266
2267 // Check for visible (non-backfacing) faces, & render
2268 for (fn = 0; fn < rp->num_facescxx . . $ room#num_faces.; fn++) {
2269 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[fn];
2270 int fogged_portal = 0;
2271
2272 if (!(fp->flagscxx . . $ face#flags. & FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!) || (fp->flagscxx . . $ face#flags. & FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!)) {
2273 if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SMOOTH_SPECULARcxx . . $ `Descent3/gametexture.h:232:9`!) {
2274 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && Detail_settingscxx . . $ Detail_settings..Specular_lightingcxx . . $ tDetailSettings#Specular_lighting. &&
2275 (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_SPECULARcxx . . $ `Descent3/gametexture.h:236:9`!) &&
2276 ((fp->special_handlecxx . . $ face#special_handle. != BAD_SPECIAL_FACE_INDEXcxx . . $ `Descent3/special_face.h:26:9`!) || (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!))) {
2277 fp->flagscxx . . $ face#flags. |= FF_SPEC_INVISIBLEcxx . . $ `Descent3/room_external.h:117:9`!;
2278 UpdateSpecularFacecxx . . $ UpdateSpecularFace(7ae16100a71bcfc5).(rp, fp);
2279 }
2280 }
2281 fp->flagscxx . . $ face#flags. &= ~(FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`! | FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!);
2282 continue; // this guy shouldn't be rendered
2283 }
2284
2285 // Clear visibility flags
2286 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room. == false) {
2287 fp->flagscxx . . $ face#flags. &= ~(FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`! | FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!);
2288 } else {
2289 if (rp == &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.]) {
2290 if (rp->facescxx . . $ room#faces.[fn].tmapcxx . . $ face#tmap. == rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap.)
2291 continue; // Don't render the mirror face if rendering the mirror
2292 }
2293 }
2294
2295 if (!FaceIsRenderablecxx . . $ FaceIsRenderable(64b515d199dd040c).(rp, fp))
2296 continue; // skip this face
2297
2298 #ifdef EDITOR
2299 if (In_editor_mode) {
2300 if ((Shell_render_flag & SRF_NO_NON_SHELL) && (fp->flags & FF_NOT_SHELL))
2301 continue;
2302 if ((Shell_render_flag & SRF_NO_SHELL) && !(fp->flags & FF_NOT_SHELL))
2303 continue;
2304 }
2305 #endif
2306
2307 if (fp->portal_numcxx . . $ face#portal_num. != -1 && !(rp->portalscxx . . $ room#portals.[fp->portal_numcxx . . $ face#portal_num.].flagscxx . . $ portal#flags. & PF_RENDER_FACEScxx . . $ `Descent3/room_external.h:155:9`!) && (rp->flagscxx . . $ room#flags. & RF_FOGcxx . . $ `Descent3/room_external.h:184:9`!)) {
2308 fogged_portal = 1;
2309 }
2310
2311 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room. == false && (fogged_portal || (GetFaceAlphacxx . . $ GetFaceAlpha(1ba15edd17ae1010).(fp, -1) & (ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`! + ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!)))) {
2312 // Place alpha faces into our postrender list
2313 if (Num_postrenderscxx . . $ Num_postrenders. < MAX_POSTRENDERScxx . . $ `Descent3/postrender.h:22:9`!) {
2314 face_depthcxx . . $ face_depth.[fn] = 0.0f;
2315 for (int vn = 0; vn < fp->num_vertscxx . . $ face#num_verts.; vn++) {
2316 face_depthcxx . . $ face_depth.[fn] += World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + fp->face_vertscxx . . $ face#face_verts.[vn]].p3_zcxx . . $ `lib/3d.h:247:9`!;
2317 }
2318 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].typecxx . . $ postrender_struct#type. = PRT_WALLcxx . . $ `Descent3/postrender.h:26:9`!;
2319 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].roomnumcxx . . $ postrender_struct#roomnum. = rp - Roomscxx . . $ Rooms.;
2320 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].facenumcxx . . $ postrender_struct#$anonymous_type_0#facenum. = fn;
2321 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.++].zcxx . . $ postrender_struct#z. = face_depthcxx . . $ face_depth.[fn] /= fp->num_vertscxx . . $ face#num_verts.;
2322 ;
2323 }
2324 } else {
2325 if (!StateLimitedcxx . . $ StateLimited.) {
2326 RenderFacecxx . . $ RenderFace(5c94b6ab436d91cf).(rp, fn);
2327 } else {
2328 // setup order list
2329 State_elementscxx . . $ State_elements.[rcount].facenumcxx . . $ state_limited_element#facenum. = fn;
2330 if (fp->flagscxx . . $ face#flags. & FF_LIGHTMAPcxx . . $ `Descent3/room_external.h:112:9`!)
2331 State_elementscxx . . $ State_elements.[rcount].sort_keycxx . . $ state_limited_element#sort_key. = (LightmapInfocxx . . $ LightmapInfo.[fp->lmi_handlecxx . . $ face#lmi_handle.].lm_handlecxx . . $ lightmap_info#lm_handle. * MAX_TEXTUREScxx . . $ `Descent3/gametexture.h:244:9`!) + fp->tmapcxx . . $ face#tmap.;
2332 else
2333 State_elementscxx . . $ State_elements.[rcount].sort_keycxx . . $ state_limited_element#sort_key. = fp->tmapcxx . . $ face#tmap.;
2334 rcount++;
2335 }
2336 }
2337 }
2338
2339 if (StateLimitedcxx . . $ StateLimited.) {
2340 // Sort the faces
2341 SortStatescxx . . $ SortStates(b1f17b8c50be1530).(State_elementscxx . . $ State_elements., rcount);
2342
2343 // Render the faces
2344 int i;
2345 for (i = rcount - 1; i >= 0; i--) {
2346 RenderFacecxx . . $ RenderFace(5c94b6ab436d91cf).(rp, State_elementscxx . . $ State_elements.[i].facenumcxx . . $ state_limited_element#facenum.);
2347 }
2348
2349 if (!UseMultitexturecxx . . $ UseMultitexture.) {
2350 // Since we're state limited, we have to render lightmap faces completely separate
2351 // Now render lightmap faces
2352 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!);
2353 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
2354 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
2355 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
2356 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.);
2357 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.);
2358 rend_SetMipStatecxx . . $ rend_SetMipState(4af4fd0e2b26c4ac).(0);
2359 for (i = rcount - 1; i >= 0; i--) {
2360 RenderLightmapFacecxx . . $ RenderLightmapFace(5c94b6ab436d91cf).(rp, State_elementscxx . . $ State_elements.[i].facenumcxx . . $ state_limited_element#facenum.);
2361 }
2362 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.);
2363 rend_SetMipStatecxx . . $ rend_SetMipState(4af4fd0e2b26c4ac).(1);
2364 }
2365 }
2366 }
2367
2368 // Figures out a scalar value to apply to all vertices in the room
2369 void ComputeRoomPulseLightcxx . . $ ComputeRoomPulseLight(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2370 if (rp->pulse_timecxx . . $ room#pulse_time. == 0 || In_editor_modecxx . . $ In_editor_mode.)
2371 Room_light_valcxx . . $ Room_light_val. = 1.0;
2372 else {
2373 float ptime = rp->pulse_timecxx . . $ room#pulse_time. * WALL_PULSE_INCREMENTcxx . . $ `Descent3/render.cpp:95:9`!;
2374 float add_time = rp->pulse_offsetcxx . . $ room#pulse_offset. * WALL_PULSE_INCREMENTcxx . . $ `Descent3/render.cpp:95:9`!;
2375
2376 int int_time = (int)((Gametimecxx . . $ Gametime. + add_time) / (ptime * 2));
2377 float left_time = (Gametimecxx . . $ Gametime. + add_time) - (int_time * ptime * 2);
2378 float norm_time = left_time / (ptime);
2379 if (norm_time > 1)
2380 Room_light_valcxx . . $ Room_light_val. = 1 - (norm_time - 1.0);
2381 else
2382 Room_light_valcxx . . $ Room_light_val. = norm_time;
2383 }
2384 if (!In_editor_modecxx . . $ In_editor_mode.) {
2385 if (rp->flagscxx . . $ room#flags. & RF_STROBEcxx . . $ `Descent3/room_external.h:193:9`!) {
2386 int val = (Gametimecxx . . $ Gametime. * 10) + (rp - Roomscxx . . $ Rooms.);
2387 if (val % 2)
2388 Room_light_valcxx . . $ Room_light_val. = 0;
2389 }
2390 if (rp->flagscxx . . $ room#flags. & RF_FLICKERcxx . . $ `Descent3/room_external.h:194:9`!) {
2391 ps_srandcxx . . $ ps_srand(cb2f890c2fdad230).((Gametimecxx . . $ Gametime. * 1000) + (rp - Roomscxx . . $ Rooms.));
2392 if (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 2)
2393 Room_light_valcxx . . $ Room_light_val. = 0;
2394 }
2395 }
2396 }
2397
2398
2399 #define CORONA_DIST_CUTOFFcxx . . $ `Descent3/render.cpp:2399:9`! 5.0f
2400 // Draws a glow around a light
2401 void RenderSingleLightGlowcxx . . $ RenderSingleLightGlow(d4f767463ce0a6b3).(int index) {
2402 int bm_handle;
2403 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[LightGlowscxx . . $ LightGlows.[index].roomnumcxx . . $ light_glow#roomnum.];
2404 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[LightGlowscxx . . $ LightGlows.[index].facenumcxx . . $ light_glow#facenum.];
2405 texturecxx . . $ texture# *texp = &GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.];
2406 bm_handle = Fireballscxx . . $ Fireballs.[DEFAULT_CORONA_INDEXcxx . . $ `Descent3/fireball_external.h:57:9`! + texp->corona_typecxx . . $ texture#corona_type.].bm_handlecxx . . $ fireball#bm_handle.;
2407
2408 // Get size of light
2409 float size = LightGlowscxx . . $ LightGlows.[index].sizecxx . . $ light_glow#size.;
2410 vectorcxx . . $ vector# center = LightGlowscxx . . $ LightGlows.[index].centercxx . . $ light_glow#center.;
2411
2412 // Get alpha of light
2413 vectorcxx . . $ vector# tvec = Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[0]];
2414 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&tvec);
2415 float facing_scalar = (tvec *cxx . . $ `operator*`(4a721543d64e126a). fp->normalcxx . . $ face#normal.) * 2;
2416 if (facing_scalar < 0)
2417 return;
2418 tvec =cxx . . $ vector#`operator=`(c0842353a20857d). center -cxx . . $ operator-(b77b703cd1e43e33). Viewer_eyecxx . . $ Viewer_eye.;
2419
2420 float dist = vm_GetMagnitudeFastcxx . . $ vm_GetMagnitudeFast(4939a7e530383cd4).(&tvec);
2421 if (dist < (size * CORONA_DIST_CUTOFFcxx . . $ `Descent3/render.cpp:2399:9`!))
2422 return;
2423 if (dist < (size * (CORONA_DIST_CUTOFFcxx . . $ `Descent3/render.cpp:2399:9`! + 15))) {
2424 float dist_scalar = ((dist - (size * CORONA_DIST_CUTOFFcxx . . $ `Descent3/render.cpp:2399:9`!)) / (size * 15));
2425 facing_scalar *= dist_scalar;
2426 }
2427
2428 facing_scalar *= LightGlowscxx . . $ LightGlows.[index].scalarcxx . . $ light_glow#scalar.;
2429 facing_scalar = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(facing_scalar, 1.0);
2430 // Take into effect pulsing
2431 ComputeRoomPulseLightcxx . . $ ComputeRoomPulseLight(cd8c4e8cd0ee4c38).(rp);
2432 facing_scalar *= Room_light_valcxx . . $ Room_light_val.;
2433 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(facing_scalar * .4 * 255);
2434
2435 float maxc = stdcxx . . $ std/::maxcxx . . $ std/max(7d979dd22a97e265).({texp->rcxx . . $ texture#r., texp->gcxx . . $ texture#g., texp->bcxx . . $ texture#b.});
2436 float r, g, b;
2437 if (maxc > 1.0) {
2438 r = texp->rcxx . . $ texture#r. / maxc;
2439 g = texp->gcxx . . $ texture#g. / maxc;
2440 b = texp->bcxx . . $ texture#b. / maxc;
2441 } else {
2442 r = texp->rcxx . . $ texture#r.;
2443 g = texp->gcxx . . $ texture#g.;
2444 b = texp->bcxx . . $ texture#b.;
2445 }
2446 if (LightGlowscxx . . $ LightGlows.[index].flagscxx . . $ light_glow#flags. & LGF_FASTcxx . . $ `Descent3/render.cpp:181:9`!) {
2447 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0);
2448 rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).((-size / 2));
2449 } else {
2450 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0);
2451 }
2452 ddgr_colorcxx . . $ ddgr_color# color = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(r * 255, g * 255, b * 255);
2453 g3_DrawBitmapcxx . . $ g3_DrawBitmap(8d67c7afa700cf9).(&center, size, (size * bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0)) / bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0), bm_handle, color);
2454 if (LightGlowscxx . . $ LightGlows.[index].flagscxx . . $ light_glow#flags. & LGF_FASTcxx . . $ `Descent3/render.cpp:181:9`!) {
2455 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
2456 rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(0);
2457 } else {
2458 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1);
2459 }
2460 }
2461 // Draws a glow around a light
2462 void RenderSingleLightGlow2cxx . . $ RenderSingleLightGlow2(d4f767463ce0a6b3).(int index) {
2463 static int first = 1;
2464 static int normal_handle, star_handle;
2465 int bm_handle;
2466 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[LightGlowscxx . . $ LightGlows.[index].roomnumcxx . . $ light_glow#roomnum.];
2467 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[LightGlowscxx . . $ LightGlows.[index].facenumcxx . . $ light_glow#facenum.];
2468 texturecxx . . $ texture# *texp = &GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.];
2469
2470 if (first) {
2471 int texhandle = FindTextureNamecxx . . $ FindTextureName(5c4306d8553b3696).("LongCorona");
2472 if (texhandle == -1)
2473 star_handle = 0;
2474 else
2475 star_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(texhandle, 0);
2476 first = 0;
2477 }
2478 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(.4 * 255);
2479 float maxc = stdcxx . . $ std/::maxcxx . . $ std/max(7d979dd22a97e265).({texp->rcxx . . $ texture#r., texp->gcxx . . $ texture#g., texp->bcxx . . $ texture#b.});
2480 float r, g, b;
2481 if (maxc > 1.0) {
2482 r = texp->rcxx . . $ texture#r. / maxc;
2483 g = texp->gcxx . . $ texture#g. / maxc;
2484 b = texp->bcxx . . $ texture#b. / maxc;
2485 } else {
2486 r = texp->rcxx . . $ texture#r.;
2487 g = texp->gcxx . . $ texture#g.;
2488 b = texp->bcxx . . $ texture#b.;
2489 }
2490 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
2491
2492 // Get size of light
2493 float size = LightGlowscxx . . $ LightGlows.[index].sizecxx . . $ light_glow#size.;
2494 vectorcxx . . $ vector# center = LightGlowscxx . . $ LightGlows.[index].centercxx . . $ light_glow#center.;
2495 vectorcxx . . $ vector# corona_pos = center +cxx . . $ operator+(b77b703cd1e43e33). (fp->normalcxx . . $ face#normal. *cxx . . $ `operator*`(252247219a31502c). size);
2496 bm_handle = star_handle;
2497 matrixcxx . . $ matrix# mat, rot_mat;
2498 vectorcxx . . $ vector# fvec, uvec, temp_vec, rvec;
2499 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). -cxx . . $ operator-(9e07539e219c6f20).fp->normalcxx . . $ face#normal.;
2500
2501 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&mat, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &temp_vec, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2502
2503 // Rotate view vector into billboard space
2504 fvec =cxx . . $ vector#`operator=`(c0842353a20857d). Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). corona_pos;
2505 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&fvec);
2506 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). fvec *cxx . . $ `operator*`(14b8f9ac5c1e7b85). mat;
2507 fvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2508 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&fvec);
2509 rvec.xcxx . . $ vector#x. = fvec.zcxx . . $ vector#z.;
2510 rvec.ycxx . . $ vector#y. = 0;
2511 rvec.zcxx . . $ vector#z. = -fvec.xcxx . . $ vector#x.;
2512 uvec.ycxx . . $ vector#y. = 1;
2513 uvec.xcxx . . $ vector#x. = 0;
2514 uvec.zcxx . . $ vector#z. = 0;
2515 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&rot_mat, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &uvec, &rvec);
2516 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&mat);
2517 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). rot_mat.rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). mat;
2518 rot_mat.rveccxx . . $ matrix#rvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2519 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). rot_mat.uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). mat;
2520 rot_mat.uveccxx . . $ matrix#uvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2521 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). rot_mat.fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). mat;
2522 rot_mat.fveccxx . . $ matrix#fvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2523 vectorcxx . . $ vector# world_vecs[4];
2524 g3Pointcxx . . $ g3Point# pnts[4], *pntlist[4];
2525 world_vecs[0] =cxx . . $ vector#`operator=`(c0842353a20857d). corona_pos -cxx . . $ operator-(b77b703cd1e43e33). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.rveccxx . . $ matrix#rvec.);
2526 world_vecs[0] +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.uveccxx . . $ matrix#uvec.);
2527 world_vecs[1] =cxx . . $ vector#`operator=`(c0842353a20857d). corona_pos +cxx . . $ operator+(b77b703cd1e43e33). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.rveccxx . . $ matrix#rvec.);
2528 world_vecs[1] +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.uveccxx . . $ matrix#uvec.);
2529 world_vecs[2] =cxx . . $ vector#`operator=`(c0842353a20857d). corona_pos +cxx . . $ operator+(b77b703cd1e43e33). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.rveccxx . . $ matrix#rvec.);
2530 world_vecs[2] -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.uveccxx . . $ matrix#uvec.);
2531 world_vecs[3] =cxx . . $ vector#`operator=`(c0842353a20857d). corona_pos -cxx . . $ operator-(b77b703cd1e43e33). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.rveccxx . . $ matrix#rvec.);
2532 world_vecs[3] -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (size *cxx . . $ `operator*`(9d6577ff3e9faa29). rot_mat.uveccxx . . $ matrix#uvec.);
2533 for (int i = 0; i < 4; i++) {
2534 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnts[i], &world_vecs[i]);
2535 pnts[i].p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_RGBAcxx . . $ `lib/3d.h:219:9`!;
2536 pnts[i].p3_rcxx . . $ `lib/3d.h:253:9`! = r;
2537 pnts[i].p3_gcxx . . $ `lib/3d.h:254:9`! = g;
2538 pnts[i].p3_bcxx . . $ `lib/3d.h:255:9`! = b;
2539 pntlist[i] = &pnts[i];
2540 }
2541 pnts[0].p3_ucxx . . $ `lib/3d.h:250:9`! = 0;
2542 pnts[0].p3_vcxx . . $ `lib/3d.h:251:9`! = 0;
2543 pnts[1].p3_ucxx . . $ `lib/3d.h:250:9`! = 1;
2544 pnts[1].p3_vcxx . . $ `lib/3d.h:251:9`! = 0;
2545 pnts[2].p3_ucxx . . $ `lib/3d.h:250:9`! = 1;
2546 pnts[2].p3_vcxx . . $ `lib/3d.h:251:9`! = 1;
2547 pnts[3].p3_ucxx . . $ `lib/3d.h:250:9`! = 0;
2548 pnts[3].p3_vcxx . . $ `lib/3d.h:251:9`! = 1;
2549 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, bm_handle);
2550 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
2551 }
2552 // Figures out if we can see the center of a light face and adds it to our globa list
2553 void CheckLightGlowsForRoomcxx . . $ CheckLightGlowsForRoom(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2554 int i;
2555 for (i = 0; i < Num_glows_this_framecxx . . $ Num_glows_this_frame.; i++) {
2556 // For each light, see if we can cast a vector to it
2557 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[i].facenumcxx . . $ light_glow#facenum.];
2558 vectorcxx . . $ vector# verts[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
2559 vectorcxx . . $ vector# center;
2560 for (int t = 0; t < fp->num_vertscxx . . $ face#num_verts.; t++)
2561 verts[t] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[t]];
2562 float size = sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(vm_GetCentroidcxx . . $ vm_GetCentroid(9f2e9a768aacd0cc).(&center, verts, fp->num_vertscxx . . $ face#num_verts.));
2563 size *= 2;
2564 center +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (fp->normalcxx . . $ face#normal. /cxx . . $ `operator/`(252247219a31502c). 4);
2565 if (vm_VectorDistanceQuickcxx . . $ vm_VectorDistanceQuick(a0b9c8659ecc16b8).(&center, &Viewer_eyecxx . . $ Viewer_eye.) < (size * CORONA_DIST_CUTOFFcxx . . $ `Descent3/render.cpp:2399:9`!))
2566 continue;
2567 // Check if we can see this light
2568 fvi_infocxx . . $ fvi_info# hit_info;
2569 fvi_querycxx . . $ fvi_query# fq;
2570 // shoot a ray from the light position to the current vertex
2571 if (FastCoronascxx . . $ FastCoronas.) {
2572 if (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) {
2573 SetGlowStatuscxx . . $ SetGlowStatus(abfd27cce48f162c).(rp - Roomscxx . . $ Rooms., LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[i].facenumcxx . . $ light_glow#facenum., &center, size, FastCoronascxx . . $ FastCoronas.);
2574 continue;
2575 }
2576 vectorcxx . . $ vector# subvec = Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). center;
2577 vm_NormalizeVectorFastcxx . . $ vm_NormalizeVectorFast(4939a7e530383cd4).(&subvec);
2578 subvec *=cxx . . $ `operator*=`(f132838b2cd11d6). size;
2579 subvec +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). center;
2580 fq.p0cxx . . $ fvi_query#p0. = &center;
2581 fq.p1cxx . . $ fvi_query#p1. = &subvec;
2582 fq.startroomcxx . . $ fvi_query#startroom. = rp - Roomscxx . . $ Rooms.;
2583 } else {
2584 fq.p0cxx . . $ fvi_query#p0. = &Viewer_eyecxx . . $ Viewer_eye.;
2585 fq.p1cxx . . $ fvi_query#p1. = &center;
2586 fq.startroomcxx . . $ fvi_query#startroom. = Viewer_objectcxx . . $ Viewer_object.->roomnumcxx . . $ object#roomnum.;
2587 }
2588
2589 fq.radcxx . . $ fvi_query#rad. = 0.0f;
2590 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_NO_RELINKcxx . . $ `lib/findintersection_external.h:73:9`! | FQ_IGNORE_WEAPONScxx . . $ `lib/findintersection_external.h:79:9`! | FQ_ROBOTS_AS_SPHEREcxx . . $ `lib/findintersection_external.h:82:9`! | FQ_PLAYERS_AS_SPHEREcxx . . $ `lib/findintersection_external.h:81:9`!;
2591 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = -1;
2592 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
2593 int fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
2594 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!)
2595 continue;
2596 SetGlowStatuscxx . . $ SetGlowStatus(abfd27cce48f162c).(rp - Roomscxx . . $ Rooms., LightGlowsThisFramecxx . . $ LightGlowsThisFrame.[i].facenumcxx . . $ light_glow#facenum., &center, size, FastCoronascxx . . $ FastCoronas.);
2597 }
2598 }
2599 // Called before a frame starts to render - sets all of our light glows to decreasing
2600 void PreUpdateAllLightGlowscxx . . $ PreUpdateAllLightGlows(49f6e7a06ebc5aa8).() {
2601 int i, count;
2602 for (i = 0, count = 0; i < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! && count < Num_glowscxx . . $ Num_glows.; i++) {
2603 if (LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. & LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`!) {
2604 count++;
2605 LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. &= ~LGF_INCREASINGcxx . . $ `Descent3/render.cpp:180:9`!;
2606 }
2607 }
2608 }
2609 // Called after a frame has been rendered - slowly morphs our light glows into nothing
2610 void PostUpdateAllLightGlowscxx . . $ PostUpdateAllLightGlows(49f6e7a06ebc5aa8).() {
2611 int i, count;
2612 for (i = 0, count = 0; i < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! && count < Num_glowscxx . . $ Num_glows.; i++) {
2613 if (LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. & LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`!) {
2614 count++;
2615 if (LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. & LGF_INCREASINGcxx . . $ `Descent3/render.cpp:180:9`!) {
2616 LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. += (Frametimecxx . . $ Frametime. * 4);
2617 if (LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. > 1)
2618 LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. = 1;
2619 } else {
2620 LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. -= (Frametimecxx . . $ Frametime. * 4);
2621 if (LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. < 0) {
2622 LightGlowscxx . . $ LightGlows.[i].scalarcxx . . $ light_glow#scalar. = 0;
2623 LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. &= ~LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`!;
2624 Num_glowscxx . . $ Num_glows.--;
2625 count--;
2626 }
2627 }
2628 }
2629 }
2630
2631 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_glows >= 0);
2632 }
2633 // Recursive function that mirrored rooms use
2634 void BuildMirroredRoomListSubcxx . . $ BuildMirroredRoomListSub(242c595644197048).(int start_room_num, clip_wndcxx . . $ clip_wnd# *wnd) {
2635 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[start_room_num];
2636 g3Pointcxx . . $ g3Point# portal_points[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
2637 int i, t;
2638 if (!Mirrored_room_checkedcxx . . $ Mirrored_room_checked.[start_room_num]) {
2639 Mirrored_room_listcxx . . $ Mirrored_room_list.[Num_mirrored_roomscxx . . $ Num_mirrored_rooms.++] = start_room_num;
2640 }
2641 Mirrored_room_checkedcxx . . $ Mirrored_room_checked.[start_room_num] = 1;
2642
2643 // If this room is a closed (non-seethrough) door, don't check any of its portals,
2644 //...UNLESS this is the first room we're looking at (meaning the viewer is in this room)
2645 if ((rp->flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!) && (DoorwayGetPositioncxx . . $ `Descent3/doorway.h:215:9`!(rp) == 0.0) &&
2646 !(Doorscxx . . $ Doors.[rp->doorway_datacxx . . $ room#doorway_data.->doornumcxx . . $ doorway#doornum.].flagscxx . . $ door#flags. & DF_SEETHROUGHcxx . . $ `Descent3/door.h:120:9`!))
2647 return;
2648 roomcxx . . $ room# *mirror_rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
2649 vectorcxx . . $ vector# *mirror_vec = &mirror_rp->vertscxx . . $ room#verts.[mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.].face_vertscxx . . $ face#face_verts.[0]];
2650 facecxx . . $ face# *mirror_fp = &mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.];
2651 vectorcxx . . $ vector# *mirror_norm = &mirror_fp->normalcxx . . $ face#normal.;
2652 // This is how far the mirror face is from the normalized plane
2653 float mirror_dist =
2654 -(mirror_vec->xcxx . . $ vector#x. * mirror_norm->xcxx . . $ vector#x. + mirror_vec->ycxx . . $ vector#y. * mirror_norm->ycxx . . $ vector#y. + mirror_vec->zcxx . . $ vector#z. * mirror_norm->zcxx . . $ vector#z.);
2655 // Check all the portals for this room
2656 for (t = 0; t < rp->num_portalscxx . . $ room#num_portals.; t++) {
2657 portalcxx . . $ portal# *pp = &rp->portalscxx . . $ room#portals.[t];
2658 int croom = pp->croomcxx . . $ portal#croom.;
2659 ASSERTcxx . . $ `misc/pserror.h:246:9`!(croom >= 0);
2660 // If we are an external room portalizing into another external room, then skip!
2661 if ((rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!) && (Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!))
2662 continue;
2663 // Check if we can see through this portal, and if not, skip it
2664 if (!RenderPastPortalcxx . . $ RenderPastPortal(5714109361f3d17d).(rp, pp))
2665 continue;
2666 // If this portal has been visited, skip it
2667 if (Mirrored_room_checkedcxx . . $ Mirrored_room_checked.[croom])
2668 continue;
2669 // Deal with external portals differently
2670 int external_door_hack = 0;
2671 if (rp->flagscxx . . $ room#flags. & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`! && Roomscxx . . $ Rooms.[croom].flagscxx . . $ room#flags. & RF_DOORcxx . . $ `Descent3/room_external.h:176:9`!)
2672 external_door_hack = 1;
2673 // Get pointer to this portal's face
2674 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[pp->portal_facecxx . . $ portal#portal_face.];
2675 // See if portal is facing toward us
2676 if (!external_door_hack) {
2677 vectorcxx . . $ vector# temp_vec;
2678 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[0]];
2679 float dist_from_mirror =
2680 vec->xcxx . . $ vector#x. * mirror_norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * mirror_norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * mirror_norm->zcxx . . $ vector#z. + mirror_dist;
2681 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
2682 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*mirror_norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
2683 vectorcxx . . $ vector# incident_norm;
2684 ReflectRaycxx . . $ ReflectRay(af83aca25ba5b41c).(&incident_norm, &fp->normalcxx . . $ face#normal., &mirror_fp->normalcxx . . $ face#normal.);
2685
2686 vectorcxx . . $ vector# tvec = Viewer_eyecxx . . $ Viewer_eye. -cxx . . $ operator-(b77b703cd1e43e33). temp_vec;
2687 if ((tvec *cxx . . $ `operator*`(4a721543d64e126a). incident_norm) <= 0)
2688 continue; // not facing
2689 }
2690
2691 g3Codescxx . . $ g3Codes# cc;
2692 cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
2693 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
2694 int nv = fp->num_vertscxx . . $ face#num_verts.;
2695 // Code the face points
2696 for (i = 0; i < nv; i++) {
2697 vectorcxx . . $ vector# temp_vec;
2698 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[i]];
2699 float dist_from_mirror =
2700 vec->xcxx . . $ vector#x. * mirror_norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * mirror_norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * mirror_norm->zcxx . . $ vector#z. + mirror_dist;
2701 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
2702 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*mirror_norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
2703 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&portal_points[i], &temp_vec);
2704
2705 uint8_tcxx . . $ uint8_t# c = portal_points[i].p3_codescxx . . $ g3Point#p3_codes.;
2706 cc.cc_andcxx . . $ g3Codes#cc_and. &= c;
2707 cc.cc_orcxx . . $ g3Codes#cc_or. |= c;
2708 }
2709 // If points are on screen, see if they're in the clip window
2710 if (cc.cc_andcxx . . $ g3Codes#cc_and. == 0 || external_door_hack) {
2711 bool clipped = 0;
2712 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!], **pl = pointlist;
2713 for (i = 0; i < nv; i++)
2714 pointlist[i] = &portal_points[i];
2715 // If portal not all on screen, must clip it
2716 if (cc.cc_orcxx . . $ g3Codes#cc_or.) {
2717 pl = g3_ClipPolygoncxx . . $ g3_ClipPolygon(729f60102f660017).(pl, &nv, &cc);
2718 clipped = 1;
2719 }
2720 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
2721 for (i = 0; i < nv; i++) {
2722 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(pl[i]);
2723 cc.cc_andcxx . . $ g3Codes#cc_and. &= clip2dcxx . . $ clip2d(9a081d096ad5b8e5).(pl[i], wnd);
2724 }
2725 // Make sure it didn't get clipped away
2726 if (cc.cc_andcxx . . $ g3Codes#cc_and. == 0 || external_door_hack) {
2727 clip_wndcxx . . $ clip_wnd# new_wnd;
2728 new_wnd.rightcxx . . $ clip_wnd#right. = new_wnd.botcxx . . $ clip_wnd#bot. = 0.0;
2729 new_wnd.leftcxx . . $ clip_wnd#left. = Render_widthcxx . . $ Render_width.;
2730 new_wnd.topcxx . . $ clip_wnd#top. = Render_heightcxx . . $ Render_height.;
2731 // make new clip window
2732 for (i = 0; i < nv; i++) {
2733 float x = pl[i]->p3_sxcxx . . $ g3Point#p3_sx., y = pl[i]->p3_sycxx . . $ g3Point#p3_sy.;
2734 if (x < new_wnd.leftcxx . . $ clip_wnd#left.)
2735 new_wnd.leftcxx . . $ clip_wnd#left. = x;
2736 if (x > new_wnd.rightcxx . . $ clip_wnd#right.)
2737 new_wnd.rightcxx . . $ clip_wnd#right. = x;
2738 if (y < new_wnd.topcxx . . $ clip_wnd#top.)
2739 new_wnd.topcxx . . $ clip_wnd#top. = y;
2740 if (y > new_wnd.botcxx . . $ clip_wnd#bot.)
2741 new_wnd.botcxx . . $ clip_wnd#bot. = y;
2742 }
2743
2744 // Combine the two windows
2745 new_wnd.leftcxx . . $ clip_wnd#left. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd->leftcxx . . $ clip_wnd#left., new_wnd.leftcxx . . $ clip_wnd#left.);
2746 new_wnd.rightcxx . . $ clip_wnd#right. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd->rightcxx . . $ clip_wnd#right., new_wnd.rightcxx . . $ clip_wnd#right.);
2747 new_wnd.topcxx . . $ clip_wnd#top. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd->topcxx . . $ clip_wnd#top., new_wnd.topcxx . . $ clip_wnd#top.);
2748 new_wnd.botcxx . . $ clip_wnd#bot. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd->botcxx . . $ clip_wnd#bot., new_wnd.botcxx . . $ clip_wnd#bot.);
2749 if (clipped) { // Free up temp points
2750 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
2751 clipped = 0;
2752 }
2753 BuildMirroredRoomListSubcxx . . $ BuildMirroredRoomListSub(242c595644197048).(croom, &new_wnd);
2754 }
2755 if (clipped) // Free up temp points
2756 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
2757 }
2758 }
2759 }
2760 // Goes through and builds a list of rooms that can be seen from a mirror
2761 void BuildMirroredRoomListcxx . . $ BuildMirroredRoomList(49f6e7a06ebc5aa8).() {
2762 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
2763 clip_wndcxx . . $ clip_wnd# wnd;
2764 Num_mirrored_roomscxx . . $ Num_mirrored_rooms. = 0;
2765 memset(Mirrored_room_checkedcxx . . $ Mirrored_room_checked., 0, MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!);
2766 Mirrored_room_checkedcxx . . $ Mirrored_room_checked.[Mirror_roomcxx . . $ Mirror_room.] = 1;
2767 Mirrored_room_listcxx . . $ Mirrored_room_list.[Num_mirrored_roomscxx . . $ Num_mirrored_rooms.++] = Mirror_roomcxx . . $ Mirror_room.;
2768
2769 // Initial clip window is whole screen
2770 wnd.leftcxx . . $ clip_wnd#left. = wnd.topcxx . . $ clip_wnd#top. = 0.0;
2771 wnd.rightcxx . . $ clip_wnd#right. = Render_widthcxx . . $ Render_width.;
2772 wnd.botcxx . . $ clip_wnd#bot. = Render_heightcxx . . $ Render_height.;
2773 g3Pointcxx . . $ g3Point# portal_points[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!], temp_points[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`! * 2];
2774 g3Pointcxx . . $ g3Point# *pointlist[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`! * 2], **pl = pointlist;
2775 roomcxx . . $ room# *mirror_rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
2776 vectorcxx . . $ vector# *mirror_vec = &mirror_rp->vertscxx . . $ room#verts.[mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.].face_vertscxx . . $ face#face_verts.[0]];
2777 facecxx . . $ face# *mirror_fp = &mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.];
2778 vectorcxx . . $ vector# *mirror_norm = &mirror_fp->normalcxx . . $ face#normal.;
2779 // This is how far the mirror face is from the normalized plane
2780 float mirror_dist =
2781 -(mirror_vec->xcxx . . $ vector#x. * mirror_norm->xcxx . . $ vector#x. + mirror_vec->ycxx . . $ vector#y. * mirror_norm->ycxx . . $ vector#y. + mirror_vec->zcxx . . $ vector#z. * mirror_norm->zcxx . . $ vector#z.);
2782 int total_points = 0;
2783 for (int t = 0; t < rp->num_mirror_facescxx . . $ room#num_mirror_faces.; t++) {
2784 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[rp->mirror_faces_listcxx . . $ room#mirror_faces_list.[t]];
2785 int i;
2786 ASSERTcxx . . $ `misc/pserror.h:246:9`!(total_points + fp->num_verts <= MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`! * 2);
2787 g3Codescxx . . $ g3Codes# cc;
2788 cc.cc_andcxx . . $ g3Codes#cc_and. = 0xff;
2789 cc.cc_orcxx . . $ g3Codes#cc_or. = 0;
2790 int nv = fp->num_vertscxx . . $ face#num_verts.;
2791 int clipped = 0;
2792
2793 for (i = 0; i < fp->num_vertscxx . . $ face#num_verts.; i++) {
2794 vectorcxx . . $ vector# temp_vec;
2795 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[i]];
2796 float dist_from_mirror =
2797 vec->xcxx . . $ vector#x. * mirror_norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * mirror_norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * mirror_norm->zcxx . . $ vector#z. + mirror_dist;
2798 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
2799 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*mirror_norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
2800 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&portal_points[i], &temp_vec);
2801 cc.cc_andcxx . . $ g3Codes#cc_and. &= portal_points[i].p3_codescxx . . $ g3Point#p3_codes.;
2802 cc.cc_orcxx . . $ g3Codes#cc_or. |= portal_points[i].p3_codescxx . . $ g3Point#p3_codes.;
2803 pointlist[i] = &portal_points[i];
2804 }
2805
2806 // Clipped away
2807 if (cc.cc_andcxx . . $ g3Codes#cc_and.)
2808 continue;
2809 if (cc.cc_orcxx . . $ g3Codes#cc_or.) {
2810 // Must clip
2811 pl = g3_ClipPolygoncxx . . $ g3_ClipPolygon(729f60102f660017).(pl, &nv, &cc);
2812
2813 if (cc.cc_andcxx . . $ g3Codes#cc_and.) {
2814 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
2815 continue;
2816 } else {
2817 for (i = 0; i < nv; i++) {
2818 temp_points[i + total_points] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). *pl[i];
2819 temp_points[i + total_points].p3_flagscxx . . $ g3Point#p3_flags. &= ~PF_TEMP_POINTcxx . . $ `lib/3d.h:216:9`!;
2820 }
2821 g3_FreeTempPointscxx . . $ g3_FreeTempPoints(3ae387dc3696f211).(pl, nv);
2822 }
2823 } else {
2824 for (i = 0; i < nv; i++) {
2825 temp_points[i + total_points] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). *pl[i];
2826 }
2827 }
2828
2829 for (i = 0; i < nv; i++)
2830 g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&temp_points[total_points + i]);
2831
2832 total_points += nv;
2833 }
2834 // make new clip window
2835 clip_wndcxx . . $ clip_wnd# new_wnd;
2836 new_wnd.rightcxx . . $ clip_wnd#right. = new_wnd.botcxx . . $ clip_wnd#bot. = 0.0;
2837 new_wnd.leftcxx . . $ clip_wnd#left. = Render_widthcxx . . $ Render_width.;
2838 new_wnd.topcxx . . $ clip_wnd#top. = Render_heightcxx . . $ Render_height.;
2839 for (int i = 0; i < total_points; i++) {
2840 float x = temp_points[i].p3_sxcxx . . $ g3Point#p3_sx., y = temp_points[i].p3_sycxx . . $ g3Point#p3_sy.;
2841
2842 if (x < new_wnd.leftcxx . . $ clip_wnd#left.)
2843 new_wnd.leftcxx . . $ clip_wnd#left. = x;
2844 if (x > new_wnd.rightcxx . . $ clip_wnd#right.)
2845 new_wnd.rightcxx . . $ clip_wnd#right. = x;
2846 if (y < new_wnd.topcxx . . $ clip_wnd#top.)
2847 new_wnd.topcxx . . $ clip_wnd#top. = y;
2848 if (y > new_wnd.botcxx . . $ clip_wnd#bot.)
2849 new_wnd.botcxx . . $ clip_wnd#bot. = y;
2850 }
2851 new_wnd.leftcxx . . $ clip_wnd#left. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd.leftcxx . . $ clip_wnd#left., new_wnd.leftcxx . . $ clip_wnd#left.);
2852 new_wnd.rightcxx . . $ clip_wnd#right. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd.rightcxx . . $ clip_wnd#right., new_wnd.rightcxx . . $ clip_wnd#right.);
2853 new_wnd.topcxx . . $ clip_wnd#top. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(wnd.topcxx . . $ clip_wnd#top., new_wnd.topcxx . . $ clip_wnd#top.);
2854 new_wnd.botcxx . . $ clip_wnd#bot. = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(wnd.botcxx . . $ clip_wnd#bot., new_wnd.botcxx . . $ clip_wnd#bot.);
2855 /*rend_SetTextureType (TT_FLAT);
2856 rend_SetAlphaType (AT_CONSTANT);
2857 rend_SetAlphaValue (255);
2858 rend_SetFlatColor (GR_RGB(255,255,255));
2859
2860 rend_DrawLine (new_wnd.left,new_wnd.top,new_wnd.right,new_wnd.top);
2861 rend_DrawLine (new_wnd.right,new_wnd.top,new_wnd.right,new_wnd.bot);
2862 rend_DrawLine (new_wnd.right,new_wnd.bot,new_wnd.left,new_wnd.bot);
2863 rend_DrawLine (new_wnd.left,new_wnd.bot,new_wnd.left,new_wnd.top);*/
2864
2865 BuildMirroredRoomListSubcxx . . $ BuildMirroredRoomListSub(242c595644197048).(Mirror_roomcxx . . $ Mirror_room., &new_wnd);
2866 }
2867 vectorcxx . . $ vector# mirror_dest_vecscxx . . $ mirror_dest_vecs.[MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!];
2868 g3Pointcxx . . $ g3Point# mirror_save_pointscxx . . $ mirror_save_points.[MAX_VERTS_PER_ROOMcxx . . $ `Descent3/room_external.h:107:9`!];
2869 // Renders a mirror flipped about the mirrored plane
2870 void RenderMirroredRoomcxx . . $ RenderMirroredRoom(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2871 int i;
2872 #if (defined(RELEASE) && defined(KATMAI))
2873 vector4 kat_vecs[MAX_VERTS_PER_ROOM];
2874 #endif
2875 uint16_tcxx . . $ uint16_t# save_flags[MAX_FACES_PER_ROOMcxx . . $ `Descent3/room_external.h:106:9`!];
2876 bool restore_index = true;
2877 int save_index = Global_buffer_indexcxx . . $ Global_buffer_index.;
2878
2879 // Save old rotated points
2880 if (rp->wpb_indexcxx . . $ room#wpb_index. == -1) {
2881 restore_index = false;
2882 rp->wpb_indexcxx . . $ room#wpb_index. = Global_buffer_indexcxx . . $ Global_buffer_index.;
2883 } else {
2884 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++)
2885 mirror_save_pointscxx . . $ mirror_save_points.[i] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i];
2886 }
2887
2888 // Find facing faces for this mirror
2889 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[0];
2890 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++) {
2891 save_flags[i] = fp->flagscxx . . $ face#flags.;
2892 fp->flagscxx . . $ face#flags. &= ~FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!;
2893 fp->flagscxx . . $ face#flags. |= FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!;
2894 }
2895 roomcxx . . $ room# *mirror_rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
2896 vectorcxx . . $ vector# *mirror_vec = &mirror_rp->vertscxx . . $ room#verts.[mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.].face_vertscxx . . $ face#face_verts.[0]];
2897 facecxx . . $ face# *mirror_fp = &mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.];
2898 vectorcxx . . $ vector# *norm = &mirror_fp->normalcxx . . $ face#normal.;
2899 // This is how far the mirror face is from the normalized plane
2900 float mirror_dist = -(mirror_vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + mirror_vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + mirror_vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z.);
2901
2902 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++) {
2903 vectorcxx . . $ vector# *vec = &rp->vertscxx . . $ room#verts.[i];
2904 float dist_from_mirror = vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z. + mirror_dist;
2905 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
2906 mirror_dest_vecscxx . . $ mirror_dest_vecs.[i] =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
2907 #if (defined(RELEASE) && defined(KATMAI))
2908 if (Katmai) {
2909 kat_vecs[i].x = mirror_dest_vecs[i].x;
2910 kat_vecs[i].y = mirror_dest_vecs[i].y;
2911 kat_vecs[i].z = mirror_dest_vecs[i].z;
2912 }
2913 #endif
2914 }
2915 // Rotate our mirror points
2916 vectorcxx . . $ vector# revnorm = -cxx . . $ operator-(9e07539e219c6f20).*norm;
2917 g3_SetCustomClipPlanecxx . . $ g3_SetCustomClipPlane(212e55486d77b625).(1, mirror_vec, &revnorm);
2918
2919 // Katmai enhanced rotate only in a release build, because not
2920 // everyone has the intel compiler!
2921 #if (defined(RELEASE) && defined(KATMAI))
2922 if (Katmai)
2923 RotateRoomPoints(rp, kat_vecs);
2924 else
2925 #endif
2926 RotateRoomPointscxx . . $ RotateRoomPoints(45b5008aac55501f).(rp, mirror_dest_vecscxx . . $ mirror_dest_vecs.);
2927
2928 // Mark facing faces
2929 int save_frame = Facing_visitedcxx . . $ Facing_visited.[rp - Roomscxx . . $ Rooms.];
2930 Facing_visitedcxx . . $ Facing_visited.[rp - Roomscxx . . $ Rooms.] = 0;
2931
2932 MarkFacingFacescxx . . $ MarkFacingFaces(6819790def3fd1d2).(rp - Roomscxx . . $ Rooms., mirror_dest_vecscxx . . $ mirror_dest_vecs.);
2933 Facing_visitedcxx . . $ Facing_visited.[rp - Roomscxx . . $ Rooms.] = save_frame;
2934 // Render the mirror room
2935 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
2936 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
2937 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.);
2938 RenderRoomUnsortedcxx . . $ RenderRoomUnsorted(cd8c4e8cd0ee4c38).(rp);
2939 if (restore_index == false) {
2940 rp->wpb_indexcxx . . $ room#wpb_index. = -1;
2941 } else {
2942 for (i = 0; i < rp->num_vertscxx . . $ room#num_verts.; i++)
2943 World_point_buffercxx . . $ World_point_buffer.[rp->wpb_indexcxx . . $ room#wpb_index. + i] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). mirror_save_pointscxx . . $ mirror_save_points.[i];
2944 }
2945 fp = &rp->facescxx . . $ room#faces.[0];
2946 for (i = 0; i < rp->num_facescxx . . $ room#num_faces.; i++, fp++)
2947 fp->flagscxx . . $ face#flags. = save_flags[i];
2948
2949 RenderRoomObjectscxx . . $ RenderRoomObjects(cd8c4e8cd0ee4c38).(rp);
2950 rp->last_render_timecxx . . $ room#last_render_time. = Gametimecxx . . $ Gametime.;
2951 g3_SetCustomClipPlanecxx . . $ g3_SetCustomClipPlane(212e55486d77b625).(0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
2952 }
2953 // Renders a specific room. If pos_offset is not NULL, adds that offset to each of the
2954 // rooms vertices
2955 void RenderRoomcxx . . $ RenderRoom(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
2956 Num_glows_this_framecxx . . $ Num_glows_this_frame. = 0;
2957
2958 // Set up rendering states
2959 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.);
2960 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
2961 rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.);
2962 if (rp->usedcxx . . $ room#used. == 0) {
2963 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Trying to draw a room that isn't in use!
2964 return;
2965 }
2966
2967 // Figure out pulse lighting for room
2968 ComputeRoomPulseLightcxx . . $ ComputeRoomPulseLight(cd8c4e8cd0ee4c38).(rp);
2969
2970 // Mark it visible for automap
2971 AutomapVisMapcxx . . $ AutomapVisMap.[rp - Roomscxx . . $ Rooms.] = 1;
2972
2973 #ifdef EDITOR
2974 if (!UseHardware) {
2975 RenderRoomSorted(rp);
2976 } else
2977 #endif
2978 {
2979 // NOTE LINK TO ABOVE ELSE
2980 RenderRoomUnsortedcxx . . $ RenderRoomUnsorted(cd8c4e8cd0ee4c38).(rp);
2981 }
2982
2983 rp->last_render_timecxx . . $ room#last_render_time. = Gametimecxx . . $ Gametime.;
2984 rp->flagscxx . . $ room#flags. &= ~RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!;
2985
2986 CheckLightGlowsForRoomcxx . . $ CheckLightGlowsForRoom(cd8c4e8cd0ee4c38).(rp);
2987
2988 if (Num_scorches_to_rendercxx . . $ Num_scorches_to_render. > 0) {
2989 RenderScorchesForRoomcxx . . $ RenderScorchesForRoom(cd8c4e8cd0ee4c38).(rp);
2990 Num_scorches_to_rendercxx . . $ Num_scorches_to_render. = 0;
2991 }
2992
2993 if (Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render. > 0) {
2994 RenderSpecularFacesFlatcxx . . $ RenderSpecularFacesFlat(cd8c4e8cd0ee4c38).(rp);
2995 Num_specular_faces_to_rendercxx . . $ Num_specular_faces_to_render. = 0;
2996 Num_real_specular_faces_to_rendercxx . . $ Num_real_specular_faces_to_render. = 0;
2997 }
2998
2999 if (Num_fog_faces_to_rendercxx . . $ Num_fog_faces_to_render. > 0) {
3000 RenderFogFacescxx . . $ RenderFogFaces(cd8c4e8cd0ee4c38).(rp);
3001 Num_fog_faces_to_rendercxx . . $ Num_fog_faces_to_render. = 0;
3002 }
3003 }
3004
3005 #define MAX_OBJECTS_PER_ROOMcxx . . $ `Descent3/render.cpp:3005:9`! 2000
3006 struct obj_sort_itemcxx . . $ obj_sort_item# {
3007 int vis_effectcxx . . $ obj_sort_item#vis_effect.;
3008 int objnumcxx . . $ obj_sort_item#objnum.;
3009 float distcxx . . $ obj_sort_item#dist.;
3010 };
3011 obj_sort_itemcxx . . $ obj_sort_item# obj_sort_listcxx . . $ obj_sort_list.[MAX_OBJECTS_PER_ROOMcxx . . $ `Descent3/render.cpp:3005:9`!];
3012 // Compare function for room face sort
3013 static int obj_sort_funccxx . . $ obj_sort_func(20b978cffff2d3d3).(const obj_sort_itemcxx . . $ obj_sort_item# *a, const obj_sort_itemcxx . . $ obj_sort_item# *b) {
3014 if (a->distcxx . . $ obj_sort_item#dist. < b->distcxx . . $ obj_sort_item#dist.)
3015 return -1;
3016 else if (a->distcxx . . $ obj_sort_item#dist. > b->distcxx . . $ obj_sort_item#dist.)
3017 return 1;
3018 else
3019 return 0;
3020 }
3021 static inline void IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(roomcxx . . $ room# *rp, int x, int y, int z, float *r, float *g, float *b) {
3022 int w = rp->volume_widthcxx . . $ room#volume_width.;
3023 int h = rp->volume_heightcxx . . $ room#volume_height.;
3024 int d = rp->volume_depthcxx . . $ room#volume_depth.;
3025
3026 uint8_tcxx . . $ uint8_t# color = rp->volume_lightscxx . . $ room#volume_lights.[(z * w * h) + (y * w) + x];
3027
3028 *r = (float)((color >> 5) / 7.0);
3029 *g = (float)((color >> 2) & 0x07) / 7.0;
3030 *b = (float)((float)(color & 0x03) / 3.0);
3031 }
3032 // Gets the dynamic light value for this position
3033 void GetRoomDynamicScalarcxx . . $ GetRoomDynamicScalar(93b972edae6e455f).(vectorcxx . . $ vector# *pos, roomcxx . . $ room# *rp, float *r, float *g, float *b) {
3034 float front_values_r[10];
3035 float back_values_r[10];
3036 float front_values_g[10];
3037 float back_values_g[10];
3038 float front_values_b[10];
3039 float back_values_b[10];
3040 if (!rp->volume_lightscxx . . $ room#volume_lights.) {
3041 *r = 1;
3042 *g = 1;
3043 *b = 1;
3044 return;
3045 }
3046 float fl_x = (pos->xcxx . . $ vector#x. - rp->min_xyzcxx . . $ room#min_xyz..xcxx . . $ vector#x.) / VOLUME_SPACINGcxx . . $ `Descent3/lighting.h:34:9`!;
3047 float fl_y = (pos->ycxx . . $ vector#y. - rp->min_xyzcxx . . $ room#min_xyz..ycxx . . $ vector#y.) / VOLUME_SPACINGcxx . . $ `Descent3/lighting.h:34:9`!;
3048 float fl_z = (pos->zcxx . . $ vector#z. - rp->min_xyzcxx . . $ room#min_xyz..zcxx . . $ vector#z.) / VOLUME_SPACINGcxx . . $ `Descent3/lighting.h:34:9`!;
3049 fl_x = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<float>(fl_x, 0);
3050 fl_y = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<float>(fl_y, 0);
3051 fl_z = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).<float>(fl_z, 0);
3052 fl_x = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(fl_x, rp->volume_widthcxx . . $ room#volume_width. - 1);
3053 fl_y = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(fl_y, rp->volume_heightcxx . . $ room#volume_height. - 1);
3054 fl_z = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<float>(fl_z, rp->volume_depthcxx . . $ room#volume_depth. - 1);
3055 int int_x = fl_x;
3056 int int_y = fl_y;
3057 int int_z = fl_z;
3058 fl_x -= int_x;
3059 fl_y -= int_y;
3060 fl_z -= int_z;
3061 int next_x = int_x + 1;
3062 int next_y = int_y + 1;
3063 int next_z = int_z + 1;
3064 next_x = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rp->volume_widthcxx . . $ room#volume_width. - 1, next_x);
3065 next_y = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rp->volume_heightcxx . . $ room#volume_height. - 1, next_y);
3066 next_z = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(rp->volume_depthcxx . . $ room#volume_depth. - 1, next_z);
3067
3068 float left_norm_r, left_norm_g, left_norm_b;
3069 float right_norm_r, right_norm_g, right_norm_b;
3070 float front_norm_r, front_norm_g, front_norm_b;
3071 float back_norm_r, back_norm_g, back_norm_b;
3072
3073 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, int_x, int_y, int_z, &front_values_r[0], &front_values_g[0], &front_values_b[0]);
3074 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, int_x, next_y, int_z, &front_values_r[1], &front_values_g[1], &front_values_b[1]);
3075 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, next_x, next_y, int_z, &front_values_r[2], &front_values_g[2], &front_values_b[2]);
3076 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, next_x, int_y, int_z, &front_values_r[3], &front_values_g[3], &front_values_b[3]);
3077 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, int_x, int_y, next_z, &back_values_r[0], &back_values_g[0], &back_values_b[0]);
3078 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, int_x, next_y, next_z, &back_values_r[1], &back_values_g[1], &back_values_b[1]);
3079 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, next_x, next_y, next_z, &back_values_r[2], &back_values_g[2], &back_values_b[2]);
3080 IsRoomDynamicValidcxx . . $ IsRoomDynamicValid(72398d980334229c).(rp, next_x, int_y, next_z, &back_values_r[3], &back_values_g[3], &back_values_b[3]);
3081 // Do front edge
3082 int left_out = 0;
3083 int right_out = 0;
3084 // Left edge
3085 left_norm_r = ((1 - fl_y) * front_values_r[0]) + (fl_y * front_values_r[1]);
3086 left_norm_g = ((1 - fl_y) * front_values_g[0]) + (fl_y * front_values_g[1]);
3087 left_norm_b = ((1 - fl_y) * front_values_b[0]) + (fl_y * front_values_b[1]);
3088
3089 // Right edge
3090 right_norm_r = ((1 - fl_y) * front_values_r[3]) + (fl_y * front_values_r[2]);
3091 right_norm_g = ((1 - fl_y) * front_values_g[3]) + (fl_y * front_values_g[2]);
3092 right_norm_b = ((1 - fl_y) * front_values_b[3]) + (fl_y * front_values_b[2]);
3093 // Figure out front edge
3094 front_norm_r = ((1 - fl_x) * left_norm_r) + (fl_x * right_norm_r);
3095 front_norm_g = ((1 - fl_x) * left_norm_g) + (fl_x * right_norm_g);
3096 front_norm_b = ((1 - fl_x) * left_norm_b) + (fl_x * right_norm_b);
3097
3098 // Do back edge
3099 left_norm_r = ((1 - fl_y) * back_values_r[0]) + (fl_y * back_values_r[1]);
3100 left_norm_g = ((1 - fl_y) * back_values_g[0]) + (fl_y * back_values_g[1]);
3101 left_norm_b = ((1 - fl_y) * back_values_b[0]) + (fl_y * back_values_b[1]);
3102
3103 right_norm_r = ((1 - fl_y) * back_values_r[3]) + (fl_y * back_values_r[2]);
3104 right_norm_g = ((1 - fl_y) * back_values_g[3]) + (fl_y * back_values_g[2]);
3105 right_norm_b = ((1 - fl_y) * back_values_b[3]) + (fl_y * back_values_b[2]);
3106 back_norm_r = ((1 - fl_x) * left_norm_r) + (fl_x * right_norm_r);
3107 back_norm_g = ((1 - fl_x) * left_norm_g) + (fl_x * right_norm_g);
3108 back_norm_b = ((1 - fl_x) * left_norm_b) + (fl_x * right_norm_b);
3109 *r = ((1 - fl_z) * front_norm_r) + (fl_z * back_norm_r);
3110 *g = ((1 - fl_z) * front_norm_g) + (fl_z * back_norm_g);
3111 *b = ((1 - fl_z) * front_norm_b) + (fl_z * back_norm_b);
3112 // Factor in flickering
3113 ComputeRoomPulseLightcxx . . $ ComputeRoomPulseLight(cd8c4e8cd0ee4c38).(rp);
3114 (*r) *= Room_light_valcxx . . $ Room_light_val.;
3115 (*g) *= Room_light_valcxx . . $ Room_light_val.;
3116 (*b) *= Room_light_valcxx . . $ Room_light_val.;
3117 }
3118 uint8_tcxx . . $ uint8_t# Trick_typecxx . . $ Trick_type. = 0;
3119 // Render the objects and viseffects in a room. Do a simple sort
3120 void RenderRoomObjectscxx . . $ RenderRoomObjects(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
3121 int n_objs = 0, objnum, i, visnum;
3122 float zdist;
3123 if (!Render_mirror_for_roomcxx . . $ Render_mirror_for_room. && UseHardwarecxx . . $ UseHardware.)
3124 return; // This function only works for mirrors now
3125
3126 // Add objects to sort list
3127 for (objnum = rp->objectscxx . . $ room#objects.; (objnum != -1) && (n_objs < MAX_OBJECTS_PER_ROOMcxx . . $ `Descent3/render.cpp:3005:9`!); objnum = Objectscxx . . $ Objects.[objnum].nextcxx . . $ object#next.) {
3128 ASSERTcxx . . $ `misc/pserror.h:246:9`!(objnum != Objects[objnum].next);
3129 objectcxx . . $ object# *obj = &Objectscxx . . $ Objects.[objnum];
3130
3131 if (obj->render_typecxx . . $ object#render_type. == RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!)
3132 continue;
3133 if (obj == Viewer_objectcxx . . $ Viewer_object. && !Render_mirror_for_roomcxx . . $ Render_mirror_for_room.)
3134 continue;
3135 float size = obj->sizecxx . . $ object#size.;
3136 // Special case weapons with streamers
3137 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_STREAMERcxx . . $ `Descent3/weapon.h:225:9`!))
3138 size = Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].phys_infocxx . . $ weapon#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.;
3139 // Check if object is trivially rejected
3140 bool isVisible = IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&obj->poscxx . . $ object#pos., size, &zdist) ? true : false;
3141 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room. || (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_ELECTRICALcxx . . $ `Descent3/weapon.h:222:9`!) || isVisible) {
3142 obj_sort_listcxx . . $ obj_sort_list.[n_objs].vis_effectcxx . . $ obj_sort_item#vis_effect. = 0;
3143 obj_sort_listcxx . . $ obj_sort_list.[n_objs].objnumcxx . . $ obj_sort_item#objnum. = objnum;
3144 obj_sort_listcxx . . $ obj_sort_list.[n_objs].distcxx . . $ obj_sort_item#dist. = zdist;
3145 n_objs++;
3146 }
3147 }
3148 // Add vis effects to sort list
3149 for (visnum = rp->vis_effectscxx . . $ room#vis_effects.; (visnum != -1) && (n_objs < MAX_OBJECTS_PER_ROOMcxx . . $ `Descent3/render.cpp:3005:9`!); visnum = VisEffectscxx . . $ VisEffects.[visnum].nextcxx . . $ vis_effect#next.) {
3150 ASSERTcxx . . $ `misc/pserror.h:246:9`!(visnum != VisEffects[visnum].next);
3151 if (VisEffectscxx . . $ VisEffects.[visnum].typecxx . . $ vis_effect#type. == VIS_NONEcxx . . $ `Descent3/viseffect_external.h:60:9`! || VisEffectscxx . . $ VisEffects.[visnum].flagscxx . . $ vis_effect#flags. & VF_DEADcxx . . $ `Descent3/viseffect_external.h:66:9`!)
3152 continue;
3153
3154 bool pointIsVisible = IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&VisEffectscxx . . $ VisEffects.[visnum].poscxx . . $ vis_effect#pos., VisEffectscxx . . $ VisEffects.[visnum].sizecxx . . $ vis_effect#size., &zdist) ? true : false;
3155 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room. || pointIsVisible) {
3156 obj_sort_listcxx . . $ obj_sort_list.[n_objs].vis_effectcxx . . $ obj_sort_item#vis_effect. = 1;
3157 obj_sort_listcxx . . $ obj_sort_list.[n_objs].objnumcxx . . $ obj_sort_item#objnum. = visnum;
3158 obj_sort_listcxx . . $ obj_sort_list.[n_objs].distcxx . . $ obj_sort_item#dist. = zdist;
3159 n_objs++;
3160 }
3161 }
3162 ASSERTcxx . . $ `misc/pserror.h:246:9`!(objnum == -1); // if not -1, ran out of space in render_order[]
3163 ASSERTcxx . . $ `misc/pserror.h:246:9`!(visnum == -1); // if not -1, ran out of space in render_order[]
3164 // Sort the objects
3165 qsortcxx . . $ qsort(ebb60b13a65e77d7).(obj_sort_listcxx . . $ obj_sort_list., n_objs, sizeof(*obj_sort_listcxx . . $ obj_sort_list.), (int (*)(const void *, const void *))obj_sort_funccxx . . $ obj_sort_func(20b978cffff2d3d3).);
3166 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
3167 bool save_polymodel_outline_mode = Polymodel_outline_modecxx . . $ Polymodel_outline_mode.;
3168 Polymodel_outline_modecxx . . $ Polymodel_outline_mode. = OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_OBJECTScxx . . $ `Descent3/render.h:203:9`!);
3169 #endif
3170 // Render the objects
3171 if (UseHardwarecxx . . $ UseHardware. && Render_mirror_for_roomcxx . . $ Render_mirror_for_room.) {
3172 // Render the mirror stuff if present
3173 roomcxx . . $ room# *mirror_rp = &Roomscxx . . $ Rooms.[Mirror_roomcxx . . $ Mirror_room.];
3174 vectorcxx . . $ vector# *mirror_vec = &mirror_rp->vertscxx . . $ room#verts.[mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.].face_vertscxx . . $ face#face_verts.[0]];
3175 facecxx . . $ face# *mirror_fp = &mirror_rp->facescxx . . $ room#faces.[mirror_rp->mirror_facecxx . . $ room#mirror_face.];
3176 vectorcxx . . $ vector# *norm = &mirror_fp->normalcxx . . $ face#normal.;
3177 // This is how far the mirror face is from the normalized plane
3178 float mirror_dist = -(mirror_vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + mirror_vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + mirror_vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z.);
3179 // Setup mirror matrix
3180
3181 vectorcxx . . $ vector# negz_vec = {0, 0, -1};
3182
3183 matrixcxx . . $ matrix# mirror_matrix, inv_mirror_matrix, dest_matrix, negz_matrix;
3184 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&mirror_matrix, norm, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
3185 inv_mirror_matrix =cxx . . $ matrix#`operator=`(4c6f8b29806742). mirror_matrix;
3186 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&inv_mirror_matrix);
3187 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&negz_matrix, &negz_vec, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!);
3188 negz_matrix.rveccxx . . $ matrix#rvec. *=cxx . . $ `operator*=`(f132838b2cd11d6). -1;
3189
3190 for (i = n_objs - 1; i >= 0; i--) {
3191 objnum = obj_sort_listcxx . . $ obj_sort_list.[i].objnumcxx . . $ obj_sort_item#objnum.;
3192 if (obj_sort_listcxx . . $ obj_sort_list.[i].vis_effectcxx . . $ obj_sort_item#vis_effect.) {
3193 vis_effectcxx . . $ vis_effect# *vis = &VisEffectscxx . . $ VisEffects.[objnum];
3194 vectorcxx . . $ vector# save_vec = vis->poscxx . . $ vis_effect#pos.;
3195 vectorcxx . . $ vector# save_end_vec = vis->end_poscxx . . $ vis_effect#end_pos.;
3196 vectorcxx . . $ vector# *vec = &vis->poscxx . . $ vis_effect#pos.;
3197 vectorcxx . . $ vector# *end_vec = &vis->end_poscxx . . $ vis_effect#end_pos.;
3198 float dist_from_mirror = vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z. + mirror_dist;
3199 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
3200 vis->poscxx . . $ vis_effect#pos. =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
3201 dist_from_mirror = end_vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + end_vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + end_vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z. + mirror_dist;
3202 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
3203 vis->end_poscxx . . $ vis_effect#end_pos. =cxx . . $ vector#`operator=`(c0842353a20857d). *end_vec -cxx . . $ operator-(b77b703cd1e43e33). (*norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
3204
3205 DrawVisEffectcxx . . $ DrawVisEffect(6089e83781d51a35).(vis);
3206 vis->poscxx . . $ vis_effect#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_vec;
3207 vis->end_poscxx . . $ vis_effect#end_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_end_vec;
3208 } else {
3209 objectcxx . . $ object# *objp = &Objectscxx . . $ Objects.[objnum];
3210
3211 vectorcxx . . $ vector# save_vec = objp->poscxx . . $ object#pos.;
3212 matrixcxx . . $ matrix# save_orient = objp->orientcxx . . $ object#orient.;
3213 matrixcxx . . $ matrix# temp_mat;
3214
3215 vectorcxx . . $ vector# *vec = &objp->poscxx . . $ object#pos.;
3216 float dist_from_mirror = vec->xcxx . . $ vector#x. * norm->xcxx . . $ vector#x. + vec->ycxx . . $ vector#y. * norm->ycxx . . $ vector#y. + vec->zcxx . . $ vector#z. * norm->zcxx . . $ vector#z. + mirror_dist;
3217 // dest_vecs contains the point on the other side of the mirror (ie the reflected point)
3218 objp->poscxx . . $ object#pos. =cxx . . $ vector#`operator=`(c0842353a20857d). *vec -cxx . . $ operator-(b77b703cd1e43e33). (*norm *cxx . . $ `operator*`(252247219a31502c). (dist_from_mirror * 2));
3219 // Check for rear view
3220 if (objp == Viewer_objectcxx . . $ Viewer_object. && Viewer_objectcxx . . $ Viewer_object. == Player_objectcxx . . $ Player_object. &&
3221 (Playerscxx . . $ Players.[Player_numcxx . . $ Player_num.].flagscxx . . $ player#flags. & PLAYER_FLAGS_REARVIEWcxx . . $ `Descent3/player_external.h:97:9`!)) {
3222 objp->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec. =cxx . . $ vector#`operator=`(c0842353a20857d). -cxx . . $ operator-(9e07539e219c6f20).objp->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec.;
3223 objp->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec. =cxx . . $ vector#`operator=`(c0842353a20857d). -cxx . . $ operator-(9e07539e219c6f20).objp->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec.;
3224 }
3225 // Get new orientation
3226 temp_mat =cxx . . $ matrix#`operator=`(e859ffc26b91394f). mirror_matrix *cxx . . $ `operator*`(683f8e040c904cb). negz_matrix *cxx . . $ `operator*`(683f8e040c904cb). inv_mirror_matrix;
3227 dest_matrix.rveccxx . . $ matrix#rvec. =cxx . . $ vector#`operator=`(c0842353a20857d). objp->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). temp_mat;
3228 dest_matrix.uveccxx . . $ matrix#uvec. =cxx . . $ vector#`operator=`(c0842353a20857d). objp->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). temp_mat;
3229 dest_matrix.fveccxx . . $ matrix#fvec. =cxx . . $ vector#`operator=`(c0842353a20857d). objp->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). temp_mat;
3230 objp->orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). dest_matrix;
3231 bool save_render = false;
3232 if (objp->flagscxx . . $ object#flags. & OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!)
3233 save_render = true;
3234 objp->flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
3235
3236 RenderObjectcxx . . $ RenderObject(419c470199a90a97).(objp);
3237 if (save_render)
3238 objp->flagscxx . . $ object#flags. |= OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
3239 else
3240 objp->flagscxx . . $ object#flags. &= ~OF_SAFE_TO_RENDERcxx . . $ `Descent3/object_external.h:277:9`!;
3241 objp->poscxx . . $ object#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_vec;
3242 objp->orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). save_orient;
3243 }
3244 }
3245 return;
3246 }
3247 for (i = n_objs - 1; i >= 0; i--) {
3248 objnum = obj_sort_listcxx . . $ obj_sort_list.[i].objnumcxx . . $ obj_sort_item#objnum.;
3249 if (obj_sort_listcxx . . $ obj_sort_list.[i].vis_effectcxx . . $ obj_sort_item#vis_effect.) {
3250 DrawVisEffectcxx . . $ DrawVisEffect(6089e83781d51a35).(&VisEffectscxx . . $ VisEffects.[objnum]);
3251 } else {
3252 objectcxx . . $ object# *objp = &Objectscxx . . $ Objects.[objnum];
3253 if (objp == Viewer_objectcxx . . $ Viewer_object.)
3254 continue;
3255 RenderObjectcxx . . $ RenderObject(419c470199a90a97).(objp);
3256 }
3257 }
3258 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
3259 Polymodel_outline_modecxx . . $ Polymodel_outline_mode. = save_polymodel_outline_mode;
3260 #endif
3261 }
3262 // Either renders the objects in a room, or stuffs them into our postrender list
3263 void CheckToRenderMineObjectscxx . . $ CheckToRenderMineObjects(d4f767463ce0a6b3).(int roomnum) {
3264
3265 if (UseHardwarecxx . . $ UseHardware.) {
3266 int index;
3267 float zdist;
3268 if (Render_mirror_for_roomcxx . . $ Render_mirror_for_room.)
3269 return;
3270 for (index = Roomscxx . . $ Rooms.[roomnum].objectscxx . . $ room#objects.; index != -1; index = Objectscxx . . $ Objects.[index].nextcxx . . $ object#next.) {
3271 objectcxx . . $ object# *obj = &Objectscxx . . $ Objects.[index];
3272 if (Objectscxx . . $ Objects.[index].render_typecxx . . $ object#render_type. == RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!)
3273 continue;
3274 if (obj == Viewer_objectcxx . . $ Viewer_object.)
3275 continue;
3276 // Don't draw piggybacked objects
3277 if (Viewer_objectcxx . . $ Viewer_object.->typecxx . . $ object#type. == OBJ_OBSERVERcxx . . $ `Descent3/object_external.h:182:9`! && index == Playerscxx . . $ Players.[Viewer_objectcxx . . $ Viewer_object.->idcxx . . $ object#id.].piggy_objnumcxx . . $ player#piggy_objnum.)
3278 continue;
3279 float size = Objectscxx . . $ Objects.[index].sizecxx . . $ object#size.;
3280 // Special case weapons with streamers
3281 if (Objectscxx . . $ Objects.[index].typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (Weaponscxx . . $ Weapons.[Objectscxx . . $ Objects.[index].idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_STREAMERcxx . . $ `Descent3/weapon.h:225:9`!))
3282 size = Weaponscxx . . $ Weapons.[Objectscxx . . $ Objects.[index].idcxx . . $ object#id.].phys_infocxx . . $ weapon#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.;
3283 // Check if object is trivially rejected
3284 int visible = IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&obj->poscxx . . $ object#pos., size, &zdist); // calculate zdist
3285 if ((obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_ELECTRICALcxx . . $ `Descent3/weapon.h:222:9`!) || visible) {
3286 if (Num_postrenderscxx . . $ Num_postrenders. < MAX_POSTRENDERScxx . . $ `Descent3/postrender.h:22:9`!) {
3287 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].typecxx . . $ postrender_struct#type. = PRT_OBJECTcxx . . $ `Descent3/postrender.h:24:9`!;
3288 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].zcxx . . $ postrender_struct#z. = zdist;
3289 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.++].objnumcxx . . $ postrender_struct#$anonymous_type_0#objnum. = index;
3290 }
3291 }
3292 }
3293 // Now do viseffects
3294 for (index = Roomscxx . . $ Rooms.[roomnum].vis_effectscxx . . $ room#vis_effects.; index != -1; index = VisEffectscxx . . $ VisEffects.[index].nextcxx . . $ vis_effect#next.) {
3295 if (VisEffectscxx . . $ VisEffects.[index].typecxx . . $ vis_effect#type. == VIS_NONEcxx . . $ `Descent3/viseffect_external.h:60:9`! || VisEffectscxx . . $ VisEffects.[index].flagscxx . . $ vis_effect#flags. & VF_DEADcxx . . $ `Descent3/viseffect_external.h:66:9`!)
3296 continue;
3297
3298 if (IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&VisEffectscxx . . $ VisEffects.[index].poscxx . . $ vis_effect#pos., VisEffectscxx . . $ VisEffects.[index].sizecxx . . $ vis_effect#size., &zdist)) {
3299 if (Num_postrenderscxx . . $ Num_postrenders. < MAX_POSTRENDERScxx . . $ `Descent3/postrender.h:22:9`!) {
3300 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].typecxx . . $ postrender_struct#type. = PRT_VISEFFECTcxx . . $ `Descent3/postrender.h:25:9`!;
3301 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].zcxx . . $ postrender_struct#z. = zdist;
3302 Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.++].visnumcxx . . $ postrender_struct#$anonymous_type_0#visnum. = index;
3303 }
3304 }
3305 }
3306 } else
3307 RenderRoomObjectscxx . . $ RenderRoomObjects(cd8c4e8cd0ee4c38).(&Roomscxx . . $ Rooms.[roomnum]);
3308 }
3309 // Renders all the mirrored rooms for this frame
3310 void RenderMirrorRoomscxx . . $ RenderMirrorRooms(49f6e7a06ebc5aa8).() {
3311 int i;
3312 if (!UseHardwarecxx . . $ UseHardware. || !Detail_settingscxx . . $ Detail_settings..Mirrored_surfacescxx . . $ tDetailSettings#Mirrored_surfaces.)
3313 return;
3314 if (Num_mirror_roomscxx . . $ Num_mirror_rooms. == 0)
3315 return;
3316 for (i = 0; i < Num_mirror_roomscxx . . $ Num_mirror_rooms.; i++) {
3317 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[Mirror_roomscxx . . $ Mirror_rooms.[i]];
3318 // Reset mirrors
3319 Render_mirror_for_roomcxx . . $ Render_mirror_for_room. = false;
3320 bool do_mirror_face = false;
3321 rp->flagscxx . . $ room#flags. &= ~RF_MIRROR_VISIBLEcxx . . $ `Descent3/room_external.h:191:9`!;
3322 // Make sure its really ok to render this mirrored room
3323 if (rp->mirror_facecxx . . $ room#mirror_face. != -1)
3324 do_mirror_face = true;
3325 if (rp->mirror_facecxx . . $ room#mirror_face. >= rp->num_facescxx . . $ room#num_faces.)
3326 do_mirror_face = false;
3327 if (do_mirror_face) {
3328 if (!(GameTexturescxx . . $ GameTextures.[rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & TF_ALPHAcxx . . $ `Descent3/gametexture.h:223:9`!))
3329 do_mirror_face = false;
3330 }
3331 if (do_mirror_face) {
3332 int on_screen = 0;
3333 // See if any of the faces that share the mirror texture are on the screen
3334 for (int k = 0; k < rp->num_mirror_facescxx . . $ room#num_mirror_faces. && on_screen == 0; k++) {
3335 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[rp->mirror_faces_listcxx . . $ room#mirror_faces_list.[k]];
3336
3337 // See if this face is on screen
3338 int anded = 0xff;
3339 g3Pointcxx . . $ g3Point# pnt;
3340 for (int t = 0; t < fp->num_vertscxx . . $ face#num_verts.; t++)
3341 anded &= g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt, &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[t]]);
3342 if (!anded)
3343 on_screen = 1;
3344 }
3345 if (!on_screen)
3346 do_mirror_face = false;
3347 }
3348 if (do_mirror_face) // This room has a mirror...render it first
3349 {
3350 Render_mirror_for_roomcxx . . $ Render_mirror_for_room. = true;
3351 Mirror_roomcxx . . $ Mirror_room. = rp - Roomscxx . . $ Rooms.;
3352
3353 BuildMirroredRoomListcxx . . $ BuildMirroredRoomList(49f6e7a06ebc5aa8).();
3354 for (int t = Num_mirrored_roomscxx . . $ Num_mirrored_rooms. - 1; t >= 0; t--)
3355 RenderMirroredRoomcxx . . $ RenderMirroredRoom(cd8c4e8cd0ee4c38).(&Roomscxx . . $ Rooms.[Mirrored_room_listcxx . . $ Mirrored_room_list.[t]]);
3356 Render_mirror_for_roomcxx . . $ Render_mirror_for_room. = false;
3357 }
3358 }
3359 // Do z buffer trick
3360 rend_ClearZBuffercxx . . $ rend_ClearZBuffer(49f6e7a06ebc5aa8).();
3361 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
3362 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1);
3363 // Draw mirror faces now
3364 for (i = 0; i < Num_mirror_roomscxx . . $ Num_mirror_rooms.; i++) {
3365 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[Mirror_roomscxx . . $ Mirror_rooms.[i]];
3366 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.];
3367 g3Pointcxx . . $ g3Point# save_points[MAX_VERTS_PER_FACEcxx . . $ `Descent3/room_external.h:108:9`!];
3368 int save_index;
3369
3370 // Now do the same for all faces in this room that share that texture of the mirror
3371 for (int k = 0; k < rp->num_facescxx . . $ room#num_faces.; k++) {
3372 facecxx . . $ face# *this_fp = &rp->facescxx . . $ room#faces.[k];
3373 if (this_fp->tmapcxx . . $ face#tmap. == fp->tmapcxx . . $ face#tmap.) {
3374 int t;
3375
3376 save_index = rp->wpb_indexcxx . . $ room#wpb_index.;
3377 for (t = 0; t < fp->num_vertscxx . . $ face#num_verts.; t++)
3378 save_points[t] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[fp->face_vertscxx . . $ face#face_verts.[t]];
3379 DrawPostrenderFacecxx . . $ DrawPostrenderFace(6908015b96d379c0).(Mirror_roomscxx . . $ Mirror_rooms.[i], rp->mirror_facecxx . . $ room#mirror_face., false);
3380
3381 rp->wpb_indexcxx . . $ room#wpb_index. = save_index;
3382 for (t = 0; t < fp->num_vertscxx . . $ face#num_verts.; t++)
3383 World_point_buffercxx . . $ World_point_buffer.[fp->face_vertscxx . . $ face#face_verts.[t]] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). save_points[t];
3384 }
3385 }
3386 }
3387 }
3388 // Renders a room in just outline form
3389 void RenderRoomOutlinecxx . . $ RenderRoomOutline(cd8c4e8cd0ee4c38).(roomcxx . . $ room# *rp) {
3390 int fn;
3391 ddgr_colorcxx . . $ ddgr_color# back_line_color, face_line_color;
3392 back_line_color = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(100, 100, 100);
3393 face_line_color = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 255);
3394 for (fn = 0; fn < rp->num_facescxx . . $ room#num_faces.; fn++) {
3395 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[fn];
3396 g3Pointcxx . . $ g3Point# p0, p1;
3397 uint8_tcxx . . $ uint8_t# c0, c1;
3398 int v;
3399 ddgr_colorcxx . . $ ddgr_color# color;
3400 for (v = 0; v < fp->num_vertscxx . . $ face#num_verts.; v++) {
3401 c0 = g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&p0, &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[v]]);
3402 c1 = g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&p1, &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[(v + 1) % fp->num_vertscxx . . $ face#num_verts.]]);
3403 if ((!(fp->flagscxx . . $ face#flags. & FF_VISIBLEcxx . . $ `Descent3/room_external.h:122:9`!)) || ((fp->flagscxx . . $ face#flags. & FF_NOT_FACINGcxx . . $ `Descent3/room_external.h:126:9`!))) {
3404 // wouldn't normally be rendered
3405 color = back_line_color;
3406 } else {
3407 color = face_line_color;
3408 }
3409 if (!(c0 & c1)) { // both not off screen?
3410 // Draw current edge in green
3411 g3_DrawLinecxx . . $ g3_DrawLine(79482445f52a1992).(color, &p0, &p1);
3412 }
3413 }
3414 }
3415 }
3416 // Draws the mine, starting at a the specified room
3417 // The rendering surface must be set up, and g3_StartFrame() must have been called
3418 // Parameters: viewer_roomnum - what room the viewer is in
3419 // flag_automap - if true, flag segments as visited when rendered
3420 // called_from_terrain - set if calling this routine from the terrain renderer
3421 void RenderMinecxx . . $ RenderMine(b1146eedae1e1d0b).(int viewer_roomnum, int flag_automap, int called_from_terrain) {
3422 #ifdef EDITOR
3423 In_editor_mode = (GetFunctionMode() == EDITOR_MODE);
3424 #endif
3425 // check to see if we should render windows
3426 if (No_render_windows_hackcxx . . $ No_render_windows_hack. == -1) {
3427 if (FindArgcxx . . $ FindArg(5c4306d8553b3696).("-NoRenderWindows"))
3428 No_render_windows_hackcxx . . $ No_render_windows_hack. = 1;
3429 else
3430 No_render_windows_hackcxx . . $ No_render_windows_hack. = 0;
3431 }
3432 // Get the viewer eye so functions down the line can look at it
3433 g3_GetViewPositioncxx . . $ g3_GetViewPosition(ec8cf6451c36d470).(&Viewer_eyecxx . . $ Viewer_eye.);
3434 g3_GetUnscaledMatrixcxx . . $ g3_GetUnscaledMatrix(dca75c48c9ab5b54).(&Viewer_orientcxx . . $ Viewer_orient.);
3435 // set these globals so functions down the line can look at them
3436 Viewer_roomnumcxx . . $ Viewer_roomnum. = viewer_roomnum;
3437 Flag_automapcxx . . $ Flag_automap. = flag_automap;
3438 Called_from_terraincxx . . $ Called_from_terrain. = called_from_terrain;
3439 // Assume no terrain
3440 Must_render_terraincxx . . $ Must_render_terrain. = 0;
3441
3442 // Get the width & height of the render window
3443 rend_GetProjectionParameterscxx . . $ rend_GetProjectionParameters(ce8f7825f8908cfa).(&Render_widthcxx . . $ Render_width., &Render_heightcxx . . $ Render_height.);
3444 if (!Called_from_terraincxx . . $ Called_from_terrain.) {
3445 Terrain_portal_topcxx . . $ Terrain_portal_top. = Render_heightcxx . . $ Render_height.;
3446 Terrain_portal_bottomcxx . . $ Terrain_portal_bottom. = 0;
3447 Terrain_portal_rightcxx . . $ Terrain_portal_right. = 0;
3448 Terrain_portal_leftcxx . . $ Terrain_portal_left. = Render_widthcxx . . $ Render_width.;
3449 }
3450 // Build the list of visible rooms
3451 BuildRoomListcxx . . $ BuildRoomList(d4f767463ce0a6b3).(viewer_roomnum); // fills in Render_list & N_render_segs
3452
3453 // If we determined that the terrain is visible, render it
3454 if (Must_render_terraincxx . . $ Must_render_terrain. && !Called_from_terraincxx . . $ Called_from_terrain. && !(In_editor_modecxx . . $ In_editor_mode. && Render_inside_onlycxx . . $ Render_inside_only.)) {
3455 RenderTerraincxx . . $ RenderTerrain(29744a30b22ab106).(1, Terrain_portal_leftcxx . . $ Terrain_portal_left., Terrain_portal_topcxx . . $ Terrain_portal_top., Terrain_portal_rightcxx . . $ Terrain_portal_right., Terrain_portal_bottomcxx . . $ Terrain_portal_bottom.);
3456 // Mark all room points to be rerotated due to terrain trashing our point list
3457 for (int i = 0; i <= Highest_room_indexcxx . . $ Highest_room_index.; i++) {
3458 Roomscxx . . $ Rooms.[i].wpb_indexcxx . . $ room#wpb_index. = -1;
3459 Global_buffer_indexcxx . . $ Global_buffer_index. = 0;
3460 }
3461 // Setup fog if needed
3462 g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(VisibleTerrainZcxx . . $ VisibleTerrainZ.);
3463
3464 if ((Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_FOGcxx . . $ `Descent3/terrain.h:58:9`!) && (UseHardwarecxx . . $ UseHardware. || (!UseHardwarecxx . . $ UseHardware. && Lighting_oncxx . . $ Lighting_on.))) {
3465 rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(0, VisibleTerrainZcxx . . $ VisibleTerrainZ.);
3466 rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(1);
3467 rend_SetFogBorderscxx . . $ rend_SetFogBorders(5102ef758adc0ae7).(VisibleTerrainZcxx . . $ VisibleTerrainZ. * .85, VisibleTerrainZcxx . . $ VisibleTerrainZ.);
3468 rend_SetFogColorcxx . . $ rend_SetFogColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..fog_colorcxx . . $ terrain_sky#fog_color.);
3469 } else
3470 rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(0, 5000);
3471 }
3472
3473 // First render mirrored rooms
3474 RenderMirrorRoomscxx . . $ RenderMirrorRooms(49f6e7a06ebc5aa8).();
3475
3476 Num_mirror_roomscxx . . $ Num_mirror_rooms. = 0;
3477
3478 // Render the list of rooms
3479 for (int nn = N_render_roomscxx . . $ N_render_rooms. - 1; nn >= 0; nn--) {
3480 int roomnum;
3481 roomnum = Render_listcxx . . $ Render_list.[nn];
3482 #ifdef _DEBUGcxx . . $ `<built-in>:482:9`!
3483 if (In_editor_modecxx . . $ In_editor_mode. && Render_one_room_onlycxx . . $ Render_one_room_only. && (roomnum != viewer_roomnum))
3484 continue;
3485 #endif
3486 if (roomnum != -1) {
3487 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Rooms_visited[roomnum] != 255);
3488 if (Outline_release_modecxx . . $ Outline_release_mode. & 1) {
3489 RenderRoomOutlinecxx . . $ RenderRoomOutline(cd8c4e8cd0ee4c38).(&Roomscxx . . $ Rooms.[roomnum]);
3490 }
3491 RenderRoomcxx . . $ RenderRoom(cd8c4e8cd0ee4c38).(&Roomscxx . . $ Rooms.[roomnum]);
3492 Rooms_visitedcxx . . $ Rooms_visited.[roomnum] = (char)255;
3493 // Stuff objects into our postrender list
3494 CheckToRenderMineObjectscxx . . $ CheckToRenderMineObjects(d4f767463ce0a6b3).(roomnum);
3495 }
3496 }
3497 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); // turn off lightmap blending
3498 if (Must_render_terraincxx . . $ Must_render_terrain. && !Called_from_terraincxx . . $ Called_from_terrain.)
3499 rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(0);
3500
3501 #ifdef EDITOR
3502 if (OUTLINE_ON(OM_MINE)) {
3503 OutlineCurrentFace(Curroomp, Curface, Curedge, Curvert, CURFACE_COLOR, CUREDGE_COLOR);
3504 if (Markedroomp)
3505 OutlineCurrentFace(Markedroomp, Markedface, Markededge, Markedvert, MARKEDFACE_COLOR, MARKEDEDGE_COLOR);
3506 if (Placed_room != -1)
3507 DrawPlacedRoomFace(&Rooms[Placed_room], &Placed_room_origin, &Placed_room_rotmat, &Placed_room_attachpoint,
3508 Placed_room_face, PLACED_COLOR);
3509 }
3510 #endif
3511 }
3512 // Simply sets the number of glows to zero
3513 void ResetLightGlowscxx . . $ ResetLightGlows(49f6e7a06ebc5aa8).() {
3514 Num_glowscxx . . $ Num_glows. = 0;
3515 for (int i = 0; i < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`!; i++) {
3516 LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. = 0;
3517 }
3518 }
3519 // Renders all the lights glows for this frame
3520 void RenderLightGlowscxx . . $ RenderLightGlows(49f6e7a06ebc5aa8).() {
3521 if (!UseHardwarecxx . . $ UseHardware.)
3522 return;
3523 // Render all the glows for this mine
3524 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.);
3525 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
3526 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.);
3527 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!);
3528 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
3529 rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(0);
3530 int count = 0;
3531
3532 for (int i = 0; i < MAX_LIGHT_GLOWScxx . . $ `Descent3/render.cpp:178:9`! && count < Num_glowscxx . . $ Num_glows.; i++) {
3533 if (LightGlowscxx . . $ LightGlows.[i].flagscxx . . $ light_glow#flags. & LGF_USEDcxx . . $ `Descent3/render.cpp:179:9`!) {
3534 RenderSingleLightGlowcxx . . $ RenderSingleLightGlow(d4f767463ce0a6b3).(i);
3535 count++;
3536 }
3537 }
3538
3539 rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1);
3540 rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1);
3541 }
3542
3543 /*
3544 // Sets fogzone start and end points
3545 void SetFogZoneStart(float z)
3546 {
3547 Fog_zone_start=z;
3548 }
3549 void SetFogZoneEnd (float z)
3550 {
3551 Fog_zone_end=z;
3552 }
3553 g3Point SolidFogPoints[128],AlphaFogPoints[128];
3554 // Adds a point to the fog zone face
3555 void FogClipPoints (g3Point *on_pnt,g3Point *off_pnt,g3Point *dest,float zval,int ending)
3556 {
3557 float z_on,z_off;
3558 float k;
3559 g3Point *tmp=dest;
3560 tmp->p3_flags=0;
3561 z_on=on_pnt->p3_z;
3562 z_off=off_pnt->p3_z;
3563 k = 1.0-((z_off-zval) / (z_off-z_on));
3564 tmp->p3_z = on_pnt->p3_z + ((off_pnt->p3_z-on_pnt->p3_z) * k);
3565
3566 tmp->p3_x = on_pnt->p3_x + ((off_pnt->p3_x-on_pnt->p3_x) * k);
3567 tmp->p3_y = on_pnt->p3_y + ((off_pnt->p3_y-on_pnt->p3_y) * k);
3568 if (on_pnt->p3_flags & PF_UV) {
3569 tmp->p3_u = on_pnt->p3_u + ((off_pnt->p3_u-on_pnt->p3_u) * k);
3570 tmp->p3_v = on_pnt->p3_v + ((off_pnt->p3_v-on_pnt->p3_v) * k);
3571 tmp->p3_flags |= PF_UV;
3572 }
3573 if (on_pnt->p3_flags & PF_UV2) {
3574 tmp->p3_u2 = on_pnt->p3_u2 + ((off_pnt->p3_u2-on_pnt->p3_u2) * k);
3575 tmp->p3_v2 = on_pnt->p3_v2 + ((off_pnt->p3_v2-on_pnt->p3_v2) * k);
3576 tmp->p3_flags |= PF_UV2;
3577 }
3578 if (on_pnt->p3_flags & PF_L) {
3579 tmp->p3_l = on_pnt->p3_l + ((off_pnt->p3_l-on_pnt->p3_l) * k);
3580 tmp->p3_flags |= PF_L;
3581 }
3582 if (on_pnt->p3_flags & PF_RGBA) {
3583 tmp->p3_r = on_pnt->p3_r + ((off_pnt->p3_r-on_pnt->p3_r) * k);
3584 tmp->p3_g = on_pnt->p3_g + ((off_pnt->p3_g-on_pnt->p3_g) * k);
3585 tmp->p3_b = on_pnt->p3_b + ((off_pnt->p3_b-on_pnt->p3_b) * k);
3586 tmp->p3_flags |= PF_RGBA;
3587 }
3588 if (ending)
3589 tmp->p3_a = 0.0;
3590 else
3591 tmp->p3_a = 1.0;
3592 g3_CodePoint(tmp);
3593 }
3594 */
3595
3596 #define STATE_PUSHcxx . . $ `Descent3/render.cpp:3596:9`!(val) \
3597 { \
3598 state_stack[state_stack_counter] = val; \
3599 state_stack_counter++; \
3600 ASSERTcxx . . $ `misc/pserror.h:246:9`!(state_stack_counter < 2000); \
3601 }
3602 #define STATE_POPcxx . . $ `Descent3/render.cpp:3602:9`!() \
3603 { \
3604 state_stack_counter--; \
3605 pop_val = state_stack[state_stack_counter]; \
3606 }
3607 // Sorts our texture states using the quicksort algorithm
3608 void SortStatescxx . . $ SortStates(b1f17b8c50be1530).(state_limited_elementcxx . . $ state_limited_element# *state_array, int cellcount) {
3609 state_limited_elementcxx . . $ state_limited_element# v, t;
3610 int pop_val;
3611 int i, j;
3612 int l, r;
3613 l = 0;
3614 r = cellcount - 1;
3615 uint16_tcxx . . $ uint16_t# state_stack_counter = 0;
3616 uint16_tcxx . . $ uint16_t# state_stack[2000];
3617
3618 while (1) {
3619 while (r > l) {
3620 i = l - 1;
3621 j = r;
3622 v =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). state_array[r];
3623 while (1) {
3624 while (state_array[++i].sort_keycxx . . $ state_limited_element#sort_key. < v.sort_keycxx . . $ state_limited_element#sort_key.)
3625 ;
3626 while (state_array[--j].sort_keycxx . . $ state_limited_element#sort_key. > v.sort_keycxx . . $ state_limited_element#sort_key.)
3627 ;
3628 if (i >= j)
3629 break;
3630 t =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). state_array[i];
3631 state_array[i] =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). state_array[j];
3632 state_array[j] =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). t;
3633 }
3634 t =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). state_array[i];
3635 state_array[i] =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). state_array[r];
3636 state_array[r] =cxx . . $ state_limited_element#`operator=`(cdca3cb490614281). t;
3637
3638 if (i - l > r - i) {
3639 STATE_PUSHcxx . . $ `Descent3/render.cpp:3596:9`!(l);
3640 STATE_PUSHcxx . . $ `Descent3/render.cpp:3596:9`!(i - 1);
3641 l = i + 1;
3642 } else {
3643 STATE_PUSHcxx . . $ `Descent3/render.cpp:3596:9`!(i + 1);
3644 STATE_PUSHcxx . . $ `Descent3/render.cpp:3596:9`!(r);
3645 r = i - 1;
3646 }
3647 }
3648 if (!state_stack_counter)
3649 break;
3650 STATE_POPcxx . . $ `Descent3/render.cpp:3602:9`!();
3651 r = pop_val;
3652 STATE_POPcxx . . $ `Descent3/render.cpp:3602:9`!();
3653 l = pop_val;
3654 }
3655 }
3656 // Builds a list of mirror faces for each room and allocs memory accordingly
3657 void ConsolidateMineMirrorscxx . . $ ConsolidateMineMirrors(49f6e7a06ebc5aa8).() {
3658 int i, t;
3659 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Consolidating mine mirrors!\n");
3660 for (i = 0; i < MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!; i++) {
3661 roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[i];
3662 if (!rp->usedcxx . . $ room#used.)
3663 continue;
3664 if (rp->mirror_faces_listcxx . . $ room#mirror_faces_list.) {
3665 mem_freecxx . . $ `mem/mem.h:80:9`!(rp->mirror_faces_list);
3666 rp->mirror_faces_listcxx . . $ room#mirror_faces_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
3667 rp->num_mirror_facescxx . . $ room#num_mirror_faces. = 0;
3668 }
3669 if (rp->mirror_facecxx . . $ room#mirror_face. == -1)
3670 continue;
3671 // Count the number of faces that have the same texture as the mirror face
3672 int num_mirror_faces = 0;
3673 for (t = 0; t < rp->num_facescxx . . $ room#num_faces.; t++) {
3674 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[t];
3675 if (fp->tmapcxx . . $ face#tmap. == rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap.)
3676 num_mirror_faces++;
3677 }
3678 if (num_mirror_faces == 0) {
3679 // No faces found? Weird.
3680 rp->mirror_facecxx . . $ room#mirror_face. = 0;
3681 continue;
3682 }
3683 rp->mirror_faces_listcxx . . $ room#mirror_faces_list. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(num_mirror_faces * sizeof(uint16_t));
3684 ASSERTcxx . . $ `misc/pserror.h:246:9`!(rp->mirror_faces_list);
3685 rp->num_mirror_facescxx . . $ room#num_mirror_faces. = num_mirror_faces;
3686 // Now go through and fill in our list
3687 int count = 0;
3688 for (t = 0; t < rp->num_facescxx . . $ room#num_faces.; t++) {
3689 facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[t];
3690 if (fp->tmapcxx . . $ face#tmap. == rp->facescxx . . $ room#faces.[rp->mirror_facecxx . . $ room#mirror_face.].tmapcxx . . $ face#tmap.)
3691 rp->mirror_faces_listcxx . . $ room#mirror_faces_list.[count++] = t;
3692 }
3693 }
3694 }
3695
3696 /*
3697 // Takes a face and adds the appropriate vertices for drawing in the fog zone
3698 // Returns number of points in new polygon
3699 // New polygon points are in FogPoints array
3700 int FogBlendFace (g3Point **src,int nv,int *num_solid,int *num_alpha)
3701 {
3702 int alpha_nv=0,solid_nv=0,temp_nv=0;
3703 g3Point temp_buf[128],temp_pnt;
3704 float fog_zone_range=Fog_zone_end-Fog_zone_start;
3705 int i;
3706
3707 for (i=0;i<nv;i++)
3708 {
3709 int next=(i+1)%nv;
3710 int prev=i-1;
3711 if (prev<0)
3712 prev=nv-1;
3713 g3Point *thispnt=src[i];
3714 g3Point *nextpnt=src[next];
3715 g3Point *prevpnt=src[prev];
3716 if (thispnt->p3_z>Fog_zone_end)
3717 {
3718 if (prevpnt->p3_z<Fog_zone_end)
3719 {
3720 FogClipPoints (prevpnt,thispnt,&temp_buf[temp_nv],Fog_zone_end,1);
3721 temp_nv++;
3722 }
3723 if (nextpnt->p3_z<Fog_zone_end)
3724 {
3725 FogClipPoints (nextpnt,thispnt,&temp_buf[temp_nv],Fog_zone_end,1);
3726 temp_nv++;
3727 }
3728 }
3729 else
3730 {
3731 temp_buf[temp_nv]=*thispnt;
3732 temp_buf[temp_nv].p3_a=0;
3733 temp_nv++;
3734 }
3735 }
3736 // At this stage all vertices are clipped to be nearer that Fog_zone_end
3737 nv=temp_nv;
3738 for (i=0;i<nv;i++)
3739 {
3740 int next=(i+1)%nv;
3741 int prev=i-1;
3742 if (prev<0)
3743 prev=nv-1;
3744 g3Point *thispnt=&temp_buf[i];
3745 g3Point *nextpnt=&temp_buf[next];
3746 g3Point *prevpnt=&temp_buf[prev];
3747 if (thispnt->p3_z>Fog_zone_start)
3748 {
3749 if (prevpnt->p3_z<Fog_zone_start)
3750 {
3751 FogClipPoints (prevpnt,thispnt,&temp_pnt,Fog_zone_start,0);
3752 SolidFogPoints[solid_nv]=temp_pnt;
3753 solid_nv++;
3754 AlphaFogPoints[alpha_nv]=temp_pnt;
3755 alpha_nv++;
3756 }
3757 // Add this point to the list
3758 //---------------------------
3759 float alpha=1.0-((thispnt->p3_z-Fog_zone_start)/fog_zone_range);
3760 if (alpha<0)
3761 alpha=0;
3762 ASSERT (alpha<=1.0);
3763 AlphaFogPoints[alpha_nv]=*thispnt;
3764 AlphaFogPoints[alpha_nv].p3_a=alpha;
3765 alpha_nv++;
3766 //------------------------------
3767 if (nextpnt->p3_z<Fog_zone_start)
3768 {
3769 FogClipPoints (nextpnt,thispnt,&temp_pnt,Fog_zone_start,0);
3770 SolidFogPoints[solid_nv]=temp_pnt;
3771 solid_nv++;
3772 AlphaFogPoints[alpha_nv]=temp_pnt;
3773 alpha_nv++;
3774
3775 }
3776 }
3777 else
3778 {
3779 SolidFogPoints[solid_nv]=*thispnt;
3780 SolidFogPoints[solid_nv].p3_a=1.0;
3781 solid_nv++;
3782 }
3783 }
3784 *num_alpha=alpha_nv;
3785 *num_solid=solid_nv;
3786 return (solid_nv>0);
3787 }
3788 */
3789
3790 // RenderBlankScreen
3791 // Renders a blank screen, to be used for UI callbacks to prevent Hall of mirrors with mouse cursor
3792 void RenderBlankScreencxx . . $ RenderBlankScreen(49f6e7a06ebc5aa8).(void) { rend_ClearScreencxx . . $ rend_ClearScreen(cb2f890c2fdad230).(GR_BLACKcxx . . $ GR_BLACK.); }
3793 #ifdef EDITOR
3794 // Finds what room & face is visible at a given screen x & y
3795 // Everything must be set up just like for RenderMineRoom(), and presumably is the same as
3796 // for the last frame rendered (though it doesn't have to be)
3797 // Parameters: x,y - the screen coordinates
3798 // start_roomnum - where to start rendering
3799 // roomnum,facenum - these are filled in with the found values
3800 // if room<0, then an object was found, and the object number is -room-1
3801 // Returns: 1 if found a room, else 0
3802 /*int FindRoomFace(int16_t x,int16_t y,int start_roomnum,int *roomnum,int *facenum)
3803 {
3804 //Init search mode
3805 search_mode = -1;
3806 search_x = x; search_y = y;
3807 found_room = INT_MAX;
3808 //Render and search
3809 RenderMine(start_roomnum,0,0);
3810 //Turn search off
3811 search_mode = 0;
3812 //Set return values
3813 *roomnum = found_room;
3814 *facenum = found_face;
3815 return (found_room != INT_MAX);
3816 }*/
3817 // finds what room,face,lumel is visible at a given screen x & y
3818 // Everything must be set up just like for RenderMineRoom(), and presumably is the same as
3819 // for the last frame rendered (though it doesn't have to be)
3820 // Parameters: x,y - the screen coordinates
3821 // start_roomnum - where to start rendering
3822 // roomnum,facenum,lumel_num - these are filled in with the found values
3823 // Returns: 1 if found a room, else 0
3824 /*int FindLightmapFace(int16_t x,int16_t y,int start_roomnum,int *roomnum,int *facenum,int *lumel_num)
3825 {
3826 Search_lightmaps=1;
3827 search_x = x; search_y = y;
3828 found_room = INT_MAX;
3829 //Get the width & height of the render window
3830 rend_GetProjectionParameters(&Render_width,&Render_height);
3831 RenderMine(start_roomnum,0,0);
3832 Search_lightmaps=0;
3833 *roomnum = found_room;
3834 *facenum = found_face;
3835 *lumel_num=found_lightmap;
3836 return (found_room != INT_MAX);
3837 }*/
3838 #endif