From 67ae443132d0aff54e9f1fa161759aaba1fcacc9 Mon Sep 17 00:00:00 2001 From: Dragos Daian Date: Mon, 6 Nov 2023 15:16:20 +0100 Subject: [PATCH] upd fetch depth --- .github/workflows/android_builds.yml | 1 + .github/workflows/ios_builds.yml | 1 + .github/workflows/linux_builds.yml | 1 + .github/workflows/macos_builds.yml | 1 + .github/workflows/web_builds.yml | 1 + .github/workflows/windows_builds.yml | 1 + SConstruct | 1 - src/box2d-wrapper/box2d_wrapper.h | 2 -- src/spaces/box2d_space_2d.cpp | 24 +++++++++++++++++------- 9 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/workflows/android_builds.yml b/.github/workflows/android_builds.yml index 7fa735f..c5b67e3 100644 --- a/.github/workflows/android_builds.yml +++ b/.github/workflows/android_builds.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Set up Java 11 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/ios_builds.yml b/.github/workflows/ios_builds.yml index 698cd44..a470d91 100644 --- a/.github/workflows/ios_builds.yml +++ b/.github/workflows/ios_builds.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Build ${{ matrix.arch }} uses: ./.github/actions/build with: diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index b324800..1ce1013 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Build ${{ matrix.arch }} uses: ./.github/actions/build diff --git a/.github/workflows/macos_builds.yml b/.github/workflows/macos_builds.yml index 6039f2f..d7a8ee0 100644 --- a/.github/workflows/macos_builds.yml +++ b/.github/workflows/macos_builds.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Build ${{ matrix.arch }} uses: ./.github/actions/build diff --git a/.github/workflows/web_builds.yml b/.github/workflows/web_builds.yml index 14324ff..4dc6cfa 100644 --- a/.github/workflows/web_builds.yml +++ b/.github/workflows/web_builds.yml @@ -20,6 +20,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Set up Emscripten latest uses: mymindstorm/setup-emsdk@v12 diff --git a/.github/workflows/windows_builds.yml b/.github/workflows/windows_builds.yml index 500a7f0..36014c4 100644 --- a/.github/workflows/windows_builds.yml +++ b/.github/workflows/windows_builds.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - name: Setup MSVC problem matcher uses: ammaraskar/msvc-problem-matcher@master diff --git a/SConstruct b/SConstruct index 67be7e4..fae82cc 100644 --- a/SConstruct +++ b/SConstruct @@ -3,7 +3,6 @@ import os import sys env = SConscript("godot-cpp/SConstruct") - box2d_folder = "box2d/" box2d_include = [ "include/", diff --git a/src/box2d-wrapper/box2d_wrapper.h b/src/box2d-wrapper/box2d_wrapper.h index 59a845a..8913662 100644 --- a/src/box2d-wrapper/box2d_wrapper.h +++ b/src/box2d-wrapper/box2d_wrapper.h @@ -442,8 +442,6 @@ size_t world_get_active_objects_count(b2World *world_handle); void world_set_active_body_callback(b2World *world_handle, ActiveBodyCallback callback); -void world_set_collision_event_callback(b2World *world_handle, CollisionEventCallback callback); - void world_set_collision_filter_callback(b2World *world_handle, b2ContactFilter *callback); diff --git a/src/spaces/box2d_space_2d.cpp b/src/spaces/box2d_space_2d.cpp index d5e5954..c3a2ced 100644 --- a/src/spaces/box2d_space_2d.cpp +++ b/src/spaces/box2d_space_2d.cpp @@ -121,6 +121,7 @@ bool Box2DSpace2D::ShouldCollide(b2Fixture *fixtureA, b2Fixture *fixtureB) { } box2d::CollisionEventInfo event_info_from_contact(b2Contact *contact) { box2d::CollisionEventInfo event_info; + event_info.is_sensor = false; event_info.is_valid = false; event_info.collider1 = contact->GetFixtureA(); event_info.collider2 = contact->GetFixtureB(); @@ -131,7 +132,7 @@ box2d::CollisionEventInfo event_info_from_contact(b2Contact *contact) { ERR_FAIL_COND_V(!box2d::is_user_data_valid(event_info.user_data1), event_info); ERR_FAIL_COND_V(!box2d::is_user_data_valid(event_info.user_data2), event_info); event_info.is_sensor = event_info.collider1->IsSensor() || event_info.collider2->IsSensor(); - event_info.is_valid = true; + event_info.is_valid = event_info.is_sensor; return event_info; } box2d::CollisionFilterInfo filter_info_from_contact(b2Contact *contact) { @@ -162,20 +163,26 @@ box2d::ContactForceEventInfo force_info_from_contact(b2Contact *contact) { } void Box2DSpace2D::BeginContact(b2Contact *contact) { box2d::CollisionEventInfo event_info = event_info_from_contact(contact); - ERR_FAIL_COND(!event_info.is_valid); + if (!event_info.is_valid) { + return; + } event_info.is_started = true; collision_event_callback(handle, &event_info); } void Box2DSpace2D::EndContact(b2Contact *contact) { box2d::CollisionEventInfo event_info = event_info_from_contact(contact); - ERR_FAIL_COND(!event_info.is_valid); + if (!event_info.is_valid) { + return; + } event_info.is_started = false; collision_event_callback(handle, &event_info); } void Box2DSpace2D::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) { box2d::CollisionFilterInfo filter_info = filter_info_from_contact(contact); - ERR_FAIL_COND(!filter_info.is_valid); + if (!filter_info.is_valid) { + return; + } box2d::OneWayDirection one_way_dir = collision_modify_contacts_callback(handle, &filter_info); Transform2D transform_a = box2d::collider_get_transform(handle, contact->GetFixtureA()); Transform2D transform_b = box2d::collider_get_transform(handle, contact->GetFixtureA()); @@ -211,7 +218,9 @@ void Box2DSpace2D::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) { } void Box2DSpace2D::PostSolve(b2Contact *contact, const b2ContactImpulse *impulse) { box2d::ContactForceEventInfo force_info = force_info_from_contact(contact); - ERR_FAIL_COND(!force_info.is_valid); + if (!force_info.is_valid) { + return; + } bool send_contacts = contact_force_event_callback(handle, &force_info); if (send_contacts) { box2d::ContactPointInfo point_info; @@ -225,8 +234,8 @@ void Box2DSpace2D::PostSolve(b2Contact *contact, const b2ContactImpulse *impulse point_info.impulse_2 = impulse->normalImpulses[1]; point_info.tangent_impulse_1 = impulse->tangentImpulses[0]; point_info.tangent_impulse_2 = impulse->tangentImpulses[1]; - point_info.local_pos_1 = contact->GetManifold()->points[0].localPoint; - point_info.local_pos_2 = contact->GetManifold()->points[1].localPoint; + point_info.local_pos_1 = worldManifold.points[0]; + point_info.local_pos_2 = worldManifold.points[1]; point_info.velocity_pos_1 = contact->GetFixtureA()->GetBody()->GetLinearVelocityFromLocalPoint(point_info.local_pos_1); point_info.velocity_pos_2 = contact->GetFixtureB()->GetBody()->GetLinearVelocityFromLocalPoint(point_info.local_pos_2); contact_point_callback(handle, &point_info, &force_info); @@ -759,6 +768,7 @@ Box2DSpace2D::Box2DSpace2D() { box2d::world_set_active_body_callback(handle, active_body_callback); box2d::world_set_collision_filter_callback(handle, this); + box2d::world_set_contact_listener(handle, this); } Box2DSpace2D::~Box2DSpace2D() {