Skip to content
This repository has been archived by the owner on Jun 29, 2024. It is now read-only.

Commit

Permalink
Fix collide to work correctly (#94)
Browse files Browse the repository at this point in the history
* try a fix for disable collision joint

* Update godot-cpp

* fix iterator issue for shape_collide

* do contacts for release build too if debug
  • Loading branch information
Ughuuu authored Dec 26, 2023
1 parent bdbb72f commit 301ee56
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion box2d
2 changes: 1 addition & 1 deletion godot-cpp
6 changes: 1 addition & 5 deletions src/bodies/box2d_body_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,9 @@ void Box2DBody2D::_init_collider(box2d::FixtureHandle collider_handle) const {

// Send contact infos for dynamic bodies
if (mode >= PhysicsServer2D::BODY_MODE_KINEMATIC) {
#ifdef DEBUG_ENABLED
// Always send contacts in case debug contacts is enabled
bool send_contacts = true;
#else
// Only send contacts if contact monitor is enabled
bool send_contacts = can_report_contacts();
#endif
// TODO set contacts callback only if needed
//box2d::collider_set_contact_force_events_enabled(space_handle, collider_handle, send_contacts);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/box2d-wrapper/box2d_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ bool box2d::is_handle_valid(b2Joint *handle) {

void box2d::joint_set_disable_collision(b2Joint *joint_handle,
bool disable_collision) {
joint_handle->SetCollideConnected(!disable_collision);
}

void box2d::joint_change_revolute_params(b2World *world_handle,
Expand Down Expand Up @@ -979,7 +980,7 @@ ShapeCollideResult box2d::shape_collide(const b2Vec2 motion1,
transformA,
b2Vec2_zero,
motion1,
shape_info2.handle.handles[i],
shape_info2.handle.handles[j],
transformB,
b2Vec2_zero,
motion2);
Expand Down
1 change: 0 additions & 1 deletion src/joints/box2d_joint_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void Box2DJoint2D::copy_settings_from(Box2DJoint2D *p_joint) {
set_max_force(p_joint->get_max_force());
set_bias(p_joint->get_bias());
set_max_bias(p_joint->get_max_bias());
disable_collisions_between_bodies(p_joint->is_disabled_collisions_between_bodies());
}

void Box2DJoint2D::disable_collisions_between_bodies(const bool p_disabled) {
Expand Down
4 changes: 0 additions & 4 deletions src/spaces/box2d_space_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,9 @@ bool Box2DSpace2D::contact_force_event_callback(b2World *world_handle, const box

bool send_contacts = false;

#ifdef DEBUG_ENABLED
if (space->is_debugging_contacts()) {
send_contacts = true;
}
#endif

uint32_t shape1 = 0;
Box2DCollisionObject2D *pObject1 = nullptr;
Expand Down Expand Up @@ -440,13 +438,11 @@ bool Box2DSpace2D::contact_point_callback(b2World *world_handle, const box2d::Co

bool keep_sending_contacts = false;

#ifdef DEBUG_ENABLED
if (space->is_debugging_contacts()) {
keep_sending_contacts = true;
space->add_debug_contact(pos1);
space->add_debug_contact(pos2);
}
#endif
// body and shape 1
uint32_t shape1 = 0;
Box2DCollisionObject2D *pObject1 = nullptr;
Expand Down

0 comments on commit 301ee56

Please sign in to comment.