|
@@ -73,14 +73,14 @@ bool CollisionSolver2DSW::solve_static_line(const Shape2DSW *p_shape_A, const Tr
|
|
|
return found;
|
|
|
}
|
|
|
|
|
|
-bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis) {
|
|
|
+bool CollisionSolver2DSW::solve_raycast(const Shape2DSW *p_shape_A, const Vector2 &p_motion_A, const Transform2D &p_transform_A, const Shape2DSW *p_shape_B, const Transform2D &p_transform_B, CallbackResult p_result_callback, void *p_userdata, bool p_swap_result, Vector2 *sep_axis, real_t p_margin) {
|
|
|
const RayShape2DSW *ray = static_cast<const RayShape2DSW *>(p_shape_A);
|
|
|
if (p_shape_B->get_type() == Physics2DServer::SHAPE_RAY) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
Vector2 from = p_transform_A.get_origin();
|
|
|
- Vector2 to = from + p_transform_A[1] * ray->get_length();
|
|
|
+ Vector2 to = from + p_transform_A[1] * (ray->get_length() + p_margin);
|
|
|
if (p_motion_A != Vector2()) {
|
|
|
//not the best but should be enough
|
|
|
Vector2 normal = (to - from).normalized();
|
|
@@ -226,9 +226,9 @@ bool CollisionSolver2DSW::solve(const Shape2DSW *p_shape_A, const Transform2D &p
|
|
|
}
|
|
|
|
|
|
if (swap) {
|
|
|
- return solve_raycast(p_shape_B, p_motion_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true, sep_axis);
|
|
|
+ return solve_raycast(p_shape_B, p_motion_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true, sep_axis, p_margin_B);
|
|
|
} else {
|
|
|
- return solve_raycast(p_shape_A, p_motion_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, sep_axis);
|
|
|
+ return solve_raycast(p_shape_A, p_motion_A, p_transform_A, p_shape_B, p_transform_B, p_result_callback, p_userdata, false, sep_axis, p_margin_A);
|
|
|
}
|
|
|
|
|
|
} else if (concave_B) {
|