mirror of
https://github.com/zeldaret/botw
synced 2026-07-26 14:31:32 -04:00
ksys/phys: Add TeraMeshRigidBodyResource
This commit is contained in:
@@ -35,6 +35,10 @@ target_sources(uking PRIVATE
|
||||
RigidBody/Shape/physSphereShape.h
|
||||
RigidBody/Shape/physWaterCylinderShape.cpp
|
||||
RigidBody/Shape/physWaterCylinderShape.h
|
||||
RigidBody/TeraMesh/physTeraMeshRigidBody.cpp
|
||||
RigidBody/TeraMesh/physTeraMeshRigidBody.h
|
||||
RigidBody/TeraMesh/physTeraMeshRigidBodyResource.cpp
|
||||
RigidBody/TeraMesh/physTeraMeshRigidBodyResource.h
|
||||
|
||||
StaticCompound/physStaticCompound.cpp
|
||||
StaticCompound/physStaticCompound.h
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#include "KingSystem/Physics/RigidBody/TeraMesh/physTeraMeshRigidBody.h"
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
// FIXME
|
||||
class TeraMeshRigidBody : public RigidBody {
|
||||
public:
|
||||
TeraMeshRigidBody(hkpRigidBody* hk_body, sead::Heap* heap);
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -0,0 +1,29 @@
|
||||
#include "KingSystem/Physics/RigidBody/TeraMesh/physTeraMeshRigidBodyResource.h"
|
||||
#include <Havok/Common/Serialize/Util/hkNativePackfileUtils.h>
|
||||
#include <Havok/Common/Serialize/Util/hkRootLevelContainer.h>
|
||||
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
|
||||
#include "KingSystem/Physics/RigidBody/TeraMesh/physTeraMeshRigidBody.h"
|
||||
#include "KingSystem/Utils/Debug.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
TeraMeshRigidBodyResource::~TeraMeshRigidBodyResource() {
|
||||
delete mRigidBody;
|
||||
if (mHkpRigidBody)
|
||||
hkNativePackfileUtils::unloadInPlace(getRawData(), int(getRawSize()));
|
||||
}
|
||||
|
||||
bool TeraMeshRigidBodyResource::parse_(u8* data, size_t size, sead::Heap* heap) {
|
||||
const char* error = nullptr;
|
||||
auto* container = static_cast<hkRootLevelContainer*>(
|
||||
hkNativePackfileUtils::loadInPlace(getRawData(), int(getRawSize()), nullptr, &error));
|
||||
if (!container) {
|
||||
util::PrintDebugFmt("failed to load TeraMeshRigidBody resource: %s", error);
|
||||
}
|
||||
|
||||
mHkpRigidBody = container->findObject<hkpRigidBody>();
|
||||
mRigidBody = new (heap) TeraMeshRigidBody(mHkpRigidBody, heap);
|
||||
return mRigidBody != nullptr;
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "KingSystem/Resource/resResource.h"
|
||||
|
||||
class hkpRigidBody;
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
class TeraMeshRigidBody;
|
||||
|
||||
class TeraMeshRigidBodyResource : public res::Resource {
|
||||
SEAD_RTTI_OVERRIDE(TeraMeshRigidBodyResource, res::Resource)
|
||||
|
||||
public:
|
||||
TeraMeshRigidBodyResource() = default;
|
||||
~TeraMeshRigidBodyResource() override;
|
||||
|
||||
hkpRigidBody* getHkpRigidBody() const { return mHkpRigidBody; }
|
||||
TeraMeshRigidBody* getRigidBody() const { return mRigidBody; }
|
||||
|
||||
bool needsParse() const override { return true; }
|
||||
bool parse_(u8* data, size_t size, sead::Heap* heap) override;
|
||||
|
||||
private:
|
||||
hkpRigidBody* mHkpRigidBody = nullptr;
|
||||
TeraMeshRigidBody* mRigidBody = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -99,8 +99,7 @@ private:
|
||||
MotionAccessor* mMotionAccessor = nullptr;
|
||||
u16 _c0 = 0;
|
||||
void* _c8 = nullptr;
|
||||
void* _d0;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(RigidBody, 0xD8);
|
||||
KSYS_CHECK_SIZE_NX150(RigidBody, 0xD0);
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
Reference in New Issue
Block a user