-improved one-way collision handling in both dynamic and character bodies for 2D, fixes #1854

This commit is contained in:
Juan Linietsky
2015-05-10 19:24:09 -03:00
parent a2b8b92a6e
commit 32b1b472af
3 changed files with 19 additions and 4 deletions

View File

@ -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;
}