| 21 | m_forced_physics_control = false; //. |
| 22 | } |
| 23 | bool CPHAICharacter::TryPosition(Fvector pos, bool exact_state) |
| 24 | { |
| 25 | if (!b_exist) |
| 26 | return false; |
| 27 | if (m_forced_physics_control || JumpState()) |
| 28 | return false; // b_was_on_object||b_on_object|| |
| 29 | if (DoCollideObj()) |
| 30 | return false; |
| 31 | Fvector current_pos; |
| 32 | GetPosition(current_pos); |
| 33 | Fvector cur_vel; |
| 34 | GetVelocity(cur_vel); |
| 35 | |
| 36 | Fvector displace; |
| 37 | displace.sub(pos, current_pos); |
| 38 | float disp_mag = displace.magnitude(); |
| 39 | |
| 40 | if (fis_zero(disp_mag) || fis_zero(Device.fTimeDelta)) |
| 41 | return true; |
| 42 | const u32 max_steps = 15; |
| 43 | const float fmax_steps = float(max_steps); |
| 44 | float fsteps_num = 1.f; |
| 45 | u32 steps_num = 1; |
| 46 | float disp_pstep = FootRadius(); |
| 47 | float rest = 0.f; |
| 48 | |
| 49 | float parts = disp_mag / disp_pstep; |
| 50 | fsteps_num = floor(parts); |
| 51 | steps_num = iFloor(parts); |
| 52 | if (steps_num > max_steps) |
| 53 | { |
| 54 | steps_num = max_steps; |
| 55 | fsteps_num = fmax_steps; |
| 56 | disp_pstep = disp_mag / fsteps_num; |
| 57 | } |
| 58 | rest = disp_mag - fsteps_num * disp_pstep; |
| 59 | |
| 60 | Fvector vel; |
| 61 | vel.mul(displace, disp_pstep / fixed_step / disp_mag); |
| 62 | bool ret = true; |
| 63 | int save_gm = dBodyGetGravityMode(m_body); |
| 64 | dBodySetGravityMode(m_body, 0); |
| 65 | for (u32 i = 0; steps_num > i; ++i) |
| 66 | { |
| 67 | SetVelocity(vel); |
| 68 | Enable(); |
| 69 | if (!step_single(fixed_step)) |
| 70 | { |
| 71 | SetVelocity(cur_vel); |
| 72 | ret = false; |
| 73 | break; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | vel.mul(displace, rest / fixed_step / disp_mag); |
| 78 | SetVelocity(vel); |
| 79 | Enable(); |
| 80 | ret = step_single(fixed_step); |
no test coverage detected