diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-05-10 19:24:09 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-05-10 19:24:09 -0300 |
commit | 32b1b472af379b3ea3b155a38158f08aed1e92e1 (patch) | |
tree | 83afb6fc024c1c951704e66bc3fabed57c24cb5e /servers/physics_2d/body_pair_2d_sw.cpp | |
parent | a2b8b92a6e8f9bf49c437eaa4b638f7e51b87161 (diff) |
-improved one-way collision handling in both dynamic and character bodies for 2D, fixes #1854
Diffstat (limited to 'servers/physics_2d/body_pair_2d_sw.cpp')
-rw-r--r-- | servers/physics_2d/body_pair_2d_sw.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index e8d37d346a..6bfed134e6 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -265,7 +265,7 @@ bool BodyPair2DSW::setup(float p_step) { } //faster to set than to check.. - bool prev_collided=collided; + //bool prev_collided=collided; collided = CollisionSolver2DSW::solve(shape_A_ptr,xform_A,motion_A,shape_B_ptr,xform_B,motion_B,_add_contact,this,&sep_axis); if (!collided) { @@ -282,12 +282,18 @@ bool BodyPair2DSW::setup(float p_step) { collided=true; } - if (!collided) + if (!collided) { + oneway_disabled=false; return false; + } } - if (!prev_collided) { + if (oneway_disabled) + return false; + + //if (!prev_collided) { + { if (A->is_using_one_way_collision()) { Vector2 direction = A->get_one_way_collision_direction(); @@ -309,6 +315,7 @@ bool BodyPair2DSW::setup(float p_step) { if (!valid) { collided=false; + oneway_disabled=true; return false; } } @@ -333,6 +340,7 @@ bool BodyPair2DSW::setup(float p_step) { } if (!valid) { collided=false; + oneway_disabled=true; return false; } } @@ -525,6 +533,7 @@ BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A,Body2DSW *p_B, int p_sha B->add_constraint(this,1); contact_count=0; collided=false; + oneway_disabled=false; } |