| 290 | ///////////////////////////////////////////////////////////////////////////////////// |
| 291 | |
| 292 | bool 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); |
no test coverage detected