Skip to content

Commit

Permalink
collide_shape: return contact points in world space
Browse files Browse the repository at this point in the history
  • Loading branch information
rburing committed Mar 24, 2022
1 parent a3a5b10 commit 1d16153
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/bullet/godot_result_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,13 @@ btScalar GodotContactPairContactResultCallback::addSingleResult(btManifoldPoint
return 1; // not used by bullet
}

// In each contact pair, the contact on the shape which was passed to collide_shape (where this callback is used) is put first.
if (m_self_object == colObj0Wrap->getCollisionObject()) {
B_TO_G(cp.m_localPointA, m_results[m_count * 2 + 0]); // Local contact
B_TO_G(cp.m_localPointB, m_results[m_count * 2 + 1]);
B_TO_G(cp.getPositionWorldOnA(), m_results[m_count * 2 + 0]);
B_TO_G(cp.getPositionWorldOnB(), m_results[m_count * 2 + 1]);
} else {
B_TO_G(cp.m_localPointB, m_results[m_count * 2 + 0]); // Local contact
B_TO_G(cp.m_localPointA, m_results[m_count * 2 + 1]);
B_TO_G(cp.getPositionWorldOnB(), m_results[m_count * 2 + 0]);
B_TO_G(cp.getPositionWorldOnA(), m_results[m_count * 2 + 1]);
}

++m_count;
Expand Down

0 comments on commit 1d16153

Please sign in to comment.