summaryrefslogtreecommitdiff
path: root/servers/physics
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2015-11-22 14:14:07 +0100
committerRémi Verschelde <rverschelde@gmail.com>2015-11-22 14:14:07 +0100
commitf33d9dab5bf05356f9a2c882537e83390a710e0b (patch)
tree824443d9ea9d1791a2b5cd0c7adc594b581e4dce /servers/physics
parentbcf4aded9a2af5f9ab48f7f279ee2032d0833f16 (diff)
Fix can_move_to and rename it for more clarity
Fixes #2416. The KinematicBody::can_move_to function was likely designed for two behaviours: - discrete: check if the body can "teleport" to the destination - continuous: check if the direct path to the destination is valid The continuous behaviour was however not implemented, and the discrete behaviour was broken too due to a wrong call to intersect_shape. The discrete behaviour has thus been fixed and the function renamed to can_teleport_to for more clarity.
Diffstat (limited to 'servers/physics')
-rw-r--r--servers/physics/space_sw.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index ba1c737530..4b59f2d0ba 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -175,6 +175,10 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transfo
if (!CollisionSolverSW::solve_static(shape,p_xform,col_obj->get_shape(shape_idx),col_obj->get_transform() * col_obj->get_shape_transform(shape_idx), NULL,NULL,NULL,p_margin,0))
continue;
+ cc++;
+
+ if (!r_results)
+ continue;
r_results[cc].collider_id=col_obj->get_instance_id();
if (r_results[cc].collider_id!=0)
r_results[cc].collider=ObjectDB::get_instance(r_results[cc].collider_id);
@@ -183,8 +187,6 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID& p_shape, const Transfo
r_results[cc].rid=col_obj->get_self();
r_results[cc].shape=shape_idx;
- cc++;
-
}
return cc;