diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 317870a8..aa5f0d02 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -83137,8 +83137,8 @@ Address,Quality,Size,Name 0x0000007100f96700,O,000068,_ZNK4ksys4phys9RigidBody9onImpulseEPS1_f 0x0000007100f96744,O,000176,_ZNK4ksys4phys9RigidBody14getAabbInLocalEPN4sead9BoundBox3IfEE 0x0000007100f967f4,m,000428,_ZNK4ksys4phys9RigidBody14getAabbInWorldEPN4sead9BoundBox3IfEE -0x0000007100f969a0,O,000072,_ZN4ksys4phys9RigidBody4lockEb -0x0000007100f969e8,O,000088,_ZN4ksys4phys9RigidBody6unlockEb +0x0000007100f969a0,O,000072,_ZN4ksys4phys9RigidBody4lockENS1_13AlsoLockWorldE +0x0000007100f969e8,O,000088,_ZN4ksys4phys9RigidBody6unlockENS1_13AlsoLockWorldE 0x0000007100f96a40,O,000012,_ZNK4ksys4phys9RigidBody9getMotionEv 0x0000007100f96a4c,U,000076,phys::RigidBody::x_123 0x0000007100f96a98,O,000188,_ZN4ksys4phys9RigidBody20setEntityMotionFlag1Eb diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp index d11aabfc..c2bb40c3 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp @@ -185,7 +185,7 @@ void RigidBody::addToWorld() { // debug code that survived because mFlags is atomic static_cast(isAddedToWorld()); - auto lock = makeScopedLock(false); + auto lock = makeScopedLock(AlsoLockWorld::No); if (mMotionAccessor) { const bool use_system_time_factor = hasFlag(Flag::UseSystemTimeFactor); @@ -251,7 +251,7 @@ bool RigidBody::removeFromWorldAndResetLinks() { // debug code that survived because mFlags is atomic? static_cast(mFlags.getDirect()); - auto lock = makeScopedLock(false); + auto lock = makeScopedLock(AlsoLockWorld::No); bool result = true; @@ -1641,7 +1641,7 @@ float RigidBody::getColImpulseScale() const { } bool RigidBody::hasConstraintWithUserData() { - auto lock = makeScopedLock(true); + auto lock = makeScopedLock(AlsoLockWorld::Yes); for (int i = 0, n = getHkBody()->getNumConstraints(); i < n; ++i) { auto* constraint = getHkBody()->getConstraint(i); @@ -1788,8 +1788,8 @@ void RigidBody::lock() { mCS.lock(); } -void RigidBody::lock(bool also_lock_world) { - if (also_lock_world) +void RigidBody::lock(AlsoLockWorld also_lock_world) { + if (bool(also_lock_world)) System::instance()->lockWorld(getLayerType()); lock(); } @@ -1798,9 +1798,9 @@ void RigidBody::unlock() { mCS.unlock(); } -void RigidBody::unlock(bool also_unlock_world) { +void RigidBody::unlock(AlsoLockWorld also_unlock_world) { unlock(); - if (also_unlock_world) + if (bool(also_unlock_world)) System::instance()->unlockWorld(getLayerType()); } diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.h b/src/KingSystem/Physics/RigidBody/physRigidBody.h index 6748d36f..b2d5d398 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.h +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.h @@ -125,9 +125,11 @@ public: _80000 = 1 << 19, }; + enum class AlsoLockWorld : bool { Yes = true, No = false }; + class ScopedLock { public: - explicit ScopedLock(RigidBody* body, bool also_lock_world) + explicit ScopedLock(RigidBody* body, AlsoLockWorld also_lock_world) : mBody(body), mAlsoLockWorld(also_lock_world) { mBody->lock(also_lock_world); } @@ -137,7 +139,7 @@ public: private: RigidBody* mBody; - bool mAlsoLockWorld; + AlsoLockWorld mAlsoLockWorld; }; RigidBody(Type type, ContactLayerType layer_type, hkpRigidBody* hk_body, @@ -507,13 +509,13 @@ public: void x_114(bool unk); void lock(); - void lock(bool also_lock_world); + void lock(AlsoLockWorld also_lock_world); void unlock(); - void unlock(bool also_unlock_world); - [[nodiscard]] auto makeScopedLock(bool also_lock_world) { + void unlock(AlsoLockWorld also_unlock_world); + [[nodiscard]] auto makeScopedLock(AlsoLockWorld also_lock_world) { return ScopedLock(this, also_lock_world); } - [[nodiscard]] auto makeScopedLock() { return makeScopedLock(isAddedToWorld()); } + [[nodiscard]] auto makeScopedLock() { return makeScopedLock(AlsoLockWorld(isAddedToWorld())); } hkpMotion* getMotion() const;