diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-14 10:59:45 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-14 10:59:45 +0100 |
commit | ca733a4bf8856972ce4710a9c5958c5f19de1e09 (patch) | |
tree | b06293bd5efa5822b99f0849419d3fc5bac2206d /scene/3d | |
parent | 92951b0295822904f0d656f2d93ab81db4f0f507 (diff) | |
parent | f2d615cdc7bbb52ee2462eff824cfd559343a282 (diff) | |
download | redot-engine-ca733a4bf8856972ce4710a9c5958c5f19de1e09.tar.gz |
Merge pull request #88019 from mihe/wrong-contact-count
Fix `get_contact_count` sometimes being incorrect in `_process`
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/physics_body_3d.cpp | 6 | ||||
-rw-r--r-- | scene/3d/physics_body_3d.h | 1 |
2 files changed, 4 insertions, 3 deletions
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index d184aec2ab..2cbd484870 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -502,6 +502,8 @@ void RigidBody3D::_sync_body_state(PhysicsDirectBodyState3D *p_state) { inverse_inertia_tensor = p_state->get_inverse_inertia_tensor(); + contact_count = p_state->get_contact_count(); + if (sleeping != p_state->is_sleeping()) { sleeping = p_state->is_sleeping(); emit_signal(SceneStringNames::get_singleton()->sleeping_state_changed); @@ -877,9 +879,7 @@ int RigidBody3D::get_max_contacts_reported() const { } int RigidBody3D::get_contact_count() const { - PhysicsDirectBodyState3D *bs = PhysicsServer3D::get_singleton()->body_get_direct_state(get_rid()); - ERR_FAIL_NULL_V(bs, 0); - return bs->get_contact_count(); + return contact_count; } void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) { diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 63fec2c585..b360954263 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -177,6 +177,7 @@ private: bool ccd = false; int max_contacts_reported = 0; + int contact_count = 0; bool custom_integrator = false; |