| 56 | float STestFootCallbackPars::max_real_depth = 0.2f; |
| 57 | template <class Pars> |
| 58 | void TTestDepthCallback(bool& do_colide, bool bo1, dContact& c, SGameMtl* material_1, SGameMtl* material_2) |
| 59 | { |
| 60 | if (saved_callback) |
| 61 | saved_callback(do_colide, bo1, c, material_1, material_2); |
| 62 | |
| 63 | if (do_colide && !material_1->Flags.test(SGameMtl::flPassable) && !material_2->Flags.test(SGameMtl::flPassable)) |
| 64 | { |
| 65 | float& depth = c.geom.depth; |
| 66 | float test_depth = depth - Pars::decrement_depth; |
| 67 | save_max(max_depth, test_depth); |
| 68 | c.surface.mu *= Pars::calback_friction_factor; |
| 69 | if (test_depth > Pars::depth_to_use_force) |
| 70 | { |
| 71 | float force = Pars::callback_force_factor * ph_world->Gravity(); |
| 72 | dBodyID b1 = dGeomGetBody(c.geom.g1); |
| 73 | dBodyID b2 = dGeomGetBody(c.geom.g2); |
| 74 | if (b1) |
| 75 | dBodyAddForce(b1, c.geom.normal[0] * force, c.geom.normal[1] * force, c.geom.normal[2] * force); |
| 76 | if (b2) |
| 77 | dBodyAddForce(b2, -c.geom.normal[0] * force, -c.geom.normal[1] * force, -c.geom.normal[2] * force); |
| 78 | dxGeomUserData* ud1 = retrieveGeomUserData(c.geom.g1); |
| 79 | dxGeomUserData* ud2 = retrieveGeomUserData(c.geom.g2); |
| 80 | |
| 81 | if (ud1) |
| 82 | { |
| 83 | CPhysicsShell* phsl = ud1->ph_ref_object->PPhysicsShell(); |
| 84 | if (phsl) |
| 85 | phsl->Enable(); |
| 86 | } |
| 87 | |
| 88 | if (ud2) |
| 89 | { |
| 90 | CPhysicsShell* phsl = ud2->ph_ref_object->PPhysicsShell(); |
| 91 | if (phsl) |
| 92 | phsl->Enable(); |
| 93 | } |
| 94 | |
| 95 | do_colide = false; |
| 96 | } |
| 97 | else if (test_depth > Pars::depth_to_change_softness_pars) |
| 98 | { |
| 99 | c.surface.soft_cfm = Pars::callback_cfm_factor; |
| 100 | c.surface.soft_erp = Pars::callback_erp_factor; |
| 101 | } |
| 102 | limit_above(depth, Pars::max_real_depth); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | ObjectContactCallbackFun* TestDepthCallback = &TTestDepthCallback<STestCallbackPars>; |
| 107 | ObjectContactCallbackFun* TestFootDepthCallback = &TTestDepthCallback<STestFootCallbackPars>; |
nothing calls this directly
no test coverage detected