| 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/scorch.cpp $ |
| 21 | * $Revision: 20 $ |
| 22 | * $Date: 5/13/99 3:42p $ |
| 23 | * $Author: Ardussi $ |
| 24 | * |
| 25 | * System for drawing scorch marks on walls |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/scorch.cpp $ |
| 28 | * |
| 29 | * 20 5/13/99 3:42p Ardussi |
| 30 | * changes for compiling on the Mac |
| 31 | * |
| 32 | * 19 4/30/99 12:10p Matt |
| 33 | * Don't add a scorch if it will overlap an edge of a face. |
| 34 | * |
| 35 | * 18 4/21/99 11:05a Kevin |
| 36 | * new ps_rand and ps_srand to replace rand & srand |
| 37 | * |
| 38 | * 17 4/16/99 11:31p Jeff |
| 39 | * added max() for Linux |
| 40 | * |
| 41 | * 16 1/26/99 5:06p Jason |
| 42 | * no scorch marks on procedurals |
| 43 | * |
| 44 | * 15 1/21/99 11:15p Jeff |
| 45 | * pulled out some structs and defines from header files and moved them |
| 46 | * into seperate header files so that multiplayer dlls don't require major |
| 47 | * game headers, just those new headers. Side effect is a shorter build |
| 48 | * time. Also cleaned up some header file #includes that weren't needed. |
| 49 | * This affected polymodel.h, object.h, player.h, vecmat.h, room.h, |
| 50 | * manage.h and multi.h |
| 51 | * |
| 52 | * 14 12/10/98 12:27p Jason |
| 53 | * added cooler specular mapping for objects |
| 54 | * |
| 55 | * 13 12/03/98 12:26p Jason |
| 56 | * fixed some scorch slowdowns with direct3d |
| 57 | * |
| 58 | * 12 6/24/98 10:19p Matt |
| 59 | * When too many scorches per face, don't add new ones, rather than not |
| 60 | * drawing old ones. |
| 61 | * |
| 62 | * 11 5/26/98 6:15p Matt |
| 63 | * Cleaned up and finished scorch mark limiting code. |
| 64 | * |
| 65 | * 10 5/26/98 3:59p Jason |
| 66 | * added LIGHTMAP_BLEND_CONSTANT alpha type |
| 67 | * |
| 68 | * 9 5/26/98 2:38p Matt |
| 69 | * Added code (not really done yet) to fade out far-away marks, and to |
| 70 | * limit the number of marks drawn. |
| 71 | * |
| 72 | * 8 5/25/98 8:36p Matt |
| 73 | * Added code to set different sizes for different weapon scorch marks. |
| 74 | * Also, don't leave scorch marks on lights. |
| 75 | * |
| 76 | * 7 5/22/98 5:58p Matt |
| 77 | * Bail (for now) if try to make a scorch mark on the ground. |
| 78 | * |
| 79 | * 6 5/22/98 5:20p Matt |
| 80 | * Added randomized rotations for scorces |
| 81 | * |
| 82 | * 5 5/22/98 4:32p Jason |
| 83 | * fixed stupid z buffer write mask bug |
| 84 | * |
| 85 | * 4 5/22/98 3:57p Jason |
| 86 | * fixed a zbuffer problem with scorches |
| 87 | * |
| 88 | * 3 5/22/98 1:16p Matt |
| 89 | * Fixed stupid bug |
| 90 | * |
| 91 | * 2 5/22/98 12:34p Matt |
| 92 | * Added scorch mark/bullet hole system. |
| 93 | * |
| 94 | * 1 5/21/98 11:32p Matt |
| 95 | * |
| 96 | */ |
| 97 | |
| 98 | #include <stdlib.h> |
| 99 | |
| 100 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 101 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 102 | #include "3d.h"cxx . . $ `<file>/lib/3d.h`/ |
| 103 | #include "scorch.h"cxx . . $ `<file>/Descent3/scorch.h`/ |
| 104 | #include "room.h"cxx . . $ `<file>/Descent3/room.h`/ |
| 105 | #include "config.h"cxx . . $ `<file>/Descent3/config.h`/ |
| 106 | #include "object_external_struct.h"cxx . . $ `<file>/lib/object_external_struct.h`/ //for ROOMNUM_OUTSIDE macro |
| 107 | #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/ |
| 108 | |
| 109 | #include <algorithm> |
| 110 | |
| 111 | // Structure for storing scorch marks |
| 112 | struct scorchcxx . . $ scorch# { |
| 113 | int roomfacecxx . . $ scorch#roomface.; // room number & face number combined into an int |
| 114 | vectorcxx . . $ vector# poscxx . . $ scorch#pos.; // the position of the center of the scorch mark |
| 115 | uint8_tcxx . . $ uint8_t# handle_indexcxx . . $ scorch#handle_index.; // which mark? |
| 116 | int8_t rxcxx . . $ scorch#rx., rycxx . . $ scorch#ry., rzcxx . . $ scorch#rz.; // right vector |
| 117 | int8_t uxcxx . . $ scorch#ux., uycxx . . $ scorch#uy., uzcxx . . $ scorch#uz.; // up vector |
| 118 | uint8_tcxx . . $ uint8_t# sizecxx . . $ scorch#size.; // floating-point size times 16 |
| 119 | }; |
| 120 | |
| 121 | // How many scorch marks |
| 122 | #define MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`! 500 |
| 123 | |
| 124 | // Buffer of scorch marks |
| 125 | scorchcxx . . $ scorch# Scorchescxx . . $ Scorches.[MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!]; |
| 126 | |
| 127 | // Indices into scorch buffer. Start is oldest item, end is newest item |
| 128 | int Scorch_startcxx . . $ Scorch_start., Scorch_endcxx . . $ Scorch_end.; |
| 129 | |
| 130 | // Bitmap handles for scorches |
| 131 | #define MAX_SCORCH_TEXTUREScxx . . $ `Descent3/scorch.cpp:131:9`! 10 |
| 132 | int Num_scorch_texturescxx . . $ Num_scorch_textures. = 0; |
| 133 | int Scorch_texture_handlescxx . . $ Scorch_texture_handles.[MAX_SCORCH_TEXTUREScxx . . $ `Descent3/scorch.cpp:131:9`!]; |
| 134 | |
| 135 | // Pack & unpack roomnum & facenum into an int |
| 136 | #define ROOMFACEcxx . . $ `Descent3/scorch.cpp:136:9`!(r, f) ((r << 16) + f) |
| 137 | #define RF_ROOMcxx . . $ `Descent3/scorch.cpp:137:9`!(rf) (rf >> 16) |
| 138 | #define RF_FACEcxx . . $ `Descent3/scorch.cpp:138:9`!(rf) (rf & 0xffff) |
| 139 | |
| 140 | // Value used to limit the number of scorches drawn per face |
| 141 | #define MAX_VIS_COUNTcxx . . $ `Descent3/scorch.cpp:141:9`! 30 |
| 142 | |
| 143 | // Called when a new level is started to reset the scorch list |
| 144 | void ResetScorchescxx . . $ ResetScorches(49f6e7a06ebc5aa8).() { Scorch_startcxx . . $ Scorch_start. = Scorch_endcxx . . $ Scorch_end. = -1; } |
| 145 | |
| 146 | // Delete the specified scorch mark |
| 147 | void DeleteScorchcxx . . $ DeleteScorch(d4f767463ce0a6b3).(int index) { |
| 148 | int roomface = Scorchescxx . . $ Scorches.[index].roomfacecxx . . $ scorch#roomface.; |
| 149 | scorchcxx . . $ scorch# *sp; |
| 150 | int i; |
| 151 | |
| 152 | // mprintf(0,"Deleting scorch %d\n",index); |
| 153 | |
| 154 | // Look through all the scorches to see if there are other scorches on the same face |
| 155 | for (i = Scorch_startcxx . . $ Scorch_start., sp = &Scorchescxx . . $ Scorches.[Scorch_startcxx . . $ Scorch_start.];;) { |
| 156 | |
| 157 | if ((sp->roomfacecxx . . $ scorch#roomface. == roomface) && (i != index)) // Found another scorch |
| 158 | return; |
| 159 | |
| 160 | // Check for end of loop |
| 161 | if (i == Scorch_endcxx . . $ Scorch_end.) |
| 162 | break; |
| 163 | |
| 164 | // Increment & wrap |
| 165 | if (++i == MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!) { |
| 166 | i = 0; |
| 167 | sp = Scorchescxx . . $ Scorches.; |
| 168 | } else |
| 169 | sp++; |
| 170 | } |
| 171 | |
| 172 | // If we're here, there are no other scorches on the face, so clear the flag |
| 173 | Roomscxx . . $ Rooms.[RF_ROOMcxx . . $ `Descent3/scorch.cpp:137:9`!(roomface)].facescxx . . $ room#faces.[RF_FACEcxx . . $ `Descent3/scorch.cpp:138:9`!(roomface)].flagscxx . . $ face#flags. &= ~FF_SCORCHEDcxx . . $ `Descent3/room_external.h:127:9`!; |
| 174 | // mprintf(0,"Clearing scorch flag from %d:%d\n",RF_ROOM(roomface),RF_FACE(roomface)); |
| 175 | } |
| 176 | |
| 177 | // Add a scorch mark |
| 178 | // Parameters: roomnum,facenum - the face that the scorch is on |
| 179 | // pos - where the scorch goes |
| 180 | // texture_handle - the texture for the scorch mark |
| 181 | // size - how big the scorch is |
| 182 | void AddScorchcxx . . $ AddScorch(f3438a7ee3e74b15).(int roomnum, int facenum, vectorcxx . . $ vector# *pos, int texture_handle, float size) { |
| 183 | // Bail if on terrain. We should probably add support for this later. |
| 184 | if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(roomnum)) |
| 185 | return; |
| 186 | |
| 187 | roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[roomnum]; |
| 188 | facecxx . . $ face# *fp = &rp->facescxx . . $ room#faces.[facenum]; |
| 189 | |
| 190 | // Check if face is a light, and if so don't add the scorch |
| 191 | if (GameTexturescxx . . $ GameTextures.[fp->tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. & (TF_LIGHTcxx . . $ `Descent3/gametexture.h:220:9`! | TF_PROCEDURALcxx . . $ `Descent3/gametexture.h:225:9`!)) |
| 192 | return; |
| 193 | |
| 194 | int roomface = ROOMFACEcxx . . $ `Descent3/scorch.cpp:136:9`!(roomnum, facenum); |
| 195 | |
| 196 | // Count the number of scorches on this face, and bail if already at max |
| 197 | int count = 0; |
| 198 | int i; |
| 199 | scorchcxx . . $ scorch# *sp; |
| 200 | for (i = Scorch_startcxx . . $ Scorch_start., sp = &Scorchescxx . . $ Scorches.[Scorch_startcxx . . $ Scorch_start.];;) { |
| 201 | float size = (float)sp->sizecxx . . $ scorch#size. / 16.0; |
| 202 | |
| 203 | // Increment count, and stop drawing if hit limit |
| 204 | if (sp->roomfacecxx . . $ scorch#roomface. == roomface) { // Found one! |
| 205 | count += stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).((int)size, 1); // count large marks more |
| 206 | if (count >= MAX_VIS_COUNTcxx . . $ `Descent3/scorch.cpp:141:9`!) |
| 207 | return; |
| 208 | } |
| 209 | |
| 210 | // Check for end of loop |
| 211 | if (i == Scorch_endcxx . . $ Scorch_end.) |
| 212 | break; |
| 213 | |
| 214 | // Increment & wrap |
| 215 | if (++i == MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!) { |
| 216 | i = 0; |
| 217 | sp = Scorchescxx . . $ Scorches.; |
| 218 | } else |
| 219 | sp++; |
| 220 | } |
| 221 | |
| 222 | // Check for scorch going off the edge of the face, and bail if does |
| 223 | vectorcxx . . $ vector# *v0, *v1 = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[fp->num_vertscxx . . $ face#num_verts. - 1]]; |
| 224 | for (int v = 0; v < fp->num_vertscxx . . $ face#num_verts.; v++) { |
| 225 | vectorcxx . . $ vector# edgevec, checkvec, checkp; |
| 226 | float dot, dist; |
| 227 | |
| 228 | v0 = v1; |
| 229 | v1 = &rp->vertscxx . . $ room#verts.[fp->face_vertscxx . . $ face#face_verts.[v]]; |
| 230 | vm_GetNormalizedDircxx . . $ vm_GetNormalizedDir(94d642bbc45232c7).(&edgevec, v1, v0); |
| 231 | |
| 232 | checkvec =cxx . . $ vector#`operator=`(c0842353a20857d). *pos -cxx . . $ operator-(b77b703cd1e43e33). *v0; |
| 233 | dot = checkvec *cxx . . $ `operator*`(4a721543d64e126a). edgevec; |
| 234 | checkp =cxx . . $ vector#`operator=`(c0842353a20857d). *v0 +cxx . . $ operator+(b77b703cd1e43e33). edgevec *cxx . . $ `operator*`(252247219a31502c). dot; |
| 235 | dist = vm_VectorDistancecxx . . $ vm_VectorDistance(e65d563e2b53cc54).(&checkp, pos); |
| 236 | if (dist < size) |
| 237 | return; |
| 238 | } |
| 239 | |
| 240 | // Get next item in circular list, freeing oldest item if necessary |
| 241 | int new_end = Scorch_endcxx . . $ Scorch_end. + 1; |
| 242 | if (new_end == MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!) |
| 243 | new_end = 0; |
| 244 | if (new_end == Scorch_startcxx . . $ Scorch_start.) { |
| 245 | DeleteScorchcxx . . $ DeleteScorch(d4f767463ce0a6b3).(Scorch_startcxx . . $ Scorch_start.); |
| 246 | Scorch_startcxx . . $ Scorch_start.++; |
| 247 | if (Scorch_startcxx . . $ Scorch_start. == MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!) |
| 248 | Scorch_startcxx . . $ Scorch_start. = 0; |
| 249 | } |
| 250 | Scorch_endcxx . . $ Scorch_end. = new_end; |
| 251 | if (Scorch_startcxx . . $ Scorch_start. == -1) |
| 252 | Scorch_startcxx . . $ Scorch_start. = 0; |
| 253 | |
| 254 | // Get a pointer to our struct |
| 255 | sp = &Scorchescxx . . $ Scorches.[Scorch_endcxx . . $ Scorch_end.]; |
| 256 | |
| 257 | // Fill in the data |
| 258 | sp->roomfacecxx . . $ scorch#roomface. = roomface; |
| 259 | sp->poscxx . . $ scorch#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *pos; |
| 260 | ASSERTcxx . . $ `misc/pserror.h:246:9`!((size >= 0.0) && (size < 15.0)); |
| 261 | sp->sizecxx . . $ scorch#size. = size * 16.0; |
| 262 | |
| 263 | int handle_index; |
| 264 | |
| 265 | // Get index for handle |
| 266 | for (handle_index = 0; handle_index < Num_scorch_texturescxx . . $ Num_scorch_textures.; handle_index++) |
| 267 | if (Scorch_texture_handlescxx . . $ Scorch_texture_handles.[handle_index] == texture_handle) |
| 268 | break; |
| 269 | if (handle_index == Num_scorch_texturescxx . . $ Num_scorch_textures.) { // didn't find one, so add |
| 270 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_scorch_textures < MAX_SCORCH_TEXTUREScxx . . $ `Descent3/scorch.cpp:131:9`!); |
| 271 | Scorch_texture_handlescxx . . $ Scorch_texture_handles.[handle_index] = texture_handle; |
| 272 | Num_scorch_texturescxx . . $ Num_scorch_textures.++; |
| 273 | } |
| 274 | sp->handle_indexcxx . . $ scorch#handle_index. = handle_index; |
| 275 | |
| 276 | // Calculate the vectors |
| 277 | matrixcxx . . $ matrix# m; |
| 278 | vm_VectorAngleToMatrixcxx . . $ vm_VectorAngleToMatrix(1c1ac24c6c4d340f).(&m, &fp->normalcxx . . $ face#normal., ps_randcxx . . $ ps_rand(b126dc7c1de90089).() * 2); |
| 279 | |
| 280 | // Store the vectors as signed 8-bit values |
| 281 | sp->rxcxx . . $ scorch#rx. = -m.rveccxx . . $ matrix#rvec..xcxx . . $ vector#x. * 127; |
| 282 | sp->rycxx . . $ scorch#ry. = -m.rveccxx . . $ matrix#rvec..ycxx . . $ vector#y. * 127; |
| 283 | sp->rzcxx . . $ scorch#rz. = -m.rveccxx . . $ matrix#rvec..zcxx . . $ vector#z. * 127; |
| 284 | |
| 285 | sp->uxcxx . . $ scorch#ux. = m.uveccxx . . $ matrix#uvec..xcxx . . $ vector#x. * 127; |
| 286 | sp->uycxx . . $ scorch#uy. = m.uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. * 127; |
| 287 | sp->uzcxx . . $ scorch#uz. = m.uveccxx . . $ matrix#uvec..zcxx . . $ vector#z. * 127; |
| 288 | |
| 289 | // Flag this face as being scorched |
| 290 | fp->flagscxx . . $ face#flags. |= FF_SCORCHEDcxx . . $ `Descent3/room_external.h:127:9`!; |
| 291 | } |
| 292 | |
| 293 | // The UVs for the blob bitmap |
| 294 | structcxx . . $ $anonymous_type_8b098f90457fef30_0# { |
| 295 | float ucxx . . $ $anonymous_type_8b098f90457fef30_0#u., vcxx . . $ $anonymous_type_8b098f90457fef30_0#v.; |
| 296 | } scorch_uvscxx . . $ scorch_uvs.[4] = {{0.0, 0.0}, {1.0, 0.0}, {1.0, 1.0}, {0.0, 1.0}}; |
| 297 | |
| 298 | // Values used to get rid of far-away scorches |
| 299 | #define MAX_VIS_DISTANCEcxx . . $ `Descent3/scorch.cpp:299:9`! 200 // if mark farther than this, don't draw |
| 300 | #define FADE_START_DISTANCEcxx . . $ `Descent3/scorch.cpp:300:9`! 170 // when mark is this far away, start fading |
| 301 | |
| 302 | // Draw the scorch(es) for a given face |
| 303 | void DrawScorchescxx . . $ DrawScorches(3e454b8ccf442868).(int roomnum, int facenum) { |
| 304 | int i; |
| 305 | scorchcxx . . $ scorch# *sp; |
| 306 | |
| 307 | if (!Detail_settingscxx . . $ Detail_settings..Scorches_enabledcxx . . $ tDetailSettings#Scorches_enabled.) |
| 308 | return; |
| 309 | |
| 310 | int roomface = ROOMFACEcxx . . $ `Descent3/scorch.cpp:136:9`!(roomnum, facenum); |
| 311 | |
| 312 | // Set alpha, transparency, & lighting for this face |
| 313 | if (!StateLimitedcxx . . $ StateLimited.) { |
| 314 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!); |
| 315 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 316 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 317 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 318 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 319 | rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(-.5); |
| 320 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0); |
| 321 | |
| 322 | // Select texture type |
| 323 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.); |
| 324 | } |
| 325 | |
| 326 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Scorch_end != -1); |
| 327 | |
| 328 | // Loop through all the scorches, and draw the ones for this face |
| 329 | for (i = Scorch_startcxx . . $ Scorch_start., sp = &Scorchescxx . . $ Scorches.[Scorch_startcxx . . $ Scorch_start.];;) { |
| 330 | |
| 331 | if (sp->roomfacecxx . . $ scorch#roomface. == roomface) { // Found one! |
| 332 | vectorcxx . . $ vector# right, up; |
| 333 | vectorcxx . . $ vector# corners[4]; |
| 334 | g3Pointcxx . . $ g3Point# points[4]; |
| 335 | g3Pointcxx . . $ g3Point# *pointlist[4]; |
| 336 | float size = (float)sp->sizecxx . . $ scorch#size. / 16.0; |
| 337 | |
| 338 | // Don't draw mark if too far away, and make smaller those marks that are almost too far |
| 339 | float depth = g3_CalcPointDepthcxx . . $ g3_CalcPointDepth(4939a7e530383cd4).(&sp->poscxx . . $ scorch#pos.); |
| 340 | if (depth > MAX_VIS_DISTANCEcxx . . $ `Descent3/scorch.cpp:299:9`!) |
| 341 | goto skip_draw; |
| 342 | if (depth > FADE_START_DISTANCEcxx . . $ `Descent3/scorch.cpp:300:9`!) |
| 343 | size *= 1.0 - ((depth - FADE_START_DISTANCEcxx . . $ `Descent3/scorch.cpp:300:9`!) / (MAX_VIS_DISTANCEcxx . . $ `Descent3/scorch.cpp:299:9`! - FADE_START_DISTANCEcxx . . $ `Descent3/scorch.cpp:300:9`!)); |
| 344 | |
| 345 | // Calculate vectors to corners |
| 346 | right.xcxx . . $ vector#x. = (float)sp->rxcxx . . $ scorch#rx. * (size / 127.0); |
| 347 | right.ycxx . . $ vector#y. = (float)sp->rycxx . . $ scorch#ry. * (size / 127.0); |
| 348 | right.zcxx . . $ vector#z. = (float)sp->rzcxx . . $ scorch#rz. * (size / 127.0); |
| 349 | |
| 350 | up.xcxx . . $ vector#x. = (float)sp->uxcxx . . $ scorch#ux. * (size / 127.0); |
| 351 | up.ycxx . . $ vector#y. = (float)sp->uycxx . . $ scorch#uy. * (size / 127.0); |
| 352 | up.zcxx . . $ vector#z. = (float)sp->uzcxx . . $ scorch#uz. * (size / 127.0); |
| 353 | |
| 354 | // Compute four corners |
| 355 | corners[0] =cxx . . $ vector#`operator=`(c0842353a20857d). sp->poscxx . . $ scorch#pos. -cxx . . $ operator-(b77b703cd1e43e33). right +cxx . . $ operator+(b77b703cd1e43e33). up; |
| 356 | corners[1] =cxx . . $ vector#`operator=`(c0842353a20857d). sp->poscxx . . $ scorch#pos. +cxx . . $ operator+(b77b703cd1e43e33). right +cxx . . $ operator+(b77b703cd1e43e33). up; |
| 357 | corners[2] =cxx . . $ vector#`operator=`(c0842353a20857d). sp->poscxx . . $ scorch#pos. +cxx . . $ operator+(b77b703cd1e43e33). right -cxx . . $ operator-(b77b703cd1e43e33). up; |
| 358 | corners[3] =cxx . . $ vector#`operator=`(c0842353a20857d). sp->poscxx . . $ scorch#pos. -cxx . . $ operator-(b77b703cd1e43e33). right -cxx . . $ operator-(b77b703cd1e43e33). up; |
| 359 | |
| 360 | // Rotate the points. Set uv values |
| 361 | for (int p = 0; p < 4; p++) { |
| 362 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&points[p], &corners[p]); |
| 363 | pointlist[p] = &points[p]; |
| 364 | points[p].p3_uvlcxx . . $ g3Point#p3_uvl..ucxx . . $ g3UVL#u. = scorch_uvscxx . . $ scorch_uvs.[p].ucxx . . $ $anonymous_type_8b098f90457fef30_0#u.; |
| 365 | points[p].p3_uvlcxx . . $ g3Point#p3_uvl..vcxx . . $ g3UVL#v. = scorch_uvscxx . . $ scorch_uvs.[p].vcxx . . $ $anonymous_type_8b098f90457fef30_0#v.; |
| 366 | points[p].p3_lcxx . . $ `lib/3d.h:252:9`! = 1.0; |
| 367 | points[p].p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_Lcxx . . $ `lib/3d.h:218:9`!; |
| 368 | } |
| 369 | |
| 370 | // Get the bitmap handle |
| 371 | int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(Scorch_texture_handlescxx . . $ Scorch_texture_handles.[sp->handle_indexcxx . . $ scorch#handle_index.], 0); |
| 372 | |
| 373 | // Draw the polygon |
| 374 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pointlist, bm_handle); |
| 375 | } |
| 376 | skip_draw:; |
| 377 | |
| 378 | // Check for end of loop |
| 379 | if (i == Scorch_endcxx . . $ Scorch_end.) |
| 380 | break; |
| 381 | |
| 382 | // Increment & wrap |
| 383 | if (++i == MAX_SCORCHEScxx . . $ `Descent3/scorch.cpp:122:9`!) { |
| 384 | i = 0; |
| 385 | sp = Scorchescxx . . $ Scorches.; |
| 386 | } else |
| 387 | sp++; |
| 388 | } |
| 389 | |
| 390 | // Reset rendering states |
| 391 | if (!StateLimitedcxx . . $ StateLimited.) { |
| 392 | rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(0); |
| 393 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1); |
| 394 | } |
| 395 | } |