mirror of https://github.com/zeldaret/botw.git
ksys/phys: Implement several easy RigidBodyRequestMgr functions
This commit is contained in:
parent
b3c9e97e00
commit
7e9d9927e1
|
@ -83460,15 +83460,15 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fa6ab0,U,000020,
|
0x0000007100fa6ab0,U,000020,
|
||||||
0x0000007100fa6ac4,M,000456,_ZN4ksys4phys19RigidBodyRequestMgr5calc1ENS0_16ContactLayerTypeEb
|
0x0000007100fa6ac4,M,000456,_ZN4ksys4phys19RigidBodyRequestMgr5calc1ENS0_16ContactLayerTypeEb
|
||||||
0x0000007100fa6c8c,O,000188,_ZN4ksys4phys19RigidBodyRequestMgr13pushRigidBodyENS0_16ContactLayerTypeEPNS0_9RigidBodyE
|
0x0000007100fa6c8c,O,000188,_ZN4ksys4phys19RigidBodyRequestMgr13pushRigidBodyENS0_16ContactLayerTypeEPNS0_9RigidBodyE
|
||||||
0x0000007100fa6d48,U,000100,phys::RigidBodyRequestMgr::addEntityToWorld
|
0x0000007100fa6d48,O,000100,_ZN4ksys4phys19RigidBodyRequestMgr16addEntityToWorldENS0_16ContactLayerTypeEP9hkpEntity
|
||||||
0x0000007100fa6dac,U,000100,phys::RigidBodyRequestMgr::removeEntityFromWorld
|
0x0000007100fa6dac,O,000100,_ZN4ksys4phys19RigidBodyRequestMgr21removeEntityFromWorldENS0_16ContactLayerTypeEP9hkpEntity
|
||||||
0x0000007100fa6e10,U,000084,phys::RigidBodyRequestMgr::x_5
|
0x0000007100fa6e10,U,000084,phys::RigidBodyRequestMgr::x_5
|
||||||
0x0000007100fa6e64,U,000088,phys::RigidBodyRequestMgr::x_6
|
0x0000007100fa6e64,U,000088,phys::RigidBodyRequestMgr::x_6
|
||||||
0x0000007100fa6ebc,U,000752,phys::RigidBodyRequestMgr::removeRigidBody
|
0x0000007100fa6ebc,U,000752,phys::RigidBodyRequestMgr::removeRigidBody
|
||||||
0x0000007100fa71ac,U,000148,phys::RigidBodyRequestMgr::pushConstraint
|
0x0000007100fa71ac,U,000148,phys::RigidBodyRequestMgr::pushConstraint
|
||||||
0x0000007100fa7240,U,000076,phys::RigidBodyRequestMgr::removeConstraint
|
0x0000007100fa7240,U,000076,phys::RigidBodyRequestMgr::removeConstraint
|
||||||
0x0000007100fa728c,U,000180,phys::RigidBodyRequestMgr::pushRigidBodyMaxPositionExceeded
|
0x0000007100fa728c,O,000180,_ZN4ksys4phys19RigidBodyRequestMgr21onMaxPositionExceededENS0_16ContactLayerTypeEPNS0_9RigidBodyE
|
||||||
0x0000007100fa7340,U,000236,phys::RigidBodyRequestMgr::addImpulse
|
0x0000007100fa7340,O,000236,_ZN4ksys4phys19RigidBodyRequestMgr10addImpulseEPNS0_9RigidBodyES3_f
|
||||||
0x0000007100fa742c,U,000376,phys::RigidBodyRequestMgr::x_8
|
0x0000007100fa742c,U,000376,phys::RigidBodyRequestMgr::x_8
|
||||||
0x0000007100fa75a4,O,000108,_ZN4ksys4phys19RigidBodyRequestMgr22registerMotionAccessorEPNS0_14MotionAccessorE
|
0x0000007100fa75a4,O,000108,_ZN4ksys4phys19RigidBodyRequestMgr22registerMotionAccessorEPNS0_14MotionAccessorE
|
||||||
0x0000007100fa7610,O,000140,_ZN4ksys4phys19RigidBodyRequestMgr24deregisterMotionAccessorEPNS0_14MotionAccessorE
|
0x0000007100fa7610,O,000140,_ZN4ksys4phys19RigidBodyRequestMgr24deregisterMotionAccessorEPNS0_14MotionAccessorE
|
||||||
|
|
Can't render this file because it is too large.
|
|
@ -1,4 +1,5 @@
|
||||||
#include "KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h"
|
#include "KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h"
|
||||||
|
#include <Havok/Physics2012/Dynamics/World/hkpWorld.h>
|
||||||
#include <prim/seadScopedLock.h>
|
#include <prim/seadScopedLock.h>
|
||||||
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
||||||
#include "KingSystem/Physics/System/physSystem.h"
|
#include "KingSystem/Physics/System/physSystem.h"
|
||||||
|
@ -38,8 +39,8 @@ RigidBodyRequestMgr::~RigidBodyRequestMgr() {
|
||||||
void RigidBodyRequestMgr::init(sead::Heap* heap) {
|
void RigidBodyRequestMgr::init(sead::Heap* heap) {
|
||||||
constexpr int Buffer138Size = 0x800;
|
constexpr int Buffer138Size = 0x800;
|
||||||
|
|
||||||
mImpulseEntriesPool.allocBufferAssert(0x100, heap);
|
mImpulseEntriesPool.allocBufferAssert(MaxNumImpulseEntries, heap);
|
||||||
_118 = 0;
|
mNumActiveImpulseEntries = 0;
|
||||||
|
|
||||||
_120.allocBufferAssert(0x100, heap);
|
_120.allocBufferAssert(0x100, heap);
|
||||||
_130 = 0;
|
_130 = 0;
|
||||||
|
@ -103,7 +104,7 @@ void RigidBodyRequestMgr::processImpulseEntries() {
|
||||||
else
|
else
|
||||||
impulse->body_a->onImpulse(impulse->body_b, impulse->impulse_a);
|
impulse->body_a->onImpulse(impulse->body_b, impulse->impulse_a);
|
||||||
}
|
}
|
||||||
_118 = 0;
|
mNumActiveImpulseEntries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RigidBodyRequestMgr::processOobRigidBodyEntries(ContactLayerType layer_type) {
|
void RigidBodyRequestMgr::processOobRigidBodyEntries(ContactLayerType layer_type) {
|
||||||
|
@ -120,6 +121,42 @@ bool RigidBodyRequestMgr::pushRigidBody(ContactLayerType type, RigidBody* body)
|
||||||
return mRigidBodies1[int(type)].push(body);
|
return mRigidBodies1[int(type)].push(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RigidBodyRequestMgr::addEntityToWorld(ContactLayerType type, hkpEntity* entity) {
|
||||||
|
static_cast<void>(System::instance()->isActorSystemIdle());
|
||||||
|
|
||||||
|
auto* world = System::instance()->getHavokWorld(type);
|
||||||
|
if (world->addEntity(entity))
|
||||||
|
++mNumEntitiesInWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyRequestMgr::removeEntityFromWorld(ContactLayerType type, hkpEntity* entity) {
|
||||||
|
static_cast<void>(System::instance()->isActorSystemIdle());
|
||||||
|
|
||||||
|
auto* world = System::instance()->getHavokWorld(type);
|
||||||
|
if (world->removeEntity(entity))
|
||||||
|
--mNumEntitiesInWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyRequestMgr::onMaxPositionExceeded(ContactLayerType layer_type, RigidBody* body) {
|
||||||
|
return mOobRigidBodies[int(layer_type)].push(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyRequestMgr::addImpulse(RigidBody* body_a, RigidBody* body_b, float impulse) {
|
||||||
|
int index = mNumActiveImpulseEntries;
|
||||||
|
++mNumActiveImpulseEntries;
|
||||||
|
if (mNumActiveImpulseEntries >= MaxNumImpulseEntries)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto* entry = mImpulseEntriesPool.get(index);
|
||||||
|
entry->body_a = body_a;
|
||||||
|
entry->body_b = body_b;
|
||||||
|
entry->impulse_a = impulse;
|
||||||
|
if (!mImpulseEntries.push(entry))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RigidBodyRequestMgr::registerMotionAccessor(MotionAccessor* accessor) {
|
bool RigidBodyRequestMgr::registerMotionAccessor(MotionAccessor* accessor) {
|
||||||
auto lock = sead::makeScopedLock(mCS);
|
auto lock = sead::makeScopedLock(mCS);
|
||||||
bool ok = !mMotionAccessors.isFull();
|
bool ok = !mMotionAccessors.isFull();
|
||||||
|
|
|
@ -51,18 +51,14 @@ public:
|
||||||
void calc1(ContactLayerType layer_type, bool paused);
|
void calc1(ContactLayerType layer_type, bool paused);
|
||||||
|
|
||||||
bool pushRigidBody(ContactLayerType type, RigidBody* body);
|
bool pushRigidBody(ContactLayerType type, RigidBody* body);
|
||||||
// 0x0000007100fa6d48
|
|
||||||
void addEntityToWorld(ContactLayerType type, hkpEntity* entity);
|
void addEntityToWorld(ContactLayerType type, hkpEntity* entity);
|
||||||
// 0x0000007100fa6dac
|
void removeEntityFromWorld(ContactLayerType type, hkpEntity* entity);
|
||||||
void removeEntityToWorld(ContactLayerType type, hkpEntity* entity);
|
|
||||||
// 0x0000007100fa6ebc
|
// 0x0000007100fa6ebc
|
||||||
void removeRigidBody(ContactLayerType type, RigidBody* body);
|
void removeRigidBody(ContactLayerType type, RigidBody* body);
|
||||||
|
|
||||||
// 0x0000007100fa728c
|
bool onMaxPositionExceeded(ContactLayerType layer_type, RigidBody* body);
|
||||||
void onMaxPositionExceeded(ContactLayerType layer_type, RigidBody* body);
|
|
||||||
|
|
||||||
// 0x0000007100fa7340
|
bool addImpulse(RigidBody* body_a, RigidBody* body_b, float impulse);
|
||||||
void addImpulse(RigidBody* body_a, RigidBody* body_b, float impulse);
|
|
||||||
|
|
||||||
bool registerMotionAccessor(MotionAccessor* accessor);
|
bool registerMotionAccessor(MotionAccessor* accessor);
|
||||||
bool deregisterMotionAccessor(MotionAccessor* accessor);
|
bool deregisterMotionAccessor(MotionAccessor* accessor);
|
||||||
|
@ -113,6 +109,7 @@ private:
|
||||||
void processOobRigidBodyEntries(ContactLayerType layer_type);
|
void processOobRigidBodyEntries(ContactLayerType layer_type);
|
||||||
|
|
||||||
static constexpr int NumRigidBodyBuffers = 2;
|
static constexpr int NumRigidBodyBuffers = 2;
|
||||||
|
static constexpr int MaxNumImpulseEntries = 0x100;
|
||||||
|
|
||||||
sead::SafeArray<util::LockFreeQueue<RigidBody>, NumRigidBodyBuffers> mRigidBodies1;
|
sead::SafeArray<util::LockFreeQueue<RigidBody>, NumRigidBodyBuffers> mRigidBodies1;
|
||||||
util::LockFreeQueue<Unk1> _38;
|
util::LockFreeQueue<Unk1> _38;
|
||||||
|
@ -125,7 +122,7 @@ private:
|
||||||
util::LockFreeQueue<Unk4> _e0;
|
util::LockFreeQueue<Unk4> _e0;
|
||||||
sead::PtrArray<MotionAccessor> mMotionAccessors;
|
sead::PtrArray<MotionAccessor> mMotionAccessors;
|
||||||
sead::Buffer<ImpulseEntry> mImpulseEntriesPool;
|
sead::Buffer<ImpulseEntry> mImpulseEntriesPool;
|
||||||
sead::Atomic<u32> _118;
|
sead::Atomic<int> mNumActiveImpulseEntries;
|
||||||
sead::Buffer<Unk6> _120;
|
sead::Buffer<Unk6> _120;
|
||||||
sead::Atomic<u32> _130;
|
sead::Atomic<u32> _130;
|
||||||
sead::Buffer<Unk4> _138;
|
sead::Buffer<Unk4> _138;
|
||||||
|
|
|
@ -112,6 +112,9 @@ public:
|
||||||
// 0x0000007101216c74
|
// 0x0000007101216c74
|
||||||
bool getEntityContactListenerField90() const;
|
bool getEntityContactListenerField90() const;
|
||||||
|
|
||||||
|
// 0x0000007101216ca4
|
||||||
|
bool isActorSystemIdle() const;
|
||||||
|
|
||||||
// 0x0000007101216800
|
// 0x0000007101216800
|
||||||
void setEntityContactListenerField91(bool value);
|
void setEntityContactListenerField91(bool value);
|
||||||
// 0x0000007101216814
|
// 0x0000007101216814
|
||||||
|
|
Loading…
Reference in New Issue