Browse Source

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

Juan Linietsky 6 years ago
parent
commit
87b303aa95
2 changed files with 11 additions and 3 deletions
  1. 0 3
      scene/2d/physics_body_2d.cpp
  2. 11 0
      servers/physics_2d/space_2d_sw.cpp

+ 0 - 3
scene/2d/physics_body_2d.cpp

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

+ 11 - 0
servers/physics_2d/space_2d_sw.cpp

@@ -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))
 			continue;
 
+		if (p_body->get_shape(i)->get_type() != Physics2DServer::SHAPE_RAY)
+			continue;
+
 		if (!shapes_found) {
 			body_aabb = p_body->get_shape_aabb(i);
 			shapes_found = true;
@@ -632,6 +635,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
 						}
 
 						if (ray_index != -1) {
+
 							Physics2DServer::SeparationResult &result = r_results[ray_index];
 
 							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))
 			continue;
 
+		if (p_exclude_raycast_shapes && p_body->get_shape(i)->get_type() == Physics2DServer::SHAPE_RAY)
+			continue;
+
 		if (!shapes_found) {
 			body_aabb = p_body->get_shape_aabb(i);
 			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);
 			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;
 
 			int amount = _cull_aabb_for_body(p_body, body_aabb);