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

Method ActivateBoxDynamic

ogsr_engine/xrGame/PHMovementDynamicActivate.cpp:292–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290/////////////////////////////////////////////////////////////////////////////////////
291
292bool CPHMovementControl::ActivateBoxDynamic(DWORD id, int num_it /*=8*/, int num_steps /*5*/, float resolve_depth /*=0.01f*/)
293{
294 bool character_exist = CharacterExist();
295 if (character_exist && trying_times[id] != u32(-1))
296 {
297 Fvector dif;
298 dif.sub(trying_poses[id], cast_fv(dBodyGetPosition(m_character->get_body()))); //-V595
299 if (Device.dwTimeGlobal - trying_times[id] < 500 && dif.magnitude() < 0.05f)
300 return false;
301 }
302 if (!m_character || m_character->PhysicsRefObject()->PPhysicsShell())
303 return false;
304 DWORD old_id = BoxID();
305
306 bool character_disabled = character_exist && !m_character->IsEnabled();
307 if (character_exist && id == old_id)
308 return true;
309
310 if (!character_exist)
311 {
312 CreateCharacter();
313 }
314
315 // m_PhysicMovementControl->ActivateBox(id);
316 m_character->CPHObject::activate();
317 ph_world->Freeze();
318 UnFreeze();
319
320 saved_callback = ObjectContactCallback();
321 SetOjectContactCallback(TestDepthCallback);
322 SetFootCallBack(TestFootDepthCallback);
323 max_depth = 0.f;
324
325 //////////////////////////////////pars///////////////////////////////////////////
326 // int num_it=8;
327 // int num_steps=5;
328 // float resolve_depth=0.01f;
329
330 if (!character_exist)
331 {
332 num_it = 20;
333 num_steps = 1;
334 resolve_depth = 0.1f;
335 }
336 ///////////////////////////////////////////////////////////////////////
337 float fnum_it = float(num_it);
338 float fnum_steps = float(num_steps);
339 float fnum_steps_r = 1.f / fnum_steps;
340
341 Fvector vel;
342 Fvector pos;
343 GetCharacterVelocity(vel);
344 GetCharacterPosition(pos);
345 // const Fbox& box =Box();
346 float pass = character_exist ? _abs(Box().getradius() - boxes[id].getradius()) : boxes[id].getradius();
347 float max_vel = pass / 2.f / fnum_it / fnum_steps / fixed_step;
348 float max_a_vel = M_PI / 8.f / fnum_it / fnum_steps / fixed_step;
349 dBodySetForce(GetBody(), 0.f, 0.f, 0.f);

Callers 3

g_cl_ValidateMStateMethod · 0.80
g_cl_CheckControlsMethod · 0.80
detach_VehicleMethod · 0.80

Calls 15

dBodyGetPositionFunction · 0.85
dBodySetForceFunction · 0.85
dBodySetLinearVelFunction · 0.85
dRSetIdentityFunction · 0.85
dBodySetAngularVelFunction · 0.85
dBodySetRotationFunction · 0.85
SwitchOFFInitContactMethod · 0.80
ApplyForceMethod · 0.80
MassMethod · 0.80
SwitchInInitContactMethod · 0.80
u32Enum · 0.70
_absFunction · 0.50

Tested by

no test coverage detected