Debian Codegraph @

Descent3/splinter.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20 #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/
21 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
22 #include "splinter.h"cxx . . $ `<file>/Descent3/splinter.h`/
23 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
24 #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/
25 #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/
26
27 #include "Macros.h"cxx . . $ `<file>/lib/Macros.h`/
28 #include <stdlib.h>
29
30 #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/
31
32 #include <algorithm>
33
34 // Given an object, renders the representation of this splinter
35 void DrawSplinterObjectcxx . . $ DrawSplinterObject(419c470199a90a97).(objectcxx . . $ object# *obj) {
36 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->type == OBJ_SPLINTERcxx . . $ `Descent3/object_external.h:180:9`!);
37 int i;
38 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->idcxx . . $ object#id.];
39 bsp_infocxx . . $ bsp_info# *sm = &pm->submodelcxx . . $ poly_model#submodel.[obj->ctypecxx . . $ object#ctype..splinter_infocxx . . $ object#$anonymous_type_9#splinter_info..subobj_numcxx . . $ splinter_info_s#subobj_num.];
40 int facenum = obj->ctypecxx . . $ object#ctype..splinter_infocxx . . $ object#$anonymous_type_9#splinter_info..facenumcxx . . $ splinter_info_s#facenum.;
41 vectorcxx . . $ vector# world_verts[MAX_VERTS_PER_SPLINTERcxx . . $ `lib/object_external_struct.h:110:9`!];
42 vectorcxx . . $ vector# temp_vec;
43 g3Pointcxx . . $ g3Point# pnts[MAX_VERTS_PER_SPLINTERcxx . . $ `lib/object_external_struct.h:110:9`!];
44 g3Pointcxx . . $ g3Point# *pntlist[MAX_VERTS_PER_SPLINTERcxx . . $ `lib/object_external_struct.h:110:9`!];
45
46 int limit = stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).<int>(MAX_VERTS_PER_SPLINTERcxx . . $ `lib/object_external_struct.h:110:9`!, sm->facescxx . . $ bsp_info#faces.[facenum].nvertscxx . . $ polyface#nverts.);
47 float lifenorm = 1.0 - ((obj->lifetimecxx . . $ object#lifetime. - obj->lifeleftcxx . . $ object#lifeleft.) / obj->lifetimecxx . . $ object#lifetime.);
48
49 rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.);
50 rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!);
51 rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255 * lifenorm);
52 rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.);
53
54 lifenorm = 1.0;
55
56 for (i = 0; i < limit; i++) {
57 // Scale a vert based on the life of the object
58 temp_vec =cxx . . $ vector#`operator=`(c0842353a20857d). obj->ctypecxx . . $ object#ctype..splinter_infocxx . . $ object#$anonymous_type_9#splinter_info..vertscxx . . $ splinter_info_s#verts.[i] *cxx . . $ `operator*`(252247219a31502c). lifenorm;
59
60 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&world_verts[i], &temp_vec, &obj->orientcxx . . $ object#orient.);
61
62 world_verts[i] +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). obj->poscxx . . $ object#pos.;
63 g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnts[i], &world_verts[i]);
64 pntlist[i] = &pnts[i];
65 pnts[i].p3_ucxx . . $ `lib/3d.h:250:9`! = sm->facescxx . . $ bsp_info#faces.[facenum].ucxx . . $ polyface#u.[i];
66 pnts[i].p3_vcxx . . $ `lib/3d.h:251:9`! = sm->facescxx . . $ bsp_info#faces.[facenum].vcxx . . $ polyface#v.[i];
67 }
68
69 int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(pm->texturescxx . . $ poly_model#textures.[sm->facescxx . . $ bsp_info#faces.[facenum].texnumcxx . . $ polyface#texnum.], 0);
70 g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(limit, pntlist, bm_handle);
71 }
72
73 // do whatever needs to be done for this piece of splinter for this frame
74 void DoSplinterFramecxx . . $ DoSplinterFrame(419c470199a90a97).(objectcxx . . $ object# *obj) {
75 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->control_type == CT_SPLINTERcxx . . $ `Descent3/object_external.h:227:9`!);
76
77 if ((obj->lifeleftcxx . . $ object#lifeleft. <= 0.0) && ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 2) == 0)) {
78 // Mark the object to die
79 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
80 } else {
81 // Create smoke for some splinters
82 if (((obj - Objectscxx . . $ Objects.) % 8) == 0) {
83 if (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 4) {
84 int type = ((obj - Objectscxx . . $ Objects.) % 2) ? GetRandomSmallExplosioncxx . . $ GetRandomSmallExplosion(b126dc7c1de90089).() : BLACK_SMOKE_INDEXcxx . . $ `Descent3/fireball_external.h:30:9`!;
85 CreateFireballcxx . . $ CreateFireball(2a769cac3223e33b).(&obj->poscxx . . $ object#pos., type, obj->roomnumcxx . . $ object#roomnum., VISUAL_FIREBALLcxx . . $ `Descent3/fireball.h:165:9`!);
86 }
87 }
88 }
89 }