From c4b55bda986d13410737c1d101004dd2f21b2b53 Mon Sep 17 00:00:00 2001 From: shameekganguly Date: Fri, 12 Jul 2024 11:16:30 -0700 Subject: [PATCH] =?UTF-8?q?Check=20if=20any=20entity=20actually=20has=20a?= =?UTF-8?q?=20ContactSensorData=20component=20before=E2=80=A6=20(#2474)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Shameek Ganguly --- src/systems/physics/Physics.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/systems/physics/Physics.cc b/src/systems/physics/Physics.cc index 93a41a3f80..28f78e9032 100644 --- a/src/systems/physics/Physics.cc +++ b/src/systems/physics/Physics.cc @@ -3794,6 +3794,18 @@ void PhysicsPrivate::UpdateCollisions(EntityComponentManager &_ecm) if (!_ecm.HasComponentType(components::ContactSensorData::typeId)) return; + // Also check if any entity currently has a ContactSensorData component. + bool needContactSensorData = false; + _ecm.Each( + [&](const Entity &/*unused*/, components::Collision *, + components::ContactSensorData */*unused*/) -> bool + { + needContactSensorData = true; + return false; + }); + if (!needContactSensorData) + return; + // TODO(addisu) If systems are assumed to only have one world, we should // capture the world Entity in a Configure call Entity worldEntity = _ecm.EntityByComponents(components::World());