diff options
author | Juan Linietsky <juan@godotengine.org> | 2018-11-02 15:44:29 -0300 |
---|---|---|
committer | Juan Linietsky <juan@godotengine.org> | 2018-11-02 15:45:36 -0300 |
commit | 64f649a80c0261c651f94c983e31d043b87b4ce8 (patch) | |
tree | 3775111f93109e09456ff4e1bf41c163baf2b239 /servers/physics | |
parent | 03563c8ddf748b73c6bef962f14e0e41eac45447 (diff) |
-Fix problem in OWC logic closes #11357
-Fix problem with kinematic move and disabled shapes, in both 2D and 3D
Diffstat (limited to 'servers/physics')
-rw-r--r-- | servers/physics/space_sw.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index feb96d8054..3b5344f020 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -544,14 +544,24 @@ int SpaceSW::test_body_ray_separation(BodySW *p_body, const Transform &p_transfo AABB body_aabb; + bool shapes_found = false; + for (int i = 0; i < p_body->get_shape_count(); i++) { - if (i == 0) + if (p_body->is_shape_set_as_disabled(i)) + continue; + + if (!shapes_found) { body_aabb = p_body->get_shape_aabb(i); - else + shapes_found = true; + } else { body_aabb = body_aabb.merge(p_body->get_shape_aabb(i)); + } } + if (!shapes_found) { + return 0; + } // Undo the currently transform the physics server is aware of and apply the provided one body_aabb = p_transform.xform(p_body->get_inv_transform().xform(body_aabb)); body_aabb = body_aabb.grow(p_margin); @@ -691,13 +701,23 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve r_result->collider_shape = 0; } AABB body_aabb; + bool shapes_found = false; for (int i = 0; i < p_body->get_shape_count(); i++) { - if (i == 0) + if (p_body->is_shape_set_as_disabled(i)) + continue; + + if (!shapes_found) { body_aabb = p_body->get_shape_aabb(i); - else + shapes_found = true; + } else { body_aabb = body_aabb.merge(p_body->get_shape_aabb(i)); + } + } + + if (!shapes_found) { + return false; } // Undo the currently transform the physics server is aware of and apply the provided one |