summaryrefslogtreecommitdiff
path: root/servers/physics_2d/space_2d_sw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d/space_2d_sw.cpp')
-rw-r--r--servers/physics_2d/space_2d_sw.cpp55
1 files changed, 17 insertions, 38 deletions
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index a17d1f6a12..9b2e586993 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "space_2d_sw.h"
+
#include "collision_solver_2d_sw.h"
#include "physics_2d_server_sw.h"
@@ -532,11 +533,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
cbk.amount = 0;
cbk.ptr = sr;
- CollisionSolver2DSW::CallbackResult cbkres = NULL;
-
- Physics2DServerSW::CollCbkData *cbkptr = NULL;
- cbkptr = &cbk;
- cbkres = Physics2DServerSW::_shape_col_cbk;
+ Physics2DServerSW::CollCbkData *cbkptr = &cbk;
+ CollisionSolver2DSW::CallbackResult cbkres = Physics2DServerSW::_shape_col_cbk;
bool collided = false;
@@ -578,21 +576,6 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
Vector2 a = sr[i * 2 + 0];
Vector2 b = sr[i * 2 + 1];
-
-#if 0
- Vector2 rel = b-a;
- real_t d = rel.length();
- if (d==0)
- continue;
-
- Vector2 n = rel/d;
- real_t traveled = n.dot(recover_motion);
- a+=n*traveled;
-
- real_t d = a.distance_to(b);
- if (d<margin)
- continue;
-#endif
recover_motion += (b - a) * 0.4;
}
@@ -678,25 +661,21 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
}
}
- if (col_obj->get_type() == CollisionObject2DSW::TYPE_BODY) {
+ if (col_obj->is_shape_set_as_one_way_collision(j)) {
- const Body2DSW *body = static_cast<const Body2DSW *>(col_obj);
- if (col_obj->is_shape_set_as_one_way_collision(j)) {
+ Vector2 cd[2];
+ Physics2DServerSW::CollCbkData cbk;
+ cbk.max = 1;
+ cbk.amount = 0;
+ cbk.ptr = cd;
+ cbk.valid_dir = body_shape_xform.get_axis(1).normalized();
+ ;
+ cbk.valid_depth = 10e20;
- Vector2 cd[2];
- Physics2DServerSW::CollCbkData cbk;
- cbk.max = 1;
- cbk.amount = 0;
- cbk.ptr = cd;
- cbk.valid_dir = body_shape_xform.get_axis(1).normalized();
- ;
- cbk.valid_depth = 10e20;
-
- Vector2 sep = mnormal; //important optimization for this to work fast enough
- bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0);
- if (!collided || cbk.amount == 0) {
- continue;
- }
+ Vector2 sep = mnormal; //important optimization for this to work fast enough
+ bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0);
+ if (!collided || cbk.amount == 0) {
+ continue;
}
}