Fixed bugs in test body motion and removed unnecesary test in move_and_slide. Fixes #25968

This commit is contained in:
Juan Linietsky 2019-02-21 17:20:44 -03:00
parent a01dca79e2
commit 87b303aa95
2 changed files with 11 additions and 3 deletions

View File

@ -1309,9 +1309,6 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const
motion = motion.slide(n); motion = motion.slide(n);
lv = lv.slide(n); lv = lv.slide(n);
} }
if (p_stop_on_slope)
break;
} }
if (!found_collision) { if (!found_collision) {

View File

@ -518,6 +518,9 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
if (p_body->is_shape_set_as_disabled(i)) if (p_body->is_shape_set_as_disabled(i))
continue; continue;
if (p_body->get_shape(i)->get_type() != Physics2DServer::SHAPE_RAY)
continue;
if (!shapes_found) { if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i); body_aabb = p_body->get_shape_aabb(i);
shapes_found = true; shapes_found = true;
@ -632,6 +635,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
} }
if (ray_index != -1) { if (ray_index != -1) {
Physics2DServer::SeparationResult &result = r_results[ray_index]; Physics2DServer::SeparationResult &result = r_results[ray_index];
for (int k = 0; k < cbk.amount; k++) { for (int k = 0; k < cbk.amount; k++) {
@ -709,6 +713,9 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (p_body->is_shape_set_as_disabled(i)) if (p_body->is_shape_set_as_disabled(i))
continue; continue;
if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == Physics2DServer::SHAPE_RAY)
continue;
if (!shapes_found) { if (!shapes_found) {
body_aabb = p_body->get_shape_aabb(i); body_aabb = p_body->get_shape_aabb(i);
shapes_found = true; shapes_found = true;
@ -1031,6 +1038,10 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j); Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j);
Shape2DSW *body_shape = p_body->get_shape(j); Shape2DSW *body_shape = p_body->get_shape(j);
if (p_exclude_raycast_shapes && body_shape->get_type() == Physics2DServer::SHAPE_RAY) {
continue;
}
body_aabb.position += p_motion * unsafe; body_aabb.position += p_motion * unsafe;
int amount = _cull_aabb_for_body(p_body, body_aabb); int amount = _cull_aabb_for_body(p_body, body_aabb);