diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/physics/shape_sw.cpp | 10 | ||||
-rw-r--r-- | servers/physics_2d/collision_solver_2d_sat.cpp | 19 |
2 files changed, 11 insertions, 18 deletions
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 8a52f29729..f01caefdce 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -543,16 +543,6 @@ void CapsuleShapeSW::project_range(const Vector3 &p_normal, const Transform &p_t r_max = p_normal.dot(p_transform.xform(n)); r_min = p_normal.dot(p_transform.xform(-n)); - return; - - n = p_transform.basis.xform(n); - - real_t distance = p_normal.dot(p_transform.origin); - real_t length = Math::abs(p_normal.dot(n)); - r_min = distance - length; - r_max = distance + length; - - ERR_FAIL_COND(r_max < r_min); } Vector3 CapsuleShapeSW::get_support(const Vector3 &p_normal) const { diff --git a/servers/physics_2d/collision_solver_2d_sat.cpp b/servers/physics_2d/collision_solver_2d_sat.cpp index f4bff66389..9d75f71ff0 100644 --- a/servers/physics_2d/collision_solver_2d_sat.cpp +++ b/servers/physics_2d/collision_solver_2d_sat.cpp @@ -313,10 +313,12 @@ public: if (best_axis == Vector2(0.0, 0.0)) return; - callback->collided = true; + if (callback) { + callback->collided = true; - if (!callback->callback) - return; //only collide, no callback + if (!callback->callback) + return; //only collide, no callback + } static const int max_supports = 2; Vector2 supports_A[max_supports]; @@ -354,12 +356,13 @@ public: supports_B[i] += best_axis * margin_B; } } + if (callback) { + callback->normal = best_axis; + _generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback); - callback->normal = best_axis; - _generate_contacts_from_supports(supports_A, support_count_A, supports_B, support_count_B, callback); - - if (callback && callback->sep_axis && *callback->sep_axis != Vector2()) - *callback->sep_axis = Vector2(); //invalidate previous axis (no test) + if (callback->sep_axis && *callback->sep_axis != Vector2()) + *callback->sep_axis = Vector2(); //invalidate previous axis (no test) + } } _FORCE_INLINE_ SeparatorAxisTest2D(const ShapeA *p_shape_A, const Transform2D &p_transform_a, const ShapeB *p_shape_B, const Transform2D &p_transform_b, _CollectorCallback2D *p_collector, const Vector2 &p_motion_A = Vector2(), const Vector2 &p_motion_B = Vector2(), real_t p_margin_A = 0, real_t p_margin_B = 0) { |