Debian Codegraph @

physics/physics.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 <cmath>
20 #include <cstdlib>
21 #include <limits>
22
23 #include "attach.h"cxx . . $ `<file>/Descent3/attach.h`/
24 #include "collide.h"cxx . . $ `<file>/physics/collide.h`/
25 #include "D3ForceFeedback.h"cxx . . $ `<file>/Descent3/D3ForceFeedback.h`/
26 #include "demofile.h"cxx . . $ `<file>/lib/demofile.h`/
27 #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/
28 #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/
29 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
30 #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/
31 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
32 #include "physics.h"cxx . . $ `<file>/physics/physics.h`/
33 #include "player.h"cxx . . $ `<file>/Descent3/player.h`/
34 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
35 #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/
36 #include "vecmat.h"cxx . . $ `<file>/lib/vecmat.h`/
37 #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/
38 #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/
39
40 // Global variables for physics system
41 uint8_tcxx . . $ uint8_t# Default_player_terrain_levelingcxx . . $ Default_player_terrain_leveling. = 0;
42 uint8_tcxx . . $ uint8_t# Default_player_room_levelingcxx . . $ Default_player_room_leveling. = 0;
43
44 // Maximum iterations thru the simulation loop NOTE: It is assumed that the player loops >= non-player loops
45 #define MAX_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:45:9`! 9
46 #define MAX_NON_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:46:9`! 5
47
48 #define CEILING_POWERUP_DELTAcxx . . $ `physics/physics.cpp:48:9`! 30.0f
49
50 #define WIGGLE_FALLOFF_TIMEcxx . . $ `physics/physics.cpp:50:9`! 2.0
51
52 int Physics_normal_countercxx . . $ Physics_normal_counter.;
53 int Physics_normal_looping_countercxx . . $ Physics_normal_looping_counter.;
54 int Physics_walking_countercxx . . $ Physics_walking_counter.;
55 int Physics_walking_looping_countercxx . . $ Physics_walking_looping_counter.;
56 int Physics_vis_countercxx . . $ Physics_vis_counter.;
57
58 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
59 // This will allow us to debug physics in a better way.
60 struct sim_loop_infocxx . . $ sim_loop_info# {
61 vectorcxx . . $ vector# start_poscxx . . $ sim_loop_info#start_pos.;
62 physics_infocxx . . $ physics_info# phys_infocxx . . $ sim_loop_info#phys_info.; // At beginnning of loop
63 fvi_infocxx . . $ fvi_info# hit_infocxx . . $ sim_loop_info#hit_info.; // Hit information returned by FVI
64 };
65
66 sim_loop_infocxx . . $ sim_loop_info# sim_loop_recordcxx . . $ sim_loop_record.[MAX_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:45:9`!];
67 #endif
68
69 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
70 int Physics_player_verbosecxx . . $ Physics_player_verbose. = 0;
71 #endif
72
73 #define PHYSICS_GROUND_TOLERANCEcxx . . $ `physics/physics.cpp:73:9`! 0.0001f
74 #define DAMP_ANGcxx . . $ `physics/physics.cpp:74:9`! 1.0f // chrishack -- this is probably too tight and should be an int not a float
75 #define MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! 100000.0f
76 int Physics_cheat_flagcxx . . $ Physics_cheat_flag. = 0;
77 extern char BounceCheatcxx . . $ BounceCheat.;
78
79 int PhysicsLinkListcxx . . $ PhysicsLinkList.[MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!];
80 int Physics_NumLinkedcxx . . $ Physics_NumLinked. = 0;
81
82 // Current strength of gravity
83 float Gravity_strengthcxx . . $ Gravity_strength. = -32.2f; // Meters/second^2
84
85 void DoPhysLinkedFramecxx . . $ DoPhysLinkedFrame(419c470199a90a97).(objectcxx . . $ object# *obj) {
86 objectcxx . . $ object# *parent = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->mtypecxx . . $ object#mtype..obj_link_infocxx . . $ object#$anonymous_type_8#obj_link_info..parent_handlecxx . . $ object_link_info#parent_handle.);
87 matrixcxx . . $ matrix# new_orient;
88 vectorcxx . . $ vector# new_pos;
89
90 if (parent && parent->typecxx . . $ object#type. != OBJ_GHOSTcxx . . $ `Descent3/object_external.h:172:9`! && parent->typecxx . . $ object#type. != OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!) {
91 poly_modelcxx . . $ poly_model# *pm;
92 vectorcxx . . $ vector# pnt;
93 vectorcxx . . $ vector# fvec;
94 vectorcxx . . $ vector# uvec;
95 matrixcxx . . $ matrix# m;
96 int mn; // submodel number
97 float normalized_time[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
98
99 pm = &Poly_modelscxx . . $ Poly_models.[parent->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
100 ASSERTcxx . . $ `misc/pserror.h:246:9`!(pm->used);
101
102 SetNormalizedTimeObjcxx . . $ SetNormalizedTimeObj(8af4de573afdac78).(parent, normalized_time);
103
104 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(pm, normalized_time);
105
106 pnt =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..obj_link_infocxx . . $ object#$anonymous_type_8#obj_link_info..poscxx . . $ object_link_info#pos.;
107 fvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..obj_link_infocxx . . $ object#$anonymous_type_8#obj_link_info..fveccxx . . $ object_link_info#fvec.;
108 uvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..obj_link_infocxx . . $ object#$anonymous_type_8#obj_link_info..uveccxx . . $ object_link_info#uvec.;
109
110 mn = obj->mtypecxx . . $ object#mtype..obj_link_infocxx . . $ object#$anonymous_type_8#obj_link_info..sobj_indexcxx . . $ object_link_info#sobj_index.;
111
112 if (mn < 0 || mn >= pm->n_modelscxx . . $ poly_model#n_models.) {
113 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Caught physics link bug!\n");
114 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
115 return;
116 }
117
118 // Instance up the tree for this gun
119 while (mn != -1) {
120 vectorcxx . . $ vector# tpnt;
121
122 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.);
123 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
124
125 tpnt =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
126 fvec =cxx . . $ vector#`operator=`(c0842353a20857d). fvec *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
127 uvec =cxx . . $ vector#`operator=`(c0842353a20857d). uvec *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
128
129 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.;
130
131 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
132 }
133
134 // now instance for the entire object
135 m =cxx . . $ matrix#`operator=`(4c6f8b29806742). parent->orientcxx . . $ object#orient.;
136 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
137
138 new_pos =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
139 fvec =cxx . . $ vector#`operator=`(c0842353a20857d). fvec *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
140 uvec =cxx . . $ vector#`operator=`(c0842353a20857d). uvec *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
141
142 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&new_orient, &fvec, &uvec, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
143
144 new_pos +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). parent->poscxx . . $ object#pos.;
145
146 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &new_pos, parent->roomnumcxx . . $ object#roomnum., &new_orient, false);
147 } else {
148 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
149 }
150 }
151
152 bool PhysCalcGroundcxx . . $ PhysCalcGround(85e3752e9562a225).(vectorcxx . . $ vector# *ground_point, vectorcxx . . $ vector# *ground_normal, objectcxx . . $ object# *obj, int ground_num) {
153 poly_modelcxx . . $ poly_model# *pm;
154 vectorcxx . . $ vector# pnt;
155 vectorcxx . . $ vector# normal;
156 matrixcxx . . $ matrix# m;
157 int mn; // submodel number
158 float normalized_time[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
159 bool f_good_gp = true;
160
161 if (obj->render_typecxx . . $ object#render_type. != RT_POLYOBJcxx . . $ `Descent3/object_external.h:258:9`! && obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
162 // mprintf(0,"Object type %d is not a polyobj!\n",obj->type);
163
164 if (ground_point)
165 *ground_point =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
166 if (ground_normal)
167 *ground_normal =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec.;
168
169 return false;
170 }
171
172 pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
173
174 if (pm->n_groundcxx . . $ poly_model#n_ground. == 0) {
175 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "WARNING: Object with no weapons is firing.\n", ground_num);
176
177 if (ground_point)
178 *ground_point =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
179 if (ground_normal)
180 *ground_normal =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec.;
181
182 return false;
183 }
184
185 SetNormalizedTimeObjcxx . . $ SetNormalizedTimeObj(8af4de573afdac78).(obj, normalized_time);
186
187 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(pm, normalized_time);
188
189 if (ground_num < 0 || ground_num >= pm->n_groundcxx . . $ poly_model#n_ground.) {
190 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "WARNING: Bashing ground num %d to 0.\n", ground_num);
191 ground_num = 0;
192 f_good_gp = false;
193 }
194
195 pnt =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->ground_slotscxx . . $ poly_model#ground_slots.[ground_num].pntcxx . . $ w_bank#pnt.;
196 normal =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->ground_slotscxx . . $ poly_model#ground_slots.[ground_num].normcxx . . $ w_bank#norm.;
197 mn = pm->ground_slotscxx . . $ poly_model#ground_slots.[ground_num].parentcxx . . $ w_bank#parent.;
198
199 // Instance up the tree for this ground
200 while (mn != -1) {
201 vectorcxx . . $ vector# tpnt;
202
203 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.);
204 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
205
206 tpnt =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
207 normal =cxx . . $ vector#`operator=`(c0842353a20857d). normal *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
208
209 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.;
210
211 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
212 }
213
214 m =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
215 vm_TransposeMatrixcxx . . $ vm_TransposeMatrix(dca75c48c9ab5b54).(&m);
216
217 if (ground_point)
218 *ground_point =cxx . . $ vector#`operator=`(c0842353a20857d). pnt *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
219 if (ground_normal)
220 *ground_normal =cxx . . $ vector#`operator=`(c0842353a20857d). normal *cxx . . $ `operator*`(14b8f9ac5c1e7b85). m;
221
222 if (ground_point)
223 *ground_point +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). obj->poscxx . . $ object#pos.;
224
225 return f_good_gp;
226 }
227
228 // Applies rotational thrust over at delta time
229 void PhysicsApplyConstRotForcecxx . . $ PhysicsApplyConstRotForce(4b3ff13ec57857bf).(objectcxx . . $ object# &objp, const vectorcxx . . $ vector# &rotforce, vectorcxx . . $ vector# &rotvel, float deltaTime) {
230 const double drag = objp.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotdragcxx . . $ physics_info#rotdrag.;
231 const double mass = objp.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.;
232
233 if (mass < std::numeric_limits<double>::epsilon() || drag < std::numeric_limits<double>::epsilon()) {
234 // Invalid mass/drag
235 rotvel +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). rotforce *cxx . . $ `operator*`(252247219a31502c). deltaTime;
236 return;
237 }
238
239 // Standard angular motion with a linear air drag (drag is proportional to angular velocity)
240 const double oneOverDrag = 1.0 / drag;
241 const double rotForceOverDrag[3] = {double(rotforce.xcxx . . $ vector#x.) * oneOverDrag, double(rotforce.ycxx . . $ vector#y.) * oneOverDrag,
242 double(rotforce.zcxx . . $ vector#z.) * oneOverDrag};
243 const double dragOverMass = drag / mass;
244 const double expDoMDt = expcxx . . $ exp(fee4f1d22bc8e617).(-dragOverMass * double(deltaTime));
245
246 double newRotVel[3];
247 newRotVel[0] = (double(rotvel.xcxx . . $ vector#x.) - rotForceOverDrag[0]) * expDoMDt + rotForceOverDrag[0];
248 newRotVel[1] = (double(rotvel.ycxx . . $ vector#y.) - rotForceOverDrag[1]) * expDoMDt + rotForceOverDrag[1];
249 newRotVel[2] = (double(rotvel.zcxx . . $ vector#z.) - rotForceOverDrag[2]) * expDoMDt + rotForceOverDrag[2];
250
251 // set the new rotational velocity
252 rotvel.xcxx . . $ vector#x. = static_cast<float>(newRotVel[0]);
253 rotvel.ycxx . . $ vector#y. = static_cast<float>(newRotVel[1]);
254 rotvel.zcxx . . $ vector#z. = static_cast<float>(newRotVel[2]);
255 }
256
257 // Applies a linear force over time. --Like gravity or thrust
258 void PhysicsApplyConstantForcecxx . . $ PhysicsApplyConstantForce(a8f705e6b2f8536d).(const objectcxx . . $ object# &objp, vectorcxx . . $ vector# &newPos, vectorcxx . . $ vector# &newVel, vectorcxx . . $ vector# &movementVec,
259 const vectorcxx . . $ vector# &force, float deltaTime) {
260 const vectorcxx . . $ vector# &pos = objp.poscxx . . $ object#pos.;
261 const vectorcxx . . $ vector# &vel = objp.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
262 const double drag = static_cast<double>(objp.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag.);
263 const double mass = static_cast<double>(objp.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.);
264
265 if (mass < std::numeric_limits<double>::epsilon() || drag < std::numeric_limits<double>::epsilon()) {
266 // No Mass/Drag
267 movementVec =cxx . . $ vector#`operator=`(c0842353a20857d). (vel *cxx . . $ `operator*`(252247219a31502c). deltaTime) +cxx . . $ operator+(b77b703cd1e43e33). (force *cxx . . $ `operator*`(252247219a31502c). (0.5f * deltaTime * deltaTime));
268 newPos =cxx . . $ vector#`operator=`(c0842353a20857d). pos +cxx . . $ operator+(b77b703cd1e43e33). movementVec;
269 newVel =cxx . . $ vector#`operator=`(c0842353a20857d). vel +cxx . . $ operator+(b77b703cd1e43e33). force *cxx . . $ `operator*`(252247219a31502c). deltaTime;
270 return;
271 }
272
273 // Standard motion with a linear air drag (drag is proportional to velocity)
274 const double dt = static_cast<double>(deltaTime);
275 const double oneOverDrag = 1.0 / drag;
276 const double massOverDrag = mass / drag;
277 const double forceOverDrag[3] = {force.xcxx . . $ vector#x. * oneOverDrag, force.ycxx . . $ vector#y. * oneOverDrag, force.zcxx . . $ vector#z. * oneOverDrag};
278 const double objVel[3] = {static_cast<double>(vel.xcxx . . $ vector#x.), static_cast<double>(vel.ycxx . . $ vector#y.), static_cast<double>(vel.zcxx . . $ vector#z.)};
279 const double expDoMDt = expcxx . . $ exp(fee4f1d22bc8e617).((-1.0 / massOverDrag) * dt);
280
281 newPos.xcxx . . $ vector#x. = static_cast<float>(static_cast<double>(pos.xcxx . . $ vector#x.) + forceOverDrag[0] * dt +
282 massOverDrag * (objVel[0] - forceOverDrag[0]) * (1.0 - expDoMDt));
283 newPos.ycxx . . $ vector#y. = static_cast<float>(static_cast<double>(pos.ycxx . . $ vector#y.) + forceOverDrag[1] * dt +
284 massOverDrag * (objVel[1] - forceOverDrag[1]) * (1.0 - expDoMDt));
285 newPos.zcxx . . $ vector#z. = static_cast<float>(static_cast<double>(pos.zcxx . . $ vector#z.) + forceOverDrag[2] * dt +
286 massOverDrag * (objVel[2] - forceOverDrag[2]) * (1.0 - expDoMDt));
287 movementVec =cxx . . $ vector#`operator=`(c0842353a20857d). newPos -cxx . . $ operator-(b77b703cd1e43e33). pos;
288 newVel.xcxx . . $ vector#x. = static_cast<float>((objVel[0] - forceOverDrag[0]) * expDoMDt + forceOverDrag[0]);
289 newVel.ycxx . . $ vector#y. = static_cast<float>((objVel[1] - forceOverDrag[1]) * expDoMDt + forceOverDrag[1]);
290 newVel.zcxx . . $ vector#z. = static_cast<float>((objVel[2] - forceOverDrag[2]) * expDoMDt + forceOverDrag[2]);
291 }
292
293 // Banks an object as it turns (we counteract this and then reapply it when we
294 // actually do the turn -- cool)
295 void set_object_turnrollcxx . . $ set_object_turnroll(6f1900cded82c08e).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *rotvel, anglecxx . . $ angle# *turnroll) {
296 float desired_bank;
297 anglecxx . . $ angle# desired_bank_angle;
298
299 desired_bank = -(rotvel->ycxx . . $ vector#y.) * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..turnroll_ratiocxx . . $ physics_info#turnroll_ratio.;
300
301 // If desired bank > 32000, we will rotate the ship in weird ways. Should limit turn-roll to 32000 if this
302 // ever occurs. BTW This is where the limiter should be placed.
303 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(desired_bank) > 32000.0) {
304 if (desired_bank < 0.0)
305 desired_bank = -32000.0f;
306 else
307 desired_bank = 32000.0f;
308 }
309
310 if (desired_bank > -1.0) // accounts for -.9999 this is rounded to 0 in a float to int conversion
311 desired_bank_angle = desired_bank;
312 else
313 desired_bank_angle = 65535 + desired_bank;
314
315 if (*turnroll != desired_bank_angle) {
316 int delta_ang;
317 int max_roll;
318
319 max_roll = obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..max_turnroll_ratecxx . . $ physics_info#max_turnroll_rate. * Frametimecxx . . $ Frametime.;
320
321 if (*turnroll > 32000)
322 delta_ang = desired_bank - (*turnroll - 65535);
323 else
324 delta_ang = desired_bank - *turnroll;
325
326 if (labscxx . . $ labs(27d244100e426cb3).(delta_ang) > max_roll)
327 if (delta_ang > 0)
328 *turnroll += max_roll;
329 else
330 *turnroll -= max_roll;
331 else
332 *turnroll = desired_bank_angle;
333 } else
334 *turnroll = desired_bank_angle;
335 }
336
337 // Maximum number of objects that we already hit.
338 #define MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`! 100
339
340 // When leveling non-player objects - how many angles per sec. do they correct with.
341 #define MAX_LEVEL_ANGLES_PER_SECcxx . . $ `physics/physics.cpp:341:9`! 30000.0f
342
343 // Base scaler for pitch scaling of autoleveling
344 #define MAX_AUTOLEVEL_TILT_ANGLEcxx . . $ `physics/physics.cpp:344:9`! 11000
345
346 // Multiplier for newbie autoleveling scaling of tilt angle
347 #define NEWBIE_AUTOLEVEL_TILT_ANGLE_SCALARcxx . . $ `physics/physics.cpp:347:9`! 1.25f
348
349 // How long a newbie sits there before the pitch leveling kicks in
350 #define NEWBIE_PITCH_LEVEL_TIMEcxx . . $ `physics/physics.cpp:350:9`! 1.5f
351
352 #define BANK_AUTOLEVEL_SPEED_SCALARcxx . . $ `physics/physics.cpp:352:9`! 2.0
353
354 // Rotational simulator the updates orient, rotvel, and turnroll
355 // (using these original values + frametime + rotthrust)
356 bool PhysicsDoSimRotcxx . . $ PhysicsDoSimRot(d5590f9f58c35daf).(objectcxx . . $ object# *obj, float frame_time, matrixcxx . . $ matrix# *orient, vectorcxx . . $ vector# *rotthrust, vectorcxx . . $ vector# *rotvel,
357 anglecxx . . $ angle# *turnroll) {
358 angveccxx . . $ angvec# tangles;
359 matrixcxx . . $ matrix# rotmat;
360 physics_infocxx . . $ physics_info# *pi;
361 bool f_leveling = false;
362 float max_tilt_angle = 0;
363 bool f_newbie_leveling = false;
364
365 if (frame_time <= 0.0)
366 return false; // chrishack
367
368 pi = &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info.;
369
370 if (obj == Player_objectcxx . . $ Player_object. && obj->control_typecxx . . $ object#control_type. != CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) {
371 max_tilt_angle = MAX_AUTOLEVEL_TILT_ANGLEcxx . . $ `physics/physics.cpp:344:9`!;
372
373 if (OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(obj)) {
374 if (Default_player_terrain_levelingcxx . . $ Default_player_terrain_leveling.) {
375 f_leveling = true;
376 if (Default_player_terrain_levelingcxx . . $ Default_player_terrain_leveling. > 1) {
377 max_tilt_angle *= NEWBIE_AUTOLEVEL_TILT_ANGLE_SCALARcxx . . $ `physics/physics.cpp:347:9`!;
378 f_newbie_leveling = true;
379 }
380 }
381 } else {
382 if (Default_player_room_levelingcxx . . $ Default_player_room_leveling.) {
383 f_leveling = true;
384 if (Default_player_room_levelingcxx . . $ Default_player_room_leveling. > 1) {
385 max_tilt_angle *= NEWBIE_AUTOLEVEL_TILT_ANGLE_SCALARcxx . . $ `physics/physics.cpp:347:9`!;
386 f_newbie_leveling = true;
387 }
388 }
389 }
390 } else {
391 if (pi->flagscxx . . $ physics_info#flags. & PF_LEVELINGcxx . . $ `Descent3/object_external.h:314:9`!)
392 f_leveling = true;
393 }
394
395 // Fixed rate rotaters
396 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_FIXED_ROT_VELOCITYcxx . . $ `Descent3/object_external.h:325:9`!) {
397 tangles.pcxx . . $ angvec#p. = (int16_t)(rotvel->xcxx . . $ vector#x. * frame_time);
398 tangles.hcxx . . $ angvec#h. = (int16_t)(rotvel->ycxx . . $ vector#y. * frame_time);
399 tangles.bcxx . . $ angvec#b. = (int16_t)(rotvel->zcxx . . $ vector#z. * frame_time);
400
401 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&rotmat, tangles.pcxx . . $ angvec#p., tangles.hcxx . . $ angvec#h., tangles.bcxx . . $ angvec#b.);
402 *orient =cxx . . $ matrix#`operator=`(e859ffc26b91394f). *orient *cxx . . $ `operator*`(683f8e040c904cb). rotmat; // ObjSetOrient below
403
404 vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(orient); // Rest done after call
405
406 return true;
407 }
408
409 // now rotate object
410 // unrotate object for bank caused by turn
411 if (*turnroll != 0) {
412 tangles.pcxx . . $ angvec#p. = tangles.hcxx . . $ angvec#h. = 0;
413 tangles.bcxx . . $ angvec#b. = -(*turnroll);
414 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&rotmat, tangles.pcxx . . $ angvec#p., tangles.hcxx . . $ angvec#h., tangles.bcxx . . $ angvec#b.);
415 // Apply rotation matrix to the orientation matrix
416 *orient =cxx . . $ matrix#`operator=`(e859ffc26b91394f). *orient *cxx . . $ `operator*`(683f8e040c904cb). rotmat; // ObjSetOrient is below
417 }
418
419 // Auto-leveling
420 if ((f_leveling) && (obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)) {
421 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(rotthrust->zcxx . . $ vector#z.) < 100.0f) {
422 if ((fabscxx . . $ fabs(fbcf3211dfe1bfd1).(rotvel->zcxx . . $ vector#z.) < 1500.0f) /*&& (pi->turnroll <= 10 || pi->turnroll >= 65535 - 10)*/) {
423 angveccxx . . $ angvec# ang;
424 vectorcxx . . $ vector# fvec;
425 int bound;
426
427 // f_leveling = true;
428 // pi->turnroll = 0;
429
430 // extract angles from a matrix
431 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&ang, orient);
432
433 if ((pi->flagscxx . . $ physics_info#flags. & PF_TURNROLLcxx . . $ `Descent3/object_external.h:313:9`!) && *turnroll) {
434 bound = *turnroll;
435 if (bound > 32768) {
436 bound = 65535 - bound;
437 }
438 } else {
439 bound = 10;
440 }
441
442 if (ang.bcxx . . $ angvec#b. > bound && ang.bcxx . . $ angvec#b. < 65535 - bound) // About 1 degree
443 {
444 float scale;
445
446 // Scale on pitch
447 if (ang.pcxx . . $ angvec#p. < 32768) {
448 scale = abscxx . . $ abs(a1851578aea3f541).(16834 - (int)ang.pcxx . . $ angvec#p.) / 16384.0f;
449 } else {
450 scale = abscxx . . $ abs(a1851578aea3f541).(49152 - (int)ang.pcxx . . $ angvec#p.) / 16384.0f;
451 }
452
453 // mprintf(0, "scale %f, ", scale);
454
455 if (ang.bcxx . . $ angvec#b. < 32768) {
456 float al_rate = scale * MAX_LEVEL_ANGLES_PER_SECcxx . . $ `physics/physics.cpp:341:9`! * (1.0f - (abscxx . . $ abs(a1851578aea3f541).(16834 - (int)ang.bcxx . . $ angvec#b.) / 16384.0f));
457
458 if (al_rate < scale * 5000.0f) {
459 al_rate = scale * 5000.0f;
460 }
461
462 al_rate *= frame_time;
463
464 if (al_rate > ang.bcxx . . $ angvec#b.)
465 al_rate = ang.bcxx . . $ angvec#b.;
466
467 // mprintf(0, "L al_rate %f\n", al_rate);
468
469 ang.bcxx . . $ angvec#b. -= al_rate;
470
471 } else {
472 float al_rate = scale * MAX_LEVEL_ANGLES_PER_SECcxx . . $ `physics/physics.cpp:341:9`! * (1.0f - (abscxx . . $ abs(a1851578aea3f541).(16384 - ((int)ang.bcxx . . $ angvec#b. - 32768)) / 16384.0f));
473
474 if (al_rate < scale * 5000.0f) {
475 al_rate = scale * 5000.0f;
476 }
477
478 al_rate *= frame_time;
479
480 if (al_rate > 65535 - ang.bcxx . . $ angvec#b.)
481 al_rate = 65535 - ang.bcxx . . $ angvec#b.;
482
483 // mprintf(0, "G al_rate %f\n", al_rate);
484
485 ang.bcxx . . $ angvec#b. += al_rate;
486 }
487
488 fvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). orient->fveccxx . . $ matrix#fvec.;
489
490 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(orient, ang.pcxx . . $ angvec#p., ang.hcxx . . $ angvec#h., ang.bcxx . . $ angvec#b.);
491 }
492 }
493 }
494 } else if ((f_leveling) && (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)) {
495 bool f_pitch_leveled = false;
496 bool f_player_fired_recently = false;
497 int i;
498
499 for (i = 0; i < 21; i++) {
500 if (obj->dynamic_wbcxx . . $ object#dynamic_wb.[i].last_fire_timecxx . . $ dynamic_wb_info#last_fire_time. + NEWBIE_PITCH_LEVEL_TIMEcxx . . $ `physics/physics.cpp:350:9`! > Gametimecxx . . $ Gametime.) {
501 f_player_fired_recently = true;
502 f_newbie_leveling = false;
503 break;
504 }
505 }
506
507 if (!f_player_fired_recently && f_newbie_leveling &&
508 (Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].last_thrust_timecxx . . $ player#last_thrust_time. + NEWBIE_PITCH_LEVEL_TIMEcxx . . $ `physics/physics.cpp:350:9`! < Gametimecxx . . $ Gametime.)) {
509 if (1) {
510 angveccxx . . $ angvec# ang;
511 int bound;
512
513 // f_leveling = true;
514 // pi->turnroll = 0;
515
516 // extract angles from a matrix
517 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&ang, orient);
518
519 bound = 750;
520
521 // About 1 degree -- front or back
522 if ((ang.pcxx . . $ angvec#p. > bound) && (ang.pcxx . . $ angvec#p. < 65535 - bound) && // Forward
523 abscxx . . $ abs(a1851578aea3f541).(ang.pcxx . . $ angvec#p. - 32768) > bound) // Backward
524 {
525 float scale;
526 f_pitch_leveled = true;
527
528 if (obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y. < 0.0f) {
529 ang.pcxx . . $ angvec#p. += 16384;
530 }
531
532 scale = 1.05f - fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec..ycxx . . $ vector#y.);
533 // scale *= scale;
534
535 if (scale > 1.0)
536 scale = 1.0;
537
538 if (ang.pcxx . . $ angvec#p. < 16834) {
539 rotthrust->xcxx . . $ vector#x. -= scale * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
540 } else if (ang.pcxx . . $ angvec#p. < 32768) {
541 rotthrust->xcxx . . $ vector#x. += scale * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
542 } else if (ang.pcxx . . $ angvec#p. < 49152) {
543 rotthrust->xcxx . . $ vector#x. -= scale * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
544 } else {
545 rotthrust->xcxx . . $ vector#x. += scale * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
546 }
547 }
548 }
549 }
550
551 if (!f_pitch_leveled && fabscxx . . $ fabs(fbcf3211dfe1bfd1).(rotthrust->zcxx . . $ vector#z.) < 100.0f) {
552 angveccxx . . $ angvec# ang;
553 int bound;
554
555 // extract angles from a matrix
556 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&ang, orient);
557 if ((ang.pcxx . . $ angvec#p. < 32768 && (abscxx . . $ abs(a1851578aea3f541).((int)ang.pcxx . . $ angvec#p. - (int)16834) > max_tilt_angle)) ||
558 (ang.pcxx . . $ angvec#p. >= 32768 && (abscxx . . $ abs(a1851578aea3f541).((int)ang.pcxx . . $ angvec#p. - (int)49152) > max_tilt_angle))) {
559
560 if ((pi->flagscxx . . $ physics_info#flags. & PF_TURNROLLcxx . . $ `Descent3/object_external.h:313:9`!) && *turnroll) {
561 bound = *turnroll;
562 if (bound > 32768) {
563 bound = 65535 - bound;
564 }
565 } else {
566 bound = 10;
567 }
568
569 if (ang.bcxx . . $ angvec#b. > bound && ang.bcxx . . $ angvec#b. < 65535 - bound) // About 1 degree
570 {
571 float scale;
572
573 // Scale on pitch
574 if (ang.pcxx . . $ angvec#p. < 32768) {
575 scale = (abscxx . . $ abs(a1851578aea3f541).(16834 - (int)ang.pcxx . . $ angvec#p.) - max_tilt_angle) / (16384.0f - max_tilt_angle);
576 } else {
577 scale = (abscxx . . $ abs(a1851578aea3f541).(49152 - (int)ang.pcxx . . $ angvec#p.) - max_tilt_angle) / (16384.0f - max_tilt_angle);
578 }
579
580 if (ang.bcxx . . $ angvec#b. < 32768) {
581 float temp_scale;
582
583 if (ang.bcxx . . $ angvec#b. > 28672) {
584 temp_scale = (1.04f - ((28672 - 16834) / 16384.0f));
585 } else {
586 temp_scale = (1.04f - (abscxx . . $ abs(a1851578aea3f541).(16834 - (int)ang.bcxx . . $ angvec#b.) / 16384.0f));
587 }
588
589 temp_scale *= temp_scale;
590 scale *= temp_scale;
591 if (f_player_fired_recently)
592 scale *= .25f;
593
594 rotthrust->zcxx . . $ vector#z. -= scale * BANK_AUTOLEVEL_SPEED_SCALARcxx . . $ `physics/physics.cpp:352:9`! * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
595 } else {
596 float temp_scale;
597
598 if (ang.bcxx . . $ angvec#b. < 36864) {
599 temp_scale = (1.04f - ((49152 - 36864) / 16384.0f));
600 } else {
601 temp_scale = (1.04f - (abscxx . . $ abs(a1851578aea3f541).(49152 - (int)ang.bcxx . . $ angvec#b.) / 16384.0f));
602 }
603
604 temp_scale *= temp_scale;
605 scale *= temp_scale;
606 if (f_player_fired_recently)
607 scale *= .25f;
608
609 rotthrust->zcxx . . $ vector#z. += scale * BANK_AUTOLEVEL_SPEED_SCALARcxx . . $ `physics/physics.cpp:352:9`! * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..full_rotthrustcxx . . $ physics_info#$anonymous_type_4#full_rotthrust.;
610 }
611 }
612 }
613 }
614 }
615
616 if (pi->rotdragcxx . . $ physics_info#rotdrag. > 0.0f) {
617 if (!(pi->flagscxx . . $ physics_info#flags. & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!)) {
618 *rotthrust =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
619 }
620
621 PhysicsApplyConstRotForcecxx . . $ PhysicsApplyConstRotForce(4b3ff13ec57857bf).(*obj, *rotthrust, *rotvel, frame_time);
622 }
623
624 // Apply rotation to the "un-rollbanked" object
625 tangles.pcxx . . $ angvec#p. = (int16_t)(rotvel->xcxx . . $ vector#x. * frame_time); // Casting to int16_t is required for aarch64 to avoid FCVTZU
626 // instruction which strips the negative sign
627 tangles.hcxx . . $ angvec#h. = (int16_t)(rotvel->ycxx . . $ vector#y. * frame_time);
628 tangles.bcxx . . $ angvec#b. = (int16_t)(rotvel->zcxx . . $ vector#z. * frame_time);
629
630 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&rotmat, tangles.pcxx . . $ angvec#p., tangles.hcxx . . $ angvec#h., tangles.bcxx . . $ angvec#b.);
631 *orient =cxx . . $ matrix#`operator=`(e859ffc26b91394f). *orient *cxx . . $ `operator*`(683f8e040c904cb). rotmat; // ObjSetOrient is below
632
633 // Determine the new turnroll from this amount of turning
634 if (pi->flagscxx . . $ physics_info#flags. & PF_TURNROLLcxx . . $ `Descent3/object_external.h:313:9`!) {
635 set_object_turnrollcxx . . $ set_object_turnroll(6f1900cded82c08e).(obj, rotvel, turnroll);
636 }
637
638 // re-rotate object for bank caused by turn
639 if (*turnroll != 0) {
640 tangles.pcxx . . $ angvec#p. = tangles.hcxx . . $ angvec#h. = 0;
641 tangles.bcxx . . $ angvec#b. = *turnroll;
642 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&rotmat, tangles.pcxx . . $ angvec#p., tangles.hcxx . . $ angvec#h., tangles.bcxx . . $ angvec#b.);
643 *orient =cxx . . $ matrix#`operator=`(e859ffc26b91394f). *orient *cxx . . $ `operator*`(683f8e040c904cb). rotmat; // ObjSetOrient is below
644 }
645 // Make sure the new orientation is valid
646 vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(orient);
647
648 return true;
649 }
650
651 void PhysicsDoSimLinearcxx . . $ PhysicsDoSimLinear(33e639d8e7a28d49).(const objectcxx . . $ object# &obj, const vectorcxx . . $ vector# &pos, const vectorcxx . . $ vector# &force, vectorcxx . . $ vector# &velocity,
652 vectorcxx . . $ vector# &movementVec, vectorcxx . . $ vector# &movementPos, float simTime, int count) {
653 // Determine velocity
654 if (obj.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_FIXED_VELOCITYcxx . . $ `Descent3/object_external.h:324:9`!) {
655 movementVec =cxx . . $ vector#`operator=`(c0842353a20857d). velocity *cxx . . $ `operator*`(252247219a31502c). simTime;
656 movementPos =cxx . . $ vector#`operator=`(c0842353a20857d). pos +cxx . . $ operator+(b77b703cd1e43e33). movementVec;
657 return;
658 }
659
660 vectorcxx . . $ vector# forceToUse = force;
661 if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj.roomnum) && !(obj.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_LOCK_MASKcxx . . $ `Descent3/object_external.h:344:9`!) &&
662 Roomscxx . . $ Rooms.[obj.roomnumcxx . . $ object#roomnum.].windcxx . . $ room#wind. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector. && count == 0 && obj.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. > 0.0f &&
663 !(obj.typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! && Level_powerups_ignore_windcxx . . $ Level_powerups_ignore_wind.)) {
664 // Factor in outside wind
665 const vectorcxx . . $ vector# &wind = Roomscxx . . $ Rooms.[obj.roomnumcxx . . $ object#roomnum.].windcxx . . $ room#wind.;
666 vectorcxx . . $ vector# deltaForce = wind *cxx . . $ `operator*`(252247219a31502c). obj.mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. *cxx . . $ `operator*`(252247219a31502c). 16.0f;
667 forceToUse +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). deltaForce;
668 }
669
670 PhysicsApplyConstantForcecxx . . $ PhysicsApplyConstantForce(a8f705e6b2f8536d).(obj, movementPos, velocity, movementVec, forceToUse, simTime);
671
672 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
673 if (Physics_player_verbosecxx . . $ Physics_player_verbose. && obj.typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
674 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Player Velocity = %f(%f)\n", vm_GetMagnitude(&velocity), vm_GetMagnitude(&movementVec) / simTime);
675 }
676 #endif
677 }
678
679 // -----------------------------------------------------------------------------------------------------------
680 // Simulate a physics object for this frame
681 void do_physics_simcxx . . $ do_physics_sim(419c470199a90a97).(objectcxx . . $ object# *obj) {
682 // Since we might not call FVI, set this here
683 Fvi_num_recorded_facescxx . . $ Fvi_num_recorded_faces. = 0;
684
685 int n_ignore_objs = 0; // The number of ignored objects
686 int ignore_obj_list[MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`! + 1]; // List of ignored objects
687
688 int fate; // Collision type for response code
689 vectorcxx . . $ vector# movement_vec; // Movement in this frame
690 vectorcxx . . $ vector# movement_pos; // End point of the movement
691
692 int count = 0; // Simulation loop counter
693 int sim_loop_limit = (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) ? MAX_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:45:9`! : MAX_NON_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:46:9`!;
694
695 int objnum = OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj); // Simulated object's index
696 fvi_infocxx . . $ fvi_info# hit_info; // Hit information
697 fvi_querycxx . . $ fvi_query# fq; // Movement query
698
699 float sim_time_remaining = Frametimecxx . . $ Frametime.; // Amount of simulation time remaining (current iteration)
700 float old_sim_time_remaining = Frametimecxx . . $ Frametime.; // Amount of simulation time remaining (previous iteration)
701
702 vectorcxx . . $ vector# init_pos = obj->poscxx . . $ object#pos.; // Initial position
703 int init_room = obj->roomnumcxx . . $ object#roomnum.; // Initial room
704
705 vectorcxx . . $ vector# start_pos; // Values at the start of current simulation loop
706 vectorcxx . . $ vector# start_vel;
707 matrixcxx . . $ matrix# start_orient;
708 vectorcxx . . $ vector# start_rotvel;
709 anglecxx . . $ angle# start_turnroll;
710 int start_room;
711
712 float moved_time; // How long objected moved before hit something
713 physics_infocxx . . $ physics_info# *pi = &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info.; // Simulated object's physics information
714
715 int bounced = 0; // Did the object bounce?
716
717 vectorcxx . . $ vector# total_force; // Constant force acting on an object
718
719 bool f_continue_sim; // Should we run another simulation loop
720 bool f_start_fvi_record = true; // Records the rooms that are passed thru
721
722 bool f_turn_gravity_on = false;
723
724 // Assert conditions
725 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->type != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!);
726 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->movement_type == MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`!);
727 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(obj->mtype.phys_info.flags & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) || obj->mtype.phys_info.drag != 0.0);
728
729 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault.
730 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
731 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
732
733 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
734 if (!Game_do_flying_simcxx . . $ Game_do_flying_sim.) {
735 return;
736 }
737 #endif
738
739 // Make powerups above the ceiling fall with gravity
740 if (obj->typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! && ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj->roomnum) &&
741 obj->poscxx . . $ object#pos..ycxx . . $ vector#y. > (CEILING_HEIGHTcxx . . $ `physics/findintersection.h:228:9`! - obj->sizecxx . . $ object#size. - CEILING_POWERUP_DELTAcxx . . $ `physics/physics.cpp:48:9`!) && !(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!)) {
742 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. |= PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!;
743 obj->flagscxx . . $ object#flags. |= OF_TEMP_GRAVITYcxx . . $ `Descent3/object_external.h:288:9`!;
744 } else if (obj->flagscxx . . $ object#flags. & OF_TEMP_GRAVITYcxx . . $ `Descent3/object_external.h:288:9`!) {
745 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= ~PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!;
746 }
747
748 // Instant bail cases
749 if ((obj->flagscxx . . $ object#flags. & (OF_DEADcxx . . $ `Descent3/object_external.h:270:9`! | OF_ATTACHEDcxx . . $ `Descent3/object_external.h:273:9`!)) || (Frametimecxx . . $ Frametime. <= 0.0) || (obj->typecxx . . $ object#type. == OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!)) {
750 return;
751 }
752
753 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! &&
754 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector. || obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.)) {
755 Playerscxx . . $ Players.[obj->idcxx . . $ object#id.].last_thrust_timecxx . . $ player#last_thrust_time. = Gametimecxx . . $ Gametime.;
756 }
757
758 // mprintf(0, "%d Over terrain = %d\n", obj - Objects, obj->flags & OF_OVER_TERRAIN);
759
760 // If the object wiggles
761 if ((obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_WIGGLEcxx . . $ `Descent3/object_external.h:316:9`!) && (Demo_flagscxx . . $ Demo_flags. != DF_PLAYBACKcxx . . $ `lib/demofile.h:123:9`!)) {
762 float swiggle;
763 vectorcxx . . $ vector# w_pos;
764
765 if (vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.) < .1) {
766 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. -= Frametimecxx . . $ Frametime. / WIGGLE_FALLOFF_TIMEcxx . . $ `physics/physics.cpp:50:9`!;
767 } else {
768 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. += Frametimecxx . . $ Frametime. / WIGGLE_FALLOFF_TIMEcxx . . $ `physics/physics.cpp:50:9`!;
769 }
770
771 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. < 0.0)
772 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. = 0.0;
773 else if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. > 1.0)
774 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time. = 1.0;
775
776 // Ship always keeps 10% of its wiggle
777 // if(obj->mtype.phys_info.last_still_time < 1.0)
778 {
779 float scaler = 1.0f - obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..last_still_timecxx . . $ physics_info#last_still_time.;
780 if (scaler < .1f)
781 scaler = .1f;
782
783 swiggle = obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..wiggle_amplitudecxx . . $ physics_info#wiggle_amplitude. * (scaler) *
784 (FixSincxx . . $ FixSin(9a38df040a81ca35).((anglecxx . . $ angle#)((int)(Gametimecxx . . $ Gametime. * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..wiggles_per_seccxx . . $ physics_info#wiggles_per_sec. * 65535) % 65535)) -
785 FixSincxx . . $ FixSin(9a38df040a81ca35).((anglecxx . . $ angle#)((int)((Gametimecxx . . $ Gametime. - Frametimecxx . . $ Frametime.) * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..wiggles_per_seccxx . . $ physics_info#wiggles_per_sec. * 65535) % 65535)));
786 w_pos =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. +cxx . . $ operator+(b77b703cd1e43e33). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(252247219a31502c). (swiggle);
787
788 fq.p0cxx . . $ fvi_query#p0. = &obj->poscxx . . $ object#pos.;
789 fq.startroomcxx . . $ fvi_query#startroom. = obj->roomnumcxx . . $ object#roomnum.;
790 fq.p1cxx . . $ fvi_query#p1. = &w_pos;
791 fq.radcxx . . $ fvi_query#rad. = obj->sizecxx . . $ object#size.;
792 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = objnum;
793 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
794 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_RECORDcxx . . $ `lib/findintersection_external.h:65:9`! | FQ_IGNORE_POWERUPScxx . . $ `lib/findintersection_external.h:62:9`!;
795 fq.flagscxx . . $ fvi_query#flags. |= FQ_NEW_RECORD_LISTcxx . . $ `lib/findintersection_external.h:66:9`!;
796 fq.flagscxx . . $ fvi_query#flags. |= FQ_CHECK_CEILINGcxx . . $ `lib/findintersection_external.h:71:9`!;
797
798 // Need for weapons to go thru transparent areas of a texture
799 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!)
800 fq.flagscxx . . $ fvi_query#flags. |= FQ_TRANSPOINTcxx . . $ `lib/findintersection_external.h:61:9`!;
801
802 if (obj->flagscxx . . $ object#flags. & OF_NO_OBJECT_COLLISIONScxx . . $ `Descent3/object_external.h:286:9`!)
803 fq.flagscxx . . $ fvi_query#flags. &= ~FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`!;
804
805 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
806
807 // Only wiggle on a non-hit case
808 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
809
810 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_room != -1);
811
812 f_start_fvi_record = false;
813
814 // update object's position and segment number
815 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &hit_info.hit_pntcxx . . $ fvi_info#hit_pnt., hit_info.hit_roomcxx . . $ fvi_info#hit_room., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
816 }
817 }
818 }
819
820 // If the object is effected by gravity (normal, lighter than air, and anti-gravity)
821 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) {
822 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0;
823 total_force.ycxx . . $ vector#y. = Gravity_strengthcxx . . $ Gravity_strength. * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.;
824 } else if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_REVERSE_GRAVITYcxx . . $ `Descent3/object_external.h:329:9`!) {
825 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0;
826 total_force.ycxx . . $ vector#y. = -Gravity_strengthcxx . . $ Gravity_strength. * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.;
827 } else {
828 total_force.xcxx . . $ vector#x. = total_force.ycxx . . $ vector#y. = total_force.zcxx . . $ vector#z. = 0.0;
829 }
830
831 obj->flagscxx . . $ object#flags. &= (~OF_STOPPED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:272:9`!);
832
833 // Do rotation velocity/accel stuff
834 bool f_rotated = false;
835
836 if (!(fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.) > .000001 ||
837 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..zcxx . . $ vector#z.) > .000001 ||
838 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..zcxx . . $ vector#z.) > .000001 ||
839 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..zcxx . . $ vector#z.) > .000001 ||
840 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) ||
841 ((!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj->roomnum)) && Roomscxx . . $ Rooms.[obj->roomnumcxx . . $ object#roomnum.].windcxx . . $ room#wind. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.) ||
842 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_WIGGLEcxx . . $ `Descent3/object_external.h:316:9`!) ||
843 ((obj->ai_infocxx . . $ object#ai_info. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) && ((obj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. & AIF_REPORT_NEW_ORIENTcxx . . $ `Descent3/aistruct_external.h:372:9`!) != 0)))) {
844 if ((obj->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!)) {
845 obj->flagscxx . . $ object#flags. &= (~OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!);
846 obj->flagscxx . . $ object#flags. |= OF_STOPPED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:272:9`!;
847 }
848
849 return;
850 }
851
852 if (obj->ai_infocxx . . $ object#ai_info.)
853 obj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. &= ~AIF_REPORT_NEW_ORIENTcxx . . $ `Descent3/aistruct_external.h:372:9`!;
854
855 obj->flagscxx . . $ object#flags. |= OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!;
856
857 // This assumes that the thrust does not change within a frame. If it does, account for it
858 // there... like missiles bouncing off a wall and changing heading. --chrishack
859 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. != 0.0) {
860 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) {
861 total_force +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
862 }
863 }
864
865 // mprintf(0, "PHYSICS: Current obj: %d, %9.2fx %9.2fy %9.2fz\n", OBJNUM(obj), XYZ(&obj->pos));
866 // mprintf(2,1,0,"x %9.2f\ny %9.2f\nz %9.2f", XYZ(&obj->mtype.phys_info.velocity));
867 // mprintf(0, "PHYSICS: Current velocity (%f, %f, %f)\n", XYZ(&obj->mtype.phys_info.velocity));
868
869 Physics_normal_countercxx . . $ Physics_normal_counter.++;
870
871 // Simulate movement until we are done (i.e. Frametime has passed or object is done moving)
872 do {
873 // Values at start of sim loop
874 start_pos =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
875 start_vel =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
876 start_orient =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
877 start_rotvel =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel.;
878 start_turnroll = obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..turnrollcxx . . $ physics_info#turnroll.;
879 start_room = obj->roomnumcxx . . $ object#roomnum.;
880
881 matrixcxx . . $ matrix# end_orient = start_orient;
882 vectorcxx . . $ vector# end_rotvel = start_rotvel;
883 anglecxx . . $ angle# end_turnroll = start_turnroll;
884 vectorcxx . . $ vector# end_vel = start_vel;
885
886 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
887 // This records the sim.
888 sim_loop_recordcxx . . $ sim_loop_record.[count].phys_infocxx . . $ sim_loop_info#phys_info. =cxx . . $ physics_info#`operator=`(fa4a94890b261b64). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info.;
889 #endif
890
891 // Initailly assume that this is the last sim cycle
892 f_continue_sim = false;
893
894 // Determines forces
895 if (count > 0) {
896 // If the object is effected by gravity (normal, lighter than air, and anti-gravity)
897 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) {
898 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0;
899 total_force.ycxx . . $ vector#y. = Gravity_strengthcxx . . $ Gravity_strength. * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.;
900 } else if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_REVERSE_GRAVITYcxx . . $ `Descent3/object_external.h:329:9`!) {
901 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0;
902 total_force.ycxx . . $ vector#y. = -Gravity_strengthcxx . . $ Gravity_strength. * obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.;
903 } else if (!(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!)) {
904 // Player ship
905 } else {
906 total_force.xcxx . . $ vector#x. = total_force.ycxx . . $ vector#y. = total_force.zcxx . . $ vector#z. = 0.0;
907 }
908 }
909
910 // Compute rotational information
911 // Chrishack -- replace OBJ_CLUTTER with a BBOX_HIT_TYPE
912 bool f_set_orient;
913
914 if ((f_rotated == false && count == 0) || obj->typecxx . . $ object#type. == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!) {
915 f_rotated = true;
916 f_set_orient = true;
917 PhysicsDoSimRotcxx . . $ PhysicsDoSimRot(d5590f9f58c35daf).(obj, sim_time_remaining, &end_orient, &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust., &end_rotvel,
918 &end_turnroll);
919
920 ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(obj, &end_orient);
921 } else {
922 f_set_orient = false;
923 }
924
925 // Updates the thrust vector to the orientation for homing weapons
926 if ((obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) && (pi->flagscxx . . $ physics_info#flags. & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) && (pi->flagscxx . . $ physics_info#flags. & PF_HOMINGcxx . . $ `Descent3/object_external.h:334:9`!)) {
927 pi->thrustcxx . . $ physics_info#thrust. =cxx . . $ vector#`operator=`(c0842353a20857d). end_orient.fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(252247219a31502c). pi->full_thrustcxx . . $ physics_info#$anonymous_type_3#full_thrust.;
928 movement_vec =cxx . . $ vector#`operator=`(c0842353a20857d). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). Frametimecxx . . $ Frametime.;
929 movement_pos =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. +cxx . . $ operator+(b77b703cd1e43e33). movement_vec;
930 }
931
932 PhysicsDoSimLinearcxx . . $ PhysicsDoSimLinear(33e639d8e7a28d49).(*obj, obj->poscxx . . $ object#pos., total_force, end_vel, movement_vec, movement_pos, sim_time_remaining, count);
933
934 // Only do velocity until we've reached our destination position
935 // This is useful for multiplayer
936 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_DESTINATION_POScxx . . $ `Descent3/object_external.h:337:9`!) {
937 vectorcxx . . $ vector# sub1 = obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dest_poscxx . . $ physics_info#dest_pos.;
938 vectorcxx . . $ vector# sub2 = movement_pos -cxx . . $ operator-(b77b703cd1e43e33). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dest_poscxx . . $ physics_info#dest_pos.;
939
940 if (vm_DotProductcxx . . $ vm_DotProduct(e65d563e2b53cc54).(&sub1, &sub2) <= 0) {
941 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= ~PF_DESTINATION_POScxx . . $ `Descent3/object_external.h:337:9`!;
942 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
943 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&movement_vec);
944 movement_pos =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
945 goto end_of_sim;
946 }
947
948 if ((vm_VectorDistanceQuickcxx . . $ vm_VectorDistanceQuick(a0b9c8659ecc16b8).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dest_poscxx . . $ physics_info#dest_pos., &obj->poscxx . . $ object#pos.)) < 1) {
949 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
950 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= ~PF_DESTINATION_POScxx . . $ `Descent3/object_external.h:337:9`!;
951 goto end_of_sim;
952 }
953 }
954
955 // We are done, as there is no collision response with PF_NO_COLLIDE
956 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_NO_COLLIDEcxx . . $ `Descent3/object_external.h:331:9`!) {
957 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). end_rotvel;
958 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..turnrollcxx . . $ physics_info#turnroll. = end_turnroll;
959 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). end_vel;
960
961 // ObjSetOrient(obj,&end_orient);
962 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &movement_pos, obj->roomnumcxx . . $ object#roomnum., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
963
964 ObjSetAABBcxx . . $ ObjSetAABB(419c470199a90a97).(obj);
965 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
966
967 goto end_of_sim;
968 }
969
970 Physics_normal_looping_countercxx . . $ Physics_normal_looping_counter.++;
971
972 // Cap ignore list -- (Objects we already hit this frame)
973 ignore_obj_list[n_ignore_objs] = -1;
974
975 vectorcxx . . $ vector# temp_vel = obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
976 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). (movement_pos -cxx . . $ operator-(b77b703cd1e43e33). start_pos) /cxx . . $ `operator/`(252247219a31502c). sim_time_remaining;
977
978 fq.p0cxx . . $ fvi_query#p0. = &obj->poscxx . . $ object#pos.;
979 fq.startroomcxx . . $ fvi_query#startroom. = obj->roomnumcxx . . $ object#roomnum.;
980 fq.p1cxx . . $ fvi_query#p1. = &movement_pos;
981 fq.radcxx . . $ fvi_query#rad. = obj->sizecxx . . $ object#size.;
982 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = objnum;
983 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = ignore_obj_list;
984 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_RECORDcxx . . $ `lib/findintersection_external.h:65:9`!;
985 if (f_start_fvi_record)
986 fq.flagscxx . . $ fvi_query#flags. |= FQ_NEW_RECORD_LISTcxx . . $ `lib/findintersection_external.h:66:9`!;
987
988 fq.o_orientcxx . . $ fvi_query#o_orient. = &start_orient;
989 fq.o_rotvelcxx . . $ fvi_query#o_rotvel. = &start_rotvel;
990 fq.o_rotthrustcxx . . $ fvi_query#o_rotthrust. = &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust.;
991 fq.o_turnrollcxx . . $ fvi_query#o_turnroll. = &start_turnroll;
992 fq.o_velocitycxx . . $ fvi_query#o_velocity. = &start_vel;
993 fq.o_thrustcxx . . $ fvi_query#o_thrust. = &total_force;
994
995 f_start_fvi_record = false;
996
997 // Need for weapons to go thru transparent areas of a texture
998 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!)
999 fq.flagscxx . . $ fvi_query#flags. |= FQ_TRANSPOINTcxx . . $ `lib/findintersection_external.h:61:9`!;
1000
1001 // Added a ceiling for players and powerups
1002 if (obj->typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->control_typecxx . . $ object#control_type. != CT_AIcxx . . $ `Descent3/object_external.h:217:9`!) ||
1003 obj->typecxx . . $ object#type. == OBJ_OBSERVERcxx . . $ `Descent3/object_external.h:182:9`! || (obj == Playerscxx . . $ Players.[Player_objectcxx . . $ Player_object.->idcxx . . $ object#id.].guided_objcxx . . $ player#guided_obj.) ||
1004 (obj->flagscxx . . $ object#flags. & OF_FORCE_CEILING_CHECKcxx . . $ `Descent3/object_external.h:269:9`!))
1005 fq.flagscxx . . $ fvi_query#flags. |= FQ_CHECK_CEILINGcxx . . $ `lib/findintersection_external.h:71:9`!;
1006
1007 if ((obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) && (obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_statuscxx . . $ laser_info_s#hit_status. != WPC_NOT_USEDcxx . . $ `Descent3/object.h:657:9`!))
1008 fq.flagscxx . . $ fvi_query#flags. |= FQ_IGNORE_WALLScxx . . $ `lib/findintersection_external.h:70:9`!;
1009
1010 if (obj->flagscxx . . $ object#flags. & OF_NO_OBJECT_COLLISIONScxx . . $ `Descent3/object_external.h:286:9`!)
1011 fq.flagscxx . . $ fvi_query#flags. &= ~FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`!;
1012
1013 if (IS_GENERICcxx . . $ `Descent3/object_external.h:190:9`!(obj->type) && (Object_infocxx . . $ Object_info.[obj->idcxx . . $ object#id.].flagscxx . . $ object_info#flags. & OIF_IGNORE_FORCEFIELDS_AND_GLASScxx . . $ `Descent3/objinfo.h:343:9`!))
1014 fq.flagscxx . . $ fvi_query#flags. |= FQ_IGNORE_RENDER_THROUGH_PORTALScxx . . $ `lib/findintersection_external.h:84:9`!;
1015
1016 // Initially assume that we fully move
1017 hit_info.hit_turnrollcxx . . $ fvi_info#hit_turnroll. = end_turnroll;
1018 hit_info.hit_orientcxx . . $ fvi_info#hit_orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). end_orient;
1019 hit_info.hit_rotvelcxx . . $ fvi_info#hit_rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). end_rotvel;
1020 hit_info.hit_velocitycxx . . $ fvi_info#hit_velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). end_vel;
1021 hit_info.hit_timecxx . . $ fvi_info#hit_time. = sim_time_remaining;
1022
1023 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1024 fq.flagscxx . . $ fvi_query#flags. |= FQ_MULTI_POINTcxx . . $ `lib/findintersection_external.h:75:9`!;
1025 }
1026
1027 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
1028
1029 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1030 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && hit_info.num_hitscxx . . $ fvi_info#num_hits. > 1) {
1031 vectorcxx . . $ vector# n = Zero_vectorcxx . . $ Zero_vector.;
1032 int i;
1033
1034 for (i = 0; i < hit_info.num_hitscxx . . $ fvi_info#num_hits.; i++) {
1035 n +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[i];
1036 }
1037
1038 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). n;
1039 }
1040 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0]);
1041 }
1042
1043 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). temp_vel;
1044
1045 // Accounts for precomputed hit rays
1046 if ((obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!) && (obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_statuscxx . . $ laser_info_s#hit_status. == WPC_HIT_WALLcxx . . $ `Descent3/object.h:659:9`!)) {
1047 vectorcxx . . $ vector# to_hit_pnt, to_fvi_pos;
1048
1049 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1050 to_hit_pnt =cxx . . $ vector#`operator=`(c0842353a20857d). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_pntcxx . . $ laser_info_s#hit_pnt. -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
1051 to_fvi_pos =cxx . . $ vector#`operator=`(c0842353a20857d). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_pntcxx . . $ laser_info_s#hit_pnt. -cxx . . $ operator-(b77b703cd1e43e33). hit_info.hit_pntcxx . . $ fvi_info#hit_pnt.;
1052 } else {
1053 to_hit_pnt =cxx . . $ vector#`operator=`(c0842353a20857d). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_wall_pntcxx . . $ laser_info_s#hit_wall_pnt. -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
1054 to_fvi_pos =cxx . . $ vector#`operator=`(c0842353a20857d). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_wall_pntcxx . . $ laser_info_s#hit_wall_pnt. -cxx . . $ operator-(b77b703cd1e43e33). hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0];
1055 }
1056
1057 if ((to_hit_pnt *cxx . . $ `operator*`(4a721543d64e126a). to_fvi_pos) <= 0.0f) {
1058 fate = hit_info.hit_typecxx . . $ fvi_info#hit_type.[0] = HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`!;
1059
1060 hit_info.hit_pntcxx . . $ fvi_info#hit_pnt. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_pntcxx . . $ laser_info_s#hit_pnt.;
1061 hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_wall_pntcxx . . $ laser_info_s#hit_wall_pnt.;
1062 hit_info.hit_roomcxx . . $ fvi_info#hit_room. = obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_roomcxx . . $ laser_info_s#hit_room.;
1063 hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0] = obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_pnt_roomcxx . . $ laser_info_s#hit_pnt_room.;
1064 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_wall_normalcxx . . $ laser_info_s#hit_wall_normal.;
1065 hit_info.hit_facecxx . . $ fvi_info#hit_face.[0] = obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_facecxx . . $ laser_info_s#hit_face.;
1066
1067 obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..hit_statuscxx . . $ laser_info_s#hit_status. = WPC_NOT_USEDcxx . . $ `Descent3/object.h:657:9`!;
1068 }
1069 }
1070
1071 // chrishack -- move all FVI ASSERT to here!
1072 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fate != HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`! || (fate == HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`! && hit_info.hit_face[0] > -1));
1073 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.x > -100000000.0);
1074 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.y > -100000000.0);
1075 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.z > -100000000.0);
1076 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.x < 100000000.0);
1077 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.y < 100000000.0);
1078 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_pnt.z < 100000000.0);
1079 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(fate != HIT_OUT_OF_TERRAIN_BOUNDScxx . . $ `lib/findintersection_external.h:50:9`! && hit_info.hit_room == -1));
1080
1081 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
1082 sim_loop_recordcxx . . $ sim_loop_record.[count].start_poscxx . . $ sim_loop_info#start_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
1083 sim_loop_recordcxx . . $ sim_loop_record.[count].hit_infocxx . . $ sim_loop_info#hit_info. =cxx . . $ fvi_info#`operator=`(e3adebb9eff2a751). hit_info;
1084
1085 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1086 if (Physics_player_verbosecxx . . $ Physics_player_verbose.) {
1087 objnum = ObjCreatecxx . . $ ObjCreate(849c3da80a4f387f).(OBJ_DEBUG_LINEcxx . . $ `Descent3/object_external.h:183:9`!, 1, hit_info.hit_roomcxx . . $ fvi_info#hit_room., &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
1088 if (objnum >= 0) { // DAJ -1FIX
1089 Objectscxx . . $ Objects.[objnum].rtypecxx . . $ object#rtype..line_infocxx . . $ object#$anonymous_type_10#line_info..end_poscxx . . $ line_info_s#end_pos. =cxx . . $ vector#`operator=`(c0842353a20857d). hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0] +cxx . . $ operator+(b77b703cd1e43e33). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1090 Objectscxx . . $ Objects.[objnum].sizecxx . . $ object#size. = vm_VectorDistancecxx . . $ vm_VectorDistance(e65d563e2b53cc54).(&Player_objectcxx . . $ Player_object.->poscxx . . $ object#pos., &hit_info.hit_pntcxx . . $ fvi_info#hit_pnt.);
1091 ObjSetAABBcxx . . $ ObjSetAABB(419c470199a90a97).(&Objectscxx . . $ Objects.[objnum]);
1092
1093 Objectscxx . . $ Objects.[objnum].flagscxx . . $ object#flags. |= OF_USES_LIFELEFTcxx . . $ `Descent3/object_external.h:276:9`!;
1094 Objectscxx . . $ Objects.[objnum].lifeleftcxx . . $ object#lifeleft. = 10.0f;
1095 Objectscxx . . $ Objects.[objnum].lifetimecxx . . $ object#lifetime. = 10.0f;
1096 }
1097 if (obj == Player_objectcxx . . $ Player_object.) {
1098 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Fate = %d for player - ", fate);
1099 if (fate == HIT_OBJECTcxx . . $ `lib/findintersection_external.h:47:9`! || fate == HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`!) {
1100 if (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].flagscxx . . $ object#flags. & OF_BIG_OBJECTcxx . . $ `Descent3/object_external.h:280:9`!) {
1101 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Big object\n");
1102 } else {
1103 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Small object\n");
1104 }
1105 } else {
1106 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "non-object\n");
1107 }
1108 }
1109 }
1110 }
1111 #endif
1112
1113 if (f_set_orient) {
1114 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..turnrollcxx . . $ physics_info#turnroll. = hit_info.hit_turnrollcxx . . $ fvi_info#hit_turnroll.;
1115 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). hit_info.hit_rotvelcxx . . $ fvi_info#hit_rotvel.;
1116
1117 f_set_orient = false;
1118 }
1119
1120 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). hit_info.hit_velocitycxx . . $ fvi_info#hit_velocity.;
1121
1122 // Instant bails for collision response
1123 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! &&
1124 ((fate == HIT_OUT_OF_TERRAIN_BOUNDScxx . . $ `lib/findintersection_external.h:50:9`!) ||
1125 (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_room) && GetTerrainCellFromPoscxx . . $ GetTerrainCellFromPos(177d9005acf670a0).(&hit_info.hit_pntcxx . . $ fvi_info#hit_pnt.) == -1))) {
1126 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &init_pos, init_room, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
1127 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
1128
1129 return;
1130 } else if (fate == HIT_OUT_OF_TERRAIN_BOUNDScxx . . $ `lib/findintersection_external.h:50:9`!) {
1131 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
1132 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
1133
1134 return;
1135 }
1136
1137 // This is so the collide code knows that last collision position if there are multiple collisions
1138 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->poscxx . . $ object#pos.;
1139
1140 // update object's position and segment number
1141 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &hit_info.hit_pntcxx . . $ fvi_info#hit_pnt., hit_info.hit_roomcxx . . $ fvi_info#hit_room., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
1142
1143 // Calulate amount of sim time left
1144 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1145 moved_time = old_sim_time_remaining = sim_time_remaining;
1146 sim_time_remaining = 0.0;
1147 f_continue_sim = false;
1148 } else {
1149 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0]);
1150
1151 vectorcxx . . $ vector# moved_vec_n;
1152 float attempted_dist, actual_dist;
1153
1154 // Save results of this simulation
1155 old_sim_time_remaining = sim_time_remaining;
1156 moved_vec_n =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). start_pos; // chrishack -- use this copy
1157 if (moved_vec_n !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.) {
1158 actual_dist = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&moved_vec_n);
1159 } else {
1160 actual_dist = 0.0f;
1161 }
1162
1163 // chrishack -- potentially bad -- outside to inside stuff
1164 // We where sitting in a wall -- invalid starting point
1165 // moved backwards
1166 if (fate == HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`! && moved_vec_n *cxx . . $ `operator*`(4a721543d64e126a). movement_vec < -0.000001 && actual_dist != 0.0) {
1167 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &start_pos, start_room, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
1168
1169 moved_time = 0.0;
1170 } else {
1171 // Compute more results of this simulation
1172 attempted_dist = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&movement_vec);
1173 sim_time_remaining = sim_time_remaining * ((attempted_dist - actual_dist) / attempted_dist);
1174 moved_time = old_sim_time_remaining - sim_time_remaining;
1175
1176 // chrishack -- we have no time left (plus some) This can happen if FVI corrects a near tangental
1177 // movement by adding the radius - thus, we move a little too far.
1178 if (sim_time_remaining < 0.0) {
1179 sim_time_remaining = 0.0;
1180 moved_time = old_sim_time_remaining;
1181 }
1182
1183 // chrishack -- negative simulation time pasted for this sim frame
1184 if (sim_time_remaining > old_sim_time_remaining) {
1185 sim_time_remaining = old_sim_time_remaining;
1186 moved_time = 0.0;
1187 f_continue_sim = false;
1188 }
1189 }
1190
1191 // Get the collision speed as a linear interp.
1192 if (fate == HIT_OBJECTcxx . . $ `lib/findintersection_external.h:47:9`! || fate == HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`! || fate == HIT_TERRAINcxx . . $ `lib/findintersection_external.h:48:9`! || fate == HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`!) {
1193 if (moved_time > 0.0001f) {
1194 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). (hit_info.hit_pntcxx . . $ fvi_info#hit_pnt. -cxx . . $ operator-(b77b703cd1e43e33). start_pos) /cxx . . $ `operator/`(252247219a31502c). moved_time;
1195 } else {
1196 // mprintf(0, "Moved time is ZERO\n"); -- Add this back -- chrishack
1197 ASSERTcxx . . $ `misc/pserror.h:246:9`!(old_sim_time_remaining > 0.0f);
1198 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). start_vel;
1199 }
1200 } else {
1201 if (old_sim_time_remaining > 0.0) {
1202 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). (moved_time / old_sim_time_remaining) +cxx . . $ operator+(b77b703cd1e43e33).
1203 start_vel *cxx . . $ `operator*`(252247219a31502c). (sim_time_remaining / old_sim_time_remaining);
1204 }
1205 }
1206 }
1207
1208 bounced = 0;
1209
1210 // Collision response code
1211 switch (fate) {
1212 case HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!:
1213 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & (PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_WINDcxx . . $ `Descent3/object_external.h:322:9`!))) {
1214 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.)
1215 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&obj->orientcxx . . $ object#orient., &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity., &obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
1216 }
1217 f_continue_sim = false;
1218 break;
1219 case HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`!: // Finally unified, still needs some work, but it certainly better like this :)
1220 case HIT_TERRAINcxx . . $ `lib/findintersection_external.h:48:9`!: {
1221 bool f_volatile_lava; // either volatile or lava
1222 bool f_forcefield;
1223 float ff_bounce_factor = 2.0f;
1224
1225 // Check if volatile
1226 int tmap;
1227 if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_face_room[0])) // Make sure we've hit a wall, and not terrain
1228 {
1229 tmap = Roomscxx . . $ Rooms.[hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0]].facescxx . . $ room#faces.[hit_info.hit_facecxx . . $ fvi_info#hit_face.[0]].tmapcxx . . $ face#tmap.;
1230 } else {
1231 tmap = Terrain_tex_segcxx . . $ Terrain_tex_seg.[Terrain_segcxx . . $ Terrain_seg.[CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(hit_info.hit_face_room[0])].texseg_indexcxx . . $ terrain_segment#texseg_index.].tex_indexcxx . . $ terrain_tex_segment#tex_index.;
1232 }
1233 f_volatile_lava = (GameTexturescxx . . $ GameTextures.[tmap].flagscxx . . $ texture#flags. & (TF_VOLATILEcxx . . $ `Descent3/gametexture.h:201:9`! + TF_LAVAcxx . . $ `Descent3/gametexture.h:230:9`!)) != 0;
1234 f_forcefield = (GameTexturescxx . . $ GameTextures.[tmap].flagscxx . . $ texture#flags. & TF_FORCEFIELDcxx . . $ `Descent3/gametexture.h:206:9`!) != 0;
1235
1236 if (f_forcefield) {
1237 int i;
1238
1239 for (i = 0; i < MAX_FORCE_FIELD_BOUNCE_TEXTUREScxx . . $ `Descent3/game.h:252:9`!; i++) {
1240 if (tmap == force_field_bounce_texturecxx . . $ force_field_bounce_texture.[i]) {
1241 ff_bounce_factor = force_field_bounce_multipliercxx . . $ force_field_bounce_multiplier.[i];
1242 break;
1243 }
1244 }
1245 }
1246
1247 {
1248 vectorcxx . . $ vector# moved_v;
1249 float hit_speed, wall_part;
1250 float hit_dot = 1.0;
1251
1252 float luke_test;
1253
1254 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1255 luke_test = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1256 }
1257
1258 // Find hit speed
1259 moved_v =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). start_pos; // chrishack -- We already computed this!!!!!!!
1260 wall_part = moved_v *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1261
1262 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..hit_die_dotcxx . . $ physics_info#$anonymous_type_5#hit_die_dot. > 0.0) {
1263 vectorcxx . . $ vector# m_normal = start_pos -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
1264 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&m_normal);
1265 hit_dot = m_normal *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1266 }
1267
1268 hit_speed = -(wall_part / moved_time);
1269
1270 // Process wall hit
1271 bool hit_wall = collide_object_with_wallcxx . . $ collide_object_with_wall(df7a53499d66690e).(obj, hit_speed, hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0], hit_info.hit_facecxx . . $ fvi_info#hit_face.[0],
1272 &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0], hit_dot);
1273
1274 if (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) {
1275 // Check for not really hitting the wall (because it was glass & broke)
1276 if (!hit_wall) {
1277 f_continue_sim = true;
1278 break;
1279 }
1280
1281 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && ((obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!) || f_forcefield))
1282 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= (~PF_NO_COLLIDE_PARENTcxx . . $ `Descent3/object_external.h:326:9`!);
1283
1284 // Slide object along wall
1285
1286 // We're constrained by wall, so subtract wall part from the velocity vector
1287 wall_part = hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(4a721543d64e126a). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
1288
1289 if (!f_forcefield && !f_volatile_lava && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces. <= 0) &&
1290 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_STICKcxx . . $ `Descent3/object_external.h:317:9`!)) {
1291 obj->movement_typecxx . . $ object#movement_type. = MT_NONEcxx . . $ `Descent3/object_external.h:233:9`!;
1292
1293 if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_face_room[0])) {
1294 if (GameTexturescxx . . $ GameTextures.[Roomscxx . . $ Rooms.[hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0]].facescxx . . $ room#faces.[hit_info.hit_facecxx . . $ fvi_info#hit_face.[0]].tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. &
1295 (TF_VOLATILEcxx . . $ `Descent3/gametexture.h:201:9`! | TF_LAVAcxx . . $ `Descent3/gametexture.h:230:9`!)) {
1296 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
1297 }
1298 } else {
1299 if (GameTexturescxx . . $ GameTextures.[Terrain_tex_segcxx . . $ Terrain_tex_seg.[Terrain_segcxx . . $ Terrain_seg.[CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(hit_info.hit_room)].texseg_indexcxx . . $ terrain_segment#texseg_index.].tex_indexcxx . . $ terrain_tex_segment#tex_index.].flagscxx . . $ texture#flags. &
1300 (TF_VOLATILEcxx . . $ `Descent3/gametexture.h:201:9`! | TF_LAVAcxx . . $ `Descent3/gametexture.h:230:9`!)) {
1301 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
1302 }
1303 }
1304
1305 if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_face_room[0]) &&
1306 (Roomscxx . . $ Rooms.[hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0]].facescxx . . $ room#faces.[hit_info.hit_facecxx . . $ fvi_info#hit_face.[0]].portal_numcxx . . $ face#portal_num. >= 0)) {
1307 obj->flagscxx . . $ object#flags. |= OF_STUCK_ON_PORTALcxx . . $ `Descent3/object_external.h:287:9`!;
1308 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..stuck_roomcxx . . $ physics_info#$anonymous_type_5#stuck_room. = hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0];
1309 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..stuck_portalcxx . . $ physics_info#$anonymous_type_6#stuck_portal. =
1310 Roomscxx . . $ Rooms.[hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0]].facescxx . . $ room#faces.[hit_info.hit_facecxx . . $ fvi_info#hit_face.[0]].portal_numcxx . . $ face#portal_num.;
1311 }
1312
1313 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1314 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
1315 goto end_of_sim;
1316 } else if (f_volatile_lava || f_forcefield || (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!)) {
1317 wall_part *= 2.0; // Subtract out wall part twice to achieve bounce
1318 bounced = 1; // this object bounced
1319
1320 if (f_forcefield) {
1321 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)
1322 wall_part *= ff_bounce_factor; // player bounce twice as much -- chrishack try without this too.
1323 }
1324
1325 // New bounceness code
1326 if (!f_forcefield && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!) &&
1327 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces. != PHYSICS_UNLIMITED_BOUNCEcxx . . $ `physics/physics.h:81:9`!)) {
1328 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces. == 0) {
1329 if (obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && (obj->flagscxx . . $ object#flags. & OF_DYINGcxx . . $ `Descent3/object_external.h:282:9`!)) {
1330 ASSERTcxx . . $ `misc/pserror.h:246:9`!((obj->control_type == CT_DYINGcxx . . $ `Descent3/object_external.h:229:9`!) || (obj->control_type == CT_DYING_AND_AIcxx . . $ `Descent3/object_external.h:230:9`!));
1331 DestroyObjectcxx . . $ DestroyObject(a11214108e4e4480).(obj, 50.0, obj->ctypecxx . . $ object#ctype..dying_infocxx . . $ object#$anonymous_type_9#dying_info..death_flagscxx . . $ dying_info_s#death_flags.);
1332 } else {
1333 if (obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)
1334 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
1335 else
1336 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Got a ship that was set for bounce!!! BAD!!!\n");
1337 }
1338 }
1339 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces.--;
1340 }
1341
1342 {
1343 float v_mag = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1344
1345 if (obj->typecxx . . $ object#type. == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! && hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0].ycxx . . $ vector#y. > .4 &&
1346 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] > -2.0f)) {
1347
1348 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) {
1349 f_turn_gravity_on = true;
1350 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= (~(PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!));
1351 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. *= 300.0f;
1352 }
1353
1354 if (v_mag < 1.8f) {
1355 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
1356 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
1357 goto skip_sim;
1358 } else {
1359 goto slide_sim;
1360 }
1361 }
1362
1363 if (!f_forcefield && !(f_volatile_lava && obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!))
1364 bump_obj_against_fixedcxx . . $ bump_obj_against_fixed(4f42c5e5dcf5b21f).(obj, &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0]);
1365 else
1366 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.0f);
1367 }
1368
1369 } else {
1370 slide_sim:
1371
1372 float wall_force;
1373
1374 wall_force = total_force *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1375
1376 if (obj->typecxx . . $ object#type. != OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!)
1377 total_force +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
1378 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_force * -1.001f); // 1.001 so that we are not quite tangential
1379 else
1380 total_force +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
1381 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_force * -1.0001f); // 1.001 so that we are not quite tangential
1382
1383 // Update velocity from wall hit.
1384 if (obj->typecxx . . $ object#type. != OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!)
1385 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
1386 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.001f); // 1.001 so that we are not quite tangential
1387 else
1388 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
1389 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.0001f); // 1.001 so that we are not quite tangential
1390
1391 if ((obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || (obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) &&
1392 sim_time_remaining == old_sim_time_remaining) {
1393 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1394 }
1395
1396 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1397 float real_vel;
1398
1399 real_vel = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1400 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *=cxx . . $ `operator*=`(f132838b2cd11d6). ((real_vel + luke_test) / 2);
1401 // obj->mtype.phys_info.velocity *= (luke_test);
1402 } else if (obj->typecxx . . $ object#type. == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! && !(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_LOCK_MASKcxx . . $ `Descent3/object_external.h:344:9`!)) {
1403 // Do rolling rotvel hack
1404 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
1405
1406 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.) {
1407 vectorcxx . . $ vector# axis;
1408 float speed = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1409
1410 vm_CrossProductcxx . . $ vm_CrossProduct(af83aca25ba5b41c).(&axis, &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity., &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0]);
1411 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&axis);
1412
1413 axis =cxx . . $ vector#`operator=`(c0842353a20857d). axis *cxx . . $ `operator*`(14b8f9ac5c1e7b85). obj->orientcxx . . $ object#orient.;
1414
1415 float scale = speed * 65535.0f / (2.0f * PIcxx . . $ `fix/fix.h:73:9`! * obj->sizecxx . . $ object#size.);
1416
1417 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(c0842353a20857d). axis *cxx . . $ `operator*`(252247219a31502c). -scale;
1418 }
1419 }
1420 }
1421
1422 skip_sim:
1423
1424 // mprintf(0, "PHYSICS: Wall normal (%f, %f, %f)\n", XYZ(&hit_info.hit_wallnorm[0]));
1425 // mprintf(0, "PHYSICS: Bounded velocity (%f, %f, %f)\n", XYZ(&obj->mtype.phys_info.velocity));
1426
1427 // This only happens if the new velocity is set from hitting a forcefield.
1428 if (!(fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..xcxx . . $ vector#x.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
1429 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
1430 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`!)) {
1431 float mag = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1432
1433 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS: Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag);
1434 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *=cxx . . $ `operator*=`(f132838b2cd11d6). MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! * 0.1f;
1435 }
1436
1437 // Weapons should face their new heading. This is so missiles are pointing in the correct direct.
1438 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (bounced || (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & (PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_WINDcxx . . $ `Descent3/object_external.h:322:9`!))))
1439 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.)
1440 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&obj->orientcxx . . $ object#orient., &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity., &obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
1441 }
1442 }
1443 f_continue_sim = true;
1444
1445 } break;
1446
1447 case HIT_CEILINGcxx . . $ `lib/findintersection_external.h:53:9`!: {
1448 vectorcxx . . $ vector# moved_v;
1449 float wall_part;
1450
1451 float luke_test;
1452
1453 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1454 luke_test = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1455 }
1456
1457 // Find hit speed
1458 moved_v =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). start_pos; // chrishack -- We already computed this!!!!!!!
1459 wall_part = moved_v *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1460
1461 // We're constrained by wall, so subtract wall part from the velocity vector
1462 wall_part = hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(4a721543d64e126a). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
1463
1464 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!) {
1465 wall_part *= 2.0; // Subtract out wall part twice to achieve bounce
1466
1467 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.0f);
1468
1469 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution. != 1.0f)
1470 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. -=cxx . . $ `operator-=`(801a8d6f7ab7bef9).
1471 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). (1.0f - obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution.));
1472 } else {
1473 float wall_force;
1474
1475 wall_force = total_force *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1476 total_force +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_force * -1.001); // 1.001 so that we are not quite tangential
1477
1478 // Update velocity from wall hit.
1479 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
1480 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.001); // 1.001 so that we are not quite tangential
1481 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1482 float real_vel;
1483
1484 real_vel = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
1485 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *=cxx . . $ `operator*=`(f132838b2cd11d6). ((real_vel + luke_test) / 2.0f);
1486 // obj->mtype.phys_info.velocity *= (luke_test);
1487 }
1488 }
1489
1490 // This only happens if the new velocity is set from hitting a forcefield.
1491 ASSERTcxx . . $ `misc/pserror.h:246:9`!(fabs(obj->mtype.phys_info.velocity.x) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
1492 fabs(obj->mtype.phys_info.velocity.y) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
1493 fabs(obj->mtype.phys_info.velocity.z) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`!);
1494
1495 // Weapons should face their new heading. This is so missiles are pointing in the correct direct.
1496 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (bounced || (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & (PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_WINDcxx . . $ `Descent3/object_external.h:322:9`!))))
1497 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&obj->orientcxx . . $ object#orient., &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity., &obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
1498
1499 f_continue_sim = true;
1500 } break;
1501
1502 case HIT_OBJECTcxx . . $ `lib/findintersection_external.h:47:9`!:
1503 case HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`!: {
1504 vectorcxx . . $ vector# old_force; // -- chrishack
1505
1506 // Mark the hit object so that on the following sim frames, in this game frame, ignore this object.
1507 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_object[0] != -1); // chrishack move this ASSERT fvi stuff above
1508
1509 // chrishack -- we should have this point from FVI!!!!!!!!!!!
1510 // Calculcate the hit point between the two objects.
1511 old_force =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
1512
1513 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). total_force;
1514
1515 collide_two_objectscxx . . $ collide_two_objects(d2b59d3704ffac80).(obj, &Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]], &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0],
1516 &hit_info);
1517 if (obj->movement_typecxx . . $ object#movement_type. == MT_OBJ_LINKEDcxx . . $ `Descent3/object_external.h:242:9`!)
1518 goto end_of_sim;
1519
1520 total_force =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
1521
1522 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). old_force;
1523
1524 if ((obj->typecxx . . $ object#type. != OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! && Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. != OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`!) &&
1525 (obj->typecxx . . $ object#type. == OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! || obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! ||
1526 (obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) &&
1527 sim_time_remaining == old_sim_time_remaining &&
1528 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].movement_typecxx . . $ object#movement_type. == MT_NONEcxx . . $ `Descent3/object_external.h:233:9`! ||
1529 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. ==cxx . . $ `operator==`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector. &&
1530 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_LOCK_MASKcxx . . $ `Descent3/object_external.h:344:9`!)))) {
1531 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1532 }
1533
1534 // Let object continue its movement if collide_two_objects does not mark it as dead
1535 if (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) {
1536 if ((obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!) ||
1537 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!)) {
1538 if (n_ignore_objs < MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`!) {
1539 ignore_obj_list[n_ignore_objs++] = hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0];
1540 count--;
1541 if (count < -1)
1542 count = -1;
1543 }
1544
1545 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!))
1546 obj->ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..last_hit_handlecxx . . $ laser_info_s#last_hit_handle. = Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].handlecxx . . $ object#handle.;
1547
1548 if (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! &&
1549 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!))
1550 Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].ctypecxx . . $ object#ctype..laser_infocxx . . $ object#$anonymous_type_9#laser_info..last_hit_handlecxx . . $ laser_info_s#last_hit_handle. = obj->handlecxx . . $ object#handle.;
1551 } else if (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || obj->typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! ||
1552 Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. == OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`! || obj->typecxx . . $ object#type. == OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`!) {
1553 if (n_ignore_objs < MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`!)
1554 ignore_obj_list[n_ignore_objs++] = hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0];
1555
1556 count--;
1557 if (count < -1)
1558 count = -1;
1559 }
1560
1561 f_continue_sim = true;
1562
1563 } else {
1564 f_continue_sim = false;
1565 }
1566 } break;
1567
1568 case HIT_BAD_P0cxx . . $ `lib/findintersection_external.h:49:9`!:
1569 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS ERROR: Bad p0 in physics!!!\n");
1570 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Unexpected collision type: start point not in specified segment.
1571 break;
1572
1573 default:
1574 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS ERROR: Unknown and unhandled hit type returned from FVI\n");
1575 Int3cxx . . $ `misc/pserror.h:247:9`!();
1576 break;
1577 }
1578
1579 // Increment the simulation loop counter
1580 count++;
1581
1582 } while ((f_continue_sim) && (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) && (sim_time_remaining > 0.0f) && (count < sim_loop_limit));
1583
1584 // Special stuff should we do if we hit the simulation loop limit
1585 // If retry count is getting large, then we might be trying to do something bad.
1586 // NOTE: These numbers limit the max collisions an object can have in a single frame
1587 if (count >= sim_loop_limit) {
1588 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
1589 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS NOTE: Too many collisions for player!\n");
1590 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
1591 }
1592 }
1593
1594 end_of_sim:
1595
1596 if (f_turn_gravity_on) {
1597 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. |= (PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!);
1598 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. /= 300.0f;
1599 }
1600
1601 AttachUpdateSubObjectscxx . . $ AttachUpdateSubObjects(419c470199a90a97).(obj);
1602
1603 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault.
1604 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
1605 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
1606
1607 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
1608 return;
1609 }
1610
1611 int PhysCastWalkRaycxx . . $ PhysCastWalkRay(7f00c7b56bebad67).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *p0, vectorcxx . . $ vector# *p1, vectorcxx . . $ vector# *hitpnt, int *start_roomnum = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!,
1612 int *end_roomnum = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, vectorcxx . . $ vector# *hit_normal = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) {
1613 int fate;
1614
1615 fvi_infocxx . . $ fvi_info# hit_info;
1616 fvi_querycxx . . $ fvi_query# fq;
1617
1618 fq.p0cxx . . $ fvi_query#p0. = p0;
1619 fq.p1cxx . . $ fvi_query#p1. = p1;
1620
1621 if (start_roomnum)
1622 fq.startroomcxx . . $ fvi_query#startroom. = *start_roomnum;
1623 else
1624 fq.startroomcxx . . $ fvi_query#startroom. = obj->roomnumcxx . . $ object#roomnum.;
1625
1626 fq.radcxx . . $ fvi_query#rad. = 0.0f;
1627 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_IGNORE_POWERUPScxx . . $ `lib/findintersection_external.h:62:9`! | FQ_IGNORE_WEAPONScxx . . $ `lib/findintersection_external.h:79:9`! | FQ_IGNORE_MOVING_OBJECTScxx . . $ `lib/findintersection_external.h:67:9`! |
1628 FQ_IGNORE_NON_LIGHTMAP_OBJECTScxx . . $ `lib/findintersection_external.h:68:9`!;
1629 if (!end_roomnum)
1630 fq.flagscxx . . $ fvi_query#flags. |= FQ_NO_RELINKcxx . . $ `lib/findintersection_external.h:73:9`!;
1631
1632 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj);
1633 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
1634
1635 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
1636 if (end_roomnum)
1637 *end_roomnum = hit_info.hit_roomcxx . . $ fvi_info#hit_room.;
1638 if (hit_normal)
1639 *hit_normal =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
1640
1641 if (fate == HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`!) {
1642 if (GameTexturescxx . . $ GameTextures.[Roomscxx . . $ Rooms.[hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0]].facescxx . . $ room#faces.[hit_info.hit_facecxx . . $ fvi_info#hit_face.[0]].tmapcxx . . $ face#tmap.].flagscxx . . $ texture#flags. &
1643 (TF_VOLATILEcxx . . $ `Descent3/gametexture.h:201:9`! | TF_FORCEFIELDcxx . . $ `Descent3/gametexture.h:206:9`! | TF_LAVAcxx . . $ `Descent3/gametexture.h:230:9`!)) {
1644 return HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!;
1645 }
1646 }
1647
1648 *hitpnt =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). hit_info.hit_pntcxx . . $ fvi_info#hit_pnt.;
1649 return fate;
1650 }
1651
1652 void PhysCalPntOnCPntPlanecxx . . $ PhysCalPntOnCPntPlane(c690688a57db19bc).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *s_pnt, vectorcxx . . $ vector# *d_pnt, float *dist) {
1653 vectorcxx . . $ vector# tpnt = *s_pnt -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
1654 *dist = obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(4a721543d64e126a). tpnt;
1655
1656 *d_pnt =cxx . . $ vector#`operator=`(c0842353a20857d). *s_pnt +cxx . . $ operator+(b77b703cd1e43e33). ((-(*dist)) *cxx . . $ `operator*`(9d6577ff3e9faa29). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.);
1657 }
1658
1659 bool PhysComputeWalkerPosOrientcxx . . $ PhysComputeWalkerPosOrient(1c39b6aef9c39585).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *pos, matrixcxx . . $ matrix# *orient) {
1660 vectorcxx . . $ vector# pnt[3];
1661 vectorcxx . . $ vector# tpnt = obj->poscxx . . $ object#pos.;
1662 matrixcxx . . $ matrix# tmatrix = obj->orientcxx . . $ object#orient.;
1663 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.];
1664 int num_gps = (pm->n_groundcxx . . $ poly_model#n_ground. == 5) ? 3 : 1;
1665 int i;
1666
1667 bool f_ok = true;
1668
1669 obj->poscxx . . $ object#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *pos;
1670 obj->orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). *orient;
1671
1672 for (i = 0; i < num_gps; i++) {
1673 PhysCalcGroundcxx . . $ PhysCalcGround(85e3752e9562a225).(&pnt[i], NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, obj, i);
1674 }
1675
1676 obj->poscxx . . $ object#pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). tpnt;
1677 obj->orientcxx . . $ object#orient. =cxx . . $ matrix#`operator=`(4c6f8b29806742). tmatrix;
1678
1679 if (num_gps == 3) {
1680 vectorcxx . . $ vector# pp[3];
1681 float pdist[3];
1682 int proom[3];
1683 vectorcxx . . $ vector# hp[3];
1684
1685 for (i = 0; i < 3; i++)
1686 PhysCalPntOnCPntPlanecxx . . $ PhysCalPntOnCPntPlane(c690688a57db19bc).(obj, &pnt[i], &pp[i], &pdist[i]);
1687
1688 // Moves the points to valid locations in the mine and determines the points' room numbers
1689 for (i = 0; i < 3; i++) {
1690 vectorcxx . . $ vector# x;
1691 vectorcxx . . $ vector# norm;
1692
1693 int fate = PhysCastWalkRaycxx . . $ PhysCastWalkRay(7f00c7b56bebad67).(obj, &obj->poscxx . . $ object#pos., &pp[i], &x, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, &proom[i], &norm);
1694 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1695 if (norm *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. < 0.4717f) {
1696 return false;
1697 }
1698
1699 pp[i] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). x;
1700 }
1701 }
1702
1703 int num_ave = 0;
1704 vectorcxx . . $ vector# ave_diff = Zero_vectorcxx . . $ Zero_vector.;
1705
1706 for (i = 0; i < 3; i++) {
1707 int fate;
1708 vectorcxx . . $ vector# foot_pnt = pp[i] +cxx . . $ operator+(b77b703cd1e43e33). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(252247219a31502c). -(obj->sizecxx . . $ object#size. * 1.5f);
1709 vectorcxx . . $ vector# norm;
1710
1711 fate = PhysCastWalkRaycxx . . $ PhysCastWalkRay(7f00c7b56bebad67).(obj, &pp[i], &foot_pnt, &hp[i], &proom[i], NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, &norm);
1712
1713 if (fate != HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1714 if (norm *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. < 0.4717f) {
1715 return false;
1716 }
1717
1718 ave_diff +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hp[i] -cxx . . $ operator-(b77b703cd1e43e33). pnt[i];
1719 num_ave++;
1720 } else {
1721 f_ok = false;
1722 }
1723 }
1724
1725 if (num_ave > 0) {
1726 ave_diff /=cxx . . $ `operator/=`(f132838b2cd11d6). num_ave;
1727 } else
1728 ave_diff =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
1729
1730 vectorcxx . . $ vector# uvec;
1731 vm_GetPerpcxx . . $ vm_GetPerp(f7eb4a62c434525d).(&uvec, &hp[0], &hp[1], &hp[2]);
1732 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&uvec);
1733
1734 // if(uvec.y < 0.0)
1735 // uvec *= -1.0f;
1736
1737 float dot = orient->fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(4a721543d64e126a). uvec;
1738 vectorcxx . . $ vector# fvec = orient->fveccxx . . $ matrix#fvec.;
1739 fvec -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). (uvec *cxx . . $ `operator*`(252247219a31502c). dot);
1740 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&fvec);
1741
1742 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(orient, &fvec, &uvec, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
1743 *pos +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). ave_diff;
1744 } else { // Alignd to Y-axis
1745 int fate;
1746 vectorcxx . . $ vector# hp;
1747 vectorcxx . . $ vector# foot_pnt = obj->poscxx . . $ object#pos.;
1748 foot_pnt.ycxx . . $ vector#y. -= obj->sizecxx . . $ object#size. * 3.0f;
1749
1750 fate = PhysCastWalkRaycxx . . $ PhysCastWalkRay(7f00c7b56bebad67).(obj, &obj->poscxx . . $ object#pos., &foot_pnt, &hp);
1751
1752 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
1753 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Walking object %d should be falling\n", OBJNUM(obj));
1754 // SetObjectDeadFlag(obj);
1755 f_ok = false;
1756 } else {
1757 float diff = hp.ycxx . . $ vector#y. - pnt[0].ycxx . . $ vector#y.;
1758
1759 pos->ycxx . . $ vector#y. += diff;
1760
1761 angveccxx . . $ angvec# a;
1762 vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&a, orient);
1763 vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(orient, 0.0f, a.hcxx . . $ angvec#h., 0.0f);
1764 }
1765 }
1766
1767 return f_ok;
1768 }
1769
1770 bool IsNodeValidcxx . . $ IsNodeValid(f1572d608d801f1f).(int cell, float min_vert_dot) {
1771 if (TerrainNormalscxx . . $ TerrainNormals.[MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1][cell].normal1cxx . . $ terrain_normals#normal1..ycxx . . $ vector#y. >= min_vert_dot &&
1772 TerrainNormalscxx . . $ TerrainNormals.[MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1][cell].normal2cxx . . $ terrain_normals#normal2..ycxx . . $ vector#y. >= min_vert_dot)
1773 return true;
1774 else
1775 return false;
1776 }
1777
1778 bool PhysValidateGroundPathcxx . . $ PhysValidateGroundPath(5174ca1c690c697b).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *s, int sroom, vectorcxx . . $ vector# *e, int eroom, float rad, float min_vert_dot) {
1779 if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(sroom)) {
1780 int x1, x2, y1, y2, x, y, delta_y, delta_x, change_x, change_y, length, cur_node, error_term, i;
1781
1782 int new_x, new_y;
1783 int counter;
1784 int delta_ter_check = rad / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! + 1;
1785
1786 // Determine the start end end nodes
1787 x1 = CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(sroom) % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!;
1788 y1 = CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(sroom) / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!;
1789
1790 x2 = CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(eroom) % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!;
1791 y2 = CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(eroom) / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!;
1792
1793 x = x1;
1794 y = y1;
1795
1796 // How many nodes did I move?
1797 delta_x = x2 - x1;
1798 delta_y = y2 - y1;
1799
1800 // Check the current node
1801 if (!IsNodeValidcxx . . $ IsNodeValid(f1572d608d801f1f).(CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(sroom), min_vert_dot)) {
1802 return false;
1803 }
1804
1805 if (delta_x == 0 && delta_y == 0)
1806 return true;
1807
1808 // check the end node
1809 cur_node = y1 * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! + x2;
1810 if (!IsNodeValidcxx . . $ IsNodeValid(f1572d608d801f1f).(cur_node, min_vert_dot)) {
1811 return false;
1812 }
1813
1814 // Do a Breshenham line algorithm
1815 if (delta_x < 0) {
1816 change_x = -1;
1817 delta_x = -delta_x;
1818 } else {
1819 change_x = 1;
1820 }
1821
1822 if (delta_y < 0) {
1823 change_y = -1;
1824 delta_y = -delta_y;
1825 } else {
1826 change_y = 1;
1827 }
1828
1829 error_term = 0;
1830 i = 1;
1831
1832 if (delta_x < delta_y) {
1833 length = delta_y + 1;
1834
1835 while (i < length) {
1836 y += change_y;
1837 error_term += delta_x;
1838
1839 if (error_term >= delta_y) {
1840 x += change_x;
1841 error_term -= delta_y;
1842 }
1843
1844 if (y >= TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! || y < 0 || x < 0 || x >= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) {
1845 return false;
1846 }
1847
1848 for (counter = -delta_ter_check; counter <= delta_ter_check; counter++) {
1849 new_x = x + counter;
1850
1851 if (new_x < 0) {
1852 counter = -x;
1853 new_x = 0;
1854 }
1855
1856 if (new_x >= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!)
1857 break;
1858
1859 // Check the current node for collisions -- chrishack -- This can be made iterative
1860 cur_node = y * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! + new_x;
1861 if (!IsNodeValidcxx . . $ IsNodeValid(f1572d608d801f1f).(cur_node, min_vert_dot)) {
1862 return false;
1863 }
1864 }
1865
1866 i++;
1867 }
1868
1869 } else {
1870 length = delta_x + 1;
1871
1872 while (i < length) {
1873 x += change_x;
1874 error_term += delta_y;
1875
1876 if (error_term >= delta_x) {
1877 y += change_y;
1878 error_term -= delta_x;
1879 }
1880
1881 if (y >= TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! || y < 0 || x < 0 || x >= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) {
1882 return false;
1883 }
1884
1885 for (counter = -delta_ter_check; counter <= delta_ter_check; counter++) {
1886 new_y = y + counter;
1887
1888 if (new_y < 0) {
1889 counter = -y;
1890 new_y = 0;
1891 }
1892 if (new_y >= TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!)
1893 break;
1894
1895 // Check the current node for collisions -- chrishack -- This can be made iterative
1896 cur_node = new_y * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! + x;
1897 if (!IsNodeValidcxx . . $ IsNodeValid(f1572d608d801f1f).(cur_node, min_vert_dot)) {
1898 return false;
1899 }
1900 }
1901
1902 i++;
1903 }
1904 }
1905
1906 return true;
1907 } else {
1908 return true;
1909 }
1910 }
1911
1912 // -----------------------------------------------------------------------------------------------------------
1913 // Simulate a physics object for this frame
1914 void do_walking_simcxx . . $ do_walking_sim(419c470199a90a97).(objectcxx . . $ object# *obj) {
1915 // Since we might not call FVI, set this here
1916 Fvi_num_recorded_facescxx . . $ Fvi_num_recorded_faces. = 0;
1917
1918 int n_ignore_objs = 0; // The number of ignored objects
1919 int ignore_obj_list[MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`! + 1]; // List of ignored objects
1920
1921 int fate; // Collision type for response code
1922 vectorcxx . . $ vector# movement_vec; // Movement in this frame
1923 vectorcxx . . $ vector# movement_pos; // End point of the movement
1924
1925 int count = 0; // Simulation loop counter
1926 int sim_loop_limit = (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) ? MAX_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:45:9`! : MAX_NON_PLAYER_SIM_LOOPScxx . . $ `physics/physics.cpp:46:9`!;
1927
1928 int objnum = OBJNUMcxx . . $ `Descent3/object.h:700:9`!(obj); // Simulated object's index
1929 fvi_infocxx . . $ fvi_info# hit_info; // Hit information
1930 fvi_querycxx . . $ fvi_query# fq; // Movement query
1931
1932 float sim_time_remaining = Frametimecxx . . $ Frametime.; // Amount of simulation time remaining (current iteration)
1933 float old_sim_time_remaining = Frametimecxx . . $ Frametime.; // Amount of simulation time remaining (previous iteration)
1934
1935 vectorcxx . . $ vector# init_pos = obj->poscxx . . $ object#pos.; // Initial position
1936 int init_room = obj->roomnumcxx . . $ object#roomnum.; // Initial room
1937
1938 vectorcxx . . $ vector# start_pos = obj->poscxx . . $ object#pos.; // Values at the start of current simulation loop
1939 vectorcxx . . $ vector# start_vel = obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
1940 int start_room = obj->roomnumcxx . . $ object#roomnum.;
1941
1942 float moved_time; // How long objected moved before hit something
1943 physics_infocxx . . $ physics_info# *pi = &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info.; // Simulated object's physics information
1944
1945 int bounced = 0; // Did the object bounce?
1946
1947 vectorcxx . . $ vector# total_force = Zero_vectorcxx . . $ Zero_vector.; // Constant force acting on an object
1948
1949 bool f_continue_sim; // Should we run another simulation loop
1950 bool f_start_fvi_record = true; // Records the rooms that are passed thru
1951
1952 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.];
1953
1954 // Assert conditions
1955 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->type != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!);
1956 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj->movement_type == MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!);
1957 ASSERTcxx . . $ `misc/pserror.h:246:9`!(!(obj->mtype.phys_info.flags & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) || obj->mtype.phys_info.drag != 0.0);
1958 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault.
1959 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
1960 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
1961
1962 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
1963 if (!Game_do_walking_simcxx . . $ Game_do_walking_sim.) {
1964 return;
1965 }
1966 #endif
1967
1968 // Instant bail cases
1969 if ((obj->flagscxx . . $ object#flags. & (OF_DEADcxx . . $ `Descent3/object_external.h:270:9`! | OF_ATTACHEDcxx . . $ `Descent3/object_external.h:273:9`!)) || (Frametimecxx . . $ Frametime. <= 0.0) || (obj->typecxx . . $ object#type. == OBJ_DUMMYcxx . . $ `Descent3/object_external.h:181:9`!)) {
1970 return;
1971 }
1972
1973 obj->flagscxx . . $ object#flags. &= (~OF_STOPPED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:272:9`!);
1974
1975 // Do rotation velocity/accel stuff
1976 bool f_rotated = false;
1977
1978 if (!(fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.) > .000001 ||
1979 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->thrustcxx . . $ physics_info#thrust..zcxx . . $ vector#z.) > .000001 ||
1980 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel..zcxx . . $ vector#z.) > .000001 ||
1981 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..xcxx . . $ vector#x.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..ycxx . . $ vector#y.) > .000001 || fabscxx . . $ fabs(fbcf3211dfe1bfd1).(pi->rotthrustcxx . . $ physics_info#$anonymous_type_2#rotthrust..zcxx . . $ vector#z.) > .000001 ||
1982 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) ||
1983 ((!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj->roomnum)) && Roomscxx . . $ Rooms.[obj->roomnumcxx . . $ object#roomnum.].windcxx . . $ room#wind. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.) ||
1984 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_WIGGLEcxx . . $ `Descent3/object_external.h:316:9`!) ||
1985 ((obj->ai_infocxx . . $ object#ai_info. != NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!) && ((obj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. & AIF_REPORT_NEW_ORIENTcxx . . $ `Descent3/aistruct_external.h:372:9`!) != 0)))) {
1986 if ((obj->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!)) {
1987 obj->flagscxx . . $ object#flags. &= (~OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!);
1988 obj->flagscxx . . $ object#flags. |= OF_STOPPED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:272:9`!;
1989 }
1990
1991 return;
1992 }
1993
1994 if (obj->ai_infocxx . . $ object#ai_info.) {
1995 if (obj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. & AIF_REPORT_NEW_ORIENTcxx . . $ `Descent3/aistruct_external.h:372:9`!) {
1996 if (pm->n_groundcxx . . $ poly_model#n_ground. == 5) {
1997 vectorcxx . . $ vector# pos = obj->poscxx . . $ object#pos.;
1998 matrixcxx . . $ matrix# orient = obj->orientcxx . . $ object#orient.;
1999
2000 if (PhysComputeWalkerPosOrientcxx . . $ PhysComputeWalkerPosOrient(1c39b6aef9c39585).(obj, &pos, &orient) &&
2001 ((!obj->ai_infocxx . . $ object#ai_info.) || (orient.uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. > .7101 && orient.fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec. > .7101 &&
2002 orient.rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec. > .7101)))
2003 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &pos, obj->roomnumcxx . . $ object#roomnum., &orient, false);
2004 else
2005 ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(obj, &obj->ai_infocxx . . $ object#ai_info.->saved_orientcxx . . $ ai_frame#saved_orient.);
2006 }
2007 obj->ai_infocxx . . $ object#ai_info.->flagscxx . . $ ai_frame#flags. &= ~AIF_REPORT_NEW_ORIENTcxx . . $ `Descent3/aistruct_external.h:372:9`!;
2008 }
2009 }
2010 obj->flagscxx . . $ object#flags. |= OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!;
2011
2012 // This assumes that the thrust does not change within a frame. If it does, account for it
2013 // there... like missiles bouncing off a wall and changing heading. --chrishack
2014 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..dragcxx . . $ physics_info#drag. != 0.0) {
2015 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_USES_THRUSTcxx . . $ `Descent3/object_external.h:319:9`!) {
2016 total_force =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
2017 }
2018 }
2019
2020 // mprintf(0, "PHYSICS: Current obj: %d, %9.2fx %9.2fy %9.2fz\n", OBJNUM(obj), XYZ(&obj->pos));
2021 // mprintf(2,1,0,"x %9.2f\ny %9.2f\nz %9.2f", XYZ(&obj->mtype.phys_info.velocity));
2022 // mprintf(0, "PHYSICS: Current velocity (%f, %f, %f)\n", XYZ(&obj->mtype.phys_info.velocity));
2023
2024 Physics_normal_countercxx . . $ Physics_normal_counter.++;
2025
2026 // Simulate movement until we are done (i.e. Frametime has passed or object is done moving)
2027 do {
2028 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..rotvelcxx . . $ physics_info#$anonymous_type_1#rotvel. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
2029
2030 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
2031 // This records the sim.
2032 sim_loop_recordcxx . . $ sim_loop_record.[count].phys_infocxx . . $ sim_loop_info#phys_info. =cxx . . $ physics_info#`operator=`(fa4a94890b261b64). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info.;
2033 #endif
2034
2035 // Remove transient portions of the velocity
2036 vectorcxx . . $ vector# t = (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.) *cxx . . $ `operator*`(9d6577ff3e9faa29). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec.;
2037 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). t;
2038
2039 // Initailly assume that this is the last sim cycle
2040 f_continue_sim = false;
2041
2042 // Determines forces
2043 if (count > 0) {
2044 total_force.xcxx . . $ vector#x. = total_force.ycxx . . $ vector#y. = total_force.zcxx . . $ vector#z. = 0.0;
2045 }
2046
2047 {
2048 movement_vec =cxx . . $ vector#`operator=`(c0842353a20857d). pi->velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). Frametimecxx . . $ Frametime.;
2049 movement_pos =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. +cxx . . $ operator+(b77b703cd1e43e33). movement_vec;
2050 vectorcxx . . $ vector# footstep = movement_pos;
2051 int new_room;
2052
2053 if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj->roomnum)) {
2054 new_room = GetTerrainRoomFromPoscxx . . $ GetTerrainRoomFromPos(177d9005acf670a0).(&footstep);
2055 } else {
2056 new_room = obj->roomnumcxx . . $ object#roomnum.;
2057 }
2058
2059 bool f_step;
2060
2061 if (PhysValidateGroundPathcxx . . $ PhysValidateGroundPath(5174ca1c690c697b).(obj, &obj->poscxx . . $ object#pos., obj->roomnumcxx . . $ object#roomnum., &footstep, new_room, obj->sizecxx . . $ object#size., 0.6f)) {
2062 f_step = true;
2063
2064 // Determine endpos
2065 matrixcxx . . $ matrix# norient;
2066 norient =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
2067 if (PhysComputeWalkerPosOrientcxx . . $ PhysComputeWalkerPosOrient(1c39b6aef9c39585).(obj, &footstep, &norient)) {
2068 if (norient.uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec. > .7101 && norient.fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..fveccxx . . $ matrix#fvec. > .7101 &&
2069 norient.rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(4a721543d64e126a). obj->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec. > .7101) {
2070 ObjSetOrientcxx . . $ ObjSetOrient(e1367e0f901c991f).(obj, &norient);
2071
2072 movement_vec =cxx . . $ vector#`operator=`(c0842353a20857d). footstep -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
2073 movement_pos =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). footstep;
2074
2075 fq.p0cxx . . $ fvi_query#p0. = &obj->poscxx . . $ object#pos.;
2076 fq.startroomcxx . . $ fvi_query#startroom. = obj->roomnumcxx . . $ object#roomnum.;
2077 fq.p1cxx . . $ fvi_query#p1. = &footstep;
2078 fq.radcxx . . $ fvi_query#rad. = obj->sizecxx . . $ object#size.;
2079 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = objnum;
2080 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
2081 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_IGNORE_WEAPONScxx . . $ `lib/findintersection_external.h:79:9`! | FQ_IGNORE_POWERUPScxx . . $ `lib/findintersection_external.h:62:9`! | FQ_IGNORE_TERRAINcxx . . $ `lib/findintersection_external.h:80:9`!;
2082
2083 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_POINT_COLLIDE_WALLScxx . . $ `Descent3/object_external.h:333:9`!) {
2084 fq.radcxx . . $ fvi_query#rad. = 0.0f;
2085 } else if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(obj->roomnum)) {
2086 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.];
2087 int num_gps = (pm->n_groundcxx . . $ poly_model#n_ground. == 5) ? 3 : 1;
2088
2089 if (num_gps == 3)
2090 fq.radcxx . . $ fvi_query#rad. *= 0.2f;
2091 else
2092 fq.radcxx . . $ fvi_query#rad. *= 0.45f;
2093 }
2094
2095 if (obj->flagscxx . . $ object#flags. & OF_NO_OBJECT_COLLISIONScxx . . $ `Descent3/object_external.h:286:9`!)
2096 fq.flagscxx . . $ fvi_query#flags. &= ~FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`!;
2097
2098 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
2099
2100 norient =cxx . . $ matrix#`operator=`(4c6f8b29806742). obj->orientcxx . . $ object#orient.;
2101 if (PhysComputeWalkerPosOrientcxx . . $ PhysComputeWalkerPosOrient(1c39b6aef9c39585).(obj, &hit_info.hit_pntcxx . . $ fvi_info#hit_pnt., &norient)) {
2102 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &hit_info.hit_pntcxx . . $ fvi_info#hit_pnt., hit_info.hit_roomcxx . . $ fvi_info#hit_room., &norient, false);
2103 } else {
2104 f_step = false;
2105 }
2106 } else {
2107 f_step = false;
2108 movement_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
2109 }
2110 } else {
2111 f_step = false;
2112 movement_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
2113 }
2114 } else {
2115 f_step = false;
2116 }
2117
2118 if (!f_step) {
2119 pi->velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Zero_vectorcxx . . $ Zero_vector.;
2120 break;
2121 }
2122
2123 // If we are stationary, we are done :)
2124 if (fabscxx . . $ fabs(fbcf3211dfe1bfd1).(movement_vec.xcxx . . $ vector#x.) < 0.0000001 && fabscxx . . $ fabs(fbcf3211dfe1bfd1).(movement_vec.ycxx . . $ vector#y.) < 0.0000001 && fabscxx . . $ fabs(fbcf3211dfe1bfd1).(movement_vec.zcxx . . $ vector#z.) < 0.0000001)
2125 break;
2126 }
2127
2128 Physics_walking_looping_countercxx . . $ Physics_walking_looping_counter.++;
2129
2130 // Instant bails for collision response
2131 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! &&
2132 ((fate == HIT_OUT_OF_TERRAIN_BOUNDScxx . . $ `lib/findintersection_external.h:50:9`!) ||
2133 (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_room) && GetTerrainCellFromPoscxx . . $ GetTerrainCellFromPos(177d9005acf670a0).(&hit_info.hit_pntcxx . . $ fvi_info#hit_pnt.) == -1))) {
2134 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &init_pos, init_room, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
2135 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
2136
2137 goto end_of_sim;
2138 } else if (fate == HIT_OUT_OF_TERRAIN_BOUNDScxx . . $ `lib/findintersection_external.h:50:9`!) {
2139 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS NOTE: Walker exited terrain\n");
2140 SetObjectDeadFlagcxx . . $ SetObjectDeadFlag(80a724877f6428f2).(obj);
2141 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
2142
2143 goto end_of_sim;
2144 }
2145
2146 // Calulate amount of sim time left
2147 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) {
2148 moved_time = old_sim_time_remaining = sim_time_remaining;
2149 sim_time_remaining = 0.0;
2150 f_continue_sim = false;
2151 } else {
2152 vectorcxx . . $ vector# moved_vec_n;
2153 float attempted_dist, actual_dist;
2154
2155 // Save results of this simulation
2156 old_sim_time_remaining = sim_time_remaining;
2157 moved_vec_n =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). start_pos; // chrishack -- use this copy
2158 if (moved_vec_n !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.) {
2159 actual_dist = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&moved_vec_n);
2160 } else {
2161 actual_dist = 0.0f;
2162 }
2163
2164 // chrishack -- potentially bad -- outside to inside stuff
2165 // We where sitting in a wall -- invalid starting point
2166 // moved backwards
2167 if (fate == HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`! && moved_vec_n *cxx . . $ `operator*`(4a721543d64e126a). movement_vec < -0.000001 && actual_dist != 0.0) {
2168
2169 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Obj %d Walked backwards!\n", OBJNUM(obj));
2170 /*
2171 mprintf(0, "PHYSICS NOTE: (%f, %f, %f) to (%f, %f, %f)\n",
2172 XYZ(&start_pos),
2173 XYZ(&obj->pos))); // don't change position or sim_time_remaining
2174 */
2175
2176 ObjSetPoscxx . . $ ObjSetPos(bbb518390bedd509).(obj, &start_pos, start_room, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!, false);
2177
2178 moved_time = 0.0;
2179 } else {
2180 // Compute more results of this simulation
2181 attempted_dist = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&movement_vec);
2182 sim_time_remaining = sim_time_remaining * ((attempted_dist - actual_dist) / attempted_dist);
2183 moved_time = old_sim_time_remaining - sim_time_remaining;
2184
2185 // chrishack -- we have no time left (plus some) This can happen if FVI corrects a near tangental
2186 // movement by adding the radius - thus, we move a little too far.
2187 if (sim_time_remaining < 0.0) {
2188 sim_time_remaining = 0.0;
2189 moved_time = old_sim_time_remaining;
2190 }
2191
2192 // chrishack -- negative simulation time pasted for this sim frame
2193 if (sim_time_remaining > old_sim_time_remaining) {
2194 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0,
2195 "PHYSICS WARNING: Bogus sim_time_remaining = %15.13f, old = %15.13f\nAttempted d = %15.13f, actual "
2196 "= %15.13f\n",
2197 sim_time_remaining, old_sim_time_remaining, attempted_dist, actual_dist);
2198 // Int3();
2199 sim_time_remaining = old_sim_time_remaining;
2200 moved_time = 0.0;
2201 f_continue_sim = false;
2202 }
2203 }
2204 }
2205
2206 // Get the collision speed as a linear interp.
2207 if (old_sim_time_remaining > 0.0) {
2208 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. =cxx . . $ vector#`operator=`(c0842353a20857d). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). (moved_time / old_sim_time_remaining) +cxx . . $ operator+(b77b703cd1e43e33).
2209 start_vel *cxx . . $ `operator*`(252247219a31502c). (sim_time_remaining / old_sim_time_remaining);
2210 }
2211
2212 // Collision response code
2213 switch (fate) {
2214 case HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!:
2215 f_continue_sim = false;
2216 break;
2217 case HIT_WALLcxx . . $ `lib/findintersection_external.h:46:9`!: // Finally unified, still needs some work, but it certainly better like this :)
2218 case HIT_TERRAINcxx . . $ `lib/findintersection_external.h:48:9`!: {
2219 // if(obj->type != OBJ_CLUTTER)
2220 {
2221 vectorcxx . . $ vector# moved_v;
2222 float hit_speed, wall_part;
2223 float hit_dot = 1.0;
2224
2225 float luke_test;
2226
2227 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!) {
2228 luke_test = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
2229 }
2230
2231 // Find hit speed
2232 moved_v =cxx . . $ vector#`operator=`(c0842353a20857d). obj->poscxx . . $ object#pos. -cxx . . $ operator-(b77b703cd1e43e33). start_pos; // chrishack -- We already computed this!!!!!!!
2233 wall_part = moved_v *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
2234
2235 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..hit_die_dotcxx . . $ physics_info#$anonymous_type_5#hit_die_dot. > 0.0) {
2236 vectorcxx . . $ vector# m_normal = start_pos -cxx . . $ operator-(b77b703cd1e43e33). obj->poscxx . . $ object#pos.;
2237 vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&m_normal);
2238 hit_dot = m_normal *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
2239 }
2240
2241 hit_speed = -(wall_part / moved_time);
2242
2243 // We hit a wall (weapons cannot scrap)
2244 if ((wall_part != 0.0 && moved_time > 0.0 && (hit_speed > 0.0)) || obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`!)
2245 collide_object_with_wallcxx . . $ collide_object_with_wall(df7a53499d66690e).(obj, hit_speed, hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0], hit_info.hit_facecxx . . $ fvi_info#hit_face.[0],
2246 &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0], hit_dot);
2247 else // We hit a wall and are moving parallel to it
2248 collide_object_with_wallcxx . . $ collide_object_with_wall(df7a53499d66690e).(obj, hit_speed, hit_info.hit_face_roomcxx . . $ fvi_info#hit_face_room.[0], hit_info.hit_facecxx . . $ fvi_info#hit_face.[0],
2249 &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0], hit_dot);
2250
2251 if (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) {
2252 bool f_forcefield = false; // bounce off a forcefield
2253
2254 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!))
2255 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. &= (~PF_NO_COLLIDE_PARENTcxx . . $ `Descent3/object_external.h:326:9`!);
2256
2257 // Slide object along wall
2258
2259 // We're constrained by wall, so subtract wall part from the velocity vector
2260 wall_part = hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(4a721543d64e126a). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.;
2261
2262 if ((obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..num_bouncescxx . . $ physics_info#num_bounces. <= 0) && (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_STICKcxx . . $ `Descent3/object_external.h:317:9`!)) {
2263 obj->movement_typecxx . . $ object#movement_type. = MT_NONEcxx . . $ `Descent3/object_external.h:233:9`!;
2264 vm_MakeZerocxx . . $ vm_MakeZero(ec8cf6451c36d470).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
2265 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
2266 goto end_of_sim;
2267 } else if (f_forcefield || (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_BOUNCEcxx . . $ `Descent3/object_external.h:315:9`!)) {
2268 wall_part *= 2.0; // Subtract out wall part twice to achieve bounce
2269
2270 if (f_forcefield) {
2271 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!)
2272 wall_part *= 2; // player bounce twice as much -- chrishack try without this too.
2273 }
2274
2275 bounced = 1; // this object bounced
2276 // mprintf(0, "(%f, %f, %f) before bounce\n", XYZ(&obj->mtype.phys_info.velocity));
2277 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.0f);
2278
2279 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution. != 1.0f)
2280 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. -=cxx . . $ `operator-=`(801a8d6f7ab7bef9).
2281 (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *cxx . . $ `operator*`(252247219a31502c). (1.0f - obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..coeff_restitutioncxx . . $ physics_info#coeff_restitution.));
2282
2283 // mprintf(0, "(%f, %f, %f) after bounce\n", XYZ(&obj->mtype.phys_info.velocity));
2284 // mprintf(0, "p (%f, %f, %f) after bounce\n", XYZ(&obj->pos));
2285 } else {
2286 float wall_force;
2287
2288 wall_force = total_force *cxx . . $ `operator*`(4a721543d64e126a). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
2289 total_force +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
2290 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_force * -1.001f); // 1.001 so that we are not quite tangential
2291
2292 // Update velocity from wall hit.
2293 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9).
2294 hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0] *cxx . . $ `operator*`(252247219a31502c). (wall_part * -1.001f); // 1.001 so that we are not quite tangential
2295
2296 if ((obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! ||
2297 (obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) &&
2298 sim_time_remaining == old_sim_time_remaining) {
2299 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
2300 }
2301
2302 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`!) {
2303 float real_vel;
2304
2305 real_vel = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
2306 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *=cxx . . $ `operator*=`(f132838b2cd11d6). ((real_vel + luke_test) / 2);
2307 }
2308 }
2309
2310 // mprintf(0, "PHYSICS: Wall normal (%f, %f, %f)\n", XYZ(&hit_info.hit_wallnorm[0]));
2311 // mprintf(0, "PHYSICS: Bounded velocity (%f, %f, %f)\n", XYZ(&obj->mtype.phys_info.velocity));
2312
2313 // This only happens if the new velocity is set from hitting a forcefield.
2314 if (!(fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..xcxx . . $ vector#x.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
2315 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..ycxx . . $ vector#y.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! &&
2316 fabscxx . . $ fabs(fbcf3211dfe1bfd1).(obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.) < MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`!)) {
2317 float mag = vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity.);
2318
2319 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS: Bashing vel for Obj %d of type %d with %f velocity", objnum, obj->type, mag);
2320 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. *=cxx . . $ `operator*=`(f132838b2cd11d6). MAX_OBJECT_VELcxx . . $ `physics/physics.cpp:75:9`! * 0.1f;
2321 }
2322
2323 // Weapons should face their new heading. This is so missiles are pointing in the correct direct.
2324 if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (bounced || (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & (PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`! | PF_WINDcxx . . $ `Descent3/object_external.h:322:9`!))))
2325 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. !=cxx . . $ `operator!=`(718c890c104af0f3). Zero_vectorcxx . . $ Zero_vector.)
2326 vm_VectorToMatrixcxx . . $ vm_VectorToMatrix(543233b88555916d).(&obj->orientcxx . . $ object#orient., &obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity., &obj->orientcxx . . $ object#orient..uveccxx . . $ matrix#uvec., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!);
2327 }
2328 }
2329 f_continue_sim = true;
2330
2331 } break;
2332
2333 case HIT_OBJECTcxx . . $ `lib/findintersection_external.h:47:9`!:
2334 case HIT_SPHERE_2_POLY_OBJECTcxx . . $ `lib/findintersection_external.h:52:9`!: {
2335 vectorcxx . . $ vector# old_force; // -- chrishack
2336
2337 // Mark the hit object so that on the following sim frames, in this game frame, ignore this object.
2338 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_object[0] != -1); // chrishack move this ASSERT fvi stuff above
2339
2340 // chrishack -- we should have this point from FVI!!!!!!!!!!!
2341 // Calculcate the hit point between the two objects.
2342 old_force =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
2343
2344 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). total_force;
2345
2346 // hit_info.hit_wallnorm[0] *= -1.0f;
2347
2348 collide_two_objectscxx . . $ collide_two_objects(d2b59d3704ffac80).(obj, &Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]], &hit_info.hit_face_pntcxx . . $ fvi_info#hit_face_pnt.[0], &hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0],
2349 &hit_info);
2350 if (obj->movement_typecxx . . $ object#movement_type. == MT_OBJ_LINKEDcxx . . $ `Descent3/object_external.h:242:9`!)
2351 goto end_of_sim;
2352
2353 total_force =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust.;
2354
2355 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..thrustcxx . . $ physics_info#thrust. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). old_force;
2356
2357 if ((obj->typecxx . . $ object#type. == OBJ_ROBOTcxx . . $ `Descent3/object_external.h:162:9`! || obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! || OBJ_CLUTTERcxx . . $ `Descent3/object_external.h:171:9`! ||
2358 (obj->typecxx . . $ object#type. == OBJ_BUILDINGcxx . . $ `Descent3/object_external.h:176:9`! && obj->ai_infocxx . . $ object#ai_info.)) &&
2359 sim_time_remaining == old_sim_time_remaining && Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].movement_typecxx . . $ object#movement_type. == MT_NONEcxx . . $ `Descent3/object_external.h:233:9`!) {
2360 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). hit_info.hit_wallnormcxx . . $ fvi_info#hit_wallnorm.[0];
2361 }
2362
2363 // mprintf(0, "OBJ %d t %d hit %d\n", OBJNUM(obj), obj->type, hit_info.hit_object[0]);
2364
2365 // Let object continue its movement if collide_two_objects does not mark it as dead
2366 if (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) {
2367 if ((obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!) ||
2368 (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_PERSISTENTcxx . . $ `Descent3/object_external.h:318:9`!)) {
2369 if (n_ignore_objs < MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`!)
2370 ignore_obj_list[n_ignore_objs++] = hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0];
2371 } else if (Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! || obj->typecxx . . $ object#type. == OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`! ||
2372 Objectscxx . . $ Objects.[hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0]].typecxx . . $ object#type. == OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`! || obj->typecxx . . $ object#type. == OBJ_MARKERcxx . . $ `Descent3/object_external.h:175:9`!) {
2373 if (n_ignore_objs < MAX_IGNORE_OBJScxx . . $ `physics/physics.cpp:338:9`!)
2374 ignore_obj_list[n_ignore_objs++] = hit_info.hit_objectcxx . . $ fvi_info#hit_object.[0];
2375
2376 count--;
2377 if (count < -1)
2378 count = -1;
2379 }
2380
2381 f_continue_sim = true;
2382 } else {
2383 f_continue_sim = false;
2384 }
2385 } break;
2386
2387 case HIT_BAD_P0cxx . . $ `lib/findintersection_external.h:49:9`!:
2388 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS ERROR: Bad p0 in physics!!!\n");
2389 Int3cxx . . $ `misc/pserror.h:247:9`!(); // Unexpected collision type: start point not in specified segment.
2390 break;
2391
2392 default:
2393 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS ERROR: Unknown and unhandled hit type returned from FVI\n");
2394 Int3cxx . . $ `misc/pserror.h:247:9`!();
2395 break;
2396 }
2397
2398 // Increment the simulation loop counter
2399 count++;
2400
2401 } while ((f_continue_sim) && (!(obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!)) && (sim_time_remaining > 0.0f) && (count < sim_loop_limit));
2402
2403 // Special stuff should we do if we hit the simulation loop limit
2404 // If retry count is getting large, then we might be trying to do something bad.
2405 // NOTE: These numbers limit the max collisions an object can have in a single frame
2406 if (count >= sim_loop_limit) {
2407 if (obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`!) {
2408 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "PHYSICS NOTE: Too many collisions for player!\n");
2409 }
2410 }
2411
2412 end_of_sim:
2413 AttachUpdateSubObjectscxx . . $ AttachUpdateSubObjects(419c470199a90a97).(obj);
2414
2415 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.x)); // Caller wants to go to infinity! -- Not FVI's fault.
2416 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.y)); // Caller wants to go to infinity! -- Not FVI's fault.
2417 ASSERTcxx . . $ `misc/pserror.h:246:9`!(std::isfinite(obj->mtype.phys_info.velocity.z)); // Caller wants to go to infinity! -- Not FVI's fault.
2418
2419 obj->last_poscxx . . $ object#last_pos. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). init_pos;
2420 return;
2421 }
2422
2423 // -----------------------------------------------------------------------------------------------------------
2424 // Simulate a physics object for this frame
2425 void do_vis_physics_simcxx . . $ do_vis_physics_sim(6089e83781d51a35).(vis_effectcxx . . $ vis_effect# *vis) {
2426 if (Frametimecxx . . $ Frametime. <= 0.0f)
2427 return;
2428
2429 vectorcxx . . $ vector# total_force;
2430 vectorcxx . . $ vector# old_pos = vis->poscxx . . $ vis_effect#pos.;
2431
2432 #ifdef _DEBUGcxx . . $ `<built-in>:480:9`!
2433 if (!Game_do_vis_simcxx . . $ Game_do_vis_sim.) {
2434 return;
2435 }
2436 #endif
2437
2438 if (vis->flagscxx . . $ vis_effect#flags. & VF_DEADcxx . . $ `Descent3/viseffect_external.h:66:9`!) {
2439 return;
2440 }
2441
2442 if (fabsf(vis->velocitycxx . . $ vis_effect#velocity..xcxx . . $ vector#x.) < 0.000001f && fabsf(vis->velocitycxx . . $ vis_effect#velocity..ycxx . . $ vector#y.) < 0.000001f && fabsf(vis->velocitycxx . . $ vis_effect#velocity..zcxx . . $ vector#z.) < 0.000001f &&
2443 !(vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!)) {
2444 return;
2445 }
2446
2447 // Determine velocity
2448 if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_FIXED_VELOCITYcxx . . $ `Descent3/object_external.h:324:9`!) {
2449 vis->poscxx . . $ vis_effect#pos. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). vis->velocitycxx . . $ vis_effect#velocity. *cxx . . $ `operator*`(252247219a31502c). Frametimecxx . . $ Frametime.;
2450 } else {
2451 if (vis->masscxx . . $ vis_effect#mass. > 0.0f && vis->dragcxx . . $ vis_effect#drag. > 0.0f) {
2452 // If the object is effected by gravity (normal, lighter than air, and anti-gravity)
2453 if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) {
2454 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0f;
2455 total_force.ycxx . . $ vector#y. = Gravity_strengthcxx . . $ Gravity_strength. * vis->masscxx . . $ vis_effect#mass.;
2456 } else if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_REVERSE_GRAVITYcxx . . $ `Descent3/object_external.h:329:9`!) {
2457 total_force.xcxx . . $ vector#x. = total_force.zcxx . . $ vector#z. = 0.0f;
2458 total_force.ycxx . . $ vector#y. = -Gravity_strengthcxx . . $ Gravity_strength. * vis->masscxx . . $ vis_effect#mass.;
2459 } else {
2460 total_force.xcxx . . $ vector#x. = total_force.ycxx . . $ vector#y. = total_force.zcxx . . $ vector#z. = 0.0f;
2461 }
2462
2463 // Note: The math here is done in 64bit floats because we will run into precision problems with 32bit
2464 const double forceOverDrag[3] = {total_force.xcxx . . $ vector#x. / vis->dragcxx . . $ vis_effect#drag., total_force.ycxx . . $ vector#y. / vis->dragcxx . . $ vis_effect#drag., total_force.zcxx . . $ vector#z. / vis->dragcxx . . $ vis_effect#drag.};
2465 const double frameTime = Frametimecxx . . $ Frametime.;
2466 const double massOverDrag = vis->masscxx . . $ vis_effect#mass. / vis->dragcxx . . $ vis_effect#drag.;
2467 const double dragOverMass = vis->dragcxx . . $ vis_effect#drag. / vis->masscxx . . $ vis_effect#mass.;
2468 const double expDoMFt = expcxx . . $ exp(fee4f1d22bc8e617).(-dragOverMass * frameTime);
2469
2470 double visNewPos[3];
2471 visNewPos[0] = double(vis->poscxx . . $ vis_effect#pos..xcxx . . $ vector#x.) + forceOverDrag[0] * frameTime +
2472 massOverDrag * (double(vis->velocitycxx . . $ vis_effect#velocity..xcxx . . $ vector#x.) - forceOverDrag[0]) * (1.0 - expDoMFt);
2473 visNewPos[1] = double(vis->poscxx . . $ vis_effect#pos..ycxx . . $ vector#y.) + forceOverDrag[1] * frameTime +
2474 massOverDrag * (double(vis->velocitycxx . . $ vis_effect#velocity..ycxx . . $ vector#y.) - forceOverDrag[1]) * (1.0 - expDoMFt);
2475 visNewPos[2] = double(vis->poscxx . . $ vis_effect#pos..zcxx . . $ vector#z.) + forceOverDrag[2] * frameTime +
2476 massOverDrag * (double(vis->velocitycxx . . $ vis_effect#velocity..zcxx . . $ vector#z.) - forceOverDrag[2]) * (1.0 - expDoMFt);
2477
2478 double visNewVel[3];
2479 visNewVel[0] = (double(vis->velocitycxx . . $ vis_effect#velocity..xcxx . . $ vector#x.) - forceOverDrag[0]) * expDoMFt + forceOverDrag[0];
2480 visNewVel[1] = (double(vis->velocitycxx . . $ vis_effect#velocity..ycxx . . $ vector#y.) - forceOverDrag[1]) * expDoMFt + forceOverDrag[1];
2481 visNewVel[2] = (double(vis->velocitycxx . . $ vis_effect#velocity..zcxx . . $ vector#z.) - forceOverDrag[2]) * expDoMFt + forceOverDrag[2];
2482
2483 vis->poscxx . . $ vis_effect#pos..xcxx . . $ vector#x. = float(visNewPos[0]);
2484 vis->poscxx . . $ vis_effect#pos..ycxx . . $ vector#y. = float(visNewPos[1]);
2485 vis->poscxx . . $ vis_effect#pos..zcxx . . $ vector#z. = float(visNewPos[2]);
2486 vis->velocitycxx . . $ vis_effect#velocity..xcxx . . $ vector#x. = float(visNewVel[0]);
2487 vis->velocitycxx . . $ vis_effect#velocity..ycxx . . $ vector#y. = float(visNewVel[1]);
2488 vis->velocitycxx . . $ vis_effect#velocity..zcxx . . $ vector#z. = float(visNewVel[2]);
2489 } else {
2490 vectorcxx . . $ vector# delta_velocity = {0.0f, 0.0f, 0.0f};
2491
2492 if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_GRAVITYcxx . . $ `Descent3/object_external.h:320:9`!) {
2493 delta_velocity.ycxx . . $ vector#y. += Gravity_strengthcxx . . $ Gravity_strength. * Frametimecxx . . $ Frametime.;
2494 } else if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_REVERSE_GRAVITYcxx . . $ `Descent3/object_external.h:329:9`!) {
2495 delta_velocity.ycxx . . $ vector#y. -= Gravity_strengthcxx . . $ Gravity_strength. * Frametimecxx . . $ Frametime.;
2496 }
2497
2498 vis->poscxx . . $ vis_effect#pos. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (vis->velocitycxx . . $ vis_effect#velocity. *cxx . . $ `operator*`(252247219a31502c). Frametimecxx . . $ Frametime.) +cxx . . $ operator+(b77b703cd1e43e33). (0.5f *cxx . . $ `operator*`(9d6577ff3e9faa29). delta_velocity *cxx . . $ `operator*`(252247219a31502c). Frametimecxx . . $ Frametime.);
2499 vis->velocitycxx . . $ vis_effect#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). delta_velocity;
2500 }
2501 }
2502
2503 if (vis->phys_flagscxx . . $ vis_effect#phys_flags. & PF_NO_COLLIDEcxx . . $ `Descent3/object_external.h:331:9`!) {
2504 return;
2505 }
2506
2507 Physics_vis_countercxx . . $ Physics_vis_counter.++;
2508
2509 // Do FVI call to check for death & update room
2510 fvi_querycxx . . $ fvi_query# fq;
2511 fvi_infocxx . . $ fvi_info# hit_info;
2512 int fate;
2513
2514 if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(vis->roomnum)) {
2515 ASSERTcxx . . $ `misc/pserror.h:246:9`!(CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(vis->roomnum) <= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!);
2516 ASSERTcxx . . $ `misc/pserror.h:246:9`!(CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(vis->roomnum) >= 0);
2517 } else {
2518 ASSERTcxx . . $ `misc/pserror.h:246:9`!(vis->roomnum >= 0 && vis->roomnum <= Highest_room_index && Rooms[vis->roomnum].used);
2519 }
2520
2521 fq.p0cxx . . $ fvi_query#p0. = &old_pos;
2522 fq.startroomcxx . . $ fvi_query#startroom. = vis->roomnumcxx . . $ vis_effect#roomnum.;
2523 fq.p1cxx . . $ fvi_query#p1. = &vis->poscxx . . $ vis_effect#pos.;
2524 fq.radcxx . . $ fvi_query#rad. = 0.0f;
2525 fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = -1;
2526 fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!;
2527 fq.flagscxx . . $ fvi_query#flags. = FQ_CHECK_OBJScxx . . $ `lib/findintersection_external.h:59:9`! | FQ_ONLY_DOOR_OBJcxx . . $ `lib/findintersection_external.h:72:9`! | FQ_IGNORE_WALLScxx . . $ `lib/findintersection_external.h:70:9`!;
2528
2529 fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info);
2530
2531 if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`! && hit_info.hit_roomcxx . . $ fvi_info#hit_room. != -1) {
2532 if (hit_info.hit_roomcxx . . $ fvi_info#hit_room. != vis->roomnumcxx . . $ vis_effect#roomnum.) {
2533 VisEffectRelinkcxx . . $ VisEffectRelink(3e454b8ccf442868).(vis - VisEffectscxx . . $ VisEffects., hit_info.hit_roomcxx . . $ fvi_info#hit_room.);
2534 }
2535
2536 if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(hit_info.hit_room)) {
2537 ASSERTcxx . . $ `misc/pserror.h:246:9`!(CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(hit_info.hit_room) <= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!);
2538 ASSERTcxx . . $ `misc/pserror.h:246:9`!(CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(hit_info.hit_room) >= 0);
2539 } else {
2540 ASSERTcxx . . $ `misc/pserror.h:246:9`!(hit_info.hit_room >= 0 && hit_info.hit_room <= Highest_room_index && Rooms[hit_info.hit_room].used);
2541 }
2542 } else {
2543 VisEffectDeletecxx . . $ VisEffectDelete(d4f767463ce0a6b3).(vis - VisEffectscxx . . $ VisEffects.);
2544 }
2545 }
2546
2547 void phys_apply_forcecxx . . $ phys_apply_force(1d7af1ec00c1f7ea).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *force_vec, int16_t weapon_index) {
2548 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass. == 0.0)
2549 return;
2550
2551 if (obj->movement_typecxx . . $ object#movement_type. != MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`! && obj->movement_typecxx . . $ object#movement_type. != MT_WALKINGcxx . . $ `Descent3/object_external.h:235:9`!)
2552 return;
2553
2554 if (obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..flagscxx . . $ physics_info#flags. & PF_LOCK_MASKcxx . . $ `Descent3/object_external.h:344:9`!) // Not done!
2555 return;
2556
2557 if ((Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) &&
2558 ((obj->typecxx . . $ object#type. == OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->idcxx . . $ object#id. != Player_numcxx . . $ Player_num.) ||
2559 ((obj->typecxx . . $ object#type. != OBJ_PLAYERcxx . . $ `Descent3/object_external.h:164:9`! && obj->typecxx . . $ object#type. != OBJ_POWERUPcxx . . $ `Descent3/object_external.h:167:9`!) && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. != LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!)))
2560 return;
2561
2562 // Do Force Feedback for the hit
2563 if (obj->idcxx . . $ object#id. == Player_numcxx . . $ Player_num.) {
2564 // we need to convert collision_normal from world space to local space
2565 vectorcxx . . $ vector# local_norm;
2566 float scale = 0, magnitude = 0;
2567
2568 // compute how much force to do
2569 magnitude = vm_GetMagnitudecxx . . $ vm_GetMagnitude(4939a7e530383cd4).(force_vec);
2570 if (magnitude) {
2571 scale = magnitude / 2500.0f;
2572 if (scale < 0.0f)
2573 scale = 0.0f;
2574 if (scale > 1.0f)
2575 scale = 1.0f;
2576
2577 vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&local_norm, force_vec, &obj->orientcxx . . $ object#orient.);
2578 local_norm *=cxx . . $ `operator*=`(f132838b2cd11d6). -1.0f;
2579
2580 ForceEffectsPlaycxx . . $ ForceEffectsPlay(7a6f7eb6ea9dc250).(FORCE_TEST_FORCEcxx . . $ `Descent3/D3ForceFeedback.h:77:9`!, &scale, &local_norm);
2581 }
2582
2583 if (weapon_index != -1) {
2584 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Force from weapon\n");
2585 }
2586
2587 // mprintf(0,"Force: Magnitude = %f Scale = %1.3f\n",magnitude,scale);
2588 }
2589 //------------------------------
2590
2591 // Add in acceleration due to force
2592 obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..velocitycxx . . $ physics_info#velocity. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). (*force_vec /cxx . . $ `operator/`(252247219a31502c). obj->mtypecxx . . $ object#mtype..phys_infocxx . . $ object#$anonymous_type_8#phys_info..masscxx . . $ physics_info#mass.);
2593 }
2594
2595 void phys_apply_rotcxx . . $ phys_apply_rot(835e87111e401cce).(objectcxx . . $ object# *obj, vectorcxx . . $ vector# *force_vec) {}