diff options
author | Ricardo Buring <ricardo.buring@gmail.com> | 2022-02-18 19:43:38 +0100 |
---|---|---|
committer | Ricardo Buring <ricardo.buring@gmail.com> | 2022-02-18 19:45:25 +0100 |
commit | d525ea2614b0f468835da005a68d62cc4a62b7e5 (patch) | |
tree | 479bda60a643f30aa8265e7aadaab20e00a50fec /servers/physics_2d | |
parent | 0217d44dfde8fcac90cc2f9c1f38a9b37042bb7e (diff) |
In final phase of test_body_motion, move and cull AABB for body once, instead of for every shape
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/godot_space_2d.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/servers/physics_2d/godot_space_2d.cpp b/servers/physics_2d/godot_space_2d.cpp index 5c2bda340b..68dac67d21 100644 --- a/servers/physics_2d/godot_space_2d.cpp +++ b/servers/physics_2d/godot_space_2d.cpp @@ -888,6 +888,9 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D:: // Allowed depth can't be lower than motion length, in order to handle contacts at low speed. rcd.min_allowed_depth = MIN(motion_length, min_contact_depth); + body_aabb.position += p_parameters.motion * unsafe; + int amount = _cull_aabb_for_body(p_body, body_aabb); + int from_shape = best_shape != -1 ? best_shape : 0; int to_shape = best_shape != -1 ? best_shape + 1 : p_body->get_shape_count(); @@ -899,10 +902,6 @@ bool GodotSpace2D::test_body_motion(GodotBody2D *p_body, const PhysicsServer2D:: Transform2D body_shape_xform = ugt * p_body->get_shape_transform(j); GodotShape2D *body_shape = p_body->get_shape(j); - body_aabb.position += p_parameters.motion * unsafe; - - int amount = _cull_aabb_for_body(p_body, body_aabb); - for (int i = 0; i < amount; i++) { const GodotCollisionObject2D *col_obj = intersection_query_results[i]; if (p_parameters.exclude_bodies.has(col_obj->get_self())) { |