mirror of
https://github.com/zeldaret/botw
synced 2026-08-17 05:01:25 -04:00
ksys: Move physInstanceSet to Physics/System
It's right after EntityGroupFilter and before MaterialTable
This commit is contained in:
@@ -0,0 +1,211 @@
|
||||
#include "KingSystem/Physics/System/physInstanceSet.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
void InstanceSet::setFlag2() {
|
||||
mFlags.set(Flag::_2);
|
||||
if (_d8 != nullptr) {
|
||||
mFlags.set(Flag::_2);
|
||||
mFlags.set(Flag::DisableDraw);
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSet::clothVisibleStuff() {
|
||||
if (_d8 != nullptr) {
|
||||
mFlags.set(Flag::DisableDraw);
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSet::setInDemo() {
|
||||
mFlags.set(Flag::InDemo);
|
||||
}
|
||||
|
||||
void InstanceSet::resetInDemo() {
|
||||
mFlags.reset(Flag::InDemo);
|
||||
}
|
||||
|
||||
void InstanceSet::clothVisibleStuff_0(s32 setting) {
|
||||
if (mFlags.isOn(Flag::InDemo))
|
||||
return;
|
||||
|
||||
switch (setting) {
|
||||
case -2:
|
||||
mFlags.reset(Flag::Cloth2);
|
||||
mFlags.set(Flag::Cloth1);
|
||||
break;
|
||||
case -1:
|
||||
mFlags.reset(Flag::Cloth3);
|
||||
mFlags.reset(Flag::Cloth2);
|
||||
mFlags.reset(Flag::Cloth1);
|
||||
mFlags.set(Flag::Cloth2);
|
||||
mFlags.set(Flag::Cloth3);
|
||||
break;
|
||||
case 0:
|
||||
mFlags.reset(Flag::Cloth1);
|
||||
mFlags.reset(Flag::Cloth2);
|
||||
mFlags.set(Flag::Cloth3);
|
||||
break;
|
||||
case 1:
|
||||
mFlags.reset(Flag::Cloth1);
|
||||
mFlags.reset(Flag::Cloth2);
|
||||
mFlags.reset(Flag::Cloth3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void InstanceSet::sub_7100FB9BAC(InstanceSet* other) {
|
||||
if (other == nullptr)
|
||||
return;
|
||||
|
||||
u32 idx = other->sub_7100FB9C2C();
|
||||
clothVisibleStuff_0(idx);
|
||||
}
|
||||
|
||||
u32 InstanceSet::sub_7100FB9C2C() const {
|
||||
u32 idx;
|
||||
if (mFlags.isOn(Flag::Cloth1)) {
|
||||
idx = -2;
|
||||
} else if (mFlags.isOn(Flag::Cloth2)) {
|
||||
idx = -1;
|
||||
} else if (mFlags.isOn(Flag::Cloth3)) {
|
||||
idx = 0;
|
||||
} else {
|
||||
idx = 1;
|
||||
}
|
||||
return idx;
|
||||
}
|
||||
|
||||
void InstanceSet::sub_7100FBA9BC() {
|
||||
for (auto& rb : mRigidBodySets) {
|
||||
rb.sub_7100FA97FC();
|
||||
}
|
||||
|
||||
for (auto& body : mList) {
|
||||
body->sub_7100F8CFA0();
|
||||
}
|
||||
|
||||
if (mCollisionController != nullptr)
|
||||
mCollisionController->sub_7100F5EC30();
|
||||
}
|
||||
|
||||
void InstanceSet::sub_7100FBACE0(phys::ContactLayer layer) {
|
||||
bool sensor = phys::getContactLayerType(layer) != ContactLayerType::Entity;
|
||||
|
||||
for (auto& rb : mRigidBodySets) {
|
||||
rb.disableCollisionMaybe(layer);
|
||||
}
|
||||
if (sensor)
|
||||
return;
|
||||
|
||||
if (mRagdollController != nullptr)
|
||||
mRagdollController->sub_7101221728(layer);
|
||||
|
||||
if (mCollisionController != nullptr)
|
||||
mCollisionController->enableCollisionMaybe_0(layer);
|
||||
}
|
||||
|
||||
void InstanceSet::sub_7100FBAD74() {
|
||||
for (auto& rb : mRigidBodySets) {
|
||||
rb.disableAllContact();
|
||||
}
|
||||
if (mRagdollController != nullptr) {
|
||||
mRagdollController->sub_71012217A8();
|
||||
}
|
||||
if (mCollisionController != nullptr) {
|
||||
mCollisionController->sub_7100F60604();
|
||||
}
|
||||
}
|
||||
|
||||
void* InstanceSet::sub_7100FBAEDC(s32 idx1, s32 idx2) const {
|
||||
if (mRigidBodySets.size() <= idx1)
|
||||
return nullptr;
|
||||
return mRigidBodySets[idx1]->getRigidBody(idx2);
|
||||
}
|
||||
|
||||
// NON_MATCHING
|
||||
void InstanceSet::sub_7100FBB00C(phys::RigidBody* body, phys::RigidBodyParam* param) {
|
||||
if (body == nullptr)
|
||||
return;
|
||||
|
||||
phys::RigidBodyParamView view;
|
||||
param->getParams(&view);
|
||||
if (view.contact_layer == phys::ContactLayer::SensorCustomReceiver) {
|
||||
body->sub_7100F8F9E8(&view.flags, _188[body->isMassScaling()]);
|
||||
} else if (view.info_5e0) {
|
||||
body->sub_7100F8FA44(view.contact_layer, view.info_5e0);
|
||||
} else {
|
||||
body->sub_7100F8F8CC(view.contact_layer, view.groundhit, _188[body->isMassScaling()]);
|
||||
}
|
||||
body->setCollideGround(view.no_hit_ground == 0);
|
||||
body->setCollideWater(view.no_hit_water == 0);
|
||||
body->sub_7100F8F51C();
|
||||
}
|
||||
|
||||
void* InstanceSet::sub_7100FBBC28(const sead::SafeString& name) const {
|
||||
for (auto& rb : mRigidBodySets) {
|
||||
void* p = rb.findXByName(name);
|
||||
if (p != nullptr)
|
||||
return p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
s32 InstanceSet::sub_7100FBBC78(const sead::SafeString& name) const {
|
||||
s32 idx = 0;
|
||||
for (auto& info : mContactInfos) {
|
||||
if (name == info.mName)
|
||||
return idx;
|
||||
idx++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
s32 InstanceSet::sub_7100FBBD9C(const sead::SafeString& name) const {
|
||||
s32 idx = 0;
|
||||
for (auto& info : mCollisionInfos) {
|
||||
if (name == info.mName)
|
||||
return idx;
|
||||
idx++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void InstanceSet::sub_7100FBD284(const sead::Matrix34f& mtx) {
|
||||
if (mFlags.isOff(Flag::_1))
|
||||
return;
|
||||
|
||||
if (mFlags.isOn(Flag::_80000000)) {
|
||||
sub_7100FBC890(mtx, true, false);
|
||||
} else {
|
||||
mFlags.reset(Flag::_8);
|
||||
if (mFlags.isOn(Flag::_2))
|
||||
setMtxAndScale(mtx, false, false, mScale);
|
||||
}
|
||||
mFlags.reset(Flag::_80000000);
|
||||
|
||||
if (mRagdollController == nullptr)
|
||||
return;
|
||||
|
||||
if (mRagdollController->sub_7101221CC4() == 0)
|
||||
sub_7100FBC890(mtx, false, false);
|
||||
}
|
||||
|
||||
s32 InstanceSet::sub_7100FBDA2C(const sead::SafeString& name) const {
|
||||
if (mRagdollBlendWt == nullptr)
|
||||
return -1;
|
||||
|
||||
s32 idx = mRagdollBlendWt->findStateIdx(name);
|
||||
if (idx >= 0)
|
||||
return idx + 2;
|
||||
|
||||
if (name == "full_dynamic") {
|
||||
return 1;
|
||||
}
|
||||
if (name == "full_key_framed") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -0,0 +1,124 @@
|
||||
#pragma once
|
||||
|
||||
#include <container/seadListImpl.h>
|
||||
#include <container/seadPtrArray.h>
|
||||
#include <hostio/seadHostIONode.h>
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
class RagdollBlendWeight {
|
||||
public:
|
||||
s32 findStateIdx(const sead::SafeString& name) const;
|
||||
};
|
||||
|
||||
} // namespace ksys::res
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
class Ragdoll {};
|
||||
|
||||
class RagdollController {
|
||||
public:
|
||||
u32 sub_7101221CC4();
|
||||
void sub_7101221728(ContactLayer);
|
||||
void sub_71012217A8();
|
||||
};
|
||||
|
||||
class CollisionController {
|
||||
public:
|
||||
void sub_7100F5EC30();
|
||||
void sub_7100F60604();
|
||||
void enableCollisionMaybe_0(ContactLayer);
|
||||
};
|
||||
|
||||
struct CollisionInfo {
|
||||
u8 filler[0x50];
|
||||
sead::SafeString mName;
|
||||
};
|
||||
|
||||
struct ContactInfo {
|
||||
u8 filler[0x8];
|
||||
sead::SafeString mName;
|
||||
};
|
||||
|
||||
class RigidBodySet {
|
||||
public:
|
||||
void disableAllContact();
|
||||
void sub_7100FA97FC();
|
||||
void disableCollisionMaybe(ContactLayer);
|
||||
void* findXByName(const sead::SafeString& name) const;
|
||||
|
||||
RigidBody* getRigidBody() const { return mBodies[0]; }
|
||||
RigidBody* getRigidBody(s32 idx) const { return mBodies[idx]; }
|
||||
|
||||
private:
|
||||
u8 _0[0x18];
|
||||
sead::PtrArray<RigidBody> mBodies;
|
||||
};
|
||||
|
||||
class InstanceSet : public sead::hostio::Node {
|
||||
public:
|
||||
enum class Flag : u32 {
|
||||
_1 = 1 << 0,
|
||||
_2 = 1 << 1,
|
||||
_8 = 1 << 3,
|
||||
DisableDraw = 1 << 2,
|
||||
_200000 = 1 << 21,
|
||||
Cloth1 = 1 << 22,
|
||||
Cloth2 = 1 << 23,
|
||||
Cloth3 = 1 << 24,
|
||||
InDemo = 1 << 25,
|
||||
_80000000 = 1u << 31,
|
||||
};
|
||||
|
||||
void setFlag2();
|
||||
void clothVisibleStuff();
|
||||
void setInDemo();
|
||||
void resetInDemo();
|
||||
void clothVisibleStuff_0(s32 setting);
|
||||
void sub_7100FB9BAC(InstanceSet* other);
|
||||
u32 sub_7100FB9C2C() const;
|
||||
void sub_7100FBA9BC();
|
||||
void sub_7100FBACE0(ContactLayer layer);
|
||||
void sub_7100FBAD74();
|
||||
void* sub_7100FBAEDC(s32 rigidbody_idx, s32 ragdoll_idx) const;
|
||||
void sub_7100FBB00C(RigidBody* body, RigidBodyParam* param);
|
||||
void setMtxAndScale(const sead::Matrix34f& mtx, bool a2, bool a3, f32 scale);
|
||||
void sub_7100FBB4B4();
|
||||
void* findX(const sead::SafeString& a1, const sead::SafeString& a2) const;
|
||||
void* sub_7100FBBC28(const sead::SafeString& name) const;
|
||||
s32 sub_7100FBBC78(const sead::SafeString& name) const;
|
||||
s32 sub_7100FBBD9C(const sead::SafeString& name) const;
|
||||
void sub_7100FBD284(const sead::Matrix34f& mtx);
|
||||
void sub_7100FBC890(const sead::Matrix34f& mtx, bool a2, bool a3);
|
||||
s32 sub_7100FBDA2C(const sead::SafeString& name) const;
|
||||
|
||||
private:
|
||||
u8 _8[0x18];
|
||||
sead::TypedBitFlag<Flag> mFlags;
|
||||
void* _28;
|
||||
f32 mScale;
|
||||
u8 _34[0x40 - 0x34];
|
||||
sead::PtrArray<RigidBodySet> mRigidBodySets;
|
||||
sead::PtrArray<CollisionInfo> mCollisionInfos;
|
||||
sead::PtrArray<ContactInfo> mContactInfos;
|
||||
|
||||
u8 _70[0x10];
|
||||
CollisionController* mCollisionController;
|
||||
u8 _88[8];
|
||||
RagdollController* mRagdollController;
|
||||
u8 _98[0xb8 - 0x98];
|
||||
res::RagdollBlendWeight* mRagdollBlendWt;
|
||||
u8 _c0[0xd8 - 0xc0];
|
||||
void* _d8;
|
||||
u8 _e0[0x148 - 0xe0];
|
||||
sead::TList<RigidBody*> mList;
|
||||
u8 _160[0x188 - 0x160];
|
||||
void* _188[2];
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InstanceSet, 0x198);
|
||||
|
||||
} // namespace ksys::phys
|
||||
Reference in New Issue
Block a user