From 683108b75cf44a50941eb153050aa0b843430531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 6 Mar 2022 12:38:26 +0100 Subject: [PATCH] ksys/phys: Add CollisionInfoBase::enableLayer/disableLayer The pattern seems to show up very often in CollisionInfoBase users --- src/KingSystem/Physics/System/physCollisionInfo.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/KingSystem/Physics/System/physCollisionInfo.h b/src/KingSystem/Physics/System/physCollisionInfo.h index 98c36cee..eec2263f 100644 --- a/src/KingSystem/Physics/System/physCollisionInfo.h +++ b/src/KingSystem/Physics/System/physCollisionInfo.h @@ -28,6 +28,8 @@ public: sead::BitFlag32& getLayerMask(ContactLayerType layer_type); const sead::BitFlag32& getLayerMask(ContactLayerType layer_type) const; + void enableLayer(ContactLayer layer); + void disableLayer(ContactLayer layer); bool isLayerEnabled(ContactLayer layer) const; void lock(); @@ -67,6 +69,15 @@ inline const sead::BitFlag32& CollisionInfoBase::getLayerMask(ContactLayerType l return mLayerMasks[int(layer_type)]; } +inline void CollisionInfoBase::enableLayer(ContactLayer layer) { + const u32 mask = makeContactLayerMask(layer); + getLayerMask(getContactLayerType(layer)).set(mask); +} + +inline void CollisionInfoBase::disableLayer(ContactLayer layer) { + getLayerMask(getContactLayerType(layer)).resetBit(int(getContactLayerBaseRelativeValue(layer))); +} + inline bool CollisionInfoBase::isLayerEnabled(ContactLayer layer) const { const auto& mask = getLayerMask(getContactLayerType(layer)); return mask.isOnBit(int(getContactLayerBaseRelativeValue(layer)));