mirror of https://github.com/zeldaret/botw.git
ksys/phys: Implement more StaticCompound functions
The other functions require RE'ing BodyGroup, which in turn requires RigidBody stuff
This commit is contained in:
parent
9343ed56e7
commit
423eb84362
|
@ -84182,7 +84182,7 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fc9eec,U,000008,
|
0x0000007100fc9eec,U,000008,
|
||||||
0x0000007100fc9ef4,U,000036,ResourceHksc::dtorDelete
|
0x0000007100fc9ef4,U,000036,ResourceHksc::dtorDelete
|
||||||
0x0000007100fc9f18,U,000040,
|
0x0000007100fc9f18,U,000040,
|
||||||
0x0000007100fc9f40,U,001356,ResourceHksc::doCreate
|
0x0000007100fc9f40,O,001356,_ZN4ksys4phys14StaticCompound9doCreate_EPhjPN4sead4HeapE
|
||||||
0x0000007100fca48c,U,000268,ResourceHksc::afterParse
|
0x0000007100fca48c,U,000268,ResourceHksc::afterParse
|
||||||
0x0000007100fca598,U,000416,ResourceHksc::m7
|
0x0000007100fca598,U,000416,ResourceHksc::m7
|
||||||
0x0000007100fca738,U,000156,ResourceHksc::calledFromMapDtor
|
0x0000007100fca738,U,000156,ResourceHksc::calledFromMapDtor
|
||||||
|
@ -84191,14 +84191,14 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fca91c,U,000212,ResourceHksc::x_4
|
0x0000007100fca91c,U,000212,ResourceHksc::x_4
|
||||||
0x0000007100fca9f0,U,000112,
|
0x0000007100fca9f0,U,000112,
|
||||||
0x0000007100fcaa60,U,000136,ResourceHksc::cleanUp
|
0x0000007100fcaa60,U,000136,ResourceHksc::cleanUp
|
||||||
0x0000007100fcaae8,U,000076,ResourceHksc::x_0
|
0x0000007100fcaae8,O,000076,_ZN4ksys4phys14StaticCompound12setMapObjectEjjPNS_3map6ObjectE
|
||||||
0x0000007100fcab34,U,000072,
|
0x0000007100fcab34,O,000072,_ZNK4ksys4phys14StaticCompound12getMapObjectEi
|
||||||
0x0000007100fcab7c,U,000176,ResourceHksc::disableObj
|
0x0000007100fcab7c,O,000176,_ZN4ksys4phys14StaticCompound16disableCollisionEib
|
||||||
0x0000007100fcac2c,U,000112,
|
0x0000007100fcac2c,U,000112,
|
||||||
0x0000007100fcac9c,U,000112,
|
0x0000007100fcac9c,U,000112,
|
||||||
0x0000007100fcad0c,U,000328,
|
0x0000007100fcad0c,U,000328,
|
||||||
0x0000007100fcae54,O,000028,_ZN4ksys4phys14StaticCompound17getFieldBodyGroupEi
|
0x0000007100fcae54,O,000028,_ZN4ksys4phys14StaticCompound17getFieldBodyGroupEi
|
||||||
0x0000007100fcae70,O,000084,_ZNK4ksys4phys14StaticCompound17hasFieldBodyGroupEPNS0_14FieldBodyGroupE
|
0x0000007100fcae70,O,000084,_ZNK4ksys4phys14StaticCompound17hasFieldBodyGroupEPNS0_9BodyGroupE
|
||||||
0x0000007100fcaec4,O,000008,_ZNK4ksys4phys14StaticCompound27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
0x0000007100fcaec4,O,000008,_ZNK4ksys4phys14StaticCompound27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||||
0x0000007100fcaecc,O,000092,_ZNK4ksys4phys14StaticCompound18getRuntimeTypeInfoEv
|
0x0000007100fcaecc,O,000092,_ZNK4ksys4phys14StaticCompound18getRuntimeTypeInfoEv
|
||||||
0x0000007100fcaf28,O,000008,_ZNK4ksys4phys14StaticCompound10needsParseEv
|
0x0000007100fcaf28,O,000008,_ZNK4ksys4phys14StaticCompound10needsParseEv
|
||||||
|
@ -84206,12 +84206,12 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fcb0a4,O,000004,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys9ShapeInfoEEEvPv
|
0x0000007100fcb0a4,O,000004,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys9ShapeInfoEEEvPv
|
||||||
0x0000007100fcb0a8,O,000004,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys9ActorInfoEEEvPv
|
0x0000007100fcb0a8,O,000004,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys9ActorInfoEEEvPv
|
||||||
0x0000007100fcb0ac,O,000136,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys18StaticCompoundInfoEEEvPv
|
0x0000007100fcb0ac,O,000136,_ZN10hkTypeInfo19cleanupFunctionImplIN4ksys4phys18StaticCompoundInfoEEEvPv
|
||||||
0x0000007100fcb134,U,000088,
|
0x0000007100fcb134,O,000088,_ZNK4ksys4phys18StaticCompoundInfo11getActorIdxEjj
|
||||||
0x0000007100fcb18c,U,000048,
|
0x0000007100fcb18c,O,000048,_ZNK4ksys4phys18StaticCompoundInfo17getShapeInfoStartEi
|
||||||
0x0000007100fcb1bc,U,000048,
|
0x0000007100fcb1bc,O,000048,_ZNK4ksys4phys18StaticCompoundInfo15getShapeInfoEndEi
|
||||||
0x0000007100fcb1ec,U,000048,
|
0x0000007100fcb1ec,O,000048,_ZNK4ksys4phys18StaticCompoundInfo12getShapeInfoEi
|
||||||
0x0000007100fcb21c,U,000120,
|
0x0000007100fcb21c,O,000120,_ZN4ksys4phys16getBodyLayerTypeENS0_12ContactLayerE
|
||||||
0x0000007100fcb294,O,000396,_GLOBAL__sub_I_physStaticCompoundInfo.cpp
|
0x0000007100fcb294,O,000396,_GLOBAL__sub_I_physStaticCompoundAutogen.cpp
|
||||||
0x0000007100fcb420,U,000080,
|
0x0000007100fcb420,U,000080,
|
||||||
0x0000007100fcb470,U,000076,
|
0x0000007100fcb470,U,000076,
|
||||||
0x0000007100fcb4bc,U,000084,
|
0x0000007100fcb4bc,U,000084,
|
||||||
|
@ -84230,7 +84230,7 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fcbbe4,U,000176,
|
0x0000007100fcbbe4,U,000176,
|
||||||
0x0000007100fcbc94,U,000324,
|
0x0000007100fcbc94,U,000324,
|
||||||
0x0000007100fcbdd8,U,000104,
|
0x0000007100fcbdd8,U,000104,
|
||||||
0x0000007100fcbe40,O,000168,_ZN4ksys4phys14FieldBodyGroupC1Ev
|
0x0000007100fcbe40,O,000168,_ZN4ksys4phys9BodyGroupC1Ev
|
||||||
0x0000007100fcbee8,U,000288,
|
0x0000007100fcbee8,U,000288,
|
||||||
0x0000007100fcc008,U,001492,FieldBodyGroup::init
|
0x0000007100fcc008,U,001492,FieldBodyGroup::init
|
||||||
0x0000007100fcc5dc,U,000120,
|
0x0000007100fcc5dc,U,000120,
|
||||||
|
|
Can't render this file because it is too large.
|
2
lib/sead
2
lib/sead
|
@ -1 +1 @@
|
||||||
Subproject commit c2ffe0c2d03a2ffa2a8b2a679810e08ebd16d45d
|
Subproject commit 21c20627a40e2c3eb2d62c36008cf68146d369ad
|
|
@ -39,7 +39,7 @@ class UMii;
|
||||||
} // namespace mii
|
} // namespace mii
|
||||||
|
|
||||||
namespace phys {
|
namespace phys {
|
||||||
class FieldBodyGroup;
|
class BodyGroup;
|
||||||
class Physics;
|
class Physics;
|
||||||
class Reaction;
|
class Reaction;
|
||||||
class RigidBody;
|
class RigidBody;
|
||||||
|
@ -380,7 +380,7 @@ protected:
|
||||||
/* 0x580 */ PhysicsConstraints mConstraints;
|
/* 0x580 */ PhysicsConstraints mConstraints;
|
||||||
/* 0x598 */ void* _598 = nullptr;
|
/* 0x598 */ void* _598 = nullptr;
|
||||||
/* 0x5a0 */ BoneControl* mBoneControl = nullptr;
|
/* 0x5a0 */ BoneControl* mBoneControl = nullptr;
|
||||||
/* 0x5a8 */ phys::FieldBodyGroup* mFieldBodyGroup = nullptr;
|
/* 0x5a8 */ phys::BodyGroup* mFieldBodyGroup = nullptr;
|
||||||
/* 0x5b0 */ void* _5b0 = nullptr;
|
/* 0x5b0 */ void* _5b0 = nullptr;
|
||||||
/* 0x5b8 */ sead::Heap* mDualHeap = nullptr; // TODO: rename
|
/* 0x5b8 */ sead::Heap* mDualHeap = nullptr; // TODO: rename
|
||||||
/* 0x5c0 */ sead::Heap* mDualHeap2 = nullptr; // TODO: rename
|
/* 0x5c0 */ sead::Heap* mDualHeap2 = nullptr; // TODO: rename
|
||||||
|
|
|
@ -32,8 +32,9 @@ target_sources(uking PRIVATE
|
||||||
|
|
||||||
StaticCompound/physStaticCompound.cpp
|
StaticCompound/physStaticCompound.cpp
|
||||||
StaticCompound/physStaticCompound.h
|
StaticCompound/physStaticCompound.h
|
||||||
StaticCompound/physStaticCompoundFieldBodyGroup.cpp
|
StaticCompound/physStaticCompoundAutogen.cpp
|
||||||
StaticCompound/physStaticCompoundFieldBodyGroup.h
|
StaticCompound/physStaticCompoundBodyGroup.cpp
|
||||||
|
StaticCompound/physStaticCompoundBodyGroup.h
|
||||||
StaticCompound/physStaticCompoundInfo.cpp
|
StaticCompound/physStaticCompoundInfo.cpp
|
||||||
StaticCompound/physStaticCompoundInfo.h
|
StaticCompound/physStaticCompoundInfo.h
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,108 @@
|
||||||
#include "KingSystem/Physics/StaticCompound/physStaticCompound.h"
|
#include "KingSystem/Physics/StaticCompound/physStaticCompound.h"
|
||||||
#include "KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h"
|
#include <Havok/Common/Serialize/Util/hkNativePackfileUtils.h>
|
||||||
|
#include <Havok/Common/Serialize/Util/hkRootLevelContainer.h>
|
||||||
|
#include <Havok/Physics2012/Utilities/Serialize/hkpPhysicsData.h>
|
||||||
|
#include "KingSystem/Physics/StaticCompound/physStaticCompoundBodyGroup.h"
|
||||||
|
#include "KingSystem/Physics/StaticCompound/physStaticCompoundInfo.h"
|
||||||
|
#include "KingSystem/Utils/Debug.h"
|
||||||
|
#include "KingSystem/Utils/HeapUtil.h"
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
// + 1 because body groups are one indexed, with the 0th group acting as a dummy group
|
||||||
|
constexpr int NumBodyGroups = 16 + 1;
|
||||||
|
|
||||||
StaticCompound::StaticCompound() = default;
|
StaticCompound::StaticCompound() = default;
|
||||||
|
|
||||||
StaticCompound::~StaticCompound() {
|
StaticCompound::~StaticCompound() {
|
||||||
// FIXME
|
// FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
FieldBodyGroup* StaticCompound::getFieldBodyGroup(int idx) {
|
void StaticCompound::doCreate_(u8* buffer, u32 buffer_size, sead::Heap* parent_heap) {
|
||||||
|
const char* error = nullptr;
|
||||||
|
mBuffer = buffer;
|
||||||
|
auto result = hkNativePackfileUtils::validatePackfileHeader(mBuffer, &error);
|
||||||
|
if (!result.isSuccess())
|
||||||
|
util::PrintDebugFmt("%s: invalid packfile: %s", __func__, error);
|
||||||
|
mBufferSize = hkNativePackfileUtils::getRequiredBufferSize(mBuffer, int(buffer_size));
|
||||||
|
mStaticCompoundInfo = static_cast<const StaticCompoundInfo*>(
|
||||||
|
hkNativePackfileUtils::loadInPlace(mBuffer, mBufferSize, nullptr, &error));
|
||||||
|
|
||||||
|
mContainerBuffer = buffer + mStaticCompoundInfo->m_Offset;
|
||||||
|
auto result2 = hkNativePackfileUtils::validatePackfileHeader(mContainerBuffer, &error);
|
||||||
|
if (!result2.isSuccess())
|
||||||
|
util::PrintDebugFmt("%s: invalid physics packfile: %s", __func__, error);
|
||||||
|
mContainerBufferSize =
|
||||||
|
hkNativePackfileUtils::getRequiredBufferSize(mContainerBuffer, int(buffer_size));
|
||||||
|
auto* container = static_cast<hkRootLevelContainer*>(
|
||||||
|
hkNativePackfileUtils::loadInPlace(mContainerBuffer, mContainerBufferSize));
|
||||||
|
|
||||||
|
auto* physics_data = container->findObject<hkpPhysicsData>();
|
||||||
|
|
||||||
|
mHeap = util::tryCreateDualHeap(parent_heap);
|
||||||
|
if (!mHeap) {
|
||||||
|
util::PrintDebugFmt("%s: failed to create dual heap", __func__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHeap->enableWarning(false);
|
||||||
|
auto* heap = mHeap;
|
||||||
|
|
||||||
|
const auto& systems = physics_data->getPhysicsSystems();
|
||||||
|
mFieldBodyGroups.allocBufferAssert(NumBodyGroups, heap);
|
||||||
|
for (int i = 0, n = mFieldBodyGroups.size(); i < n; ++i)
|
||||||
|
mFieldBodyGroups[i].init(*systems[i], &mMtx, this, heap);
|
||||||
|
|
||||||
|
mName = systems[0]->getName();
|
||||||
|
mName.trimMatchedString("_0");
|
||||||
|
|
||||||
|
if (mStaticCompoundInfo->m_ActorInfo.getSize() > 0)
|
||||||
|
mMapObjects.allocBufferAssert(mStaticCompoundInfo->m_ActorInfo.getSize(), heap);
|
||||||
|
|
||||||
|
mFlags.set(Flag::Initialised);
|
||||||
|
mHeap->adjust();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StaticCompound::setMapObject(u32 hash_id, u32 srt_hash, map::Object* object) {
|
||||||
|
int idx = mStaticCompoundInfo->getActorIdx(hash_id, srt_hash);
|
||||||
|
if (idx < 0 || idx >= mMapObjects.size())
|
||||||
|
return;
|
||||||
|
mMapObjects[idx] = object;
|
||||||
|
}
|
||||||
|
|
||||||
|
map::Object* StaticCompound::getMapObject(int shape_idx) const {
|
||||||
|
auto* info = mStaticCompoundInfo->getShapeInfo(shape_idx);
|
||||||
|
if (!info)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const int idx = info->m_ActorInfoIndex;
|
||||||
|
if (!mMapObjects.isIndexValid(idx))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return mMapObjects[idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool StaticCompound::disableCollision(int actor_idx, bool x) {
|
||||||
|
const int start = mStaticCompoundInfo->getShapeInfoStart(actor_idx);
|
||||||
|
const int end = mStaticCompoundInfo->getShapeInfoEnd(actor_idx);
|
||||||
|
for (int i = start; i <= end; ++i) {
|
||||||
|
auto* info = mStaticCompoundInfo->getShapeInfo(i);
|
||||||
|
if (!info || info->m_ActorInfoIndex < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const auto group = info->m_BodyGroup;
|
||||||
|
const auto type = static_cast<BodyLayerType>(info->m_BodyLayerType);
|
||||||
|
const auto instance_id = info->m_InstanceId;
|
||||||
|
|
||||||
|
mFieldBodyGroups[group].disableCollision(type, instance_id, x);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BodyGroup* StaticCompound::getFieldBodyGroup(int idx) {
|
||||||
return &mFieldBodyGroups[idx];
|
return &mFieldBodyGroups[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticCompound::hasFieldBodyGroup(FieldBodyGroup* group) const {
|
bool StaticCompound::hasFieldBodyGroup(BodyGroup* group) const {
|
||||||
for (int i = 0, n = mFieldBodyGroups.size(); i < n; ++i) {
|
for (int i = 0, n = mFieldBodyGroups.size(); i < n; ++i) {
|
||||||
if (&mFieldBodyGroups[i] == group)
|
if (&mFieldBodyGroups[i] == group)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -10,9 +10,15 @@
|
||||||
#include "KingSystem/Resource/resResource.h"
|
#include "KingSystem/Resource/resResource.h"
|
||||||
#include "KingSystem/Utils/Types.h"
|
#include "KingSystem/Utils/Types.h"
|
||||||
|
|
||||||
|
namespace ksys::map {
|
||||||
|
class Object;
|
||||||
|
}
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
class FieldBodyGroup;
|
struct ActorInfo;
|
||||||
|
class BodyGroup;
|
||||||
|
struct StaticCompoundInfo;
|
||||||
|
|
||||||
class StaticCompound : public res::Resource, public sead::hostio::Node {
|
class StaticCompound : public res::Resource, public sead::hostio::Node {
|
||||||
SEAD_RTTI_OVERRIDE(StaticCompound, res::Resource)
|
SEAD_RTTI_OVERRIDE(StaticCompound, res::Resource)
|
||||||
|
@ -21,11 +27,16 @@ public:
|
||||||
StaticCompound();
|
StaticCompound();
|
||||||
~StaticCompound() override;
|
~StaticCompound() override;
|
||||||
|
|
||||||
FieldBodyGroup* getFieldBodyGroup(int idx);
|
void setMapObject(u32 hash_id, u32 srt_hash, map::Object* object);
|
||||||
bool hasFieldBodyGroup(FieldBodyGroup* group) const;
|
map::Object* getMapObject(int shape_idx) const;
|
||||||
|
|
||||||
|
bool disableCollision(int actor_idx, bool x);
|
||||||
|
|
||||||
|
BodyGroup* getFieldBodyGroup(int idx);
|
||||||
|
bool hasFieldBodyGroup(BodyGroup* group) const;
|
||||||
|
|
||||||
// res::Resource interface
|
// res::Resource interface
|
||||||
void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* heap) override;
|
void doCreate_(u8* buffer, u32 buffer_size, sead::Heap* parent_heap) override;
|
||||||
bool needsParse() const override { return true; }
|
bool needsParse() const override { return true; }
|
||||||
bool finishParsing_() override;
|
bool finishParsing_() override;
|
||||||
bool m7_() override;
|
bool m7_() override;
|
||||||
|
@ -37,15 +48,15 @@ private:
|
||||||
|
|
||||||
sead::TypedBitFlag<Flag> mFlags;
|
sead::TypedBitFlag<Flag> mFlags;
|
||||||
sead::Heap* mHeap{};
|
sead::Heap* mHeap{};
|
||||||
void* _50{};
|
const StaticCompoundInfo* mStaticCompoundInfo{};
|
||||||
void* mData{};
|
void* mBuffer{};
|
||||||
int _60{};
|
int mBufferSize{};
|
||||||
void* _68{};
|
void* mContainerBuffer{};
|
||||||
int _70{};
|
int mContainerBufferSize{};
|
||||||
sead::Buffer<FieldBodyGroup> mFieldBodyGroups;
|
sead::Buffer<BodyGroup> mFieldBodyGroups;
|
||||||
sead::FixedSafeString<32> mName;
|
sead::FixedSafeString<32> mName;
|
||||||
sead::Matrix34f mMtx = sead::Matrix34f::ident;
|
sead::Matrix34f mMtx = sead::Matrix34f::ident;
|
||||||
sead::Buffer<void*> _f0{};
|
sead::Buffer<map::Object*> mMapObjects{};
|
||||||
sead::CriticalSection mCS;
|
sead::CriticalSection mCS;
|
||||||
};
|
};
|
||||||
KSYS_CHECK_SIZE_NX150(StaticCompound, 0x140);
|
KSYS_CHECK_SIZE_NX150(StaticCompound, 0x140);
|
||||||
|
|
|
@ -0,0 +1,104 @@
|
||||||
|
#include <Havok/Common/Base/Reflection/hkClass.h>
|
||||||
|
#include <Havok/Common/Base/Reflection/hkClassMember.h>
|
||||||
|
#include <Havok/Common/Base/Reflection/hkTypeInfo.h>
|
||||||
|
#include <array>
|
||||||
|
#include "KingSystem/Physics/StaticCompound/physStaticCompoundInfo.h"
|
||||||
|
|
||||||
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
// Reflection data is normally autogenerated with a Havok script and type parser,
|
||||||
|
// but considering we only have 3 classes it's easier to just write the data manually.
|
||||||
|
|
||||||
|
// ShapeInfo
|
||||||
|
|
||||||
|
static constexpr hkClassMember ShapeInfo_Members[] = {
|
||||||
|
{"ActorInfoIndex", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
||||||
|
hkClassMember::Type::TYPE_VOID, 0, 0, 0, nullptr},
|
||||||
|
{"InstanceId", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
||||||
|
hkClassMember::Type::TYPE_VOID, 0, 0, 4, nullptr},
|
||||||
|
{"BodyGroup", nullptr, nullptr, hkClassMember::Type::TYPE_INT8, hkClassMember::Type::TYPE_VOID,
|
||||||
|
0, 0, 8, nullptr},
|
||||||
|
{"BodyLayerType", nullptr, nullptr, hkClassMember::Type::TYPE_UINT8,
|
||||||
|
hkClassMember::Type::TYPE_VOID, 0, 0, 9, nullptr},
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass ShapeInfo_Class{
|
||||||
|
"ShapeInfo",
|
||||||
|
nullptr,
|
||||||
|
sizeof(ShapeInfo),
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
ShapeInfo_Members,
|
||||||
|
std::size(ShapeInfo_Members),
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass& ShapeInfo::staticClass() {
|
||||||
|
return ShapeInfo_Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hkTypeInfo ShapeInfo_TypeInfo = hkTypeInfo::make<ShapeInfo>("ShapeInfo", "!ShapeInfo");
|
||||||
|
|
||||||
|
// ActorInfo
|
||||||
|
|
||||||
|
static constexpr hkClassMember ActorInfo_Members[] = {
|
||||||
|
{"HashId", nullptr, nullptr, hkClassMember::Type::TYPE_UINT32, hkClassMember::Type::TYPE_VOID,
|
||||||
|
0, 0, 0, nullptr},
|
||||||
|
{"SRTHash", nullptr, nullptr, hkClassMember::Type::TYPE_INT32, hkClassMember::Type::TYPE_VOID,
|
||||||
|
0, 0, 4, nullptr},
|
||||||
|
{"ShapeInfoStart", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
||||||
|
hkClassMember::Type::TYPE_VOID, 0, 0, 8, nullptr},
|
||||||
|
{"ShapeInfoEnd", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
||||||
|
hkClassMember::Type::TYPE_VOID, 0, 0, 0xc, nullptr},
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass ActorInfo_Class{
|
||||||
|
"ActorInfo",
|
||||||
|
nullptr,
|
||||||
|
sizeof(ActorInfo),
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
ActorInfo_Members,
|
||||||
|
std::size(ActorInfo_Members),
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass& ActorInfo::staticClass() {
|
||||||
|
return ActorInfo_Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hkTypeInfo ActorInfo_TypeInfo = hkTypeInfo::make<ActorInfo>("ActorInfo", "!ActorInfo");
|
||||||
|
|
||||||
|
// StaticCompoundInfo
|
||||||
|
|
||||||
|
static constexpr hkClassMember StaticCompoundInfo_Members[] = {
|
||||||
|
{"Offset", nullptr, nullptr, hkClassMember::Type::TYPE_UINT32, hkClassMember::Type::TYPE_VOID,
|
||||||
|
0, 0, 0, nullptr},
|
||||||
|
{"ActorInfo", &ActorInfo_Class, nullptr, hkClassMember::Type::TYPE_ARRAY,
|
||||||
|
hkClassMember::Type::TYPE_STRUCT, 0, 0, 8, nullptr},
|
||||||
|
{"ShapeInfo", &ShapeInfo_Class, nullptr, hkClassMember::Type::TYPE_ARRAY,
|
||||||
|
hkClassMember::Type::TYPE_STRUCT, 0, 0, 0x18, nullptr},
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass StaticCompoundInfo_Class{
|
||||||
|
"StaticCompoundInfo",
|
||||||
|
nullptr,
|
||||||
|
sizeof(StaticCompoundInfo),
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
nullptr,
|
||||||
|
0,
|
||||||
|
StaticCompoundInfo_Members,
|
||||||
|
std::size(StaticCompoundInfo_Members),
|
||||||
|
};
|
||||||
|
|
||||||
|
const hkClass& StaticCompoundInfo::staticClass() {
|
||||||
|
return StaticCompoundInfo_Class;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hkTypeInfo StaticCompoundInfo_TypeInfo =
|
||||||
|
hkTypeInfo::make<StaticCompoundInfo>("StaticCompoundInfo", "!StaticCompoundInfo");
|
||||||
|
|
||||||
|
} // namespace ksys::phys
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "KingSystem/Physics/StaticCompound/physStaticCompoundBodyGroup.h"
|
||||||
|
|
||||||
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
BodyGroup::BodyGroup() = default;
|
||||||
|
|
||||||
|
} // namespace ksys::phys
|
|
@ -8,18 +8,26 @@
|
||||||
#include <thread/seadAtomic.h>
|
#include <thread/seadAtomic.h>
|
||||||
#include "KingSystem/Utils/Types.h"
|
#include "KingSystem/Utils/Types.h"
|
||||||
|
|
||||||
|
class hkpPhysicsSystem;
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
enum class BodyLayerType;
|
||||||
class RigidBody;
|
class RigidBody;
|
||||||
class StaticCompound;
|
class StaticCompound;
|
||||||
|
|
||||||
class FieldBodyGroup {
|
class BodyGroup {
|
||||||
public:
|
public:
|
||||||
FieldBodyGroup();
|
BodyGroup();
|
||||||
~FieldBodyGroup();
|
~BodyGroup();
|
||||||
|
|
||||||
FieldBodyGroup(const FieldBodyGroup&) = delete;
|
BodyGroup(const BodyGroup&) = delete;
|
||||||
auto operator=(const FieldBodyGroup&) = delete;
|
auto operator=(const BodyGroup&) = delete;
|
||||||
|
|
||||||
|
void init(const hkpPhysicsSystem& system, sead::Matrix34f* mtx, StaticCompound* sc,
|
||||||
|
sead::Heap* heap);
|
||||||
|
|
||||||
|
void disableCollision(BodyLayerType body_layer_type, int instance_id, bool x);
|
||||||
|
|
||||||
sead::Atomic<u32> _0;
|
sead::Atomic<u32> _0;
|
||||||
sead::Atomic<u32> _4;
|
sead::Atomic<u32> _4;
|
||||||
|
@ -37,6 +45,6 @@ public:
|
||||||
u32 _e0{};
|
u32 _e0{};
|
||||||
sead::Buffer<void*> _e8;
|
sead::Buffer<void*> _e8;
|
||||||
};
|
};
|
||||||
KSYS_CHECK_SIZE_NX150(FieldBodyGroup, 0xf8);
|
KSYS_CHECK_SIZE_NX150(BodyGroup, 0xf8);
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
|
@ -1,7 +0,0 @@
|
||||||
#include "KingSystem/Physics/StaticCompound/physStaticCompoundFieldBodyGroup.h"
|
|
||||||
|
|
||||||
namespace ksys::phys {
|
|
||||||
|
|
||||||
FieldBodyGroup::FieldBodyGroup() = default;
|
|
||||||
|
|
||||||
} // namespace ksys::phys
|
|
|
@ -1,104 +1,56 @@
|
||||||
#include "KingSystem/Physics/StaticCompound/physStaticCompoundInfo.h"
|
#include "KingSystem/Physics/StaticCompound/physStaticCompoundInfo.h"
|
||||||
#include <Havok/Common/Base/Reflection/hkClass.h>
|
|
||||||
#include <Havok/Common/Base/Reflection/hkClassMember.h>
|
|
||||||
#include <Havok/Common/Base/Reflection/hkTypeInfo.h>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
// Reflection data is normally autogenerated with a Havok script and type parser,
|
int StaticCompoundInfo::getActorIdx(u32 hash_id, u32 srt_hash) const {
|
||||||
// but considering we only have 3 classes it's easier to just write the data manually.
|
for (int i = 0; i < m_ActorInfo.getSize(); ++i) {
|
||||||
|
const auto& info = m_ActorInfo[i];
|
||||||
// ShapeInfo
|
if (info.m_HashId == hash_id && u32(info.m_SRTHash) == srt_hash)
|
||||||
|
return i;
|
||||||
static constexpr hkClassMember ShapeInfo_Members[] = {
|
}
|
||||||
{"ActorInfoIndex", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
return -1;
|
||||||
hkClassMember::Type::TYPE_VOID, 0, 0, 0, nullptr},
|
|
||||||
{"InstanceId", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
|
||||||
hkClassMember::Type::TYPE_VOID, 0, 0, 4, nullptr},
|
|
||||||
{"BodyGroup", nullptr, nullptr, hkClassMember::Type::TYPE_INT8, hkClassMember::Type::TYPE_VOID,
|
|
||||||
0, 0, 8, nullptr},
|
|
||||||
{"BodyLayerType", nullptr, nullptr, hkClassMember::Type::TYPE_UINT8,
|
|
||||||
hkClassMember::Type::TYPE_VOID, 0, 0, 9, nullptr},
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass ShapeInfo_Class{
|
|
||||||
"ShapeInfo",
|
|
||||||
nullptr,
|
|
||||||
sizeof(ShapeInfo),
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
ShapeInfo_Members,
|
|
||||||
std::size(ShapeInfo_Members),
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass& ShapeInfo::staticClass() {
|
|
||||||
return ShapeInfo_Class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hkTypeInfo ShapeInfo_TypeInfo = hkTypeInfo::make<ShapeInfo>("ShapeInfo", "!ShapeInfo");
|
int StaticCompoundInfo::getShapeInfoStart(int actor_idx) const {
|
||||||
|
if (actor_idx < 0 || actor_idx >= m_ActorInfo.getSize())
|
||||||
// ActorInfo
|
return -1;
|
||||||
|
return m_ActorInfo[actor_idx].m_ShapeInfoStart;
|
||||||
static constexpr hkClassMember ActorInfo_Members[] = {
|
|
||||||
{"HashId", nullptr, nullptr, hkClassMember::Type::TYPE_UINT32, hkClassMember::Type::TYPE_VOID,
|
|
||||||
0, 0, 0, nullptr},
|
|
||||||
{"SRTHash", nullptr, nullptr, hkClassMember::Type::TYPE_INT32, hkClassMember::Type::TYPE_VOID,
|
|
||||||
0, 0, 4, nullptr},
|
|
||||||
{"ShapeInfoStart", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
|
||||||
hkClassMember::Type::TYPE_VOID, 0, 0, 8, nullptr},
|
|
||||||
{"ShapeInfoEnd", nullptr, nullptr, hkClassMember::Type::TYPE_INT32,
|
|
||||||
hkClassMember::Type::TYPE_VOID, 0, 0, 0xc, nullptr},
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass ActorInfo_Class{
|
|
||||||
"ActorInfo",
|
|
||||||
nullptr,
|
|
||||||
sizeof(ActorInfo),
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
ActorInfo_Members,
|
|
||||||
std::size(ActorInfo_Members),
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass& ActorInfo::staticClass() {
|
|
||||||
return ActorInfo_Class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hkTypeInfo ActorInfo_TypeInfo = hkTypeInfo::make<ActorInfo>("ActorInfo", "!ActorInfo");
|
int StaticCompoundInfo::getShapeInfoEnd(int actor_idx) const {
|
||||||
|
if (actor_idx < 0 || actor_idx >= m_ActorInfo.getSize())
|
||||||
// StaticCompoundInfo
|
return -1;
|
||||||
|
return m_ActorInfo[actor_idx].m_ShapeInfoEnd;
|
||||||
static constexpr hkClassMember StaticCompoundInfo_Members[] = {
|
|
||||||
{"Offset", nullptr, nullptr, hkClassMember::Type::TYPE_UINT32, hkClassMember::Type::TYPE_VOID,
|
|
||||||
0, 0, 0, nullptr},
|
|
||||||
{"ActorInfo", &ActorInfo_Class, nullptr, hkClassMember::Type::TYPE_ARRAY,
|
|
||||||
hkClassMember::Type::TYPE_STRUCT, 0, 0, 8, nullptr},
|
|
||||||
{"ShapeInfo", &ShapeInfo_Class, nullptr, hkClassMember::Type::TYPE_ARRAY,
|
|
||||||
hkClassMember::Type::TYPE_STRUCT, 0, 0, 0x18, nullptr},
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass StaticCompoundInfo_Class{
|
|
||||||
"StaticCompoundInfo",
|
|
||||||
nullptr,
|
|
||||||
sizeof(StaticCompoundInfo),
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
StaticCompoundInfo_Members,
|
|
||||||
std::size(StaticCompoundInfo_Members),
|
|
||||||
};
|
|
||||||
|
|
||||||
const hkClass& StaticCompoundInfo::staticClass() {
|
|
||||||
return StaticCompoundInfo_Class;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const hkTypeInfo StaticCompoundInfo_TypeInfo =
|
const ShapeInfo* StaticCompoundInfo::getShapeInfo(int shape_idx) const {
|
||||||
hkTypeInfo::make<StaticCompoundInfo>("StaticCompoundInfo", "!StaticCompoundInfo");
|
if (shape_idx < 0 || shape_idx >= m_ShapeInfo.getSize())
|
||||||
|
return nullptr;
|
||||||
|
return &m_ShapeInfo[shape_idx];
|
||||||
|
}
|
||||||
|
|
||||||
|
static ContactLayer getContactLayerForBodyLayerType(BodyLayerType type) {
|
||||||
|
ContactLayer map[NumBodyLayerTypes];
|
||||||
|
map[int(BodyLayerType::EntityGround)] = ContactLayer::EntityGround;
|
||||||
|
map[int(BodyLayerType::EntityGroundSmooth)] = ContactLayer::EntityGroundSmooth;
|
||||||
|
map[int(BodyLayerType::EntityGroundRough)] = ContactLayer::EntityGroundRough;
|
||||||
|
map[int(BodyLayerType::EntityObject)] = ContactLayer::EntityObject;
|
||||||
|
map[int(BodyLayerType::EntityGroundObject)] = ContactLayer::EntityGroundObject;
|
||||||
|
map[int(BodyLayerType::EntityTree)] = ContactLayer::EntityTree;
|
||||||
|
map[int(BodyLayerType::SensorInDoor)] = ContactLayer::SensorInDoor;
|
||||||
|
map[int(BodyLayerType::EntityNoHit)] = ContactLayer::EntityNoHit;
|
||||||
|
map[int(BodyLayerType::EntityWallForClimb)] = ContactLayer::EntityWallForClimb;
|
||||||
|
map[int(BodyLayerType::EntityWater)] = ContactLayer::EntityWater;
|
||||||
|
return map[int(type)];
|
||||||
|
}
|
||||||
|
|
||||||
|
BodyLayerType getBodyLayerType(ContactLayer layer) {
|
||||||
|
for (int i = 0; i < NumBodyLayerTypes; ++i) {
|
||||||
|
auto type = static_cast<BodyLayerType>(i);
|
||||||
|
if (int(getContactLayerForBodyLayerType(type)) == int(layer))
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
return BodyLayerType::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
||||||
|
|
|
@ -1,11 +1,27 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Havok/Common/Base/hkBase.h>
|
#include <Havok/Common/Base/hkBase.h>
|
||||||
|
#include "KingSystem/Physics/System/physDefines.h"
|
||||||
|
|
||||||
class hkTypeInfo;
|
class hkTypeInfo;
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
enum class BodyLayerType {
|
||||||
|
EntityGround,
|
||||||
|
EntityGroundSmooth,
|
||||||
|
EntityGroundRough,
|
||||||
|
EntityObject,
|
||||||
|
EntityGroundObject,
|
||||||
|
EntityTree,
|
||||||
|
SensorInDoor,
|
||||||
|
EntityNoHit,
|
||||||
|
EntityWallForClimb,
|
||||||
|
EntityWater,
|
||||||
|
Invalid = -1,
|
||||||
|
};
|
||||||
|
constexpr int NumBodyLayerTypes = 10;
|
||||||
|
|
||||||
struct ShapeInfo {
|
struct ShapeInfo {
|
||||||
HK_DECLARE_REFLECTION()
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
@ -31,6 +47,11 @@ extern const hkTypeInfo ActorInfo_TypeInfo;
|
||||||
struct StaticCompoundInfo {
|
struct StaticCompoundInfo {
|
||||||
HK_DECLARE_REFLECTION()
|
HK_DECLARE_REFLECTION()
|
||||||
|
|
||||||
|
int getActorIdx(u32 hash_id, u32 srt_hash) const;
|
||||||
|
int getShapeInfoStart(int actor_idx) const;
|
||||||
|
int getShapeInfoEnd(int actor_idx) const;
|
||||||
|
const ShapeInfo* getShapeInfo(int shape_idx) const;
|
||||||
|
|
||||||
hkUint32 m_Offset;
|
hkUint32 m_Offset;
|
||||||
hkArray<ActorInfo> m_ActorInfo;
|
hkArray<ActorInfo> m_ActorInfo;
|
||||||
hkArray<ShapeInfo> m_ShapeInfo;
|
hkArray<ShapeInfo> m_ShapeInfo;
|
||||||
|
@ -38,4 +59,6 @@ struct StaticCompoundInfo {
|
||||||
extern const hkClass StaticCompoundInfo_Class;
|
extern const hkClass StaticCompoundInfo_Class;
|
||||||
extern const hkTypeInfo StaticCompoundInfo_TypeInfo;
|
extern const hkTypeInfo StaticCompoundInfo_TypeInfo;
|
||||||
|
|
||||||
|
BodyLayerType getBodyLayerType(ContactLayer layer);
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
||||||
|
|
Loading…
Reference in New Issue