From f2d615cdc7bbb52ee2462eff824cfd559343a282 Mon Sep 17 00:00:00 2001 From: Mikael Hermansson Date: Tue, 6 Feb 2024 14:23:08 +0100 Subject: Fix contact count sometimes being incorrect in `_process` --- scene/3d/physics_body_3d.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scene/3d/physics_body_3d.cpp') diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index 7d08d767c7..67a7f76d7d 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) { -- cgit v1.2.3