Debian Codegraph @

physics/newstyle_fi.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 #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/
20 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
21 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
22 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
23 #include "vecmat.h"cxx . . $ `<file>/lib/vecmat.h`/
24
25 #ifndef NED_PHYSICS
26 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
27 #endif
28
29 extern matrixcxx . . $ matrix# View_matrixcxx . . $ View_matrix.;
30 extern vectorcxx . . $ vector# View_positioncxx . . $ View_position.;
31
32 static vectorcxx . . $ vector# Original_poscxx . . $ Original_pos.;
33 static matrixcxx . . $ matrix# Original_orientcxx . . $ Original_orient.;
34
35 static vectorcxx . . $ vector# fvi_move_fveccxx . . $ fvi_move_fvec.;
36 static vectorcxx . . $ vector# fvi_move_uveccxx . . $ fvi_move_uvec.;
37 static bool fvi_do_orientcxx . . $ fvi_do_orient.;
38
39 static bool Fvi_f_normalcxx . . $ Fvi_f_normal.;
40
41 #define MAX_INSTANCE_DEPTHcxx . . $ `physics/newstyle_fi.cpp:41:9`! 30
42
43 struct instance_contextcxx . . $ instance_context# {
44 matrixcxx . . $ matrix# mcxx . . $ instance_context#m.;
45 vectorcxx . . $ vector# pcxx . . $ instance_context#p.;
46 vectorcxx . . $ vector# p0cxx . . $ instance_context#p0.;
47 vectorcxx . . $ vector# p1cxx . . $ instance_context#p1.;
48 vectorcxx . . $ vector# fveccxx . . $ instance_context#fvec.;
49 vectorcxx . . $ vector# uveccxx . . $ instance_context#uvec.;
50 };
51 static struct instance_contextcxx . . $ instance_context# instance_stackcxx . . $ instance_stack.[MAX_INSTANCE_DEPTHcxx . . $ `physics/newstyle_fi.cpp:41:9`!];
52
53 static int instance_depthcxx . . $ instance_depth. = 0;
54
55 static inline void ns_compute_movement_AABBcxx . . $ ns_compute_movement_AABB(49f6e7a06ebc5aa8).();
56 static inline bool ns_movement_manual_AABBcxx . . $ ns_movement_manual_AABB(73e76fc48bf5de61).(vectorcxx . . $ vector# *min_xyz, vectorcxx . . $ vector# *max_xyz);
57 static void CollideSubmodelFacesUnsortedcxx . . $ CollideSubmodelFacesUnsorted(dea5851e769905e8).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm);
58
59 /// instance at specified point with specified orientation.
60 /// if matrix==NULL, don't modify matrix. This will be like doing an offset.
61 static void newstyle_StartInstanceMatrixcxx . . $ newstyle_StartInstanceMatrix(bc315f98e1febb02).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient);
62 /// instance at specified point with specified orientation.
63 /// if angles==NULL, don't modify matrix. This will be like doing an offset.
64 static void newstyle_StartInstanceAnglescxx . . $ newstyle_StartInstanceAngles(5a7036e8e0f776d8).(vectorcxx . . $ vector# *pos, angveccxx . . $ angvec# *angles);
65
66 /// pops the old context
67 static void newstyle_DoneInstancecxx . . $ newstyle_DoneInstance(49f6e7a06ebc5aa8).();
68 static void CollideSubmodelcxx . . $ CollideSubmodel(3a5661cc5f0d8c55).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm, uint32_tcxx . . $ uint32_t# f_render_sub);
69 static void CollidePolygonModelcxx . . $ CollidePolygonModel(4ff26f5b2d1f72fa).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient, int model_num, float *normalized_time,
70 uint32_tcxx . . $ uint32_t# f_render_sub);
71
72 static void BuildModelAngleMatrixcxx . . $ BuildModelAngleMatrix(7f72adbe2f6dad73).(matrixcxx . . $ matrix# *mat, anglecxx . . $ angle# ang, vectorcxx . . $ vector# *axis) {
73 float x, y, z;
74 float s, c, t;
75
76 x = axis->xcxx . . $ vector#x.;
77 y = axis->ycxx . . $ vector#y.;
78 z = axis->zcxx . . $ vector#z.;
79
80 s = (float)FixSincxx . . $ FixSin(9a38df040a81ca35).(ang);
81 c = (float)FixCoscxx . . $ FixCos(9a38df040a81ca35).(ang);
82 t = 1.0f - c;
83
84 mat->rveccxx . . $ matrix#rvec..xcxx . . $ vector#x. = t * x * x + c;
85 mat->rveccxx . . $ matrix#rvec..ycxx . . $ vector#y. = t * x * y + s * z;
86 mat->rveccxx . . $ matrix#rvec..zcxx . . $ vector#z. = t * x * z - s * y;
87
88 mat->uveccxx . . $ matrix#uvec..xcxx . . $ vector#x. = t * x * y - s * z;
89 mat->uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. = t * y * y + c;
90 mat->uveccxx . . $ matrix#uvec..zcxx . . $ vector#z. = t * y * z + s * x;
91
92 mat->fveccxx . . $ matrix#fvec..xcxx . . $ vector#x. = t * x * z + s * y;
93 mat->fveccxx . . $ matrix#fvec..ycxx . . $ vector#y. = t * y * z - s * x;
94 mat->fveccxx . . $ matrix#fvec..zcxx . . $ vector#z. = t * z * z + c;
95 }
96
97 float fvi_hit_paramcxx . . $ fvi_hit_param.;
98 bool fvi_check_paramcxx . . $ fvi_check_param.;
99
100 static vectorcxx . . $ vector# ns_min_xyzcxx . . $ ns_min_xyz.;
101 static vectorcxx . . $ vector# ns_max_xyzcxx . . $ ns_max_xyz.;
102
103 inline void ns_compute_movement_AABBcxx . . $ ns_compute_movement_AABB(49f6e7a06ebc5aa8).() {
104 vectorcxx . . $ vector# delta_movement = *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. -cxx . . $ operator-(b77b703cd1e43e33). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.;
105 vectorcxx . . $ vector# offset_vec;
106
107 offset_vec.xcxx . . $ vector#x. = fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.;
108 offset_vec.ycxx . . $ vector#y. = fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.;
109 offset_vec.zcxx . . $ vector#z. = fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.;
110
111 ns_min_xyzcxx . . $ ns_min_xyz. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). ns_max_xyzcxx . . $ ns_max_xyz. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.;
112
113 ns_min_xyzcxx . . $ ns_min_xyz. -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). offset_vec;
114 ns_max_xyzcxx . . $ ns_max_xyz. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). offset_vec;
115
116 if (delta_movement.xcxx . . $ vector#x. > 0.0f)
117 ns_max_xyzcxx . . $ ns_max_xyz..xcxx . . $ vector#x. += delta_movement.xcxx . . $ vector#x.;
118 else
119 ns_min_xyzcxx . . $ ns_min_xyz..xcxx . . $ vector#x. += delta_movement.xcxx . . $ vector#x.;
120
121 if (delta_movement.ycxx . . $ vector#y. > 0.0f)
122 ns_max_xyzcxx . . $ ns_max_xyz..ycxx . . $ vector#y. += delta_movement.ycxx . . $ vector#y.;
123 else
124 ns_min_xyzcxx . . $ ns_min_xyz..ycxx . . $ vector#y. += delta_movement.ycxx . . $ vector#y.;
125
126 if (delta_movement.zcxx . . $ vector#z. > 0.0f)
127 ns_max_xyzcxx . . $ ns_max_xyz..zcxx . . $ vector#z. += delta_movement.zcxx . . $ vector#z.;
128 else
129 ns_min_xyzcxx . . $ ns_min_xyz..zcxx . . $ vector#z. += delta_movement.zcxx . . $ vector#z.;
130 }
131
132 inline bool ns_movement_manual_AABBcxx . . $ ns_movement_manual_AABB(73e76fc48bf5de61).(vectorcxx . . $ vector# *min_xyz, vectorcxx . . $ vector# *max_xyz) {
133 bool overlap = true;
134
135 if (max_xyz->ycxx . . $ vector#y. < ns_min_xyzcxx . . $ ns_min_xyz..ycxx . . $ vector#y. || ns_max_xyzcxx . . $ ns_max_xyz..ycxx . . $ vector#y. < min_xyz->ycxx . . $ vector#y. || max_xyz->xcxx . . $ vector#x. < ns_min_xyzcxx . . $ ns_min_xyz..xcxx . . $ vector#x. ||
136 ns_max_xyzcxx . . $ ns_max_xyz..xcxx . . $ vector#x. < min_xyz->xcxx . . $ vector#x. || max_xyz->zcxx . . $ vector#z. < ns_min_xyzcxx . . $ ns_min_xyz..zcxx . . $ vector#z. || ns_max_xyzcxx . . $ ns_max_xyz..zcxx . . $ vector#z. < min_xyz->zcxx . . $ vector#z.)
137 overlap = false;
138
139 return overlap;
140 }
141
142 // collide with a submodel
143 // Parameters: nv - the number of verts in the poly
144 // pointlist - a pointer to a list of pointers to points
145 // bm - the bitmap handle if texturing. ignored if flat shading
146
147 static void CollideSubmodelFacesUnsortedcxx . . $ CollideSubmodelFacesUnsorted(dea5851e769905e8).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm) {
148 int i;
149 int j;
150 vectorcxx . . $ vector# colp;
151 vectorcxx . . $ vector# newp;
152 float col_dist; // distance to hit point
153 vectorcxx . . $ vector# *vertex_list[32];
154 vectorcxx . . $ vector# wall_norm;
155 int face_hit_type;
156
157 // (For this reference frame)
158 ns_compute_movement_AABBcxx . . $ ns_compute_movement_AABB(49f6e7a06ebc5aa8).();
159
160 if (ns_movement_manual_AABBcxx . . $ ns_movement_manual_AABB(73e76fc48bf5de61).(&sm->mincxx . . $ bsp_info#min., &sm->maxcxx . . $ bsp_info#max.)) {
161
162 for (i = 0; i < sm->num_facescxx . . $ bsp_info#num_faces.; i++) {
163 if (ns_movement_manual_AABBcxx . . $ ns_movement_manual_AABB(73e76fc48bf5de61).(&sm->face_mincxx . . $ bsp_info#face_min.[i], &sm->face_maxcxx . . $ bsp_info#face_max.[i])) {
164 polyfacecxx . . $ polyface# *fp = &sm->facescxx . . $ bsp_info#faces.[i];
165
166 if ((GameTexturescxx . . $ GameTextures.[pm->texturescxx . . $ poly_model#textures.[fp->texnumcxx . . $ polyface#texnum.]].flagscxx . . $ texture#flags. & (TF_FLY_THRUcxx . . $ `Descent3/gametexture.h:217:9`! | TF_PASS_THRUcxx . . $ `Descent3/gametexture.h:218:9`!)) == 0) {
167 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fp->nverts <= 32);
168
169 for (j = 0; j < fp->nvertscxx . . $ polyface#nverts.; j++) {
170 vertex_list[j] = &sm->vertscxx . . $ bsp_info#verts.[fp->vertnumscxx . . $ polyface#vertnums.[j]];
171 }
172
173 face_hit_type = check_line_to_facecxx . . $ check_line_to_face(3d5b8c488b5418a3).(&newp, &colp, &col_dist, &wall_norm, fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0., fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1.,
174 &fp->normalcxx . . $ polyface#normal., vertex_list, fp->nvertscxx . . $ polyface#nverts., fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.);
175 if ((fvi_query_ptrcxx . . $ fvi_query_ptr.->flagscxx . . $ fvi_query#flags. & FQ_OBJ_BACKFACEcxx . . $ `lib/findintersection_external.h:60:9`!) && (!face_hit_type)) {
176 vectorcxx . . $ vector# face_normal = fp->normalcxx . . $ polyface#normal.;
177 int count;
178
179 face_normal *=cxx . . $ `operator*=`(f132838b2cd11d6). -1.0f;
180 for (count = 0; count < fp->nvertscxx . . $ polyface#nverts.; count++) {
181 vertex_list[fp->nvertscxx . . $ polyface#nverts. - count - 1] = &sm->vertscxx . . $ bsp_info#verts.[fp->vertnumscxx . . $ polyface#vertnums.[count]];
182 }
183
184 face_hit_type =
185 check_line_to_facecxx . . $ check_line_to_face(3d5b8c488b5418a3).(&newp, &colp, &col_dist, &wall_norm, fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0., fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1.,
186 &face_normal, vertex_list, fp->nvertscxx . . $ polyface#nverts., fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.);
187 }
188
189 if (face_hit_type) {
190 if (col_dist < fvi_collision_distcxx . . $ fvi_collision_dist.) {
191 vectorcxx . . $ vector# x;
192
193 fvi_check_paramcxx . . $ fvi_check_param. = true;
194 x =cxx . . $ vector#`operator=`(c0842353a20857d). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. -cxx . . $ operator-(b77b703cd1e43e33). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.;
195 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&x);
196
197 fvi_hit_paramcxx . . $ fvi_hit_param. = (newp -cxx . . $ operator-(b77b703cd1e43e33). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.) *cxx . . $ `operator*`(4a721543d64e126a). x;
198
199 if (!(fvi_hit_paramcxx . . $ fvi_hit_param. > -10000000.0 && fvi_hit_paramcxx . . $ fvi_hit_param. < 10000000.0)) {
200 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "FVI Warning: fvi_hit_param seems yucky!\n");
201 }
202
203 fvi_collision_distcxx . . $ fvi_collision_dist. = col_dist;
204 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->num_hitscxx . . $ fvi_info#num_hits. = 1;
205
206 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_objectcxx . . $ fvi_info#hit_object.[0] = fvi_curobjcxx . . $ fvi_curobj.;
207 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_subobjectcxx . . $ fvi_info#hit_subobject.[0] = sm - pm->submodelcxx . . $ poly_model#submodel.;
208 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_typecxx . . $ fvi_info#hit_type.[0] = HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`!;
209 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). wall_norm;
210 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). colp;
211 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_facecxx . . $ fvi_info#hit_face.[0] = i;
212
213 Fvi_f_normalcxx . . $ Fvi_f_normal. = true;
214
215 if (fvi_do_orientcxx . . $ fvi_do_orient.) {
216 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_subobj_fveccxx . . $ fvi_info#hit_subobj_fvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). fvi_move_fveccxx . . $ fvi_move_fvec.;
217 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_subobj_uveccxx . . $ fvi_info#hit_subobj_uvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). fvi_move_uveccxx . . $ fvi_move_uvec.;
218 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_subobj_poscxx . . $ fvi_info#hit_subobj_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). newp;
219 }
220 }
221 }
222 }
223 }
224 }
225 }
226 }
227
228 // instance at specified point with specified orientation
229 // if matrix==NULL, don't modify matrix. This will be like doing an offset
230 void newstyle_StartInstanceMatrixcxx . . $ newstyle_StartInstanceMatrix(bc315f98e1febb02).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient) {
231 vectorcxx . . $ vector# tempv, temp0, temp1;
232 matrixcxx . . $ matrix# tempm, tempm2;
233
234 ASSERTcxx . . $ `misc/pserror.h:246:9`!(instance_depth < MAX_INSTANCE_DEPTHcxx . . $ `physics/newstyle_fi.cpp:41:9`!);
235
236 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].mcxx . . $ instance_context#m. =cxx . . $ matrix#`operator=`(4c6f8b29806742). View_matrixcxx . . $ View_matrix.;
237 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].pcxx . . $ instance_context#p. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). View_positioncxx . . $ View_position.;
238 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].p0cxx . . $ instance_context#p0. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.;
239 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].p1cxx . . $ instance_context#p1. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1.;
240 if (fvi_do_orientcxx . . $ fvi_do_orient.) {
241 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].fveccxx . . $ instance_context#fvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). fvi_move_fveccxx . . $ fvi_move_fvec.;
242 instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].uveccxx . . $ instance_context#uvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). fvi_move_uveccxx . . $ fvi_move_uvec.;
243 }
244 instance_depthcxx . . $ instance_depth.++;
245
246 // step 1: subtract object position from view position
247
248 tempv =cxx . . $ vector#`operator=`(c0842353a20857d). View_positioncxx . . $ View_position. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
249 temp0 =cxx . . $ vector#`operator=`(c0842353a20857d). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
250 temp1 =cxx . . $ vector#`operator=`(c0842353a20857d). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. -cxx . . $ operator-(b77b703cd1e43e33). *pos;
251
252 if (orient) {
253 // step 2: rotate view vector through object matrix
254
255 View_positioncxx . . $ View_position. =cxx . . $ vector#`operator=`(c0842353a20857d). tempv *cxx . . $ `operator*`(14b8f9ac5c1e7b85). *orient;
256 *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0. =cxx . . $ vector#`operator=`(c0842353a20857d). temp0 *cxx . . $ `operator*`(14b8f9ac5c1e7b85). *orient;
257 *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. =cxx . . $ vector#`operator=`(c0842353a20857d). temp1 *cxx . . $ `operator*`(14b8f9ac5c1e7b85). *orient;
258
259 if (fvi_do_orientcxx . . $ fvi_do_orient.) {
260 fvi_move_fveccxx . . $ fvi_move_fvec. =cxx . . $ vector#`operator=`(c0842353a20857d). fvi_move_fveccxx . . $ fvi_move_fvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). *orient;
261 fvi_move_uveccxx . . $ fvi_move_uvec. =cxx . . $ vector#`operator=`(c0842353a20857d). fvi_move_uveccxx . . $ fvi_move_uvec. *cxx . . $ `operator*`(14b8f9ac5c1e7b85). *orient;
262 }
263
264 // step 3: rotate object matrix through view_matrix (vm = ob * vm)
265
266 tempm2 =cxx . . $ matrix#`operator=`(e859ffc26b91394f). ~cxx . . $ `operator~`(1e820934589b6814).*orient;
267
268 tempm =cxx . . $ matrix#`operator=`(e859ffc26b91394f). tempm2 *cxx . . $ `operator*`(683f8e040c904cb). View_matrixcxx . . $ View_matrix.;
269
270 View_matrixcxx . . $ View_matrix. =cxx . . $ matrix#`operator=`(4c6f8b29806742). tempm;
271 }
272 }
273
274 // instance at specified point with specified orientation
275 // if angles==NULL, don't modify matrix. This will be like doing an offset
276 static void newstyle_StartInstanceAnglescxx . . $ newstyle_StartInstanceAngles(5a7036e8e0f776d8).(vectorcxx . . $ vector# *pos, angveccxx . . $ angvec# *angles) {
277 matrixcxx . . $ matrix# tm;
278
279 if (angles == nullptr) {
280 newstyle_StartInstanceMatrixcxx . . $ newstyle_StartInstanceMatrix(bc315f98e1febb02).(pos, nullptr);
281 return;
282 }
283
284 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&tm, angles->pcxx . . $ angvec#p., angles->hcxx . . $ angvec#h., angles->bcxx . . $ angvec#b.);
285
286 newstyle_StartInstanceMatrixcxx . . $ newstyle_StartInstanceMatrix(bc315f98e1febb02).(pos, &tm);
287 }
288
289 // pops the old context
290 static void newstyle_DoneInstancecxx . . $ newstyle_DoneInstance(49f6e7a06ebc5aa8).() {
291 instance_depthcxx . . $ instance_depth.--;
292
293 ASSERTcxx . . $ `misc/pserror.h:246:9`!(instance_depth >= 0);
294
295 View_positioncxx . . $ View_position. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].pcxx . . $ instance_context#p.;
296 View_matrixcxx . . $ View_matrix. =cxx . . $ matrix#`operator=`(4c6f8b29806742). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].mcxx . . $ instance_context#m.;
297
298 *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].p0cxx . . $ instance_context#p0.;
299 *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].p1cxx . . $ instance_context#p1.;
300 if (fvi_do_orientcxx . . $ fvi_do_orient.) {
301 fvi_move_fveccxx . . $ fvi_move_fvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].fveccxx . . $ instance_context#fvec.;
302 fvi_move_uveccxx . . $ fvi_move_uvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). instance_stackcxx . . $ instance_stack.[instance_depthcxx . . $ instance_depth.].uveccxx . . $ instance_context#uvec.;
303 }
304 }
305
306 void CollideSubmodelcxx . . $ CollideSubmodel(3a5661cc5f0d8c55).(poly_modelcxx . . $ poly_model# *pm, bsp_infocxx . . $ bsp_info# *sm, uint32_tcxx . . $ uint32_t# f_render_sub) {
307 // Don't collide with door housings (That is the 'room' portion of the door)
308 if ((sm->flagscxx . . $ bsp_info#flags. & SOF_SHELLcxx . . $ `lib/polymodel_external.h:82:9`!) || (sm->flagscxx . . $ bsp_info#flags. & SOF_FRONTFACEcxx . . $ `lib/polymodel_external.h:83:9`!))
309 return;
310
311 StartPolyModelPosInstancecxx . . $ StartPolyModelPosInstance(ec8cf6451c36d470).(&sm->mod_poscxx . . $ bsp_info#mod_pos.);
312 vectorcxx . . $ vector# temp_vec = sm->mod_poscxx . . $ bsp_info#mod_pos. +cxx . . $ operator+(b77b703cd1e43e33). sm->offsetcxx . . $ bsp_info#offset.;
313 newstyle_StartInstanceAnglescxx . . $ newstyle_StartInstanceAngles(5a7036e8e0f776d8).(&temp_vec, &sm->angscxx . . $ bsp_info#angs.);
314
315 // Check my bit to see if I get collided with. :)
316 if (f_render_sub & (0x00000001 << (sm - pm->submodelcxx . . $ poly_model#submodel.)))
317 CollideSubmodelFacesUnsortedcxx . . $ CollideSubmodelFacesUnsorted(dea5851e769905e8).(pm, sm);
318
319 for (int i = 0; i < sm->num_childrencxx . . $ bsp_info#num_children.; i++) {
320 CollideSubmodelcxx . . $ CollideSubmodel(3a5661cc5f0d8c55).(pm, &pm->submodelcxx . . $ poly_model#submodel.[sm->childrencxx . . $ bsp_info#children.[i]], f_render_sub);
321 }
322
323 newstyle_DoneInstancecxx . . $ newstyle_DoneInstance(49f6e7a06ebc5aa8).();
324 DonePolyModelPosInstancecxx . . $ DonePolyModelPosInstance(49f6e7a06ebc5aa8).();
325 }
326
327 void CollidePolygonModelcxx . . $ CollidePolygonModel(4ff26f5b2d1f72fa).(vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient, int model_num, float *normalized_time, uint32_tcxx . . $ uint32_t# f_render_sub) {
328 poly_modelcxx . . $ poly_model# *po;
329
330 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[model_num].used);
331 ASSERTcxx . . $ `misc/pserror.h:246:9`!(Poly_models[model_num].new_style);
332
333 fvi_check_paramcxx . . $ fvi_check_param. = false;
334
335 po = &Poly_modelscxx . . $ Poly_models.[model_num];
336
337 newstyle_StartInstanceMatrixcxx . . $ newstyle_StartInstanceMatrix(bc315f98e1febb02).(pos, orient);
338
339 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(po, normalized_time);
340
341 for (int i = 0; i < po->n_modelscxx . . $ poly_model#n_models.; i++) {
342 bsp_infocxx . . $ bsp_info# *sm = &po->submodelcxx . . $ poly_model#submodel.[i];
343 if (sm->parentcxx . . $ bsp_info#parent. == -1)
344 CollideSubmodelcxx . . $ CollideSubmodel(3a5661cc5f0d8c55).(po, sm, f_render_sub);
345 }
346
347 newstyle_DoneInstancecxx . . $ newstyle_DoneInstance(49f6e7a06ebc5aa8).();
348 }
349
350 #define MULTI_ADD_SPHERE_MINcxx . . $ `physics/newstyle_fi.cpp:350:9`! 1.4f
351 #define MULTI_ADD_SPHERE_MAXcxx . . $ `physics/newstyle_fi.cpp:351:9`! 2.5f
352
353 bool PolyCollideObjectcxx . . $ PolyCollideObject(39516aeee13ca5ab).(objectcxx . . $ object# *obj) {
354 #ifndef NED_PHYSICS
355 float normalized_time[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
356 #endif
357 vectorcxx . . $ vector# temp_pos = Original_poscxx . . $ Original_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). View_positioncxx . . $ View_position.;
358 matrixcxx . . $ matrix# temp_orient = Original_orientcxx . . $ Original_orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). View_matrixcxx . . $ View_matrix.;
359 bool f_use_big_sphere = false;
360 float addition;
361
362 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj >= Objects && obj <= &Objects[Highest_object_index]);
363
364 #ifndef NED_PHYSICS
365 if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) && !(Netgamecxx . . $ Netgame..flagscxx . . $ netgame_info#flags. & NF_USE_ACC_WEAPcxx . . $ `Descent3/multi_external.h:236:9`!) && Objectscxx . . $ Objects.[fvi_moveobjcxx . . $ fvi_moveobj.].typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! &&
366 obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)
367 f_use_big_sphere = true;
368 #endif
369
370 fvi_do_orientcxx . . $ fvi_do_orient. = (Objectscxx . . $ Objects.[fvi_moveobjcxx . . $ fvi_moveobj.].typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!);
371
372 #ifndef NED_PHYSICS
373 if (f_use_big_sphere) {
374 addition = fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad.;
375
376 if (addition < MULTI_ADD_SPHERE_MINcxx . . $ `physics/newstyle_fi.cpp:350:9`!) {
377 addition = MULTI_ADD_SPHERE_MINcxx . . $ `physics/newstyle_fi.cpp:350:9`!;
378 if (Objectscxx . . $ Objects.[fvi_moveobjcxx . . $ fvi_moveobj.].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_NEVER_USE_BIG_SPHEREcxx . . $ `Descent3/object_external.h:345:9`!)
379 addition /= 2;
380 } else if (addition > MULTI_ADD_SPHERE_MAXcxx . . $ `physics/newstyle_fi.cpp:351:9`!)
381 addition = MULTI_ADD_SPHERE_MAXcxx . . $ `physics/newstyle_fi.cpp:351:9`!;
382
383 fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad. += addition;
384 }
385 #endif
386
387 if (fvi_do_orientcxx . . $ fvi_do_orient.) {
388 fvi_move_fveccxx . . $ fvi_move_fvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Objectscxx . . $ Objects.[fvi_moveobjcxx . . $ fvi_moveobj.].orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec.;
389 fvi_move_uveccxx . . $ fvi_move_uvec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Objectscxx . . $ Objects.[fvi_moveobjcxx . . $ fvi_moveobj.].orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.;
390 }
391
392 Fvi_f_normalcxx . . $ Fvi_f_normal. = false;
393
394 View_positioncxx . . $ View_position. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
395 View_matrixcxx . . $ View_matrix. =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
396
397 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->flags & OF_POLYGON_OBJECTcxx . . $ `Descent3/object_external.h:281:9`!);
398
399 #ifndef NED_PHYSICS
400 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->typecxx . . $ object#type. == OBJ_DEBRIScxx . . $ `Descent3/object_external.h:168:9`! || obj->typecxx . . $ object#type. == OBJ_DOORcxx . . $ `Descent3/object_external.h:177:9`! ||
401 obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! || obj->typecxx . . $ object#type. == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! || obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`!) {
402 SetNormalizedTimeObjcxx . . $ SetNormalizedTimeObj(8af4de573afdac78).(obj, normalized_time);
403 CollidePolygonModelcxx . . $ CollidePolygonModel(4ff26f5b2d1f72fa).(&obj->poscxx . . $ object#pos., &obj->orientcxx . . $ object#orient., obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num., normalized_time,
404 obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..subobj_flagscxx . . $ polyobj_info#subobj_flags.);
405 } else {
406 CollidePolygonModelcxx . . $ CollidePolygonModel(4ff26f5b2d1f72fa).(&obj->poscxx . . $ object#pos., &obj->orientcxx . . $ object#orient., obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num., nullptr,
407 obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..subobj_flagscxx . . $ polyobj_info#subobj_flags.);
408 }
409 #else
410 CollidePolygonModel(&obj->pos, &obj->orient, obj->rtype.pobj_info.model_num, NULL, obj->rtype.pobj_info.subobj_flags);
411 #endif
412
413 View_positioncxx . . $ View_position. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_pos;
414 View_matrixcxx . . $ View_matrix. =cxx . . $ matrix#`operator=`(4c6f8b29806742). temp_orient;
415
416 // Converts everything into world coordinates from submodel space
417 if (fvi_check_paramcxx . . $ fvi_check_param.) {
418 vectorcxx . . $ vector# pnt = fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0];
419 int mn = fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_subobjectcxx . . $ fvi_info#hit_subobject.[0];
420 matrixcxx . . $ matrix# m;
421 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.];
422
423 while (mn != -1) {
424 vectorcxx . . $ vector# tpnt;
425
426 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.);
427 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
428
429 tpnt =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
430 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] =cxx . . $ vector#`operator=`(c0842353a20857d). fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
431
432 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.;
433
434 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
435 }
436
437 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pnt;
438
439 m =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
440 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
441
442 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] =cxx . . $ vector#`operator=`(c0842353a20857d). fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
443
444 // now instance for the entire object
445 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] =cxx . . $ vector#`operator=`(c0842353a20857d). fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
446 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). obj->poscxx . . $ object#pos.;
447
448 // Now get the hit point
449 vectorcxx . . $ vector# x = *fvi_query_ptrcxx . . $ fvi_query_ptr.->p1cxx . . $ fvi_query#p1. -cxx . . $ operator-(b77b703cd1e43e33). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0.;
450 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&x);
451
452 fvi_hit_data_ptrcxx . . $ fvi_hit_data_ptr.->hit_pntcxx . . $ fvi_info#hit_pnt. =cxx . . $ vector#`operator=`(c0842353a20857d). *fvi_query_ptrcxx . . $ fvi_query_ptr.->p0cxx . . $ fvi_query#p0. +cxx . . $ operator+(b77b703cd1e43e33). x *cxx . . $ `operator*`(252247219a31502c). fvi_hit_paramcxx . . $ fvi_hit_param.;
453 }
454
455 if (f_use_big_sphere) {
456 fvi_query_ptrcxx . . $ fvi_query_ptr.->radcxx . . $ fvi_query#rad. -= addition;
457 }
458
459 return Fvi_f_normalcxx . . $ Fvi_f_normal.;
460 }