Skip to content

Commit

Permalink
Implement Godot physics RayShape against plane collisions.
Browse files Browse the repository at this point in the history
  • Loading branch information
madmiraal committed Mar 6, 2021
1 parent 502a0f8 commit 18532e6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions servers/physics/collision_solver_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ bool CollisionSolverSW::solve_static_plane(const ShapeSW *p_shape_A, const Trans
found = true;

Vector3 support_A = p.project(supports[i]);
if (p_shape_B->get_type() == PhysicsServer::SHAPE_RAY) {
const RayShapeSW *ray = static_cast<const RayShapeSW *>(p_shape_B);
if (!ray->get_slips_on_slope()) {
plane->get_plane().intersects_ray(p_transform_B.origin, p_transform_B.basis.get_axis(2), &support_A);
}
}

if (p_result_callback) {
if (p_swap_result)
Expand Down Expand Up @@ -215,9 +221,6 @@ bool CollisionSolverSW::solve_static(const ShapeSW *p_shape_A, const Transform &

if (type_B == PhysicsServer::SHAPE_PLANE)
return false;
if (type_B == PhysicsServer::SHAPE_RAY) {
return false;
}

if (swap) {
return solve_static_plane(p_shape_B, p_transform_B, p_shape_A, p_transform_A, p_result_callback, p_userdata, true);
Expand Down

0 comments on commit 18532e6

Please sign in to comment.