mirror of
https://github.com/zeldaret/botw
synced 2026-06-28 02:23:01 -04:00
783e6a510f
Also contains readability/accuracy fixes to LockFreeQueue.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
#include "KingSystem/Physics/Ragdoll/physRagdollControllerMgr.h"
|
|
#include <prim/seadScopedLock.h>
|
|
#include "KingSystem/Physics/Ragdoll/physRagdollController.h"
|
|
#include "KingSystem/Physics/System/physSystem.h"
|
|
|
|
namespace ksys::phys {
|
|
|
|
RagdollControllerMgr::RagdollControllerMgr() = default;
|
|
|
|
RagdollControllerMgr::~RagdollControllerMgr() {
|
|
mControllers.freeBuffer();
|
|
}
|
|
|
|
void RagdollControllerMgr::init(sead::Heap* heap) {
|
|
mControllers.alloc(0x400, heap);
|
|
}
|
|
|
|
bool RagdollControllerMgr::addController(RagdollController* controller) {
|
|
return mControllers.push(controller);
|
|
}
|
|
|
|
void RagdollControllerMgr::removeController(RagdollController* controller) {
|
|
auto lock = sead::makeScopedLock(mCS);
|
|
mControllers.erase(controller);
|
|
}
|
|
|
|
void RagdollControllerMgr::calc() {
|
|
ScopedWorldLock world_lock{ContactLayerType::Entity};
|
|
auto lock = sead::makeScopedLock(mCS);
|
|
|
|
RagdollController* first_processed = nullptr;
|
|
|
|
while (auto* ctrl = mControllers.pop()) {
|
|
mControllers.push(ctrl);
|
|
|
|
// If we have processed the entire buffer and wrapped around, stop.
|
|
if (first_processed == ctrl)
|
|
break;
|
|
|
|
ctrl->update();
|
|
|
|
if (first_processed == nullptr)
|
|
first_processed = ctrl;
|
|
}
|
|
}
|
|
|
|
void RagdollControllerMgr::calc1() {}
|
|
|
|
} // namespace ksys::phys
|