MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / ExplosionEffect

Method ExplosionEffect

ogsr_engine/xrGame/Explosive.cpp:206–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206float CExplosive::ExplosionEffect(collide::rq_results& storage, CExplosive* exp_obj, CPhysicsShellHolder* blasted_obj, const Fvector& expl_centre, const float expl_radius)
207{
208 const Fmatrix& obj_xform = blasted_obj->XFORM();
209 Fmatrix inv_obj_form;
210 inv_obj_form.invert(obj_xform);
211 Fvector local_exp_center;
212 inv_obj_form.transform_tiny(local_exp_center, expl_centre);
213
214 const Fbox& l_b1 = blasted_obj->BoundingBox();
215 if (l_b1.contains(local_exp_center))
216 return 1.f;
217 Fvector l_c, l_d;
218 l_b1.get_CD(l_c, l_d);
219 float effective_volume = l_d.x * l_d.y * l_d.z;
220 float max_s = effective_volume / (_min(_min(l_d.x, l_d.y), l_d.z));
221 if (blasted_obj->PPhysicsShell() && blasted_obj->PPhysicsShell()->isActive())
222 {
223 float ph_volume = blasted_obj->PPhysicsShell()->getVolume();
224 if (ph_volume < effective_volume)
225 effective_volume = ph_volume;
226 }
227 float effect = 0.f;
228#ifdef DEBUG
229 if (ph_dbg_draw_mask.test(phDbgDrawExplosions))
230 {
231 Fmatrix dbg_box_m;
232 dbg_box_m.set(obj_xform);
233 dbg_box_m.c.set(l_c);
234 obj_xform.transform(dbg_box_m.c);
235 DBG_DrawOBB(dbg_box_m, l_d, D3DCOLOR_XRGB(255, 255, 0));
236 }
237#endif
238
239 for (u16 i = 0; i < TEST_RAYS_PER_OBJECT; ++i)
240 {
241 Fvector l_source_p, l_end_p;
242 l_end_p.random_point(l_d);
243 l_end_p.add(l_c);
244 obj_xform.transform_tiny(l_end_p);
245 GetRaySourcePos(exp_obj, expl_centre, l_source_p);
246 Fvector l_local_source_p;
247 inv_obj_form.transform_tiny(l_local_source_p, l_source_p);
248 if (l_b1.contains(l_local_source_p))
249 {
250 effect += 1.f;
251 continue;
252 }
253 Fvector l_dir;
254 l_dir.sub(l_end_p, l_source_p);
255 float mag = l_dir.magnitude();
256
257 if (fis_zero(mag))
258 return 1.f;
259
260 l_dir.mul(1.f / mag);
261#ifdef DEBUG
262 if (ph_dbg_draw_mask.test(phDbgDrawExplosions))
263 {

Callers

nothing calls this directly

Calls 15

DBG_DrawOBBFunction · 0.85
fis_zeroFunction · 0.85
DBG_DrawPointFunction · 0.85
DBG_DrawLineFunction · 0.85
_sqrtFunction · 0.85
MsgFunction · 0.85
transform_tinyMethod · 0.80
get_CDMethod · 0.80
random_pointMethod · 0.80
_minFunction · 0.50
_absFunction · 0.50
invertMethod · 0.45

Tested by

no test coverage detected