Skip to content

Commit

Permalink
Fix OWC detection at Attempt Motion step
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergej Gureev committed Jul 24, 2020
1 parent 1977999 commit 0af1cb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 8 additions & 6 deletions servers/physics_2d/body_pair_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,12 @@ bool BodyPair2DSW::setup(real_t p_step) {
bool valid = false;
for (int i = 0; i < contact_count; i++) {
Contact &c = contacts[i];
if (!c.reused){
if (!c.reused) {
continue;
}
if (c.normal.dot(direction) > 0) { //greater (normal inverted)
continue;
}
if (c.normal.dot(direction) > 0) {//greater (normal inverted)
continue;}

valid = true;
break;
Expand All @@ -312,11 +313,12 @@ bool BodyPair2DSW::setup(real_t p_step) {
bool valid = false;
for (int i = 0; i < contact_count; i++) {
Contact &c = contacts[i];
if (!c.reused){
if (!c.reused) {
continue;
}
if (c.normal.dot(direction) < 0) { //less (normal ok)
continue;
}
if (c.normal.dot(direction) < 0) {//less (normal ok)
continue;}

valid = true;
break;
Expand Down
6 changes: 3 additions & 3 deletions servers/physics_2d/physics_server_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
return;
}

if (cbk->valid_dir != Vector2()) {
Vector2 rel_dir = (p_point_A - p_point_B).normalized();
if (cbk->valid_dir != Vector2() && rel_dir != Vector2() && cbk->valid_depth < 10e20) {
if (p_point_A.distance_squared_to(p_point_B) > cbk->valid_depth * cbk->valid_depth) {
cbk->invalid_by_dir++;
return;
}
Vector2 rel_dir = (p_point_A - p_point_B).normalized();

if (rel_dir != Vector2() && cbk->valid_dir.dot(rel_dir) <= 0) {
if (cbk->valid_dir.dot(rel_dir) <= 0) {
cbk->invalid_by_dir++;
return;
}
Expand Down

0 comments on commit 0af1cb7

Please sign in to comment.