Debian Codegraph @

model/polymodel.cpp

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
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/model/polymodel.cpp $
21 * $Revision: 152 $
22 * $Date: 10/08/01 4:20p $
23 * $Author: Matt $
24 *
25 * Jason should put something here
26 *
27 * $Log: /DescentIII/Main/model/polymodel.cpp $
28 *
29 * 152 10/08/01 4:20p Matt
30 * Added system to check for errors when reading in add-on data.
31 *
32 * 151 10/01/01 1:58p Matt
33 * In release build, Increment the used count when loading a model that's
34 * already in memory. This was already done in non-release builds.
35 *
36 * 150 5/10/00 2:43p Jeff
37 * fixed bug when paging in data if the tablefile specifies a full path to
38 * a primative instead of just a filename (bug in 3rd party tablefile
39 * editors)
40 *
41 * 149 4/19/00 5:34p Matt
42 * From Duane for 1.4
43 * Check for glow_info memory already allocated before mallocing
44 *
45 * 148 10/21/99 2:40p Kevin
46 * Mac merge
47 *
48 * 147 10/16/99 6:40p Jeff
49 * swaped way of determining textures for objects on load
50 *
51 * 146 10/14/99 3:02p Jeff
52 * correctly look up texture names
53 *
54 * 145 7/08/99 5:48p Jason
55 * changes for new bumpmapping system in 1.1 update patch
56 *
57 * 144 6/08/99 1:00p Jason
58 * changes for bumpmapping
59 *
60 * 143 5/18/99 10:31a Jason
61 * polymodel stuff wasn't getting paged in before drawing
62 *
63 * 142 5/14/99 2:04p Jason
64 * added polymodel errors to catch bugs
65 *
66 * 141 4/28/99 1:55a Samir
67 * error instead of assert when we can't open a model for paging in a
68 * polymodel.
69 *
70 * 140 4/19/99 3:50p Jeff
71 * fixed mem_free/copy-paste bug, wasn't setting the correct pointer to
72 * NULL after free
73 *
74 * 139 4/19/99 4:00a Jeff
75 * fixed min/max for Linux
76 *
77 * 138 4/09/99 12:51p Jason
78 * fixed bug with new lookup code
79 *
80 * 137 4/09/99 12:06p Jason
81 * made model setup code faster
82 *
83 * 136 4/08/99 11:45a Jason
84 * greatly sped up the time it takes to get model anges/positions by
85 * precalculation
86 *
87 * 135 3/05/99 11:24a Jason
88 * fixed pesky no-lightmap drawing problem that has plagued me for the
89 * last 10 months
90 *
91 * 134 2/16/99 12:42p Kevin
92 * Improvements to the paging data progress indicator
93 *
94 * 133 2/10/99 4:58p Jeff
95 * put assert if pageinpolymodel file open fails
96 *
97 * 132 2/09/99 7:01p Kevin
98 * First work for new and improved progress screen while loading a level.
99 * Note that this is a hack at this point, while I get the details worked
100 * out, then I'll make it cleaner.
101 *
102 * 131 1/15/99 3:04p Jason
103 * fixed polymodel data freeing problem
104 *
105 * 130 1/13/99 12:43p Jason
106 * added some more detail settings
107 *
108 * 129 10/16/98 1:54p Kevin
109 * Changes for Demo Beta 4
110 *
111 * 128 10/13/98 5:25p Jason
112 * fixed zero faced submodel problem
113 *
114 * 127 10/12/98 10:59a Jason
115 * fixed zero length malloc
116 *
117 * 126 10/12/98 9:35a Jason
118 * New polymodel memory scheme
119 *
120 * 125 10/08/98 4:24p Kevin
121 * Changed code to comply with memory library usage. Always use mem_malloc
122 * , mem_free and mem_strdup
123 *
124 * 124 10/08/98 2:27p Jason
125 * sped up table file loading
126 *
127 * 123 10/07/98 5:29p Chris
128 * Added SOF_THRUSTER support
129 *
130 * 122 10/07/98 3:40p Chris
131 * Added $thruster
132 *
133 * 121 9/11/98 4:04p Jason
134 * added better multitexture support
135 *
136 * 120 8/27/98 11:16a Jason
137 * fixed math bug in GetPolymodelPointInWorld
138 *
139 * 119 8/25/98 12:22p Jason
140 * more changes for cockpits
141 *
142 * 118 8/24/98 6:43p Keneta
143 * Long proofed the turrets and weapon batteries
144 *
145 * 117 8/24/98 2:44p Jason
146 * checked in so Samir can test
147 *
148 * 116 8/21/98 5:14p Jason
149 * made better memory use of primitives
150 *
151 * 115 8/18/98 11:38a Jason
152 * fixed polymodel fog lighting
153 *
154 * 114 8/18/98 11:26a Matt
155 * Changed outline code to only outline polymodel objects when they're
156 * being rendered in the mine, and not when they're being drawn in the
157 * editor, main menu, cockpit, etc.
158 *
159 * 113 8/17/98 12:10p Chris
160 * Fixed MAJOR bug in getting gunpoint positions
161 *
162 * 112 8/16/98 9:52p Chris
163 * Added some error checking for the attach system
164 *
165 * 111 8/14/98 4:00p Jason
166 * added specular objects outside
167 *
168 * 110 8/13/98 6:56p Jason
169 * made objects foggable correctly
170 *
171 * 109 8/12/98 12:04p Chris
172 * Attach system version .5 (still needs more work to be multiplayer
173 * friendly)
174 *
175 * 108 8/07/98 2:49p Keneta
176 * fixed number of subobjects assertion
177 *
178 * 107 8/04/98 2:32p Chris
179 * Improved attach code added more fixes to the AABB partial computation
180 * patch
181 *
182 * 106 7/31/98 11:52a Chris
183 * Weapons can be persistent. Added ability for objects to be manually
184 * set for no object collisions.
185 *
186 * 105 7/30/98 1:13p Chris
187 * Improved attach point code
188 *
189 * 104 7/29/98 5:05p Chris
190 * Made more of the wb info dynamically allocated. Added Attach points to
191 * the polymodel structure
192 *
193 * 103 7/27/98 10:39a Jason
194 * added customizable skins
195 *
196 * 102 7/02/98 2:49p Chris
197 *
198 * 101 7/02/98 2:47p Chris
199 * Dynamic weapon info is now dynamically allocated
200 * Dynamic weapon info is now dynamically allocated
201 *
202 * 100 6/15/98 4:00p Jason
203 * replaced monochromatic polymodel lighting with rgb lighting
204 *
205 * 99 5/27/98 5:17p Jason
206 * fixed some bugs for the E3 Demo
207 *
208 * 98 5/15/98 3:24p Keneta
209 *
210 * 97 4/30/98 11:32a Chris
211 * ClearWB to WBClear
212 *
213 * 96 4/24/98 1:35p Jason
214 * Don't sort non-alphaed polymodels
215 *
216 * 95 4/22/98 12:10p Chris
217 * Fixed path length problems
218 *
219 * 94 4/17/98 12:45p Jason
220 * various changes for multiplayer
221 *
222 * 93 4/15/98 3:28p Jason
223 * changed glow stuff to work with new system
224 *
225 * 92 4/07/98 3:35p Jason
226 * possible fix for polymodel paging bug
227 *
228 * 91 4/06/98 3:03p Jason
229 * added polygon rendering overlays
230 *
231 * 90 4/03/98 12:23p Jason
232 * dealt with overlay types being loaded from disk more than once
233 *
234 * 89 4/03/98 11:55a Jason
235 * fixed polymodel paging problem
236 *
237 * 88 4/03/98 10:07a Chris
238 * Added support for objects getting their size computed when the
239 * polymodel is paged in the first time as an object
240 *
241 * 87 4/02/98 3:54p Jason
242 * first pass in getting polymodel paging to work
243 *
244 * 86 4/01/98 6:23p Jason
245 * added a slew of stuff for multiplayer
246 *
247 * 85 3/31/98 3:49p Jason
248 * added memory lib
249 *
250 * 84 3/31/98 11:12a Brent
251 * added assert for max textures
252 *
253 * 83 3/30/98 12:27a Jason
254 * fixed memory leaks as reported by BoundsChecker
255 *
256 * 82 3/25/98 5:51p Chris
257 * Added full model/body animations for weapon firing
258 *
259 * 81 3/24/98 2:12p Brent
260 * fixed another glowcount bug
261 *
262 * 80 3/24/98 12:47p Brent
263 * fixed glow bug
264 *
265 * 79 3/24/98 12:38p Brent
266 * added assert
267 *
268 * 78 3/23/98 10:03a Chris
269 * Added independant wb animations
270 *
271 * 77 3/19/98 4:30p Samir
272 * added ability to mark subobjects as layered.
273 *
274 * 76 3/18/98 6:24p Samir
275 * Fixed some bugs with normalizing MONITORs and added VIEWER flag.
276 *
277 * 75 3/16/98 11:34a Chris
278 * Polymodels have 3 levels of AABB (object, subobject, and face level)
279 *
280 * 74 3/10/98 2:03p Chris
281 * Added support for 0.0 angle fov
282 *
283 * 73 2/16/98 4:05p Jason
284 * render polymodels sorted or unsorted depending on whether or not they
285 * have alpha faces
286 *
287 * 72 2/16/98 2:49p Chris
288 * Made the MAX_SUBOBJECTS determine the number of normalized_time values
289 * to be processed. No longer a 'literal' problem.
290 *
291 * 71 2/16/98 2:25p Jason
292 * fixed bad indexing into subobjects problem
293 *
294 * 70 2/16/98 2:12p Jason
295 * fixed bug with lightmaps and door shells
296 *
297 * 69 2/13/98 6:59p Chris
298 * FIxed the normalized_time array from being smaller than the number of
299 * subobjects. Also update newstyle_fi.cpp
300 *
301 * 68 2/13/98 12:44p Jason
302 * upped max number of subobjects
303 *
304 * 67 2/10/98 3:50p Jason
305 * added pulsing walls
306 *
307 * 66 2/06/98 8:08p Jason
308 * fixed size problem with facing subobjects
309 *
310 * 65 2/06/98 6:44p Jason
311 * made polymodels replace themselves if they find the same name
312 *
313 * 64 2/06/98 4:33p Jason
314 * fixed facing model sizes
315 *
316 * 63 2/06/98 1:45p Jason
317 * No really, I fixed the min max problem.
318 *
319 * 62 2/06/98 12:53p Jason
320 * fixed object min max stuff
321 *
322 * 61 2/04/98 9:28p Jason
323 * added the ability to have models that always face you
324 *
325 * 60 1/26/98 4:32p Jason
326 * took out some goofy mprintfs
327 *
328 * 59 1/23/98 5:39p Matt
329 * Removed some door frontface error checking now more thoroughly handled
330 * in WorldObjectsDoorDialog.cpp
331 *
332 * 58 1/23/98 11:16a Luke
333 * Remove a really old Assert that limitted which types could animate
334 *
335 * 57 1/13/98 3:46p Jason
336 * fixed memory corruption bug introduced by my last rev
337 *
338 * 56 1/13/98 3:09p Jason
339 * added glow effect for engines
340 *
341 * 55 1/02/98 1:03p Jason
342 * fixed memory deallocation leak in FreePolymodel
343 *
344 * 54 12/31/97 3:34p Jason
345 * added alpha per vertex for polymodels
346 *
347 * 53 12/08/97 6:18p Jason
348 * more tweaks for destroyable buildings
349 *
350 * 52 11/17/97 6:28p Mark
351 * FROM Jason:fixed memory leak
352 *
353 * 51 11/17/97 12:02p Jason
354 * added extra newstyle variable set
355 *
356 * 50 11/10/97 3:33p Jason
357 * ignore whitespace
358 *
359 * 49 11/04/97 4:58p Samir
360 * Added 4 more monitors.
361 *
362 * 48 10/30/97 10:53a Jason
363 * set color model to be MONO when drawing gouraud shaded polymodels
364 *
365 * 47 10/28/97 6:37p Samir
366 * Submodels now can be monitors.
367 *
368 * 46 10/28/97 11:10a Jason
369 * tweaked subojbect rotation
370 *
371 * 45 10/24/97 11:57a Jason
372 * fixed memory leak
373 *
374 * 44 10/23/97 2:07p Jason
375 * fixed some problems with debris not spinning about their center point
376 *
377 * 43 10/20/97 4:46p Jason
378 * changes for explosions
379 *
380 * 42 10/06/97 6:39p Jason
381 * fixed frame min/max problem
382 *
383 * 41 10/05/97 5:30a Chris
384 * Added more support for TIMED animations
385 *
386 * 40 10/01/97 7:00p Jason
387 * did more work on object lightmaps
388 *
389 * 39 9/30/97 6:40p Jason
390 * got lightmap stuff sort of working with objects
391 *
392 * 38 9/29/97 3:48p Jason
393 * added more code to support new timed models
394 *
395 * 37 9/26/97 12:09p Jason
396 * made positional/rotational animations have differing
397 * track_min/track_max
398 *
399 * 36 9/25/97 4:54p Jason
400 * added timer info to polymodels
401 *
402 * 35 9/18/97 1:27p Matt
403 * Cleaned up object struct
404 *
405 * 34 9/17/97 10:59a Chris
406 * Added a new way to compute radi
407 *
408 * 33 9/15/97 11:11a Jason
409 * fixed mins/maxs to be based on the center of the model
410 *
411 * 32 9/12/97 5:38p Jason
412 * got doors working
413 *
414 * 31 9/11/97 5:38p Jason
415 * initial door coding for room engine
416 *
417 * 30 9/10/97 6:01p Jason
418 * fixed double used variable bug
419 *
420 * 29 9/10/97 5:17p Jason
421 * more lighting improvements
422 *
423 * 28 9/09/97 6:55p Jason
424 * better error checking for model usage counts
425 *
426 * 27 9/09/97 6:15p Jason
427 * made dynamic lighting on objects more memory efficient
428 *
429 * 26 9/09/97 11:05a Jason
430 * fixed wacky bizarre problem with instancing and positional
431 * interpolation
432 *
433 * 25 9/05/97 1:29p Jason
434 * revamped generic object lighting
435 *
436 * 24 9/04/97 5:38p Jason
437 * fixed dumb bug that was fixed a long time ago...model positional
438 * interpolation
439 *
440 * 23 9/04/97 3:49p Chris
441 * Added additional turret information from pofgen, added ground plane
442 * stuff
443 *
444 * 22 9/03/97 4:41p Chris
445 * Moved some code so that pofview will compile
446 *
447 * 21 9/03/97 2:12p Chris
448 * Added new weapon battery system and made the animation system usable.
449 *
450 * 20 8/25/97 6:19p Chris
451 * Added support for knowing which subobject a gun point is linked to
452 *
453 * 19 8/24/97 1:40p Jason
454 * don't compute normals on model load...let pofgen do it
455 *
456 * 18 8/22/97 12:13p Jason
457 * made rotators work on keyframe 1 instead of keyframe 0 since max
458 * insists on some weird "start axis" for keyframe 0
459 *
460 * 17 8/20/97 4:24p Matt
461 * Removed unused code
462 *
463 * 16 8/20/97 3:16p Chris
464 * Added some hooks for turrets
465 *
466 * 15 8/08/97 4:38p Jason
467 * added sliding textures for models
468 *
469 * 14 8/08/97 2:30p Jason
470 * added error checking for rotators without keyframes
471 *
472 * 13 8/08/97 10:58a Jason
473 * fixed out of bounds error
474 *
475 * 12 8/07/97 3:19p Jason
476 * only remap models when explicitely told to
477 *
478 * 11 8/06/97 3:07p Jason
479 * fixed problem where polymodels were being freed twice
480 *
481 * 10 8/06/97 12:40p Jason
482 * fixed some potentially serious memory problems
483 *
484 * 9 8/05/97 5:18p Jason
485 * fixed circular dependencies with child/parents
486 *
487 * 8 8/03/97 2:25p Jason
488 * made polymodels use less memory
489 *
490 * 7 7/28/97 1:14p Chris
491 * Added support for sub-object visability. Plus, debris.
492 *
493 * 6 7/23/97 11:48a Jason
494 * added support for newstyle pof format
495 *
496 * 5 7/22/97 1:34a Jason
497 * added code to support newstyle polymodels
498 *
499 * 4 7/15/97 4:27p Mark
500 *
501 * 36 6/24/97 6:13p Matt
502 * Got rid of DrawPolygonObject(), since it required the inclusion of
503 * object.h, which is a main directory header file (& thus shouldn't be
504 * accessible by a library).
505 *
506 * 34 5/20/97 7:21p Jason
507 * fixed stupid off-by-one bug
508 *
509 * 33 5/20/97 5:52p Jason
510 * tweaked a couple of things with magnitude division
511 *
512 * 32 5/19/97 5:10p Jason
513 * changes for our new abstracted renderer code
514 *
515 * 31 5/19/97 11:46a Jason
516 * normalize rotation vectors
517 *
518 * 30 5/16/97 3:13p Jason
519 * fixed more problems with model rotation
520 *
521 * 29 5/16/97 1:24p Jason
522 * changed the way models work their angle magic
523 * Now its much more intuitive
524 *
525 * 28 5/16/97 12:04p Jason
526 * better memory use for rotational keyframes
527 *
528 * 27 5/15/97 4:23p Jason
529 * swap interpreted model data for mac
530 *
531 * 26 5/14/97 11:57p Jason
532 * made polymodels use far less memory
533 *
534 * 25 5/14/97 7:45p Jason
535 * fixed polymodel bug where it would not get deallocated correctly
536 *
537 *
538 * 24 5/13/97 5:59p Jason
539 * fixed yet another local transform bug
540 *
541 * 23 5/13/97 12:43p Jason
542 * fixed a delta rotation problem, plus add interpolated rotational axis
543 *
544 * 22 5/08/97 5:11p Jason
545 * fixed bug with animation rotation keyframes
546 *
547 * 21 5/08/97 1:16p Jason
548 * made ChangeEndName work with device independant calls
549 *
550 * 20 4/30/97 5:43p Jason
551 * remap polymodels when pagefile is done loading
552 *
553 * 19 4/28/97 6:46p Jason
554 * made ships have multiple gun points
555 *
556 * 18 4/21/97 5:29p Jason
557 * got animating textures to work on polygonal objects
558 *
559 * 17 4/21/97 4:09p Jason
560 * added GetNormalizedKeyframe function
561 *
562 * 16 4/04/97 11:48a Jason
563 * render polygon objects as linear maps
564 *
565 * 15 4/02/97 5:21p Jason
566 * added the ability for pages to free the models that they point to
567 *
568 * 14 3/26/97 3:29p Jason
569 * made robots work/render
570 *
571 * 13 3/18/97 5:22p Jason
572 * took out dumb mprintfs
573 *
574 * 12 3/14/97 5:54p Jason
575 * made positional interpolation work with 3d doors
576 *
577 * 11 3/14/97 10:55a Jason
578 * made polymodels use delta angles instead of absolute angles
579 *
580 * 10 3/13/97 6:13p Jason
581 * got poly doors working
582 *
583 * 9 3/07/97 3:59p Samir
584 * Took out include to memory.h for portability.
585 *
586 * 8 3/05/97 3:10p Jason
587 * added FreeAllModels call
588 *
589 * 7 3/05/97 12:17p Jason
590 * took out autoloading of the ship.pof upon startup
591 *
592 * 6 3/04/97 11:52a Jason
593 * made polymodels remap correctly
594 *
595 * 5 3/03/97 6:21p Matt
596 * Changed cfile functions to use D3 naming convention
597 *
598 * $NoKeywords: $
599 */
600
601 #include <algorithm>
602 #include <cstdlib>
603 #include <cstring>
604 #include <filesystem>
605
606 #include "3d.h"cxx . . $ `<file>/lib/3d.h`/
607 #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/
608 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
609 #include "gamesequence.h"cxx . . $ `<file>/Descent3/gamesequence.h`/
610 #include "mem.h"cxx . . $ `<file>/mem/mem.h`/
611 #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/
612 #include "objinfo.h"cxx . . $ `<file>/Descent3/objinfo.h`/
613 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
614 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
615
616 int Num_poly_modelscxx . . $ Num_poly_models. = 0;
617 poly_modelcxx . . $ poly_model# Poly_modelscxx . . $ Poly_models.[MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!];
618
619 g3Pointcxx . . $ g3Point# Robot_pointscxx . . $ Robot_points.[MAX_POLYGON_VECScxx . . $ `lib/polymodel_external.h:69:9`!];
620
621 vectorcxx . . $ vector# Interp_pos_instance_veccxx . . $ Interp_pos_instance_vec. = {0, 0, 0};
622 vectorcxx . . $ vector# Instance_vec_stackcxx . . $ Instance_vec_stack.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
623 int Instance_vec_cntcxx . . $ Instance_vec_cnt. = 0;
624
625 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
626 // Flag to draw an outline around the faces
627 bool Polymodel_outline_modecxx . . $ Polymodel_outline_mode. = false;
628 #endif
629
630 #define ID_OHDRcxx . . $ `model/polymodel.cpp:630:9`! 'RDHO' // POF file header
631 #define ID_SOBJcxx . . $ `model/polymodel.cpp:631:9`! 'JBOS' // Subobject header
632 #define ID_IDTAcxx . . $ `model/polymodel.cpp:632:9`! 'ATDI' // Interpreter data
633 #define ID_TXTRcxx . . $ `model/polymodel.cpp:633:9`! 'RTXT' // Texture filename list
634 #define ID_INFOcxx . . $ `model/polymodel.cpp:634:9`! 'FNIP' // POF file information, like command line, etc
635 #define ID_GRIDcxx . . $ `model/polymodel.cpp:635:9`! 'DIRG' // Grid information
636 #define ID_GPNTcxx . . $ `model/polymodel.cpp:636:9`! 'TNPG' // gun points
637 #define ID_ROT_ANIMcxx . . $ `model/polymodel.cpp:637:9`! 'INAR' // angular animation data
638 #define ID_POS_ANIMcxx . . $ `model/polymodel.cpp:638:9`! 'INAP' // positional animation data
639 #define ID_ANIMcxx . . $ `model/polymodel.cpp:639:9`! 'MINA' // angular information
640 #define ID_WBScxx . . $ `model/polymodel.cpp:640:9`! 'TABW' // Weapon Battery Info
641 #define ID_GROUNDcxx . . $ `model/polymodel.cpp:641:9`! 'DNRG' // Ground Plane info
642 #define ID_ATTACHcxx . . $ `model/polymodel.cpp:642:9`! 'HCTA' // Attach points
643 #define ID_ATTACH_NORMALScxx . . $ `model/polymodel.cpp:643:9`! 'HTAN' // Attach uvecs
644
645 int Polymodel_use_effectcxx . . $ Polymodel_use_effect. = 0;
646 polymodel_effectcxx . . $ polymodel_effect# Polymodel_effectcxx . . $ Polymodel_effect.;
647 polymodel_light_typecxx . . $ polymodel_light_type# Polymodel_light_typecxx . . $ Polymodel_light_type. = POLYMODEL_LIGHTING_STATICcxx . . $ POLYMODEL_LIGHTING_STATIC.;
648 float Polylighting_static_redcxx . . $ Polylighting_static_red.;
649 float Polylighting_static_greencxx . . $ Polylighting_static_green.;
650 float Polylighting_static_bluecxx . . $ Polylighting_static_blue.;
651 lightmap_objectcxx . . $ lightmap_object# *Polylighting_lightmap_objectcxx . . $ Polylighting_lightmap_object.;
652
653 vectorcxx . . $ vector# *Polymodel_light_directioncxx . . $ Polymodel_light_direction., Polymodel_fog_planecxx . . $ Polymodel_fog_plane., Polymodel_specular_poscxx . . $ Polymodel_specular_pos., Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert.,
654 Polymodel_bump_poscxx . . $ Polymodel_bump_pos.;
655
656 static inline void RecursiveAssignWBcxx . . $ RecursiveAssignWB(6cbf4e27cc4de793).(poly_modelcxx . . $ poly_model# *pm, int sm_index, int wb_index);
657 static void FindWBSubobjectscxx . . $ FindWBSubobjects(1a01b89d31d9e19d).(poly_modelcxx . . $ poly_model# *pm);
658 /// Sets aside a polymodel for use.
659 /// Errors and returns -1 if none free.
660 static int AllocPolyModelcxx . . $ AllocPolyModel(b126dc7c1de90089).();
661 static void ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(vectorcxx . . $ vector# *vec, CFILEcxx . . $ CFILE# *infile);
662 static void ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(char *ptr, int len, CFILEcxx . . $ CFILE# *infile);
663 /// Given a modelnumber, opens the original pof file and attempts to rematch that
664 /// models textures with the bitmaps with have in memory.
665 static int ReloadModelTexturescxx . . $ ReloadModelTextures(7864480464b09eea).(int modelnum);
666 static void SetPolymodelPropertiescxx . . $ SetPolymodelProperties(85d0b29186c3877f).(bsp_infocxx . . $ bsp_info# *subobj, char *props);
667 static void MinMaxSubmodelcxx . . $ MinMaxSubmodel(6bb2bfab53364435).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm, vectorcxx . . $ vector# offset);
668 static void FindMinMaxForModelcxx . . $ FindMinMaxForModel(1a01b89d31d9e19d).(poly_modelcxx . . $ poly_model# *pm);
669 static int ReadNewModelFilecxx . . $ ReadNewModelFile(9b62bdb6c772a53a).(int polynum, CFILEcxx . . $ CFILE# *infile);
670 static void SetNormalizedTimeObjTimedcxx . . $ SetNormalizedTimeObjTimed(8af4de573afdac78).(objectcxx . . $ object# *obj, float *normalized_time);
671 static void SetNormalizedTimeAnimTimedcxx . . $ SetNormalizedTimeAnimTimed(40d1f0252a152310).(float frame, float *normalized_time, poly_modelcxx . . $ poly_model# *pm);
672 static void FreeAllModelscxx . . $ FreeAllModels(49f6e7a06ebc5aa8).();
673 /// Given a model pointer and an array of floats that go from 0..1, calculate the interpolated
674 /// position/angle of each corresponding subobject.
675 static void SetModelAnglesAndPosTimedcxx . . $ SetModelAnglesAndPosTimed(a00e94110fc4ea4c).(poly_modelcxx . . $ poly_model# *po, float *normalized_time, uint32_tcxx . . $ uint32_t# subobj_flags);
676 static void BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(matrixcxx . . $ matrix# *mat, anglecxx . . $ angle# ang, vectorcxx . . $ vector# *axis);
677
678 void WBClearInfocxx . . $ WBClearInfo(1a01b89d31d9e19d).(poly_modelcxx . . $ poly_model# *pm) { pm->num_wbscxx . . $ poly_model#num_wbs. = 0; }
679
680 inline void RecursiveAssignWBcxx . . $ RecursiveAssignWB(6cbf4e27cc4de793).(poly_modelcxx . . $ poly_model# *pm, int sm_index, int wb_index) {
681 int flags;
682 int i;
683
684 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
685
686 flags = wb_index << WB_INDEX_SHIFTcxx . . $ `model/polymodel.h:308:9`!;
687
688 pm->submodelcxx . . $ poly_model#submodel.[sm_index].flagscxx . . $ bsp_info#flags. |= flags | SOF_WBcxx . . $ `lib/polymodel_external.h:95:9`!;
689
690 for (i = 0; i < pm->submodelcxx . . $ poly_model#submodel.[sm_index].num_childrencxx . . $ bsp_info#num_children.; i++) {
691 RecursiveAssignWBcxx . . $ RecursiveAssignWB(6cbf4e27cc4de793).(pm, pm->submodelcxx . . $ poly_model#submodel.[sm_index].childrencxx . . $ bsp_info#children.[i], wb_index);
692 }
693 }
694
695 void FindWBSubobjectscxx . . $ FindWBSubobjects(1a01b89d31d9e19d).(poly_modelcxx . . $ poly_model# *pm) {
696 int i;
697 bool found;
698
699 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
700
701 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
702 if (pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!) {
703 int j;
704 found = false;
705
706 for (j = 0; j < pm->num_wbscxx . . $ poly_model#num_wbs.; j++) {
707 int k;
708
709 for (k = 0; k < pm->poly_wbcxx . . $ poly_model#poly_wb.[j].num_turretscxx . . $ poly_wb_info#num_turrets.; k++) {
710 if (pm->poly_wbcxx . . $ poly_model#poly_wb.[j].turret_indexcxx . . $ poly_wb_info#turret_index.[k] == i) {
711 found = true;
712 RecursiveAssignWBcxx . . $ RecursiveAssignWB(6cbf4e27cc4de793).(pm, i, j);
713 }
714
715 if (found)
716 break;
717 }
718
719 if (found)
720 break;
721 }
722 }
723 }
724 }
725
726 // Sets aside a polymodel for use
727 // Errors and returns -1 if none free
728 int AllocPolyModelcxx . . $ AllocPolyModel(b126dc7c1de90089).() {
729 for (int i = 0; i < MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!; i++)
730 if (Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. == 0) {
731 WBClearInfocxx . . $ WBClearInfo(1a01b89d31d9e19d).(&Poly_modelscxx . . $ Poly_models.[i]);
732 memset(&Poly_modelscxx . . $ Poly_models.[i], 0, sizeof(poly_modelcxx . . $ poly_model#));
733 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. = 1;
734 Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. |= PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!; // not in memory yet!
735 return i;
736 }
737
738 Errorcxx . . $ Error(326aeb464d16410c).("Couldn't find a free polymodel!");
739 return -1;
740 }
741
742 // Frees all the polymodel data, but doesn't free the actual polymodel itself
743 void FreePolymodelDatacxx . . $ FreePolymodelData(d4f767463ce0a6b3).(int i) {
744 int t;
745
746 for (t = 0; t < Poly_modelscxx . . $ Poly_models.[i].n_modelscxx . . $ poly_model#n_models.; t++) {
747 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.) {
748 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_axiscxx . . $ bsp_info#keyframe_axis.) {
749 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].keyframe_axis);
750 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_axiscxx . . $ bsp_info#keyframe_axis. = nullptr;
751 }
752
753 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].tick_pos_remapcxx . . $ bsp_info#tick_pos_remap.) {
754 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].tick_pos_remap);
755 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].tick_pos_remapcxx . . $ bsp_info#tick_pos_remap. = nullptr;
756 }
757
758 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].tick_ang_remapcxx . . $ bsp_info#tick_ang_remap.) {
759 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].tick_ang_remap);
760 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].tick_ang_remapcxx . . $ bsp_info#tick_ang_remap. = nullptr;
761 }
762
763 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_anglescxx . . $ bsp_info#keyframe_angles.) {
764 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].keyframe_angles);
765 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_anglescxx . . $ bsp_info#keyframe_angles. = nullptr;
766 }
767 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.) {
768 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].keyframe_matrix);
769 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix. = nullptr;
770 }
771
772 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_poscxx . . $ bsp_info#keyframe_pos.) {
773 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].keyframe_pos);
774 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].keyframe_poscxx . . $ bsp_info#keyframe_pos. = nullptr;
775 }
776
777 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertscxx . . $ bsp_info#verts.) {
778 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].verts);
779 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertscxx . . $ bsp_info#verts. = nullptr;
780 }
781
782 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertnormscxx . . $ bsp_info#vertnorms.) {
783 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].vertnorms);
784 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertnormscxx . . $ bsp_info#vertnorms. = nullptr;
785 }
786
787 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].alphacxx . . $ bsp_info#alpha.) {
788 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].alpha);
789 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].alphacxx . . $ bsp_info#alpha. = nullptr;
790 }
791
792 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertnum_memorycxx . . $ bsp_info#vertnum_memory.) {
793 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].vertnum_memory);
794 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].vertnum_memorycxx . . $ bsp_info#vertnum_memory. = nullptr;
795 }
796
797 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].u_memorycxx . . $ bsp_info#u_memory.) {
798 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].u_memory);
799 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].u_memorycxx . . $ bsp_info#u_memory. = nullptr;
800 }
801
802 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].v_memorycxx . . $ bsp_info#v_memory.) {
803 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].v_memory);
804 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].v_memorycxx . . $ bsp_info#v_memory. = nullptr;
805 }
806
807 if (Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. & PMF_TIMEDcxx . . $ `lib/polymodel_external.h:222:9`!) {
808 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].rot_start_timecxx . . $ bsp_info#rot_start_time.) {
809 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].rot_start_time);
810 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].rot_start_timecxx . . $ bsp_info#rot_start_time. = nullptr;
811 }
812
813 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].pos_start_timecxx . . $ bsp_info#pos_start_time.) {
814 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].pos_start_time);
815 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].pos_start_timecxx . . $ bsp_info#pos_start_time. = nullptr;
816 }
817 }
818
819 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].flagscxx . . $ bsp_info#flags. & (SOF_GLOWcxx . . $ `lib/polymodel_external.h:96:9`! | SOF_THRUSTERcxx . . $ `lib/polymodel_external.h:98:9`!)) {
820 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].glow_info);
821 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].glow_infocxx . . $ bsp_info#glow_info. = nullptr;
822 }
823
824 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].facescxx . . $ bsp_info#faces.) {
825 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].faces);
826 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].facescxx . . $ bsp_info#faces. = nullptr;
827
828 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].face_mincxx . . $ bsp_info#face_min.) {
829 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].face_min);
830 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].face_mincxx . . $ bsp_info#face_min. = nullptr;
831 }
832 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].face_maxcxx . . $ bsp_info#face_max.) {
833 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel[t].face_max);
834 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.[t].face_maxcxx . . $ bsp_info#face_max. = nullptr;
835 }
836 }
837 }
838 }
839
840 if (Poly_modelscxx . . $ Poly_models.[i].model_datacxx . . $ poly_model#model_data.) {
841 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].model_data);
842 Poly_modelscxx . . $ Poly_models.[i].model_datacxx . . $ poly_model#model_data. = nullptr;
843 }
844 if (Poly_modelscxx . . $ Poly_models.[i].gun_slotscxx . . $ poly_model#gun_slots.) {
845 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].gun_slots);
846 Poly_modelscxx . . $ Poly_models.[i].gun_slotscxx . . $ poly_model#gun_slots. = nullptr;
847 }
848 if (Poly_modelscxx . . $ Poly_models.[i].poly_wbcxx . . $ poly_model#poly_wb.) {
849 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].poly_wb);
850 Poly_modelscxx . . $ Poly_models.[i].poly_wbcxx . . $ poly_model#poly_wb. = nullptr;
851 }
852 if (Poly_modelscxx . . $ Poly_models.[i].attach_slotscxx . . $ poly_model#attach_slots.) {
853 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].attach_slots);
854 Poly_modelscxx . . $ Poly_models.[i].attach_slotscxx . . $ poly_model#attach_slots. = nullptr;
855 }
856
857 if (Poly_modelscxx . . $ Poly_models.[i].ground_slotscxx . . $ poly_model#ground_slots.) {
858 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].ground_slots);
859 Poly_modelscxx . . $ Poly_models.[i].ground_slotscxx . . $ poly_model#ground_slots. = nullptr;
860 }
861 if (Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel.) {
862 mem_freecxx . . $ `mem/mem.h:80:9`!(Poly_models[i].submodel);
863 Poly_modelscxx . . $ Poly_models.[i].submodelcxx . . $ poly_model#submodel. = nullptr;
864 }
865
866 Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. |= PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!;
867 Poly_modelscxx . . $ Poly_models.[i].n_modelscxx . . $ poly_model#n_models. = 0;
868 }
869
870 // Frees polymodel located in index of Poly_models array
871 void FreePolyModelcxx . . $ FreePolyModel(d4f767463ce0a6b3).(int i) {
872 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[i].used > 0);
873
874 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used.--;
875
876 if (Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used.)
877 return;
878
879 FreePolymodelDatacxx . . $ FreePolymodelData(d4f767463ce0a6b3).(i);
880
881 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. = 0;
882 Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. |= PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!;
883 }
884
885 void ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(vectorcxx . . $ vector# *vec, CFILEcxx . . $ CFILE# *infile) {
886 vec->xcxx . . $ vector#x. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
887 vec->ycxx . . $ vector#y. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
888 vec->zcxx . . $ vector#z. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
889 }
890
891 void ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(char *ptr, int len, CFILEcxx . . $ CFILE# *infile) {
892 int i;
893
894 int mlen = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
895 for (i = 0; i < mlen; i++)
896 ptr[i] = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
897 }
898
899 // Given a modelnumber, opens the original pof file and attempts to rematch that
900 // models textures with the bitmaps with have in memory
901 int ReloadModelTexturescxx . . $ ReloadModelTextures(7864480464b09eea).(int modelnum) {
902 CFILEcxx . . $ CFILE# *infile;
903 int done = 0, id, len;
904 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[modelnum];
905
906 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(Poly_models[modelnum].flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
907
908 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(Poly_modelscxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).[modelnum].namecxx . . $ poly_model#name., "rb");
909 if (!infile)
910 return 0;
911
912 id = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
913
914 if (id != 'OPSP')
915 Errorcxx . . $ Error(326aeb464d16410c).("Bad ID in model file!");
916 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // skip version
917
918 while (!done) {
919 if (cfeofcxx . . $ cfeof(413716a422df0036).(infile)) {
920 done = 1;
921 continue;
922 }
923
924 id = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // read chunk type
925 len = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // read chunk length
926
927 switch (id) {
928 case ID_TXTRcxx . . $ `model/polymodel.cpp:633:9`!: {
929 // Texture filename list
930 int i, n;
931 char name_buf[128];
932
933 n = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
934 if (n != pm->n_texturescxx . . $ poly_model#n_textures.) {
935 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Get Jason, new model doesn't match old model!!!
936 cfclosecxx . . $ cfclose(3639e799710acb68).(infile);
937 return 0;
938 }
939
940 for (i = 0; i < n; i++) {
941 int ret;
942 char temp[256];
943
944 // Read the name of this texture
945 ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(name_buf, 127, infile);
946
947 strcpy(temp, name_buf);
948 strcat(temp, ".OGF");
949 ret = FindTextureBitmapNamecxx . . $ FindTextureBitmapName(5c4306d8553b3696).(temp);
950 if (ret == -1) {
951 // See if its already in memory
952 ret = FindTextureNamecxx . . $ FindTextureName(5c4306d8553b3696).(name_buf);
953 if (ret == -1) {
954 ret = 0;
955 // mprintf(0,"Object texture %s is not in memory!\n",name_buf);
956 }
957 }
958
959 pm->texturescxx . . $ poly_model#textures.[i] = ret;
960 if (GameTexturescxx . . $ GameTextures.[ret].alphacxx . . $ texture#alpha. < .99)
961 pm->flagscxx . . $ poly_model#flags. |= PMF_ALPHAcxx . . $ `lib/polymodel_external.h:223:9`!;
962 }
963
964 done = 1;
965 break;
966 }
967
968 default:
969 cfseekcxx . . $ cfseek(f9992d249f032805).(infile, len, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!);
970 break;
971 }
972 }
973
974 cfclosecxx . . $ cfclose(3639e799710acb68).(infile);
975 return 1;
976 }
977
978 void BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(matrixcxx . . $ matrix# *mat, anglecxx . . $ angle# ang, vectorcxx . . $ vector# *axis) {
979 float x, y, z;
980 float s, c, t;
981
982 x = axis->xcxx . . $ vector#x.;
983 y = axis->ycxx . . $ vector#y.;
984 z = axis->zcxx . . $ vector#z.;
985
986 s = (float)FixSincxx . . $ FixSin(9a38df040a81ca35).(ang);
987 c = (float)FixCoscxx . . $ FixCos(9a38df040a81ca35).(ang);
988 t = 1.0f - c;
989
990 mat->rveccxx . . $ matrix#rvec..xcxx . . $ vector#x. = t * x * x + c;
991 mat->rveccxx . . $ matrix#rvec..ycxx . . $ vector#y. = t * x * y + s * z;
992 mat->rveccxx . . $ matrix#rvec..zcxx . . $ vector#z. = t * x * z - s * y;
993
994 mat->uveccxx . . $ matrix#uvec..xcxx . . $ vector#x. = t * x * y - s * z;
995 mat->uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. = t * y * y + c;
996 mat->uveccxx . . $ matrix#uvec..zcxx . . $ vector#z. = t * y * z + s * x;
997
998 mat->fveccxx . . $ matrix#fvec..xcxx . . $ vector#x. = t * x * z + s * y;
999 mat->fveccxx . . $ matrix#fvec..ycxx . . $ vector#y. = t * y * z - s * x;
1000 mat->fveccxx . . $ matrix#fvec..zcxx . . $ vector#z. = t * z * z + c;
1001 }
1002
1003 void SetPolymodelPropertiescxx . . $ SetPolymodelProperties(85d0b29186c3877f).(bsp_infocxx . . $ bsp_info# *subobj, char *props) {
1004 // first, extract the command
1005
1006 int len, i;
1007 char command[200], data[200];
1008
1009 len = strlen(props);
1010
1011 if (len < 3)
1012 return; // nothing to set!
1013
1014 for (i = 0; i < len; i++) {
1015 command[i] = props[i];
1016 if (command[i] == '=') {
1017 i++;
1018 break; // we've found some data!
1019 }
1020 }
1021
1022 command[i] = 0;
1023
1024 if (len != i) {
1025 int datastart = i;
1026
1027 for (; i < len; i++) {
1028 data[i - datastart] = props[i];
1029 }
1030 data[i - datastart] = 0;
1031 }
1032
1033 // now act on the command/data pair
1034
1035 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$rotate=")) {
1036 // constant rotation for a subobject
1037 float spinrate = atof(data);
1038
1039 if (spinrate <= 0 || spinrate > 20)
1040 return; // bad data
1041
1042 subobj->flagscxx . . $ bsp_info#flags. |= SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!;
1043 subobj->rpscxx . . $ bsp_info#rps. = 1.0f / spinrate;
1044
1045 return;
1046 }
1047
1048 if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "$jitter", 7)) {
1049 // this subobject is a jittery object
1050 subobj->flagscxx . . $ bsp_info#flags. |= SOF_JITTERcxx . . $ `lib/polymodel_external.h:99:9`!;
1051
1052 return;
1053 }
1054
1055 if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "$shell", 6)) {
1056 // this subobject is a door shell
1057
1058 subobj->flagscxx . . $ bsp_info#flags. |= SOF_SHELLcxx . . $ `lib/polymodel_external.h:82:9`!;
1059
1060 return;
1061 }
1062 if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "$facing", 7)) {
1063 // this subobject always faces you
1064 subobj->flagscxx . . $ bsp_info#flags. |= SOF_FACINGcxx . . $ `lib/polymodel_external.h:92:9`!;
1065 return;
1066 }
1067
1068 if (!strnicmpcxx . . $ `linux/linux_fix.h:44:9`!(command, "$frontface", 10)) {
1069 // this subobject is a door front
1070
1071 subobj->flagscxx . . $ bsp_info#flags. |= SOF_FRONTFACEcxx . . $ `lib/polymodel_external.h:83:9`!;
1072
1073 return;
1074 }
1075
1076 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$glow=")) {
1077 float r, g, b;
1078 float size;
1079 int num_found;
1080
1081 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(subobj->flags & (SOF_GLOWcxx . . $ `lib/polymodel_external.h:96:9`! | SOF_THRUSTERcxx . . $ `lib/polymodel_external.h:98:9`!)));
1082
1083 num_found = sscanf(data, " %f, %f, %f, %f", &r, &g, &b, &size);
1084
1085 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_found == 4);
1086
1087 subobj->flagscxx . . $ bsp_info#flags. |= SOF_GLOWcxx . . $ `lib/polymodel_external.h:96:9`!;
1088
1089 if (subobj->glow_infocxx . . $ bsp_info#glow_info. == nullptr) // DAJ may already exist
1090 subobj->glow_infocxx . . $ bsp_info#glow_info. = (glowinfocxx . . $ glowinfo# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(glowinfo));
1091
1092 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_rcxx . . $ glowinfo#glow_r. = r;
1093 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_gcxx . . $ glowinfo#glow_g. = g;
1094 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_bcxx . . $ glowinfo#glow_b. = b;
1095 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_sizecxx . . $ glowinfo#glow_size. = size;
1096
1097 return;
1098 }
1099
1100 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$thruster=")) {
1101 float r, g, b;
1102 float size;
1103 int num_found;
1104
1105 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(subobj->flags & (SOF_GLOWcxx . . $ `lib/polymodel_external.h:96:9`! | SOF_THRUSTERcxx . . $ `lib/polymodel_external.h:98:9`!)));
1106
1107 num_found = sscanf(data, " %f, %f, %f, %f", &r, &g, &b, &size);
1108
1109 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_found == 4);
1110
1111 subobj->flagscxx . . $ bsp_info#flags. |= SOF_THRUSTERcxx . . $ `lib/polymodel_external.h:98:9`!;
1112
1113 if (subobj->glow_infocxx . . $ bsp_info#glow_info. == nullptr) // DAJ may already exist
1114 subobj->glow_infocxx . . $ bsp_info#glow_info. = (glowinfocxx . . $ glowinfo# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(glowinfo));
1115
1116 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_rcxx . . $ glowinfo#glow_r. = r;
1117 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_gcxx . . $ glowinfo#glow_g. = g;
1118 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_bcxx . . $ glowinfo#glow_b. = b;
1119 subobj->glow_infocxx . . $ bsp_info#glow_info.->glow_sizecxx . . $ glowinfo#glow_size. = size;
1120
1121 return;
1122 }
1123
1124 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$fov=")) {
1125 float fov_angle;
1126 float turret_spr;
1127 float reaction_time;
1128 int num_found;
1129
1130 num_found = sscanf(data, " %f, %f, %f", &fov_angle, &turret_spr, &reaction_time);
1131
1132 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_found == 3);
1133
1134 if (fov_angle < 0.0f || fov_angle > 360.0f) {
1135 // Bad data
1136 ASSERTcxx . . $ `misc/pserror.h:246:9`!(0);
1137 fov_angle = 1.0;
1138 }
1139
1140 // .4 is really fast and really arbitrary
1141 if (turret_spr < 0.0f || turret_spr > 60.0f) {
1142 // Bad data
1143 ASSERTcxx . . $ `misc/pserror.h:246:9`!(0);
1144 turret_spr = 1.0f;
1145 }
1146
1147 // 10 seconds is really slow and really arbitrary
1148 if (reaction_time < 0.0f || reaction_time > 10.0f) {
1149 // Bad data
1150 ASSERTcxx . . $ `misc/pserror.h:246:9`!(0);
1151 reaction_time = 10.0f;
1152 }
1153
1154 subobj->flagscxx . . $ bsp_info#flags. |= SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!;
1155 subobj->fovcxx . . $ bsp_info#fov. = fov_angle / 720.0f; // 720 = 360 * 2 and we want to make fov the amount we can move in either
1156 // direction it has a minimum value of (0.0) to [0.5]
1157 subobj->rpscxx . . $ bsp_info#rps. = 1.0f / turret_spr; // convert spr to rps (rotations per second)
1158 subobj->think_intervalcxx . . $ bsp_info#think_interval. = reaction_time;
1159
1160 return;
1161 }
1162
1163 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor01")) {
1164 // this subobject is a monitor
1165 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR1cxx . . $ `lib/polymodel_external.h:84:9`!;
1166 return;
1167 }
1168
1169 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor02")) {
1170 // this subobject is a 2nd monitor
1171 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR2cxx . . $ `lib/polymodel_external.h:85:9`!;
1172 return;
1173 }
1174
1175 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor03")) {
1176 // this subobject is a 3rd monitor
1177 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR3cxx . . $ `lib/polymodel_external.h:86:9`!;
1178 return;
1179 }
1180
1181 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor04")) {
1182 // this subobject is a 4th monitor
1183 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR4cxx . . $ `lib/polymodel_external.h:87:9`!;
1184 return;
1185 }
1186
1187 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor05")) {
1188 // this subobject is a 4th monitor
1189 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR5cxx . . $ `lib/polymodel_external.h:88:9`!;
1190 return;
1191 }
1192
1193 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor06")) {
1194 // this subobject is a 4th monitor
1195 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR6cxx . . $ `lib/polymodel_external.h:89:9`!;
1196 return;
1197 }
1198
1199 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor07")) {
1200 // this subobject is a 4th monitor
1201 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR7cxx . . $ `lib/polymodel_external.h:90:9`!;
1202 return;
1203 }
1204
1205 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$monitor08")) {
1206 // this subobject is a 4th monitor
1207 subobj->flagscxx . . $ bsp_info#flags. |= SOF_MONITOR8cxx . . $ `lib/polymodel_external.h:91:9`!;
1208 return;
1209 }
1210
1211 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$viewer")) {
1212 // this subobject is a viewer
1213 subobj->flagscxx . . $ bsp_info#flags. |= SOF_VIEWERcxx . . $ `lib/polymodel_external.h:93:9`!;
1214 return;
1215 }
1216
1217 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$layer")) {
1218 // this subobject is a layer to be drawn after original object.
1219 subobj->flagscxx . . $ bsp_info#flags. |= SOF_LAYERcxx . . $ `lib/polymodel_external.h:94:9`!;
1220 return;
1221 }
1222 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(command, "$custom")) {
1223 // this subobject has custom textures/colors
1224 subobj->flagscxx . . $ bsp_info#flags. |= SOF_CUSTOMcxx . . $ `lib/polymodel_external.h:97:9`!;
1225
1226 return;
1227 }
1228 }
1229
1230 void MinMaxSubmodelcxx . . $ MinMaxSubmodel(6bb2bfab53364435).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm, vectorcxx . . $ vector# offset) {
1231
1232 offset +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). sm->offsetcxx . . $ bsp_info#offset.;
1233 // Get max
1234 if ((sm->maxcxx . . $ bsp_info#max..xcxx . . $ vector#x. + offset.xcxx . . $ vector#x.) > pm->maxscxx . . $ poly_model#maxs..xcxx . . $ vector#x.)
1235 pm->maxscxx . . $ poly_model#maxs..xcxx . . $ vector#x. = sm->maxcxx . . $ bsp_info#max..xcxx . . $ vector#x. + offset.xcxx . . $ vector#x.;
1236 if ((sm->maxcxx . . $ bsp_info#max..ycxx . . $ vector#y. + offset.ycxx . . $ vector#y.) > pm->maxscxx . . $ poly_model#maxs..ycxx . . $ vector#y.)
1237 pm->maxscxx . . $ poly_model#maxs..ycxx . . $ vector#y. = sm->maxcxx . . $ bsp_info#max..ycxx . . $ vector#y. + offset.ycxx . . $ vector#y.;
1238 if ((sm->maxcxx . . $ bsp_info#max..zcxx . . $ vector#z. + offset.zcxx . . $ vector#z.) > pm->maxscxx . . $ poly_model#maxs..zcxx . . $ vector#z.)
1239 pm->maxscxx . . $ poly_model#maxs..zcxx . . $ vector#z. = sm->maxcxx . . $ bsp_info#max..zcxx . . $ vector#z. + offset.zcxx . . $ vector#z.;
1240
1241 // Get min
1242 if ((sm->mincxx . . $ bsp_info#min..xcxx . . $ vector#x. + offset.xcxx . . $ vector#x.) < pm->minscxx . . $ poly_model#mins..xcxx . . $ vector#x.)
1243 pm->minscxx . . $ poly_model#mins..xcxx . . $ vector#x. = sm->mincxx . . $ bsp_info#min..xcxx . . $ vector#x. + offset.xcxx . . $ vector#x.;
1244 if ((sm->mincxx . . $ bsp_info#min..ycxx . . $ vector#y. + offset.ycxx . . $ vector#y.) < pm->minscxx . . $ poly_model#mins..ycxx . . $ vector#y.)
1245 pm->minscxx . . $ poly_model#mins..ycxx . . $ vector#y. = sm->mincxx . . $ bsp_info#min..ycxx . . $ vector#y. + offset.ycxx . . $ vector#y.;
1246 if ((sm->mincxx . . $ bsp_info#min..zcxx . . $ vector#z. + offset.zcxx . . $ vector#z.) < pm->minscxx . . $ poly_model#mins..zcxx . . $ vector#z.)
1247 pm->minscxx . . $ poly_model#mins..zcxx . . $ vector#z. = sm->mincxx . . $ bsp_info#min..zcxx . . $ vector#z. + offset.zcxx . . $ vector#z.;
1248
1249 for (int i = 0; i < sm->num_childrencxx . . $ bsp_info#num_children.; i++)
1250 MinMaxSubmodelcxx . . $ MinMaxSubmodel(6bb2bfab53364435).(pm, &pm->submodelcxx . . $ poly_model#submodel.[sm->childrencxx . . $ bsp_info#children.[i]], offset);
1251 }
1252
1253 void FindMinMaxForModelcxx . . $ FindMinMaxForModel(1a01b89d31d9e19d).(poly_modelcxx . . $ poly_model# *pm) {
1254
1255 vectorcxx . . $ vector# zero_vec;
1256
1257 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
1258
1259 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&zero_vec);
1260 pm->minscxx . . $ poly_model#mins..xcxx . . $ vector#x. = pm->minscxx . . $ poly_model#mins..ycxx . . $ vector#y. = pm->minscxx . . $ poly_model#mins..zcxx . . $ vector#z. = 90000;
1261 pm->maxscxx . . $ poly_model#maxs..xcxx . . $ vector#x. = pm->maxscxx . . $ poly_model#maxs..ycxx . . $ vector#y. = pm->maxscxx . . $ poly_model#maxs..zcxx . . $ vector#z. = -90000;
1262
1263 for (int i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
1264 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[i];
1265 if (sm->parentcxx . . $ bsp_info#parent. == -1)
1266 MinMaxSubmodelcxx . . $ MinMaxSubmodel(6bb2bfab53364435).(pm, sm, zero_vec);
1267 }
1268 }
1269
1270 int ReadNewModelFilecxx . . $ ReadNewModelFile(9b62bdb6c772a53a).(int polynum, CFILEcxx . . $ CFILE# *infile) {
1271 int version, done = 0, i, t, version_major;
1272 int id, len;
1273 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[polynum];
1274 int timed = 0;
1275
1276 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->new_style);
1277
1278 id = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1279
1280 if (id != 'OPSP')
1281 Errorcxx . . $ Error(326aeb464d16410c).("Bad ID in model file!");
1282
1283 // Version is major*100+minor
1284 // So, major = version / 100;
1285 // minor = version % 100;
1286
1287 version = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1288 if (version < 18) {
1289 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Old POF Version of %d fixed up to %d\n", version, version * 100);
1290 version *= 100;
1291 }
1292
1293 if (version < PM_COMPATIBLE_VERSIONcxx . . $ `model/polymodel.h:305:9`! || version > PM_OBJFILE_VERSIONcxx . . $ `model/polymodel.h:306:9`!) {
1294 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Bad version (%d) in model file!\n", version);
1295 Int3cxx . . $ `misc/pserror.h:247:9`!();
1296 return 0;
1297 }
1298
1299 pm->versioncxx . . $ poly_model#version. = version;
1300 version_major = version / 100;
1301
1302 if (version_major >= 21)
1303 pm->flagscxx . . $ poly_model#flags. |= PMF_LIGHTMAP_REScxx . . $ `lib/polymodel_external.h:221:9`!;
1304 if (version_major >= 22) {
1305 timed = 1;
1306 pm->flagscxx . . $ poly_model#flags. |= PMF_TIMEDcxx . . $ `lib/polymodel_external.h:222:9`!;
1307 pm->frame_mincxx . . $ poly_model#frame_min. = 0;
1308 pm->frame_maxcxx . . $ poly_model#frame_max. = 0;
1309 }
1310
1311 pm->n_attachcxx . . $ poly_model#n_attach. = 0;
1312
1313 memset(&pm->view_poscxx . . $ poly_model#view_pos., 0, sizeof(pm->view_poscxx . . $ poly_model#view_pos.));
1314
1315 while (!done) {
1316 if (cfeofcxx . . $ cfeof(413716a422df0036).(infile)) {
1317 done = 1;
1318 continue;
1319 }
1320
1321 id = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1322 len = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1323
1324 switch (id) {
1325 case ID_OHDRcxx . . $ `model/polymodel.cpp:630:9`!: {
1326 // Object header
1327
1328 // mprintf(0,"Object header...\n");
1329
1330 pm->n_modelscxx . . $ poly_model#n_models. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1331 pm->radcxx . . $ poly_model#rad. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1332
1333 pm->submodelcxx . . $ poly_model#submodel. = (bsp_infocxx . . $ bsp_info# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(bsp_info) * pm->n_models);
1334 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel != nullptr);
1335 memset(pm->submodelcxx . . $ poly_model#submodel., 0, sizeof(bsp_infocxx . . $ bsp_info#) * pm->n_modelscxx . . $ poly_model#n_models.);
1336
1337 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->minscxx . . $ poly_model#mins., infile);
1338 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->maxscxx . . $ poly_model#maxs., infile);
1339
1340 // pm->n_detail_levels = cf_ReadInt(infile);
1341 int det = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // skip detail
1342
1343 for (i = 0; i < det; i++) {
1344 // pm->detail[i] = cf_ReadInt(infile);
1345 // pm->detail_depth[i] = 0.0f;
1346 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1347 }
1348
1349 // Adjust min/maxs to be based on zero
1350 /*vector temp_vec=pm->maxs-pm->mins;
1351
1352 temp_vec/=2;
1353
1354 pm->mins=-temp_vec;
1355 pm->maxs=temp_vec;*/
1356
1357 break;
1358 }
1359
1360 case ID_SOBJcxx . . $ `model/polymodel.cpp:631:9`!: {
1361 // Subobject header
1362 int n;
1363 char props[MAX_PROP_LENcxx . . $ `lib/polymodel_external.h:71:9`!];
1364 float d;
1365
1366 // mprintf(0,"Got chunk SOBJ, len=%d\n",len);
1367
1368 n = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1369
1370 ASSERTcxx . . $ `misc/pserror.h:246:9`!(n < pm->n_models);
1371
1372 pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..xcxx . . $ vector#x. = pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..ycxx . . $ vector#y. = pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..zcxx . . $ vector#z. = 90000;
1373 pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..xcxx . . $ vector#x. = pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..ycxx . . $ vector#y. = pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..zcxx . . $ vector#z. = -90000;
1374
1375 pm->submodelcxx . . $ poly_model#submodel.[n].parentcxx . . $ bsp_info#parent. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1376
1377 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].normcxx . . $ bsp_info#norm., infile);
1378
1379 d = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1380 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].pntcxx . . $ bsp_info#pnt., infile);
1381 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].offsetcxx . . $ bsp_info#offset., infile);
1382
1383 pm->submodelcxx . . $ poly_model#submodel.[n].radcxx . . $ bsp_info#rad. = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile); // radius
1384
1385 pm->submodelcxx . . $ poly_model#submodel.[n].tree_offsetcxx . . $ bsp_info#tree_offset. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // offset
1386 pm->submodelcxx . . $ poly_model#submodel.[n].data_offsetcxx . . $ bsp_info#data_offset. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); // offset
1387
1388 if (pm->versioncxx . . $ poly_model#version. > 1805)
1389 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].geometric_centercxx . . $ bsp_info#geometric_center., infile);
1390 else {
1391 // for old models, hack in 0,0,0, which says the geometric center is
1392 // equal to pivot point, which is not always true.
1393 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&pm->submodelcxx . . $ poly_model#submodel.[n].geometric_centercxx . . $ bsp_info#geometric_center.);
1394 }
1395
1396 pm->submodelcxx . . $ poly_model#submodel.[n].namecxx . . $ bsp_info#name.[0] = '\0';
1397
1398 ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(pm->submodelcxx . . $ poly_model#submodel.[n].namecxx . . $ bsp_info#name., PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, infile);
1399 ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(props, MAX_PROP_LENcxx . . $ `lib/polymodel_external.h:71:9`!, infile); // and the user properites
1400
1401 SetPolymodelPropertiescxx . . $ SetPolymodelProperties(85d0b29186c3877f).(&pm->submodelcxx . . $ poly_model#submodel.[n], props);
1402
1403 pm->submodelcxx . . $ poly_model#submodel.[n].movement_typecxx . . $ bsp_info#movement_type. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1404 pm->submodelcxx . . $ poly_model#submodel.[n].movement_axiscxx . . $ bsp_info#movement_axis. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1405
1406 if (pm->submodelcxx . . $ poly_model#submodel.[n].namecxx . . $ bsp_info#name.[0] == '\0')
1407 strcpy(pm->submodelcxx . . $ poly_model#submodel.[n].namecxx . . $ bsp_info#name., "unknown object name");
1408
1409 memset(&pm->submodelcxx . . $ poly_model#submodel.[n].angscxx . . $ bsp_info#angs., 0, sizeof(angveccxx . . $ angvec#));
1410
1411 // Skip freespace chunks
1412 int n_chunks = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1413 if (n_chunks > 0) {
1414 for (i = 0; i < n_chunks; i++)
1415 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1416 }
1417
1418 int nverts = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1419 ASSERTcxx . . $ `misc/pserror.h:246:9`!(nverts < MAX_POLYGON_VECScxx . . $ `lib/polymodel_external.h:69:9`!);
1420
1421 if (nverts) {
1422 pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nverts * sizeof(vector));
1423 pm->submodelcxx . . $ poly_model#submodel.[n].vertnormscxx . . $ bsp_info#vertnorms. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nverts * sizeof(vector));
1424 pm->submodelcxx . . $ poly_model#submodel.[n].alphacxx . . $ bsp_info#alpha. = (float *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nverts * sizeof(float));
1425 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[n].verts);
1426 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[n].vertnorms);
1427 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[n].alpha);
1428 } else {
1429 // Let me take a moment right here to say how annoying it is that I can't
1430 // set all these pointers to nullptr with one assignment on the same line due
1431 // to the stupid strong typying they've added to C.
1432 pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts. = nullptr;
1433 pm->submodelcxx . . $ poly_model#submodel.[n].vertnormscxx . . $ bsp_info#vertnorms. = nullptr;
1434 pm->submodelcxx . . $ poly_model#submodel.[n].alphacxx . . $ bsp_info#alpha. = nullptr;
1435 }
1436
1437 pm->submodelcxx . . $ poly_model#submodel.[n].nvertscxx . . $ bsp_info#nverts. = nverts;
1438
1439 for (i = 0; i < nverts; i++) {
1440 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i], infile);
1441
1442 // Get max
1443 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].xcxx . . $ vector#x. > pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..xcxx . . $ vector#x.)
1444 pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..xcxx . . $ vector#x. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].xcxx . . $ vector#x.;
1445 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].ycxx . . $ vector#y. > pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..ycxx . . $ vector#y.)
1446 pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..ycxx . . $ vector#y. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].ycxx . . $ vector#y.;
1447 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].zcxx . . $ vector#z. > pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..zcxx . . $ vector#z.)
1448 pm->submodelcxx . . $ poly_model#submodel.[n].maxcxx . . $ bsp_info#max..zcxx . . $ vector#z. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].zcxx . . $ vector#z.;
1449
1450 // Get min
1451 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].xcxx . . $ vector#x. < pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..xcxx . . $ vector#x.)
1452 pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..xcxx . . $ vector#x. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].xcxx . . $ vector#x.;
1453 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].ycxx . . $ vector#y. < pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..ycxx . . $ vector#y.)
1454 pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..ycxx . . $ vector#y. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].ycxx . . $ vector#y.;
1455 if (pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].zcxx . . $ vector#z. < pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..zcxx . . $ vector#z.)
1456 pm->submodelcxx . . $ poly_model#submodel.[n].mincxx . . $ bsp_info#min..zcxx . . $ vector#z. = pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[i].zcxx . . $ vector#z.;
1457 }
1458 for (i = 0; i < nverts; i++)
1459 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].vertnormscxx . . $ bsp_info#vertnorms.[i], infile);
1460
1461 // Read alpha per vertex
1462 if (version_major >= 23) {
1463 for (i = 0; i < nverts; i++) {
1464 pm->submodelcxx . . $ poly_model#submodel.[n].alphacxx . . $ bsp_info#alpha.[i] = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1465 if (pm->submodelcxx . . $ poly_model#submodel.[n].alphacxx . . $ bsp_info#alpha.[i] < .99)
1466 pm->flagscxx . . $ poly_model#flags. |= PMF_ALPHAcxx . . $ `lib/polymodel_external.h:223:9`!;
1467 }
1468 } else {
1469 for (i = 0; i < nverts; i++)
1470 pm->submodelcxx . . $ poly_model#submodel.[n].alphacxx . . $ bsp_info#alpha.[i] = 1.0;
1471 }
1472
1473 int nfaces = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1474 pm->submodelcxx . . $ poly_model#submodel.[n].num_facescxx . . $ bsp_info#num_faces. = nfaces;
1475
1476 if (nfaces) {
1477 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces. = (polyfacecxx . . $ polyface# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nfaces * sizeof(polyface));
1478 pm->submodelcxx . . $ poly_model#submodel.[n].face_mincxx . . $ bsp_info#face_min. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nfaces * sizeof(vector));
1479 pm->submodelcxx . . $ poly_model#submodel.[n].face_maxcxx . . $ bsp_info#face_max. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(nfaces * sizeof(vector));
1480 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[n].faces);
1481 } else {
1482 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces. = nullptr;
1483 pm->submodelcxx . . $ poly_model#submodel.[n].face_maxcxx . . $ bsp_info#face_max. = nullptr;
1484 pm->submodelcxx . . $ poly_model#submodel.[n].face_mincxx . . $ bsp_info#face_min. = nullptr;
1485 }
1486
1487 // Find out how much space we'll need
1488 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[n];
1489
1490 vectorcxx . . $ vector# tvec;
1491 int current_count = 0;
1492
1493 int save_position = cftellcxx . . $ cftell(65b457210a6528a1).(infile);
1494 int *start_index;
1495
1496 if (nfaces) {
1497 start_index = (int *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(int) * nfaces);
1498 ASSERTcxx . . $ `misc/pserror.h:246:9`!(start_index);
1499 } else
1500 start_index = nullptr;
1501
1502 uint8_tcxx . . $ uint8_t# tempbuf[2000];
1503
1504 for (i = 0; i < nfaces; i++) {
1505 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&tvec, infile);
1506 int num_verts = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1507
1508 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_verts < 100);
1509 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num_verts > 0);
1510 start_index[i] = current_count;
1511 current_count += num_verts;
1512
1513 // Skip the rest
1514 if (cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile))
1515 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1516 else
1517 cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).(tempbuf, 3, infile);
1518
1519 cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).(tempbuf, 12 * num_verts, infile);
1520
1521 if (version_major >= 21)
1522 cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).(tempbuf, 8, infile);
1523 }
1524
1525 // Allocate our space
1526 if (current_count) {
1527 sm->vertnum_memorycxx . . $ bsp_info#vertnum_memory. = (int16_t *)mem_malloccxx . . $ `mem/mem.h:79:9`!(current_count * sizeof(int16_t));
1528 ASSERTcxx . . $ `misc/pserror.h:246:9`!(sm->vertnum_memory);
1529
1530 sm->u_memorycxx . . $ bsp_info#u_memory. = (float *)mem_malloccxx . . $ `mem/mem.h:79:9`!(current_count * sizeof(float));
1531 ASSERTcxx . . $ `misc/pserror.h:246:9`!(sm->u_memory);
1532
1533 sm->v_memorycxx . . $ bsp_info#v_memory. = (float *)mem_malloccxx . . $ `mem/mem.h:79:9`!(current_count * sizeof(float));
1534 ASSERTcxx . . $ `misc/pserror.h:246:9`!(sm->v_memory);
1535 } else {
1536 sm->vertnum_memorycxx . . $ bsp_info#vertnum_memory. = nullptr;
1537 sm->u_memorycxx . . $ bsp_info#u_memory. = nullptr;
1538 sm->v_memorycxx . . $ bsp_info#v_memory. = nullptr;
1539 }
1540
1541 // Now go through and set up our fake pointers
1542 for (i = 0; i < nfaces; i++) {
1543 sm->facescxx . . $ bsp_info#faces.[i].vertnumscxx . . $ polyface#vertnums. = &sm->vertnum_memorycxx . . $ bsp_info#vertnum_memory.[start_index[i]];
1544 sm->facescxx . . $ bsp_info#faces.[i].ucxx . . $ polyface#u. = &sm->u_memorycxx . . $ bsp_info#u_memory.[start_index[i]];
1545 sm->facescxx . . $ bsp_info#faces.[i].vcxx . . $ polyface#v. = &sm->v_memorycxx . . $ bsp_info#v_memory.[start_index[i]];
1546 }
1547
1548 // Reset our file pointer and free the temp memory
1549 cfseekcxx . . $ cfseek(f9992d249f032805).(infile, save_position, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!);
1550
1551 if (start_index)
1552 mem_freecxx . . $ `mem/mem.h:80:9`!(start_index);
1553
1554 for (i = 0; i < nfaces; i++) {
1555 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].normalcxx . . $ polyface#normal., infile);
1556
1557 int num_verts = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1558 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].nvertscxx . . $ polyface#nverts. = num_verts;
1559
1560 int textured = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1561 if (textured) {
1562 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].texnumcxx . . $ polyface#texnum. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1563
1564 } else {
1565 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].texnumcxx . . $ polyface#texnum. = -1;
1566 uint8_tcxx . . $ uint8_t# r, g, b;
1567 r = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
1568 g = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
1569 b = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile);
1570 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].colorcxx . . $ polyface#color. = GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(r, g, b);
1571 }
1572
1573 for (t = 0; t < pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].nvertscxx . . $ polyface#nverts.; t++) {
1574 int val;
1575 vectorcxx . . $ vector# *min_ptr = &pm->submodelcxx . . $ poly_model#submodel.[n].face_mincxx . . $ bsp_info#face_min.[i];
1576 vectorcxx . . $ vector# *max_ptr = &pm->submodelcxx . . $ poly_model#submodel.[n].face_maxcxx . . $ bsp_info#face_max.[i];
1577 vectorcxx . . $ vector# *v_ptr;
1578
1579 val = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1580 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].vertnumscxx . . $ polyface#vertnums.[t] = val;
1581 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].ucxx . . $ polyface#u.[t] = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1582 pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].vcxx . . $ polyface#v.[t] = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1583
1584 v_ptr = &pm->submodelcxx . . $ poly_model#submodel.[n].vertscxx . . $ bsp_info#verts.[pm->submodelcxx . . $ poly_model#submodel.[n].facescxx . . $ bsp_info#faces.[i].vertnumscxx . . $ polyface#vertnums.[t]];
1585
1586 if (t == 0) {
1587 *min_ptr =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *max_ptr =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *v_ptr;
1588 } else {
1589 if (v_ptr->xcxx . . $ vector#x. < min_ptr->xcxx . . $ vector#x.)
1590 min_ptr->xcxx . . $ vector#x. = v_ptr->xcxx . . $ vector#x.;
1591 else if (v_ptr->xcxx . . $ vector#x. > max_ptr->xcxx . . $ vector#x.)
1592 max_ptr->xcxx . . $ vector#x. = v_ptr->xcxx . . $ vector#x.;
1593
1594 if (v_ptr->ycxx . . $ vector#y. < min_ptr->ycxx . . $ vector#y.)
1595 min_ptr->ycxx . . $ vector#y. = v_ptr->ycxx . . $ vector#y.;
1596 else if (v_ptr->ycxx . . $ vector#y. > max_ptr->ycxx . . $ vector#y.)
1597 max_ptr->ycxx . . $ vector#y. = v_ptr->ycxx . . $ vector#y.;
1598
1599 if (v_ptr->zcxx . . $ vector#z. < min_ptr->zcxx . . $ vector#z.)
1600 min_ptr->zcxx . . $ vector#z. = v_ptr->zcxx . . $ vector#z.;
1601 else if (v_ptr->zcxx . . $ vector#z. > max_ptr->zcxx . . $ vector#z.)
1602 max_ptr->zcxx . . $ vector#z. = v_ptr->zcxx . . $ vector#z.;
1603 }
1604 }
1605
1606 // Do lightmap res computation
1607 if (version_major >= 21) {
1608 float xdiff, ydiff;
1609
1610 xdiff = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1611 ydiff = cf_ReadFloatcxx . . $ cf_ReadFloat(9a03a00aead0d542).(infile);
1612 }
1613 }
1614
1615 break;
1616 }
1617
1618 case ID_GPNTcxx . . $ `model/polymodel.cpp:636:9`!:
1619 pm->n_gunscxx . . $ poly_model#n_guns. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1620 pm->gun_slotscxx . . $ poly_model#gun_slots. = (w_bankcxx . . $ w_bank# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(w_bank) * pm->n_guns);
1621 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->gun_slots != nullptr);
1622
1623 for (i = 0; i < pm->n_gunscxx . . $ poly_model#n_guns.; i++) {
1624 w_bankcxx . . $ w_bank# *bank = &pm->gun_slotscxx . . $ poly_model#gun_slots.[i];
1625
1626 // In Version 19.08 and beyond, gunpoints are associated to their parent object.
1627 if (version >= 19 * 100 + 8) {
1628 bank->parentcxx . . $ w_bank#parent. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1629 } else {
1630 bank->parentcxx . . $ w_bank#parent. = 0;
1631 }
1632
1633 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->pntcxx . . $ w_bank#pnt., infile);
1634 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->normcxx . . $ w_bank#norm., infile);
1635 }
1636 break;
1637
1638 case ID_ATTACHcxx . . $ `model/polymodel.cpp:642:9`!:
1639 pm->n_attachcxx . . $ poly_model#n_attach. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1640 if (pm->n_attachcxx . . $ poly_model#n_attach.) {
1641 pm->attach_slotscxx . . $ poly_model#attach_slots. = (a_bankcxx . . $ a_bank# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(a_bank) * pm->n_attach);
1642 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->attach_slots != nullptr);
1643
1644 for (i = 0; i < pm->n_attachcxx . . $ poly_model#n_attach.; i++) {
1645 a_bankcxx . . $ a_bank# *bank = &pm->attach_slotscxx . . $ poly_model#attach_slots.[i];
1646
1647 bank->parentcxx . . $ a_bank#parent. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1648 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->pntcxx . . $ a_bank#pnt., infile);
1649 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->normcxx . . $ a_bank#norm., infile);
1650 bank->f_uveccxx . . $ a_bank#f_uvec. = false;
1651 }
1652 } else {
1653 pm->attach_slotscxx . . $ poly_model#attach_slots. = nullptr;
1654 }
1655 break;
1656
1657 case ID_ATTACH_NORMALScxx . . $ `model/polymodel.cpp:643:9`!: {
1658 bool f_uvec = false;
1659 int num_normals;
1660
1661 if (pm->n_attachcxx . . $ poly_model#n_attach. == (num_normals = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile)))
1662 f_uvec = true;
1663 else {
•1664 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "WARNING: Ignoring ATTACH normals - total number doesn't match number of attach points\n");
1665 // Int3();
1666 DataErrorcxx . . $ DataError(326aeb464d16410c).("Model <%s> specifies %d attach points but only contains %d attach normals\n", pm->namecxx . . $ poly_model#name., pm->n_attachcxx . . $ poly_model#n_attach.,
1667 num_normals);
1668 }
1669
1670 if (num_normals) {
1671 for (i = 0; i < num_normals; i++) {
1672 vectorcxx . . $ vector# temp;
1673 a_bankcxx . . $ a_bank# *bank = &pm->attach_slotscxx . . $ poly_model#attach_slots.[i];
1674
1675 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1676 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&temp, infile);
1677 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->uveccxx . . $ a_bank#uvec., infile);
1678 bank->f_uveccxx . . $ a_bank#f_uvec. = f_uvec;
1679 }
1680 } else {
1681 pm->attach_slotscxx . . $ poly_model#attach_slots. = nullptr;
1682 }
1683 break;
1684 }
1685
1686 case ID_WBScxx . . $ `model/polymodel.cpp:640:9`!: {
1687 int i;
1688 int j;
1689
1690 // Get the number of weapon batteries on this object
1691 pm->num_wbscxx . . $ poly_model#num_wbs. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1692
1693 if (pm->num_wbscxx . . $ poly_model#num_wbs.) {
1694 pm->poly_wbcxx . . $ poly_model#poly_wb. = (poly_wb_infocxx . . $ poly_wb_info# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(poly_wb_info) * pm->num_wbs);
1695
1696 // Get each individual wb info struct
1697 for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) {
1698 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_gpscxx . . $ poly_wb_info#num_gps. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1699 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_gpscxx . . $ poly_wb_info#num_gps.; j++) {
1700 if (j <= 7)
1701 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].gp_indexcxx . . $ poly_wb_info#gp_index.[j] = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1702 else
1703 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1704 }
1705
1706 if (pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_gpscxx . . $ poly_wb_info#num_gps. > 8)
1707 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_gpscxx . . $ poly_wb_info#num_gps. = 8;
1708
1709 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1710 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
1711 if (j <= 7)
1712 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j] = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1713 else
1714 cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1715 }
1716 if (pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets. > 8)
1717 pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets. = 8;
1718 }
1719 } else {
1720 pm->poly_wbcxx . . $ poly_model#poly_wb. = nullptr;
1721 }
1722
1723 break;
1724 }
1725
1726 case ID_GROUNDcxx . . $ `model/polymodel.cpp:641:9`!:
1727 pm->n_groundcxx . . $ poly_model#n_ground. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1728 pm->ground_slotscxx . . $ poly_model#ground_slots. = (w_bankcxx . . $ w_bank# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(sizeof(w_bank) * pm->n_ground);
1729 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->ground_slots != nullptr);
1730
1731 for (i = 0; i < pm->n_groundcxx . . $ poly_model#n_ground.; i++) {
1732 w_bankcxx . . $ w_bank# *bank = &pm->ground_slotscxx . . $ poly_model#ground_slots.[i];
1733
1734 bank->parentcxx . . $ w_bank#parent. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1735
1736 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->pntcxx . . $ w_bank#pnt., infile);
1737 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&bank->normcxx . . $ w_bank#norm., infile);
1738 }
1739 break;
1740
1741 case ID_TXTRcxx . . $ `model/polymodel.cpp:633:9`!: {
1742 // Texture filename list
1743 int i, n;
1744 char name_buf[128];
1745
1746 // mprintf(0,"Got chunk TXTR, len=%d\n",len);
1747
1748 n = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1749 pm->n_texturescxx . . $ poly_model#n_textures. = n;
1750 ASSERTcxx . . $ `misc/pserror.h:246:9`!(n < MAX_MODEL_TEXTUREScxx . . $ `lib/polymodel_external.h:68:9`!);
1751
1752 for (i = 0; i < n; i++) {
1753 int ret;
1754 char temp[256];
1755
1756 // Read the name of this texture
1757 ReadModelStringLencxx . . $ ReadModelStringLen(72a43f457f0ba537).(name_buf, 127, infile);
1758
1759 strcpy(temp, name_buf);
1760 strcat(temp, ".OGF");
1761
1762 ret = FindTextureBitmapNamecxx . . $ FindTextureBitmapName(5c4306d8553b3696).(temp);
1763 if (ret == -1) {
1764 // See if its already in memory
1765 ret = FindTextureNamecxx . . $ FindTextureName(5c4306d8553b3696).(name_buf);
1766 if (ret == -1) {
1767 ret = 0;
1768 // mprintf(0,"Object texture %s is not in memory!\n",name_buf);
1769 }
1770 }
1771
1772 pm->texturescxx . . $ poly_model#textures.[i] = ret;
1773 if (GameTexturescxx . . $ GameTextures.[ret].alphacxx . . $ texture#alpha. < .99)
1774 pm->flagscxx . . $ poly_model#flags. |= PMF_ALPHAcxx . . $ `lib/polymodel_external.h:223:9`!;
1775 }
1776
1777 break;
1778 }
1779
1780 case ID_ROT_ANIMcxx . . $ `model/polymodel.cpp:637:9`!:
1781 case ID_ANIMcxx . . $ `model/polymodel.cpp:639:9`!: {
1782 int nframes = 0;
1783 // mprintf(0,"ROT ANIM chunk!!!\n");
1784
1785 if (!timed) {
1786 nframes = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1787 pm->num_key_anglescxx . . $ poly_model#num_key_angles. = nframes;
1788 }
1789
1790 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
1791
1792 if (timed) {
1793 pm->submodelcxx . . $ poly_model#submodel.[i].num_key_anglescxx . . $ bsp_info#num_key_angles. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1794 pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_mincxx . . $ bsp_info#rot_track_min. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1795 pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_maxcxx . . $ bsp_info#rot_track_max. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1796
1797 if (pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_mincxx . . $ bsp_info#rot_track_min. < pm->frame_mincxx . . $ poly_model#frame_min.)
1798 pm->frame_mincxx . . $ poly_model#frame_min. = pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_mincxx . . $ bsp_info#rot_track_min.;
1799 if (pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_maxcxx . . $ bsp_info#rot_track_max. > pm->frame_maxcxx . . $ poly_model#frame_max.)
1800 pm->frame_maxcxx . . $ poly_model#frame_max. = pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_maxcxx . . $ bsp_info#rot_track_max.;
1801 } else {
1802 pm->submodelcxx . . $ poly_model#submodel.[i].num_key_anglescxx . . $ bsp_info#num_key_angles. = nframes;
1803 }
1804
1805 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_angles + 1) * sizeof(vector));
1806 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_anglescxx . . $ bsp_info#keyframe_angles. = (int *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_angles + 1) * sizeof(int));
1807 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix. = (matrixcxx . . $ matrix# *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_angles + 1) * sizeof(matrix));
1808 if (timed) {
1809 pm->submodelcxx . . $ poly_model#submodel.[i].rot_start_timecxx . . $ bsp_info#rot_start_time. = (int *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_angles + 1) * sizeof(int));
1810 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].rot_start_time != nullptr);
1811
1812 int num_ticks = (pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_maxcxx . . $ bsp_info#rot_track_max. - pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_mincxx . . $ bsp_info#rot_track_min.);
1813
1814 if (num_ticks > 0) {
1815 pm->submodelcxx . . $ poly_model#submodel.[i].tick_ang_remapcxx . . $ bsp_info#tick_ang_remap. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(num_ticks * 2);
1816 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].tick_ang_remap);
1817 } else {
1818 pm->submodelcxx . . $ poly_model#submodel.[i].tick_ang_remapcxx . . $ bsp_info#tick_ang_remap. = nullptr;
1819 }
1820 }
1821
1822 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].keyframe_axis != nullptr);
1823 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].keyframe_angles != nullptr);
1824 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].keyframe_matrix != nullptr);
1825
1826 for (t = 0; t < pm->submodelcxx . . $ poly_model#submodel.[i].num_key_anglescxx . . $ bsp_info#num_key_angles.; t++) {
1827 vectorcxx . . $ vector# *axis;
1828 float mag;
1829
1830 if (timed)
1831 pm->submodelcxx . . $ poly_model#submodel.[i].rot_start_timecxx . . $ bsp_info#rot_start_time.[t] = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1832
1833 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[t + 0], infile);
1834 axis = &pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[t + 0];
1835
1836 mag = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(axis);
1837 if (mag > 0)
1838 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[t] /=cxx . . $ `operator/=`(f132838b2cd11d6). mag;
1839
1840 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_anglescxx . . $ bsp_info#keyframe_angles.[t + 0] = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1841 // if this axis is backwards, rotate the angle the other direction
1842 if (t == 0) {
1843 /*if (pm->submodel[i].keyframe_angles[0]>=32768)
1844 {
1845 mprintf(0,"\nFlipping suboject %s!\n",pm->submodel[i].name);
1846 pm->submodel[i].keyframe_angles[0]*=-1;
1847 }*/
1848 }
1849 /*else
1850 dir=vm_DotProduct (axis,&pm->submodel[i].keyframe_axis[1]);
1851
1852 if (dir<0)
1853 {
1854 pm->submodel[i].keyframe_angles[t+0]*=-1;
1855 pm->submodel[i].keyframe_axis[t+0]*=-1.0;
1856 }*/
1857 }
1858 }
1859
1860 break;
1861 }
1862
1863 case ID_POS_ANIMcxx . . $ `model/polymodel.cpp:638:9`!: {
1864 int nframes = 0;
1865
1866 // mprintf(0,"POS ANIM chunk!!!\n");
1867 if (!timed) {
1868 nframes = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1869 pm->num_key_poscxx . . $ poly_model#num_key_pos. = nframes;
1870 }
1871
1872 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
1873 if (timed) {
1874 pm->submodelcxx . . $ poly_model#submodel.[i].num_key_poscxx . . $ bsp_info#num_key_pos. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1875 pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_mincxx . . $ bsp_info#pos_track_min. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1876 pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_maxcxx . . $ bsp_info#pos_track_max. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1877
1878 if (pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_mincxx . . $ bsp_info#pos_track_min. < pm->frame_mincxx . . $ poly_model#frame_min.)
1879 pm->frame_mincxx . . $ poly_model#frame_min. = pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_mincxx . . $ bsp_info#pos_track_min.;
1880 if (pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_maxcxx . . $ bsp_info#pos_track_max. > pm->frame_maxcxx . . $ poly_model#frame_max.)
1881 pm->frame_maxcxx . . $ poly_model#frame_max. = pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_maxcxx . . $ bsp_info#pos_track_max.;
1882
1883 int num_ticks = (pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_maxcxx . . $ bsp_info#pos_track_max. - pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_mincxx . . $ bsp_info#pos_track_min.);
1884
1885 if (num_ticks > 0) {
1886 pm->submodelcxx . . $ poly_model#submodel.[i].tick_pos_remapcxx . . $ bsp_info#tick_pos_remap. = (uint16_tcxx . . $ uint16_t# *)mem_malloccxx . . $ `mem/mem.h:79:9`!(num_ticks * 2);
1887 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].tick_pos_remap);
1888 } else {
1889 pm->submodelcxx . . $ poly_model#submodel.[i].tick_pos_remapcxx . . $ bsp_info#tick_pos_remap. = nullptr;
1890 }
1891
1892 } else
1893 pm->submodelcxx . . $ poly_model#submodel.[i].num_key_poscxx . . $ bsp_info#num_key_pos. = nframes;
1894
1895 pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos. = (vectorcxx . . $ vector# *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_pos + 1) * sizeof(vector));
1896 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].keyframe_pos != nullptr);
1897
1898 if (timed) {
1899 pm->submodelcxx . . $ poly_model#submodel.[i].pos_start_timecxx . . $ bsp_info#pos_start_time. = (int *)mem_malloccxx . . $ `mem/mem.h:79:9`!((pm->submodel[i].num_key_pos + 1) * sizeof(int));
1900 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].pos_start_time != nullptr);
1901 }
1902
1903 for (t = 0; t < pm->submodelcxx . . $ poly_model#submodel.[i].num_key_poscxx . . $ bsp_info#num_key_pos.; t++) {
1904 if (timed)
1905 pm->submodelcxx . . $ poly_model#submodel.[i].pos_start_timecxx . . $ bsp_info#pos_start_time.[t] = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile);
1906
1907 ReadModelVectorcxx . . $ ReadModelVector(bd156e1228da3ce).(&pm->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[t + 0], infile);
1908 }
1909 }
1910
1911 break;
1912 }
1913 default:
1914 // mprintf(0,"Unknown chunk <%c%c%c%c>, len = %d\n",id,id>>8,id>>16,id>>24,len);
1915 cfseekcxx . . $ cfseek(f9992d249f032805).(infile, len, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!);
1916 break;
1917 }
1918 }
1919
1920 // Set the greater of keyframe of positions or keyframe angles to to be max keyframes
1921 pm->max_keyscxx . . $ poly_model#max_keys. = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(pm->num_key_poscxx . . $ poly_model#num_key_pos., pm->num_key_anglescxx . . $ poly_model#num_key_angles.);
1922
1923 // Build animation keyframe matrices
1924
1925 matrixcxx . . $ matrix# base_matrix, dest_matrix, temp_matrix;
1926 int cur_angle;
1927 int parent;
1928
1929 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
1930 vm_MakeIdentitycxx . . $ vm_MakeIdentity(dca75c48c9ab5b54).(&base_matrix);
1931
1932 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[i];
1933
1934 for (int newt = 0; newt < sm->num_key_anglescxx . . $ bsp_info#num_key_angles.; newt++) {
1935 cur_angle = sm->keyframe_anglescxx . . $ bsp_info#keyframe_angles.[newt];
1936 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, cur_angle, &sm->keyframe_axiscxx . . $ bsp_info#keyframe_axis.[newt]);
1937 vm_MakeIdentitycxx . . $ vm_MakeIdentity(dca75c48c9ab5b54).(&dest_matrix);
1938 dest_matrix =cxx . . $ matrix#`operator=`(e859ffc26b91394f). temp_matrix *cxx . . $ `operator*`(683f8e040c904cb). base_matrix;
1939 base_matrix =cxx . . $ matrix#`operator=`(4c6f8b29806742). dest_matrix;
1940 sm->keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[newt] =cxx . . $ matrix#`operator=`(4c6f8b29806742). base_matrix;
1941 }
1942
1943 // Build children
1944 parent = pm->submodelcxx . . $ poly_model#submodel.[i].parentcxx . . $ bsp_info#parent.;
1945
1946 if (parent == i) {
1947 pm->submodelcxx . . $ poly_model#submodel.[i].parentcxx . . $ bsp_info#parent. = -1;
1948
1949 } else if (parent != -1) {
1950 pm->submodelcxx . . $ poly_model#submodel.[parent].childrencxx . . $ bsp_info#children.[pm->submodelcxx . . $ poly_model#submodel.[parent].num_childrencxx . . $ bsp_info#num_children.] = i;
1951 pm->submodelcxx . . $ poly_model#submodel.[parent].num_childrencxx . . $ bsp_info#num_children.++;
1952 }
1953
1954 if (pm->submodelcxx . . $ poly_model#submodel.[i].num_key_anglescxx . . $ bsp_info#num_key_angles. == 0 && (pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!)) {
1955 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "You have a rotator that has no keyframe on model %s.\n", pm->name);
1956 pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. &= ~SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!;
1957 } else if (pm->submodelcxx . . $ poly_model#submodel.[i].num_key_anglescxx . . $ bsp_info#num_key_angles. == 0 && (pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!)) {
1958 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "You have a turret that has no keyframe on model %s.\n", pm->name);
1959 pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. &= ~SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!;
1960 }
1961
1962 // Figure out the size of this facing subobject
1963 if (pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_FACINGcxx . . $ `lib/polymodel_external.h:92:9`!) {
1964 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].num_faces == 1); // This facing has more than one face
1965 vectorcxx . . $ vector# vecs[30];
1966 vectorcxx . . $ vector# avg;
1967
1968 for (int newt = 0; newt < pm->submodelcxx . . $ poly_model#submodel.[i].facescxx . . $ bsp_info#faces.[0].nvertscxx . . $ polyface#nverts.; newt++) {
1969 vecs[newt] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->submodelcxx . . $ poly_model#submodel.[i].vertscxx . . $ bsp_info#verts.[pm->submodelcxx . . $ poly_model#submodel.[i].facescxx . . $ bsp_info#faces.[0].vertnumscxx . . $ polyface#vertnums.[newt]];
1970 }
1971
1972 pm->submodelcxx . . $ poly_model#submodel.[i].radcxx . . $ bsp_info#rad. = (sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(vm_GetCentroidcxx . . $ vm_GetCentroid(9f2e9a768aacd0cc).(&avg, vecs, pm->submodelcxx . . $ poly_model#submodel.[i].facescxx . . $ bsp_info#faces.[0].nvertscxx . . $ polyface#nverts.)) / 2);
1973
1974 pm->flagscxx . . $ poly_model#flags. |= PMF_FACINGcxx . . $ `lib/polymodel_external.h:224:9`!;
1975 }
1976
1977 if (pm->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & (SOF_GLOWcxx . . $ `lib/polymodel_external.h:96:9`! | SOF_THRUSTERcxx . . $ `lib/polymodel_external.h:98:9`!)) {
1978 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->submodel[i].num_faces == 1); // This glow has more than one face
1979 vectorcxx . . $ vector# vecs[30];
1980
1981 for (t = 0; t < pm->submodelcxx . . $ poly_model#submodel.[i].facescxx . . $ bsp_info#faces.[0].nvertscxx . . $ polyface#nverts.; t++)
1982 vecs[t] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->submodelcxx . . $ poly_model#submodel.[i].vertscxx . . $ bsp_info#verts.[pm->submodelcxx . . $ poly_model#submodel.[i].facescxx . . $ bsp_info#faces.[0].vertnumscxx . . $ polyface#vertnums.[t]];
1983
1984 vm_GetNormalcxx . . $ vm_GetNormal(f84d76fdbff5e570).(&pm->submodelcxx . . $ poly_model#submodel.[i].glow_infocxx . . $ bsp_info#glow_info.->normalcxx . . $ glowinfo#normal., &vecs[0], &vecs[1], &vecs[2]);
1985
1986 pm->flagscxx . . $ poly_model#flags. |= PMF_FACINGcxx . . $ `lib/polymodel_external.h:224:9`!; // Set this so we know when to draw
1987 }
1988
1989 // Now build the tick/keyframe remap list
1990 int num_ticks = (pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_maxcxx . . $ bsp_info#pos_track_max. - pm->submodelcxx . . $ poly_model#submodel.[i].pos_track_mincxx . . $ bsp_info#pos_track_min.);
1991 for (t = 0; timed && t < num_ticks; t++) {
1992 int done = 0;
1993 int current_tick = sm->pos_track_mincxx . . $ bsp_info#pos_track_min. + t;
1994
1995 if (sm->num_key_poscxx . . $ bsp_info#num_key_pos. > 1) {
1996 for (int k = sm->num_key_poscxx . . $ bsp_info#num_key_pos. - 1; k >= 0 && !done; k--) {
1997 if (current_tick >= sm->pos_start_timecxx . . $ bsp_info#pos_start_time.[k]) {
1998 sm->tick_pos_remapcxx . . $ bsp_info#tick_pos_remap.[t] = k;
1999 done = 1;
2000 }
2001 }
2002
2003 if (done == 0) {
2004 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Couldn't get a good keyframe!\n");
2005 Int3cxx . . $ `misc/pserror.h:247:9`!();
2006 }
2007 }
2008 }
2009
2010 // Now build the tick/keyframe remap list
2011 num_ticks = (pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_maxcxx . . $ bsp_info#rot_track_max. - pm->submodelcxx . . $ poly_model#submodel.[i].rot_track_mincxx . . $ bsp_info#rot_track_min.);
2012 for (t = 0; timed && t < num_ticks; t++) {
2013 if (sm->num_key_anglescxx . . $ bsp_info#num_key_angles. > 1) {
2014 int done = 0;
2015 int current_tick = sm->rot_track_mincxx . . $ bsp_info#rot_track_min. + t;
2016 for (int k = sm->num_key_anglescxx . . $ bsp_info#num_key_angles. - 1; k >= 0 && !done; k--) {
2017 if (current_tick >= sm->rot_start_timecxx . . $ bsp_info#rot_start_time.[k]) {
2018 sm->tick_ang_remapcxx . . $ bsp_info#tick_ang_remap.[t] = k;
2019 done = 1;
2020 }
2021 }
2022
2023 if (done == 0) {
2024 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Couldn't get a good keyframe!\n");
2025 Int3cxx . . $ `misc/pserror.h:247:9`!();
2026 }
2027 }
2028 }
2029 }
2030
2031 pm->flagscxx . . $ poly_model#flags. &= ~PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!; // mark it as in memory
2032
2033 // Find Min/Max of whole model
2034 FindMinMaxForModelcxx . . $ FindMinMaxForModel(1a01b89d31d9e19d).(pm);
2035
2036 // adjust positional interpolation frames
2037
2038
2039 FindWBSubobjectscxx . . $ FindWBSubobjects(1a01b89d31d9e19d).(pm);
2040
2041 // Set as newstyle
2042 pm->new_stylecxx . . $ poly_model#new_style. = 1;
2043
2044 if (pm->n_modelscxx . . $ poly_model#n_models. > MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!) {
2045 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "This model has more than the max number of subobjects! (%d)\n", MAX_SUBOBJECTS);
2046 Int3cxx . . $ `misc/pserror.h:247:9`!();
2047 FreePolyModelcxx . . $ FreePolyModel(d4f767463ce0a6b3).(pm - Poly_modelscxx . . $ Poly_models.);
2048 return 0;
2049 }
2050
2051 return 1;
2052 }
2053
2054 // given a filename, reads in a POF and returns an index into the Poly_models array
2055 // returns -1 if something is wrong
2056 int LoadPolyModelcxx . . $ LoadPolyModel(220e687f58daa9be).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &filename, int pageable) {
2057 int i, polynum = -1;
2058 CFILEcxx . . $ CFILE# *infile = nullptr;
2059 int overlay = 0;
2060
2061 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_poly_models >= 0);
2062 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Num_poly_models < MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!);
2063
2064 stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# name = ChangePolyModelNamecxx . . $ ChangePolyModelName(4ac62a867fe4334a).(filename);
2065
2066 // If this polymodel is already in memory, just use that index
2067 i = FindPolyModelNamecxx . . $ FindPolyModelName(293b0826c8d9cb54).(name);
2068 if (i != -1) {
2069 #ifdef RELEASE
2070 Poly_models[i].used++;
2071 return i;
2072 #endif
2073
2074 int old_used = Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used.;
2075 int not_res = 0;
2076
2077 if (Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!)
2078 not_res = 1;
2079
2080 mprintfcxx . . $ `ddebug/mono.h:82:9`!(1, "Model '%s' usage count is now %d.\n", Poly_models[i].name, Poly_models[i].used + 1);
2081
2082 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. = 1;
2083 FreePolyModelcxx . . $ FreePolyModel(d4f767463ce0a6b3).(i);
2084
2085 memset(&Poly_modelscxx . . $ Poly_models.[i], 0, sizeof(poly_modelcxx . . $ poly_model#));
2086 WBClearInfocxx . . $ WBClearInfo(1a01b89d31d9e19d).(&Poly_modelscxx . . $ Poly_models.[i]);
2087 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. = old_used + 1;
2088 if (not_res)
2089 Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. = PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!;
2090
2091 overlay = 1;
2092 polynum = i;
2093 }
2094
2095 // Not in memory, so we must load it
2096
2097 if (!pageable) {
2098 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filename, "rb");
2099 if (!infile)
2100 return -1;
2101 }
2102
2103 if (!overlay)
2104 polynum = AllocPolyModelcxx . . $ AllocPolyModel(b126dc7c1de90089).();
2105 else {
2106 if (!(Poly_modelscxx . . $ Poly_models.[polynum].flagscxx . . $ poly_model#flags. & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!)) {
2107 if (pageable) {
2108 infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(filename, "rb");
2109 if (!infile)
2110 return -1;
2111 }
2112 pageable = 0;
2113 }
2114 }
2115
2116 ASSERTcxx . . $ `misc/pserror.h:246:9`!(polynum >= 0);
2117
2118 // Used for progress bar when loading the level
2119 if (infile) {
2120 paged_in_countcxx . . $ paged_in_count. += cfilelengthcxx . . $ cfilelength(e4541f75b25d0ae5).(infile);
2121 paged_in_numcxx . . $ paged_in_num.++;
2122 }
2123
2124 // if this is an oof instead of a pof, flag it as such
2125 if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(".oof", filename.extension().u8string().c_str())) {
2126 Poly_modelscxx . . $ Poly_models.[polynum].new_stylecxx . . $ poly_model#new_style. = 1;
2127 } else
2128 Poly_modelscxx . . $ Poly_models.[polynum].new_stylecxx . . $ poly_model#new_style. = 0;
2129
2130 strcpy(Poly_modelscxx . . $ Poly_models.[polynum].namecxx . . $ poly_model#name., name.u8stringcxx . . $ std/filesystem/__cxx11/path#u8string(219584694fe2b248).().c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).());
2131
2132 int ret = 0;
2133 if (!pageable)
2134 ret = ReadNewModelFilecxx . . $ ReadNewModelFile(9b62bdb6c772a53a).(polynum, infile);
2135 else
2136 ret = 1;
2137
2138 if (infile)
2139 cfclosecxx . . $ cfclose(3639e799710acb68).(infile);
2140
2141 Poly_modelscxx . . $ Poly_models.[polynum].idcxx . . $ poly_model#id. = polynum;
2142
2143 if (ret)
2144 return polynum; // loaded successfully
2145
2146 return -1; // damn, didn't load
2147 }
2148
2149 // Pages in a polymodel if its not already in memory
2150 void PageInPolymodelcxx . . $ PageInPolymodel(726816c99d57134).(int polynum, int type, float *size_ptr) {
2151 if (!(Poly_modelscxx . . $ Poly_models.[polynum].flagscxx . . $ poly_model#flags. & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!)) {
2152 if (!(Poly_modelscxx . . $ Poly_models.[polynum].flagscxx . . $ poly_model#flags. & PMF_SIZE_COMPUTEDcxx . . $ `lib/polymodel_external.h:226:9`!))
2153 if (type != -1) {
2154 ComputeDefaultSizecxx . . $ ComputeDefaultSize(30915566dd087c6c).(type, polynum, size_ptr);
2155 }
2156 return;
2157 }
2158
2159 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Paging in polymodel %s.\n", Poly_models[polynum].name);
2160
2161 CFILEcxx . . $ CFILE# *infile;
2162 infile = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(Poly_modelscxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).[polynum].namecxx . . $ poly_model#name., "rb");
2163
2164 if (!infile) {
2165 // due to a bug in some 3rd party tablefile editors, full paths might
2166 // have been used when they shouldn't have been
2167 char *end_ptr, *start_ptr;
2168 start_ptr = Poly_modelscxx . . $ Poly_models.[polynum].namecxx . . $ poly_model#name.;
2169 end_ptr = start_ptr + strlen(start_ptr) - 1;
2170 while ((end_ptr >= start_ptr) && (*end_ptr != '\\'))
2171 end_ptr--;
2172 if (end_ptr < start_ptr) {
2173 Errorcxx . . $ Error(326aeb464d16410c).("Failed to page in %s.", Poly_modelscxx . . $ Poly_models.[polynum].namecxx . . $ poly_model#name.);
2174 return;
2175 }
2176
2177 ASSERTcxx . . $ `misc/pserror.h:246:9`!(*end_ptr == '\\');
2178 end_ptr++;
2179
2180 infile = (CFILEcxx . . $ CFILE# *)cfopencxx . . $ cfopen(7c7b94e455f1ae56).(end_ptrcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb");
2181 if (!infile) {
2182 Errorcxx . . $ Error(326aeb464d16410c).("Failed to page in %s.", Poly_modelscxx . . $ Poly_models.[polynum].namecxx . . $ poly_model#name.);
2183 return;
2184 }
2185 }
2186
2187 // ASSERT(infile);
2188
2189 int ret = ReadNewModelFilecxx . . $ ReadNewModelFile(9b62bdb6c772a53a).(polynum, infile);
2190
2191 cfclosecxx . . $ cfclose(3639e799710acb68).(infile);
2192 ASSERTcxx . . $ `misc/pserror.h:246:9`!(ret > 0);
2193
2194 // See if textures need to be remapped
2195 int remap = 0;
2196 for (int t = 0; t < Poly_modelscxx . . $ Poly_models.[polynum].n_texturescxx . . $ poly_model#n_textures.; t++)
2197 if (Poly_modelscxx . . $ Poly_models.[polynum].texturescxx . . $ poly_model#textures.[t] == 0) // is there a bad texture?
2198 remap = 1;
2199
2200 if (remap == 1) {
2201 // remap the damn textures
2202 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Remapping model textures for model %s.\n", Poly_models[polynum].name);
2203 ReloadModelTexturescxx . . $ ReloadModelTextures(7864480464b09eea).(polynum);
2204 }
2205
2206 if (type != -1) {
2207 ComputeDefaultSizecxx . . $ ComputeDefaultSize(30915566dd087c6c).(type, polynum, size_ptr);
2208 }
2209 }
2210
2211 // Gets a pointer to a polymodel. Pages it in if neccessary
2212 poly_modelcxx . . $ poly_model# *GetPolymodelPointercxx . . $ GetPolymodelPointer(ac85e77c73ebf794).(int polynum) {
2213 if (Poly_modelscxx . . $ Poly_models.[polynum].flagscxx . . $ poly_model#flags. & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!)
2214 PageInPolymodelcxx . . $ PageInPolymodel(726816c99d57134).(polynum);
2215
2216 return (&Poly_modelscxx . . $ Poly_models.[polynum]);
2217 }
2218
2219 // gets the filename from a path
2220 stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# ChangePolyModelNamecxx . . $ ChangePolyModelName(4ac62a867fe4334a).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &src) {
2221 // Make sure we don't go over our name length limit
2222 stdcxx . . $ std/::stringcxx . . $ std/string# dest = src.stemcxx . . $ std/filesystem/__cxx11/path#stem(159787a050b29eb0).().stringcxx . . $ std/filesystem/__cxx11/path#string(219584694fe2b248).().substrcxx . . $ std/__cxx11/basic_string#substr(149c655009c9bbd2).(0, PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`! - 5);
2223 stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# filename = stdcxx . . $ std/filesystem/__cxx11/path#path(3f42e2c2fac0d5fc).::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#(dest).replace_extensioncxx . . $ std/filesystem/__cxx11/path#replace_extension(554473e25f389c7d).(src.extensioncxx . . $ std/filesystem/__cxx11/path#extension(159787a050b29eb0).());
2224 return filenamecxx . . $ std/filesystem/__cxx11/path#path(91601bf9ad65ca31).;
2225 }
2226
2227 // Searches thru all polymodels for a specific name, returns -1 if not found
2228 // or index of polymodel with name
2229 int FindPolyModelNamecxx . . $ FindPolyModelName(293b0826c8d9cb54).(const stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# &name) {
2230 for (int i = 0; i < MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!; i++) {
2231 if (Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. && !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(Poly_models[i].name, name.u8string().c_str())) {
2232 return i;
2233 }
2234 }
2235
2236 return -1;
2237 }
2238
2239 // Sets a positional instance
2240 void StartPolyModelPosInstancecxx . . $ StartPolyModelPosInstance(ec8cf6451c36d470).(vectorcxx . . $ vector# *posvec) {
2241
2242 Interp_pos_instance_veccxx . . $ Interp_pos_instance_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *posvec;
2243
2244 Instance_vec_stackcxx . . $ Instance_vec_stack.[Instance_vec_cntcxx . . $ Instance_vec_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Interp_pos_instance_veccxx . . $ Interp_pos_instance_vec.;
2245 Instance_vec_cntcxx . . $ Instance_vec_cnt.++;
2246 }
2247
2248 // Pops a positional instance
2249 void DonePolyModelPosInstancecxx . . $ DonePolyModelPosInstance(49f6e7a06ebc5aa8).() {
2250 Instance_vec_cntcxx . . $ Instance_vec_cnt.--;
2251
2252 if (Instance_vec_cntcxx . . $ Instance_vec_cnt. == 0)
2253 memset(&Interp_pos_instance_veccxx . . $ Interp_pos_instance_vec., 0, sizeof(vectorcxx . . $ vector#));
2254 else
2255 Interp_pos_instance_veccxx . . $ Interp_pos_instance_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_vec_stackcxx . . $ Instance_vec_stack.[Instance_vec_cntcxx . . $ Instance_vec_cnt.];
2256 }
2257
2258 void SetNormalizedTimeObjTimedcxx . . $ SetNormalizedTimeObjTimed(8af4de573afdac78).(objectcxx . . $ object# *obj, float *normalized_time) {
2259 int i, j;
2260 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
2261 object_infocxx . . $ object_info# *obj_info = &Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.];
2262
2263 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!)
2264 return;
2265
2266 // Setup all the subobjects for the keyframe
2267 float frame = obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_framecxx . . $ polyobj_info#anim_frame.;
2268
2269 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
2270 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[i];
2271 int x = (sm->flagscxx . . $ bsp_info#flags. & SOF_WB_MASKScxx . . $ `model/polymodel.h:309:9`!) >> WB_INDEX_SHIFTcxx . . $ `model/polymodel.h:308:9`!;
2272
2273 if (!(sm->flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!) &&
2274 !((sm->flagscxx . . $ bsp_info#flags. & SOF_WBcxx . . $ `lib/polymodel_external.h:95:9`!) && ((obj_info->static_wbcxx . . $ object_info#static_wb.[x].flagscxx . . $ otype_wb_info#flags. & WBF_ANIM_MASKScxx . . $ `lib/robotfirestruct_external.h:30:9`!) == WBF_ANIM_LOCALcxx . . $ `lib/robotfirestruct_external.h:28:9`!))) {
2275 if (frame <= sm->rot_track_mincxx . . $ bsp_info#rot_track_min.)
2276 normalized_time[i] = 0.0;
2277 else if (frame >= sm->rot_track_maxcxx . . $ bsp_info#rot_track_max.)
2278 normalized_time[i] = 1.0;
2279 else {
2280 float total_time = sm->rot_track_maxcxx . . $ bsp_info#rot_track_max. - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.;
2281 normalized_time[i] = (frame - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.) / total_time;
2282 }
2283 } else if ((sm->flagscxx . . $ bsp_info#flags. & SOF_WBcxx . . $ `lib/polymodel_external.h:95:9`!) && !(sm->flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!)) {
2284 static float w_frame;
2285 ASSERTcxx . . $ `misc/pserror.h:246:9`!(x >= 0 && x < MAX_WBS_PER_OBJcxx . . $ `lib/robotfirestruct.h:32:9`!);
2286
2287 if (obj->dynamic_wbcxx . . $ object#dynamic_wb.)
2288 w_frame = obj->dynamic_wbcxx . . $ object#dynamic_wb.[x].wb_anim_framecxx . . $ dynamic_wb_info#wb_anim_frame.;
2289 else
2290 w_frame = 0;
2291
2292 if (w_frame <= sm->rot_track_mincxx . . $ bsp_info#rot_track_min.)
2293 normalized_time[i] = 0.0;
2294 else if (w_frame >= sm->rot_track_maxcxx . . $ bsp_info#rot_track_max.)
2295 normalized_time[i] = 1.0;
2296 else {
2297 float total_time = sm->rot_track_maxcxx . . $ bsp_info#rot_track_max. - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.;
2298 normalized_time[i] = (w_frame - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.) / total_time;
2299 }
2300 }
2301 }
2302
2303 // Now, override angles of weapon bank turrets
2304 if (obj->dynamic_wbcxx . . $ object#dynamic_wb.) {
2305 for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) {
2306 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
2307 int sobj_index;
2308
2309 sobj_index = pm->poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j];
2310 normalized_time[sobj_index] = obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].norm_turret_anglecxx . . $ dynamic_wb_info#norm_turret_angle.[j];
2311 }
2312 }
2313 } else {
2314 for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) {
2315 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
2316 int sobj_index;
2317
2318 sobj_index = pm->poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j];
2319 normalized_time[sobj_index] = 0;
2320 }
2321 }
2322 }
2323 }
2324
2325 void SetNormalizedTimeObjcxx . . $ SetNormalizedTimeObj(8af4de573afdac78).(objectcxx . . $ object# *obj, float *normalized_time) {
2326 int i, j;
2327
2328 if (Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.].flagscxx . . $ poly_model#flags. & PMF_TIMEDcxx . . $ `lib/polymodel_external.h:222:9`!) {
2329 SetNormalizedTimeObjTimedcxx . . $ SetNormalizedTimeObjTimed(8af4de573afdac78).(obj, normalized_time);
2330 return;
2331 }
2332
2333 float norm_anim_frame = GetNormalizedKeyframecxx . . $ GetNormalizedKeyframe(d7799857c894622e).(obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num., obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_framecxx . . $ polyobj_info#anim_frame.);
2334
2335 // Setup all the subobjects for the keyframe
2336 for (i = 0; i < Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.].n_modelscxx . . $ poly_model#n_models.; i++)
2337 normalized_time[i] = norm_anim_frame;
2338
2339 // Currently, we are not handling player weapons in this manner
2340 // chrishack -- weapons with turrets -- COOL.
2341 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!)
2342 return;
2343
2344 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->type == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || obj->type == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->type == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! || obj->type == OBJ_DEBRIScxx . . $ `Descent3/object_external.h:168:9`! ||
2345 obj->type == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`! || obj->type == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!);
2346
2347 // Now, override angles of weapon bank turrets
2348 for (i = 0; i < Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.].num_wbscxx . . $ poly_model#num_wbs.; i++) {
2349 for (j = 0; j < Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.].poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
2350 int sobj_index;
2351
2352 sobj_index = Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.].poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j];
2353 normalized_time[sobj_index] = obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].norm_turret_anglecxx . . $ dynamic_wb_info#norm_turret_angle.[j];
2354 }
2355 }
2356 }
2357
2358 void SetNormalizedTimeAnimTimedcxx . . $ SetNormalizedTimeAnimTimed(40d1f0252a152310).(float frame, float *normalized_time, poly_modelcxx . . $ poly_model# *pm) {
2359 int i, j;
2360
2361 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2362
2363 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
2364 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[i];
2365
2366 if (frame <= sm->rot_track_mincxx . . $ bsp_info#rot_track_min.)
2367 normalized_time[i] = 0.0;
2368 else if (frame >= sm->rot_track_maxcxx . . $ bsp_info#rot_track_max.)
2369 normalized_time[i] = 1.0;
2370 else {
2371 float total_time = sm->rot_track_maxcxx . . $ bsp_info#rot_track_max. - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.;
2372 normalized_time[i] = (frame - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.) / total_time;
2373 }
2374 }
2375
2376 // Now, override angles of weapon bank turrets
2377 for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) {
2378 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
2379 int sobj_index;
2380
2381 sobj_index = pm->poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j];
2382 normalized_time[sobj_index] = 0.0;
2383 }
2384 }
2385 }
2386
2387 // This is for non-rotated turrets or rotators
2388 void SetNormalizedTimeAnimcxx . . $ SetNormalizedTimeAnim(40d1f0252a152310).(float anim_frame, float *normalized_time, poly_modelcxx . . $ poly_model# *pm) {
2389 int i, j;
2390
2391 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2392
2393 float norm_anim_frame = anim_frame / pm->max_keyscxx . . $ poly_model#max_keys.;
2394
2395 if (pm->flagscxx . . $ poly_model#flags. & PMF_TIMEDcxx . . $ `lib/polymodel_external.h:222:9`!) {
2396 SetNormalizedTimeAnimTimedcxx . . $ SetNormalizedTimeAnimTimed(40d1f0252a152310).(anim_frame, normalized_time, pm);
2397 return;
2398 }
2399
2400 // Setup all the subobjects for the keyframe
2401 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++)
2402 normalized_time[i] = norm_anim_frame;
2403
2404 // Now, override angles of weapon bank turrets
2405 for (i = 0; i < pm->num_wbscxx . . $ poly_model#num_wbs.; i++) {
2406 for (j = 0; j < pm->poly_wbcxx . . $ poly_model#poly_wb.[i].num_turretscxx . . $ poly_wb_info#num_turrets.; j++) {
2407 int sobj_index;
2408
2409 sobj_index = pm->poly_wbcxx . . $ poly_model#poly_wb.[i].turret_indexcxx . . $ poly_wb_info#turret_index.[j];
2410 normalized_time[sobj_index] = 0.0;
2411 }
2412 }
2413 }
2414
2415 // Given a model pointer and an array of floats that go from 0..1, calculate the angles of each
2416 // corresponding subobject
2417 void SetModelAnglescxx . . $ SetModelAngles(ed97be8d9db46e36).(poly_modelcxx . . $ poly_model# *po, const float *normalized_angles) {
2418 int i;
2419
2420 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(po->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2421
2422 if (po->num_key_anglescxx . . $ poly_model#num_key_angles. > 0 && normalized_angles) {
2423 // get time per keyframe state
2424 float state_time = 1.0 / (po->num_key_anglescxx . . $ poly_model#num_key_angles. - 1);
2425 float cur_state_time;
2426 int cur_state;
2427 float normal_state_time;
2428
2429 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2430 // Don't rotate turrets or auto-rotators or weapon battery submodels
2431 if (!(po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & (SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`! | SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!))) {
2432
2433 // Find out which keyframe we're at
2434
2435 cur_state = normalized_angles[i] / state_time;
2436 matrixcxx . . $ matrix# dest_matrix;
2437
2438 // Find out how far into that keyframe we are
2439 cur_state_time = normalized_angles[i] - ((float)cur_state * state_time);
2440 normal_state_time = cur_state_time / state_time;
2441
2442 // Now do a parametric adjustment on the angles
2443
2444 int cur_angle = 0;
2445
2446 // If we're already at the high point of the interpolation then just
2447 // stuff some values
2448 if (cur_state == po->num_key_anglescxx . . $ poly_model#num_key_angles. - 1) {
2449 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[po->num_key_anglescxx . . $ poly_model#num_key_angles. - 1]);
2450 continue;
2451 }
2452
2453 dest_matrix =cxx . . $ matrix#`operator=`(e859ffc26b91394f). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[cur_state] +cxx . . $ operator+(683f8e040c904cb).
2454 ((po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[cur_state + 1] -cxx . . $ operator-(683f8e040c904cb). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[cur_state]) *cxx . . $ `operator*`(2f7784e05c935c16).
2455 normal_state_time);
2456
2457 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &dest_matrix);
2458 // po->submodel[i].mod_matrix=dest_matrix;
2459
2460 } else if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!) {
2461 float flrot = Gametimecxx . . $ Gametime. * po->submodelcxx . . $ poly_model#submodel.[i].rpscxx . . $ bsp_info#rps.;
2462 int introt = flrot;
2463
2464 float fdiff = flrot - introt;
2465
2466 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fdiff >= 0 && fdiff <= 1);
2467
2468 // fdiff now equals 0 to 1
2469 matrixcxx . . $ matrix# temp_matrix;
2470 vectorcxx . . $ vector# temp_vec;
2471 if (po->new_stylecxx . . $ poly_model#new_style.)
2472 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[1];
2473 else
2474 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.;
2475
2476 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, fdiff * 65535, &temp_vec);
2477 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2478 } else if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!) {
2479 matrixcxx . . $ matrix# temp_matrix;
2480 if (po->new_stylecxx . . $ poly_model#new_style.)
2481 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, normalized_angles[i] * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[1]);
2482 else
2483 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, normalized_angles[i] * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.);
2484
2485 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2486 }
2487 }
2488 } else {
2489 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2490 if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!) {
2491 float flrot = Gametimecxx . . $ Gametime. * po->submodelcxx . . $ poly_model#submodel.[i].rpscxx . . $ bsp_info#rps.;
2492 int introt = flrot;
2493
2494 float fdiff = flrot - introt;
2495
2496 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fdiff >= 0 && fdiff <= 1);
2497
2498 // fdiff now equals 0 to 1
2499 matrixcxx . . $ matrix# temp_matrix;
2500 vectorcxx . . $ vector# temp_vec;
2501 if (po->new_stylecxx . . $ poly_model#new_style.)
2502 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[1];
2503 else
2504 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.;
2505
2506 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, fdiff * 65535, &temp_vec);
2507 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2508 } else if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!) {
2509 // We need to find where in this rotation is relative to gametime
2510 float flrot = Gametimecxx . . $ Gametime.;
2511 int introt = flrot;
2512
2513 float fdiff = flrot - introt;
2514
2515 // fdiff now equals 0 to 1
2516 matrixcxx . . $ matrix# temp_matrix;
2517 if (po->new_stylecxx . . $ poly_model#new_style.)
2518 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, fdiff * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[0]);
2519 else
2520 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, fdiff * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.);
2521
2522 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2523 } else {
2524 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h. = 0;
2525 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..pcxx . . $ angvec#p. = 0;
2526 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h. = 0;
2527 }
2528 }
2529 }
2530 }
2531
2532 // Given a model pointer and an array of floats that go from 0..1, calculate the interpolated
2533 // position of each corresponding subobject
2534 void SetModelInterpPoscxx . . $ SetModelInterpPos(ed97be8d9db46e36).(poly_modelcxx . . $ poly_model# *po, const float *normalized_pos) {
2535 int i;
2536
2537 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(po->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2538
2539 if (normalized_pos && po->num_key_poscxx . . $ poly_model#num_key_pos. > 0) {
2540 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2541 bsp_infocxx . . $ bsp_info# *sm = &po->submodelcxx . . $ poly_model#submodel.[i];
2542
2543 // get time per keyframe state
2544 float state_time = 1.0 / (po->num_key_poscxx . . $ poly_model#num_key_pos. - 1);
2545 float cur_state_time;
2546 int cur_state;
2547 float normal_state_time;
2548
2549 // Find out which keyframe we're at
2550 cur_state = normalized_pos[i] / state_time;
2551
2552 // Find out how far into that keyframe we are
2553 cur_state_time = normalized_pos[i] - ((float)cur_state * state_time);
2554 normal_state_time = cur_state_time / state_time;
2555
2556 // Now do a parametric adjustment on the positions
2557
2558 vectorcxx . . $ vector# total_delta_pos = {0, 0, 0};
2559 vectorcxx . . $ vector# subpos;
2560 vectorcxx . . $ vector# final_pos;
2561
2562 // If we're already at the high point of the interpolation then just
2563 // stuff some values
2564 if (cur_state == sm->num_key_poscxx . . $ bsp_info#num_key_pos. - 1) {
2565 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[po->num_key_poscxx . . $ poly_model#num_key_pos. - 1];
2566 continue;
2567 }
2568
2569 if (cur_state == 0)
2570 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(c0842353a20857d). normal_state_time *cxx . . $ `operator*`(9d6577ff3e9faa29). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[1];
2571 else {
2572 vm_SubVectorscxx . . $ vm_SubVectors(24e6685d32847ac5).(&subpos, &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[cur_state + 1], &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[cur_state]);
2573 final_pos =cxx . . $ vector#`operator=`(c0842353a20857d). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_poscxx . . $ bsp_info#keyframe_pos.[cur_state] +cxx . . $ operator+(b77b703cd1e43e33). (subpos *cxx . . $ `operator*`(252247219a31502c). normal_state_time);
2574 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). final_pos;
2575 }
2576 }
2577 } else {
2578 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2579 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..xcxx . . $ vector#x. = 0;
2580 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..ycxx . . $ vector#y. = 0;
2581 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..zcxx . . $ vector#z. = 0;
2582 }
2583 }
2584 }
2585
2586 // Sets the effect used by a polymodel
2587 void SetPolymodelEffectcxx . . $ SetPolymodelEffect(c6aad29469640daf).(polymodel_effectcxx . . $ polymodel_effect# *poly_effect) { Polymodel_effectcxx . . $ Polymodel_effect. =cxx . . $ polymodel_effect#`operator=`(556ead67fa5d1b1a). *poly_effect; }
2588
2589 // Given a model pointer and an array of floats that go from 0..1, calculate the interpolated
2590 // position/angle of each corresponding subobject
2591 void SetModelAnglesAndPosTimedcxx . . $ SetModelAnglesAndPosTimed(a00e94110fc4ea4c).(poly_modelcxx . . $ poly_model# *po, float *normalized_time, uint32_tcxx . . $ uint32_t# subobj_flags) {
2592 int i;
2593
2594 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(po->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2595
2596 if (normalized_time) {
2597 // get time per keyframe state
2598
2599 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2600 bsp_infocxx . . $ bsp_info# *sm = &po->submodelcxx . . $ poly_model#submodel.[i];
2601 int int_tick, current_frame, total_ticks;
2602 float normal_state_time, current_tick;
2603
2604 if (!(subobj_flags & (1 << i)))
2605 continue;
2606
2607 if (sm->num_key_poscxx . . $ bsp_info#num_key_pos. <= 1) {
2608 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&sm->mod_poscxx . . $ bsp_info#mod_pos.);
2609 goto do_angles;
2610 }
2611
2612 if (normalized_time[i] == 1.0) {
2613 sm->mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). sm->keyframe_poscxx . . $ bsp_info#keyframe_pos.[sm->num_key_poscxx . . $ bsp_info#num_key_pos. - 1];
2614 goto do_angles;
2615 }
2616
2617 // Find out which keyframe we're at
2618 total_ticks = sm->pos_track_maxcxx . . $ bsp_info#pos_track_max. - sm->pos_track_mincxx . . $ bsp_info#pos_track_min.;
2619 current_tick = (normalized_time[i] * total_ticks) + sm->pos_track_mincxx . . $ bsp_info#pos_track_min.;
2620 int_tick = current_tick;
2621 current_frame = sm->tick_pos_remapcxx . . $ bsp_info#tick_pos_remap.[int_tick - sm->pos_track_mincxx . . $ bsp_info#pos_track_min.];
2622
2623 ASSERTcxx . . $ `misc/pserror.h:246:9`!(current_frame >= 0 && current_frame <= sm->num_key_pos - 1);
2624
2625 if (current_frame == sm->num_key_poscxx . . $ bsp_info#num_key_pos. - 1) {
2626 sm->mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). sm->keyframe_poscxx . . $ bsp_info#keyframe_pos.[sm->num_key_poscxx . . $ bsp_info#num_key_pos. - 1];
2627 goto do_angles;
2628 } else {
2629 int ticks_between_frames = sm->pos_start_timecxx . . $ bsp_info#pos_start_time.[current_frame + 1] - sm->pos_start_timecxx . . $ bsp_info#pos_start_time.[current_frame];
2630 float this_tick = current_tick - sm->pos_start_timecxx . . $ bsp_info#pos_start_time.[current_frame];
2631 normal_state_time = (float)this_tick / (float)ticks_between_frames;
2632
2633 vectorcxx . . $ vector# subpos;
2634 vm_SubVectorscxx . . $ vm_SubVectors(24e6685d32847ac5).(&subpos, &sm->keyframe_poscxx . . $ bsp_info#keyframe_pos.[current_frame + 1], &sm->keyframe_poscxx . . $ bsp_info#keyframe_pos.[current_frame]);
2635 sm->mod_poscxx . . $ bsp_info#mod_pos. =cxx . . $ vector#`operator=`(c0842353a20857d). sm->keyframe_poscxx . . $ bsp_info#keyframe_pos.[current_frame] +cxx . . $ operator+(b77b703cd1e43e33). (subpos *cxx . . $ `operator*`(252247219a31502c). normal_state_time);
2636 }
2637
2638 // Now do angle stuff here
2639 do_angles:
2640 // Don't rotate turrets or auto-rotators
2641 if (!(sm->flagscxx . . $ bsp_info#flags. & (SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`! | SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!))) {
2642 if (sm->num_key_anglescxx . . $ bsp_info#num_key_angles. <= 1) {
2643 sm->angscxx . . $ bsp_info#angs..pcxx . . $ angvec#p. = 0;
2644 sm->angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h. = 0;
2645 sm->angscxx . . $ bsp_info#angs..bcxx . . $ angvec#b. = 0;
2646 continue;
2647 }
2648
2649 if (normalized_time[i] == 1.0) {
2650 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[sm->num_key_anglescxx . . $ bsp_info#num_key_angles. - 1]);
2651 continue;
2652 }
2653
2654 // Find out which keyframe we're at
2655 total_ticks = sm->rot_track_maxcxx . . $ bsp_info#rot_track_max. - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.;
2656 current_tick = (normalized_time[i] * total_ticks) + sm->rot_track_mincxx . . $ bsp_info#rot_track_min.;
2657 int_tick = current_tick;
2658 current_frame = sm->tick_ang_remapcxx . . $ bsp_info#tick_ang_remap.[int_tick - sm->rot_track_mincxx . . $ bsp_info#rot_track_min.];
2659
2660 ASSERTcxx . . $ `misc/pserror.h:246:9`!(current_frame >= 0 && current_frame <= sm->num_key_angles - 1);
2661
2662 if (current_frame == sm->num_key_anglescxx . . $ bsp_info#num_key_angles. - 1) {
2663 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[sm->num_key_anglescxx . . $ bsp_info#num_key_angles. - 1]);
2664 continue;
2665 } else {
2666 int ticks_between_frames = sm->rot_start_timecxx . . $ bsp_info#rot_start_time.[current_frame + 1] - sm->rot_start_timecxx . . $ bsp_info#rot_start_time.[current_frame];
2667 float this_tick = current_tick - sm->rot_start_timecxx . . $ bsp_info#rot_start_time.[current_frame];
2668 normal_state_time = (float)this_tick / (float)ticks_between_frames;
2669
2670 // Now do a parametric adjustment on the angles
2671
2672 matrixcxx . . $ matrix# dest_matrix =
2673 sm->keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[current_frame] +cxx . . $ operator+(683f8e040c904cb).
2674 ((sm->keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[current_frame + 1] -cxx . . $ operator-(683f8e040c904cb). sm->keyframe_matrixcxx . . $ bsp_info#keyframe_matrix.[current_frame]) *cxx . . $ `operator*`(2f7784e05c935c16). normal_state_time);
2675
2676 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&sm->angscxx . . $ bsp_info#angs., &dest_matrix);
2677 }
2678
2679 } else {
2680 // Adjust special subobjects
2681 if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`!) {
2682 float flrot = Gametimecxx . . $ Gametime. * po->submodelcxx . . $ poly_model#submodel.[i].rpscxx . . $ bsp_info#rps.;
2683 int introt = flrot;
2684
2685 float fdiff = flrot - introt;
2686
2687 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fdiff >= 0 && fdiff <= 1);
2688
2689 // fdiff now equals 0 to 1
2690 matrixcxx . . $ matrix# temp_matrix;
2691 vectorcxx . . $ vector# temp_vec;
2692 if (po->new_stylecxx . . $ poly_model#new_style.)
2693 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[1];
2694 else
2695 temp_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.;
2696
2697 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, fdiff * 65535, &temp_vec);
2698 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2699 } else if (po->submodelcxx . . $ poly_model#submodel.[i].flagscxx . . $ bsp_info#flags. & SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!) {
2700 matrixcxx . . $ matrix# temp_matrix;
2701 if (po->new_stylecxx . . $ poly_model#new_style.)
2702 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, normalized_time[i] * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].keyframe_axiscxx . . $ bsp_info#keyframe_axis.[1]);
2703 else
2704 BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(&temp_matrix, normalized_time[i] * 65535, &po->submodelcxx . . $ poly_model#submodel.[i].normcxx . . $ bsp_info#norm.);
2705
2706 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., &temp_matrix);
2707 }
2708 }
2709 }
2710
2711 } else {
2712 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2713 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..xcxx . . $ vector#x. = 0;
2714 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..ycxx . . $ vector#y. = 0;
2715 po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos..zcxx . . $ vector#z. = 0;
2716
2717 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..pcxx . . $ angvec#p. = 0;
2718 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h. = 0;
2719 po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs..bcxx . . $ angvec#b. = 0;
2720 }
2721 }
2722 }
2723
2724 // Sets the position and rotation of a polymodel. Used for rendering and collision detection
2725 void SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(poly_modelcxx . . $ poly_model# *po, float *normalized_time, uint32_tcxx . . $ uint32_t# subobj_flags) {
2726 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(po->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2727
2728 if (po->flagscxx . . $ poly_model#flags. & PMF_TIMEDcxx . . $ `lib/polymodel_external.h:222:9`!) {
2729 SetModelAnglesAndPosTimedcxx . . $ SetModelAnglesAndPosTimed(a00e94110fc4ea4c).(po, normalized_time, subobj_flags);
2730 return;
2731 } else {
2732 SetModelAnglescxx . . $ SetModelAngles(ed97be8d9db46e36).(po, normalized_time);
2733 SetModelInterpPoscxx . . $ SetModelInterpPos(ed97be8d9db46e36).(po, normalized_time);
2734 }
2735 }
2736
2737 static vectorcxx . . $ vector# Instance_fog_plane_stackcxx . . $ Instance_fog_plane_stack.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
2738 static vectorcxx . . $ vector# Instance_fog_portal_vert_stackcxx . . $ Instance_fog_portal_vert_stack.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
2739 static vectorcxx . . $ vector# Instance_light_stackcxx . . $ Instance_light_stack.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
2740 static vectorcxx . . $ vector# Instance_specular_poscxx . . $ Instance_specular_pos.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
2741 static vectorcxx . . $ vector# Instance_bump_poscxx . . $ Instance_bump_pos.[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
2742
2743 static int Instance_light_cntcxx . . $ Instance_light_cnt. = 0;
2744
2745 void StartLightInstancecxx . . $ StartLightInstance(bc315f98e1febb02).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient) {
2746 int gouraud = 0, specular = 0, fogged = 0, bumped = 0;
2747
2748 if (Polymodel_light_typecxx . . $ Polymodel_light_type. == POLYMODEL_LIGHTING_GOURAUDcxx . . $ POLYMODEL_LIGHTING_GOURAUD.)
2749 gouraud = 1;
2750 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_FOGGED_MODELcxx . . $ `lib/polymodel_external.h:295:9`!)
2751 fogged = 1;
2752 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & (PEF_SPECULAR_MODELcxx . . $ `lib/polymodel_external.h:296:9`! | PEF_SPECULAR_FACEScxx . . $ `lib/polymodel_external.h:297:9`!))
2753 specular = 1;
2754 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && (Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_BUMPMAPPEDcxx . . $ `lib/polymodel_external.h:303:9`!))
2755 bumped = 1;
2756
2757 if (gouraud)
2758 Instance_light_stackcxx . . $ Instance_light_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *Polymodel_light_directioncxx . . $ Polymodel_light_direction.;
2759 if (fogged) {
2760 Instance_fog_plane_stackcxx . . $ Instance_fog_plane_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_fog_planecxx . . $ Polymodel_fog_plane.;
2761 Instance_fog_portal_vert_stackcxx . . $ Instance_fog_portal_vert_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert.;
2762 }
2763
2764 if (specular)
2765 Instance_specular_poscxx . . $ Instance_specular_pos.[Instance_light_cntcxx . . $ Instance_light_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_specular_poscxx . . $ Polymodel_specular_pos.;
2766
2767 if (bumped)
2768 Instance_bump_poscxx . . $ Instance_bump_pos.[Instance_light_cntcxx . . $ Instance_light_cnt.] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_bump_poscxx . . $ Polymodel_bump_pos.;
2769
2770 Instance_light_cntcxx . . $ Instance_light_cnt.++;
2771
2772 vectorcxx . . $ vector# temp_vec;
2773
2774 if (gouraud) {
2775 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&temp_vec, Polymodel_light_directioncxx . . $ Polymodel_light_direction., orient);
2776 *Polymodel_light_directioncxx . . $ Polymodel_light_direction. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2777 }
2778 if (fogged) {
2779 vectorcxx . . $ vector# tempv = Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
2780 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&temp_vec, &tempv, orient);
2781 Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2782
2783 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&temp_vec, &Polymodel_fog_planecxx . . $ Polymodel_fog_plane., orient);
2784 Polymodel_fog_planecxx . . $ Polymodel_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2785 }
2786 if (specular) {
2787 vectorcxx . . $ vector# tempv = Polymodel_specular_poscxx . . $ Polymodel_specular_pos. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
2788 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&temp_vec, &tempv, orient);
2789 Polymodel_specular_poscxx . . $ Polymodel_specular_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2790 }
2791
2792 if (bumped) {
2793 vectorcxx . . $ vector# tempv = Polymodel_bump_poscxx . . $ Polymodel_bump_pos. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
2794 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&temp_vec, &tempv, orient);
2795 Polymodel_bump_poscxx . . $ Polymodel_bump_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vec;
2796 }
2797 }
2798 void DoneLightInstancecxx . . $ DoneLightInstance(49f6e7a06ebc5aa8).() {
2799 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Instance_light_cnt != 0);
2800 Instance_light_cntcxx . . $ Instance_light_cnt.--;
2801
2802 if (Polymodel_light_typecxx . . $ Polymodel_light_type. == POLYMODEL_LIGHTING_GOURAUDcxx . . $ POLYMODEL_LIGHTING_GOURAUD.)
2803 *Polymodel_light_directioncxx . . $ Polymodel_light_direction. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_light_stackcxx . . $ Instance_light_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.];
2804
2805 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_FOGGED_MODELcxx . . $ `lib/polymodel_external.h:295:9`!) {
2806 Polymodel_fog_planecxx . . $ Polymodel_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_fog_plane_stackcxx . . $ Instance_fog_plane_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.];
2807 Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_fog_portal_vert_stackcxx . . $ Instance_fog_portal_vert_stack.[Instance_light_cntcxx . . $ Instance_light_cnt.];
2808 }
2809
2810 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & (PEF_SPECULAR_MODELcxx . . $ `lib/polymodel_external.h:296:9`! | PEF_SPECULAR_FACEScxx . . $ `lib/polymodel_external.h:297:9`!))
2811 Polymodel_specular_poscxx . . $ Polymodel_specular_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_specular_poscxx . . $ Instance_specular_pos.[Instance_light_cntcxx . . $ Instance_light_cnt.];
2812
2813 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && (Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_BUMPMAPPEDcxx . . $ `lib/polymodel_external.h:303:9`!))
2814 Polymodel_bump_poscxx . . $ Polymodel_bump_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Instance_bump_poscxx . . $ Instance_bump_pos.[Instance_light_cntcxx . . $ Instance_light_cnt.];
2815 }
2816
2817 // Draws a polygon model to the viewport
2818 // Normalized_time is an array of floats from 0 to 1 that represent how far into
2819 // an animation state we are
2820
2821 // This is the static light version
2822 void DrawPolygonModelcxx . . $ DrawPolygonModel(505ac7ffa3f87ac5).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient, int model_num, float *normalized_time, int flags, float r, float g,
2823 float b, uint32_tcxx . . $ uint32_t# f_render_sub, uint8_tcxx . . $ uint8_t# use_effect, uint8_tcxx . . $ uint8_t# overlay) {
2824 poly_modelcxx . . $ poly_model# *po;
2825
2826 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[model_num].used);
2827 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(Poly_models[model_num].flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2828
2829 GetPolymodelPointercxx . . $ GetPolymodelPointer(ac85e77c73ebf794).(model_num);
2830
2831 Polymodel_use_effectcxx . . $ Polymodel_use_effect. = use_effect;
2832 Polymodel_light_typecxx . . $ Polymodel_light_type. = POLYMODEL_LIGHTING_STATICcxx . . $ POLYMODEL_LIGHTING_STATIC.;
2833 Polylighting_static_redcxx . . $ Polylighting_static_red. = r;
2834 Polylighting_static_greencxx . . $ Polylighting_static_green. = g;
2835 Polylighting_static_bluecxx . . $ Polylighting_static_blue. = b;
2836
2837 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
2838 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
2839
2840 po = &Poly_modelscxx . . $ Poly_models.[model_num];
2841
2842 g3_StartInstanceMatrixcxx . . $ g3_StartInstanceMatrix(bc315f98e1febb02).(pos, orient);
2843
2844 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_FOGGED_MODELcxx . . $ `lib/polymodel_external.h:295:9`!) {
2845 Polymodel_fog_planecxx . . $ Polymodel_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_planecxx . . $ polymodel_effect#fog_plane.;
2846 Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_portal_vertcxx . . $ polymodel_effect#fog_portal_vert.;
2847 }
2848
2849 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & (PEF_SPECULAR_MODELcxx . . $ `lib/polymodel_external.h:296:9`! | PEF_SPECULAR_FACEScxx . . $ `lib/polymodel_external.h:297:9`!))
2850 Polymodel_specular_poscxx . . $ Polymodel_specular_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..spec_light_poscxx . . $ polymodel_effect#spec_light_pos.;
2851
2852 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && (Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_BUMPMAPPEDcxx . . $ `lib/polymodel_external.h:303:9`!))
2853 Polymodel_bump_poscxx . . $ Polymodel_bump_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..bump_light_poscxx . . $ polymodel_effect#bump_light_pos.;
2854
2855 StartLightInstancecxx . . $ StartLightInstance(bc315f98e1febb02).(pos, orient);
2856
2857 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(po, normalized_time, f_render_sub);
2858
2859 if (f_render_sub == 0xFFFFFFFF || overlay) // draw entire object
2860 {
2861 if (po->new_stylecxx . . $ poly_model#new_style.) {
2862 RenderPolygonModelcxx . . $ RenderPolygonModel(f5dd01fd8e510d62).(po, f_render_sub);
2863 }
2864 } else {
2865 ASSERTcxx . . $ `misc/pserror.h:246:9`!(po->new_style == 1);
2866
2867 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`! + ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!);
2868
2869 int i;
2870 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2871 if ((f_render_sub & (1 << i))) {
2872 if (i != 0) {
2873 // if submodel, rotate around its center point, not pivot point
2874
2875 vectorcxx . . $ vector# ofs = (po->submodelcxx . . $ poly_model#submodel.[i].mincxx . . $ bsp_info#min. +cxx . . $ operator+(b77b703cd1e43e33). po->submodelcxx . . $ poly_model#submodel.[i].maxcxx . . $ bsp_info#max.) /cxx . . $ `operator/`(252247219a31502c). 2;
2876 vectorcxx . . $ vector# save_offset = po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.;
2877 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.);
2878 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos.);
2879 memset(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., 0, sizeof(angveccxx . . $ angvec#));
2880 ofs *=cxx . . $ `operator*=`(f132838b2cd11d6). -1;
2881
2882 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). ofs;
2883 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
2884
2885 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_offset;
2886 } else
2887 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
2888 }
2889 }
2890 }
2891
2892 DoneLightInstancecxx . . $ DoneLightInstance(49f6e7a06ebc5aa8).();
2893 g3_DoneInstancecxx . . $ g3_DoneInstance(49f6e7a06ebc5aa8).();
2894 }
2895
2896 // This draws a gouraud shaded version
2897 void DrawPolygonModelcxx . . $ DrawPolygonModel(af314eb3da32d535).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient, int model_num, float *normalized_time, int flags, vectorcxx . . $ vector# *lightdir,
2898 float r, float g, float b, uint32_tcxx . . $ uint32_t# f_render_sub, uint8_tcxx . . $ uint8_t# use_effect, uint8_tcxx . . $ uint8_t# overlay) {
2899 poly_modelcxx . . $ poly_model# *po;
2900 vectorcxx . . $ vector# light_vec = *lightdir;
2901
2902 Polymodel_use_effectcxx . . $ Polymodel_use_effect. = use_effect;
2903
2904 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[model_num].used);
2905 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(Poly_models[model_num].flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2906
2907 GetPolymodelPointercxx . . $ GetPolymodelPointer(ac85e77c73ebf794).(model_num);
2908
2909 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
2910 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.);
2911 rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.);
2912
2913 Polymodel_light_typecxx . . $ Polymodel_light_type. = POLYMODEL_LIGHTING_GOURAUDcxx . . $ POLYMODEL_LIGHTING_GOURAUD.;
2914 Polylighting_static_redcxx . . $ Polylighting_static_red. = r;
2915 Polylighting_static_greencxx . . $ Polylighting_static_green. = g;
2916 Polylighting_static_bluecxx . . $ Polylighting_static_blue. = b;
2917
2918 Polymodel_light_directioncxx . . $ Polymodel_light_direction. = &light_vec;
2919
2920 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_FOGGED_MODELcxx . . $ `lib/polymodel_external.h:295:9`!) {
2921 Polymodel_fog_planecxx . . $ Polymodel_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_planecxx . . $ polymodel_effect#fog_plane.;
2922 Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_portal_vertcxx . . $ polymodel_effect#fog_portal_vert.;
2923 }
2924
2925 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & (PEF_SPECULAR_MODELcxx . . $ `lib/polymodel_external.h:296:9`! | PEF_SPECULAR_FACEScxx . . $ `lib/polymodel_external.h:297:9`!))
2926 Polymodel_specular_poscxx . . $ Polymodel_specular_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..spec_light_poscxx . . $ polymodel_effect#spec_light_pos.;
2927
2928 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && (Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_BUMPMAPPEDcxx . . $ `lib/polymodel_external.h:303:9`!))
2929 Polymodel_bump_poscxx . . $ Polymodel_bump_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..bump_light_poscxx . . $ polymodel_effect#bump_light_pos.;
2930
2931 g3_StartInstanceMatrixcxx . . $ g3_StartInstanceMatrix(bc315f98e1febb02).(pos, orient);
2932 StartLightInstancecxx . . $ StartLightInstance(bc315f98e1febb02).(pos, orient);
2933
2934 po = &Poly_modelscxx . . $ Poly_models.[model_num];
2935 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(po, normalized_time, f_render_sub);
2936
2937 if (f_render_sub == 0xFFFFFFFF || overlay) // draw entire object
2938 {
2939 if (po->new_stylecxx . . $ poly_model#new_style.)
2940 RenderPolygonModelcxx . . $ RenderPolygonModel(f5dd01fd8e510d62).(po, f_render_sub);
2941 } else {
2942 ASSERTcxx . . $ `misc/pserror.h:246:9`!(po->new_style == 1);
2943
2944 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`! + ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!);
2945
2946 int i;
2947 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
2948 if ((f_render_sub & (1 << i))) {
2949 if (i != 0) {
2950 // if submodel, rotate around its center point, not pivot point
2951
2952 vectorcxx . . $ vector# ofs = (po->submodelcxx . . $ poly_model#submodel.[i].mincxx . . $ bsp_info#min. +cxx . . $ operator+(b77b703cd1e43e33). po->submodelcxx . . $ poly_model#submodel.[i].maxcxx . . $ bsp_info#max.) /cxx . . $ `operator/`(252247219a31502c). 2;
2953 vectorcxx . . $ vector# save_offset = po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.;
2954 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.);
2955 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos.);
2956 memset(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., 0, sizeof(angveccxx . . $ angvec#));
2957 ofs *=cxx . . $ `operator*=`(f132838b2cd11d6). -1;
2958
2959 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). ofs;
2960 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
2961
2962 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_offset;
2963 } else
2964 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
2965 }
2966 }
2967 }
2968
2969 g3_DoneInstancecxx . . $ g3_DoneInstance(49f6e7a06ebc5aa8).();
2970 DoneLightInstancecxx . . $ DoneLightInstance(49f6e7a06ebc5aa8).();
2971 }
2972
2973 // This draws a lightmap shaded version
2974 void DrawPolygonModelcxx . . $ DrawPolygonModel(dfc7b9e8076b2536).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient, int model_num, float *normalized_time, int flags,
2975 lightmap_objectcxx . . $ lightmap_object# *lm_object, uint32_tcxx . . $ uint32_t# f_render_sub, uint8_tcxx . . $ uint8_t# use_effect, uint8_tcxx . . $ uint8_t# overlay) {
2976 poly_modelcxx . . $ poly_model# *po;
2977
2978 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[model_num].used);
2979 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(Poly_models[model_num].flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
2980
2981 GetPolymodelPointercxx . . $ GetPolymodelPointer(ac85e77c73ebf794).(model_num);
2982
2983 Polymodel_use_effectcxx . . $ Polymodel_use_effect. = use_effect;
2984
2985 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
2986 Polymodel_light_typecxx . . $ Polymodel_light_type. = POLYMODEL_LIGHTING_LIGHTMAPcxx . . $ POLYMODEL_LIGHTING_LIGHTMAP.;
2987 Polylighting_lightmap_objectcxx . . $ Polylighting_lightmap_object. = lm_object;
2988
2989 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_FOGGED_MODELcxx . . $ `lib/polymodel_external.h:295:9`!) {
2990 Polymodel_fog_planecxx . . $ Polymodel_fog_plane. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_planecxx . . $ polymodel_effect#fog_plane.;
2991 Polymodel_fog_portal_vertcxx . . $ Polymodel_fog_portal_vert. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..fog_portal_vertcxx . . $ polymodel_effect#fog_portal_vert.;
2992 }
2993
2994 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & (PEF_SPECULAR_MODELcxx . . $ `lib/polymodel_external.h:296:9`! | PEF_SPECULAR_FACEScxx . . $ `lib/polymodel_external.h:297:9`!))
2995 Polymodel_specular_poscxx . . $ Polymodel_specular_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..spec_light_poscxx . . $ polymodel_effect#spec_light_pos.;
2996
2997 if (Polymodel_use_effectcxx . . $ Polymodel_use_effect. && (Polymodel_effectcxx . . $ Polymodel_effect..typecxx . . $ polymodel_effect#type. & PEF_BUMPMAPPEDcxx . . $ `lib/polymodel_external.h:303:9`!))
2998 Polymodel_bump_poscxx . . $ Polymodel_bump_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Polymodel_effectcxx . . $ Polymodel_effect..bump_light_poscxx . . $ polymodel_effect#bump_light_pos.;
2999
3000 g3_StartInstanceMatrixcxx . . $ g3_StartInstanceMatrix(bc315f98e1febb02).(pos, orient);
3001 StartLightInstancecxx . . $ StartLightInstance(bc315f98e1febb02).(pos, orient);
3002
3003 po = &Poly_modelscxx . . $ Poly_models.[model_num];
3004 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(po, normalized_time, f_render_sub);
3005
3006 if (f_render_sub == 0xFFFFFFFF || overlay) // draw entire object
3007 {
3008 if (po->new_stylecxx . . $ poly_model#new_style.)
3009 RenderPolygonModelcxx . . $ RenderPolygonModel(f5dd01fd8e510d62).(po, f_render_sub);
3010 } else {
3011 ASSERTcxx . . $ `misc/pserror.h:246:9`!(po->new_style == 1);
3012
3013 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`! + ATF_VERTEXcxx . . $ `lib/renderer.h:396:9`!);
3014
3015 int i;
3016 for (i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
3017 if ((f_render_sub & (1 << i))) {
3018 if (i != 0) {
3019 // if submodel, rotate around its center point, not pivot point
3020
3021 vectorcxx . . $ vector# ofs = (po->submodelcxx . . $ poly_model#submodel.[i].mincxx . . $ bsp_info#min. +cxx . . $ operator+(b77b703cd1e43e33). po->submodelcxx . . $ poly_model#submodel.[i].maxcxx . . $ bsp_info#max.) /cxx . . $ `operator/`(252247219a31502c). 2;
3022 vectorcxx . . $ vector# save_offset = po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.;
3023 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset.);
3024 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&po->submodelcxx . . $ poly_model#submodel.[i].mod_poscxx . . $ bsp_info#mod_pos.);
3025 memset(&po->submodelcxx . . $ poly_model#submodel.[i].angscxx . . $ bsp_info#angs., 0, sizeof(angveccxx . . $ angvec#));
3026 ofs *=cxx . . $ `operator*=`(f132838b2cd11d6). -1;
3027
3028 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). ofs;
3029 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
3030
3031 po->submodelcxx . . $ poly_model#submodel.[i].offsetcxx . . $ bsp_info#offset. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). save_offset;
3032 } else
3033 RenderSubmodelcxx . . $ RenderSubmodel(3a5661cc5f0d8c55).(po, &po->submodelcxx . . $ poly_model#submodel.[i], f_render_sub);
3034 }
3035 }
3036 }
3037
3038 g3_DoneInstancecxx . . $ g3_DoneInstance(49f6e7a06ebc5aa8).();
3039 DoneLightInstancecxx . . $ DoneLightInstance(49f6e7a06ebc5aa8).();
3040 rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!);
3041 }
3042
3043 void FreeAllModelscxx . . $ FreeAllModels(49f6e7a06ebc5aa8).() {
3044 for (int i = 0; i < MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!; i++) {
3045 if (Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. > 0) {
3046 Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. = 1;
3047
3048 FreePolyModelcxx . . $ FreePolyModel(d4f767463ce0a6b3).(i);
3049 }
3050 }
3051 }
3052
3053 // Inits our models array and loads our ship pof
3054 int InitModelscxx . . $ InitModels(b126dc7c1de90089).() {
3055 for (auto &Poly_model : Poly_modelscxx . . $ Poly_models.) {
3056 memset(&Poly_model, 0, sizeof(poly_modelcxx . . $ poly_model#));
3057 Poly_model.usedcxx . . $ poly_model#used. = 0;
3058 }
3059
3060 atexit(FreeAllModelscxx . . $ FreeAllModels(49f6e7a06ebc5aa8).);
3061
3062 return 1;
3063 }
3064
3065 // MTS: used only in this file.
3066 // Given an actual keyframe number, returns the normalized (0 to 1) position of that
3067 // keyframe
3068 // Handle is an index into the Poly_models array
3069 float GetNormalizedKeyframecxx . . $ GetNormalizedKeyframe(d7799857c894622e).(int handle, float num) {
3070 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[handle];
3071
3072 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
3073
3074 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->used);
3075 ASSERTcxx . . $ `misc/pserror.h:246:9`!(num >= 0 && num <= pm->max_keys);
3076
3077 return ((num / (float)pm->max_keyscxx . . $ poly_model#max_keys.));
3078 }
3079
3080 // Goes through all poly models and gets all missing textures
3081 void RemapPolyModelscxx . . $ RemapPolyModels(49f6e7a06ebc5aa8).() {
3082 int i;
3083
3084 for (i = 0; i < MAX_POLY_MODELScxx . . $ `lib/polymodel_external.h:66:9`!; i++) {
3085 int remap = 0;
3086
3087 if (Poly_modelscxx . . $ Poly_models.[i].usedcxx . . $ poly_model#used. == 0 || (Poly_modelscxx . . $ Poly_models.[i].flagscxx . . $ poly_model#flags. & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!))
3088 continue;
3089
3090 for (int t = 0; t < Poly_modelscxx . . $ Poly_models.[i].n_texturescxx . . $ poly_model#n_textures.; t++)
3091 if (Poly_modelscxx . . $ Poly_models.[i].texturescxx . . $ poly_model#textures.[t] == 0) // is there a bad texture?
3092 remap = 1;
3093
3094 if (remap == 1) {
3095 // remap the damn textures
3096 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Remapping model textures for model %s.\n", Poly_models[i].name);
3097 ReloadModelTexturescxx . . $ ReloadModelTextures(7864480464b09eea).(i);
3098 }
3099 }
3100 }
3101
3102 // MTS: not used?
3103 // Returns the total number of faces in a model
3104 int CountFacesInPolymodelcxx . . $ CountFacesInPolymodel(e7380ea24692efb1).(poly_modelcxx . . $ poly_model# *pm) {
3105 int i;
3106 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->used > 0);
3107 int count = 0;
3108
3109 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
3110
3111 for (i = 0; i < pm->n_modelscxx . . $ poly_model#n_models.; i++) {
3112 if (IsNonRenderableSubmodelcxx . . $ IsNonRenderableSubmodel(bb32db98789388a4).(pm, i))
3113 continue;
3114
3115 count += pm->submodelcxx . . $ poly_model#submodel.[i].num_facescxx . . $ bsp_info#num_faces.;
3116 }
3117
3118 return count;
3119 }
3120
3121 // Given an object, a submodel, and a vertex number, calculates the world position
3122 // of that point
3123 void GetPolyModelPointInWorldcxx . . $ GetPolyModelPointInWorld(89309ad7c08ec4a9).(vectorcxx . . $ vector# *dest, poly_modelcxx . . $ poly_model# *pm, vectorcxx . . $ vector# *wpos, matrixcxx . . $ matrix# *orient, int subnum, vectorcxx . . $ vector# *pos,
3124 vectorcxx . . $ vector# *norm) {
3125 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[subnum];
3126 float normalized_time[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
3127 int i;
3128
3129 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
3130
3131 if (!pm->new_stylecxx . . $ poly_model#new_style.)
3132 return;
3133
3134 for (i = 0; i < MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!; i++)
3135 normalized_time[i] = 0.0;
3136
3137 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(pm, normalized_time);
3138
3139 vectorcxx . . $ vector# pnt = *pos;
3140 int mn = subnum;
3141 vectorcxx . . $ vector# cur_norm;
3142
3143 if (norm != nullptr)
3144 cur_norm =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *norm;
3145
3146 matrixcxx . . $ matrix# m;
3147
3148 // Instance up the tree for this gun
3149 while (mn != -1) {
3150 vectorcxx . . $ vector# tpnt;
3151
3152 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&m, pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..pcxx . . $ angvec#p., pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h., pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..bcxx . . $ angvec#b.);
3153 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
3154
3155 tpnt =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3156
3157 if (norm != nullptr)
3158 cur_norm =cxx . . $ vector#`operator=`(c0842353a20857d). cur_norm *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3159
3160 pnt =cxx . . $ vector#`operator=`(c0842353a20857d). tpnt +cxx . . $ operator+(b77b703cd1e43e33). pm->submodelcxx . . $ poly_model#submodel.[mn].offsetcxx . . $ bsp_info#offset. +cxx . . $ operator+(b77b703cd1e43e33). pm->submodelcxx . . $ poly_model#submodel.[mn].mod_poscxx . . $ bsp_info#mod_pos.;
3161
3162 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
3163 }
3164
3165 // now instance for the entire object
3166 m =cxx . . $ matrix#`operator=`(4c6f8b29806742). *orient;
3167 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
3168
3169 if (norm != nullptr)
3170 *norm =cxx . . $ vector#`operator=`(c0842353a20857d). (cur_norm *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m);
3171 *dest =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3172 *dest +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (*wpos);
3173 }
3174
3175 void GetPolyModelPointInWorldcxx . . $ GetPolyModelPointInWorld(fee16eb52aacf77f).(vectorcxx . . $ vector# *dest, poly_modelcxx . . $ poly_model# *pm, vectorcxx . . $ vector# *wpos, matrixcxx . . $ matrix# *orient, int subnum,
3176 float *normalized_time, vectorcxx . . $ vector# *pos, vectorcxx . . $ vector# *norm) {
3177 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[subnum];
3178
3179 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
3180
3181 if (!pm->new_stylecxx . . $ poly_model#new_style.)
3182 return;
3183
3184 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(pm, normalized_time);
3185
3186 vectorcxx . . $ vector# pnt = *pos;
3187 int mn = subnum;
3188 vectorcxx . . $ vector# cur_norm;
3189
3190 if (norm != nullptr)
3191 cur_norm =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *norm;
3192
3193 matrixcxx . . $ matrix# m;
3194
3195 // Instance up the tree for this gun
3196 while (mn != -1) {
3197 vectorcxx . . $ vector# tpnt;
3198
3199 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&m, pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..pcxx . . $ angvec#p., pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..hcxx . . $ angvec#h., pm->submodelcxx . . $ poly_model#submodel.[mn].angscxx . . $ bsp_info#angs..bcxx . . $ angvec#b.);
3200 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
3201
3202 tpnt =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3203
3204 if (norm != nullptr)
3205 cur_norm =cxx . . $ vector#`operator=`(c0842353a20857d). cur_norm *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3206
3207 pnt =cxx . . $ vector#`operator=`(c0842353a20857d). tpnt +cxx . . $ operator+(b77b703cd1e43e33). pm->submodelcxx . . $ poly_model#submodel.[mn].offsetcxx . . $ bsp_info#offset. +cxx . . $ operator+(b77b703cd1e43e33). pm->submodelcxx . . $ poly_model#submodel.[mn].mod_poscxx . . $ bsp_info#mod_pos.;
3208
3209 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
3210 }
3211
3212 // now instance for the entire object
3213 m =cxx . . $ matrix#`operator=`(4c6f8b29806742). *orient;
3214 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
3215
3216 if (norm != nullptr)
3217 *norm =cxx . . $ vector#`operator=`(c0842353a20857d). (cur_norm *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m);
3218 *dest =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
3219 *dest +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (*wpos);
3220 }
3221
3222 // Returns 1 if this submodel shouldn't be rendered
3223 int IsNonRenderableSubmodelcxx . . $ IsNonRenderableSubmodel(bb32db98789388a4).(poly_modelcxx . . $ poly_model# *pm, int submodelnum) {
3224 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->used);
3225 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(pm->flags & PMF_NOT_RESIDENTcxx . . $ `lib/polymodel_external.h:225:9`!));
3226
3227 if ((pm->submodelcxx . . $ poly_model#submodel.[submodelnum].flagscxx . . $ bsp_info#flags. & SOF_FRONTFACEcxx . . $ `lib/polymodel_external.h:83:9`!) || (pm->submodelcxx . . $ poly_model#submodel.[submodelnum].flagscxx . . $ bsp_info#flags. & SOF_SHELLcxx . . $ `lib/polymodel_external.h:82:9`!))
3228 return 1;
3229
3230 if (pm->submodelcxx . . $ poly_model#submodel.[submodelnum].num_facescxx . . $ bsp_info#num_faces. == 0)
3231 return 1;
3232
3233 return 0;
3234 }