mirror of https://github.com/zeldaret/botw.git
ksys/phys: Add AlsoLockWorld to improve call site readability
This commit is contained in:
parent
a68d10ec47
commit
c423a56a63
|
@ -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
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -185,7 +185,7 @@ void RigidBody::addToWorld() {
|
|||
// debug code that survived because mFlags is atomic
|
||||
static_cast<void>(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<void>(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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue