From 55164640d52ed76d16bdbacffb882e3d9ccdd30a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 2 Feb 2022 15:09:28 +0100 Subject: [PATCH] ksys/phys: Add BoxWaterRigidBody --- data/uking_functions.csv | 32 +++++----- src/KingSystem/Physics/CMakeLists.txt | 10 ++-- .../RigidBody/Shape/physBoxWaterRigidBody.cpp | 60 +++++++++++++++++++ .../RigidBody/Shape/physBoxWaterRigidBody.h | 40 +++++++++++++ 4 files changed, 122 insertions(+), 20 deletions(-) create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index 2eb2baf2..8107f359 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -83167,22 +83167,22 @@ Address,Quality,Size,Name 0x0000007100f9746c,O,000288,_ZNK4ksys4phys12BoxRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE 0x0000007100f9758c,O,000092,_ZNK4ksys4phys12BoxRigidBody18getRuntimeTypeInfoEv 0x0000007100f975e8,U,000004, -0x0000007100f975ec,U,000088, -0x0000007100f97644,U,000076, -0x0000007100f97690,U,000076, -0x0000007100f976dc,U,000084, -0x0000007100f97730,U,000084, -0x0000007100f97784,U,000056, -0x0000007100f977bc,U,000056, -0x0000007100f977f4,U,000012, -0x0000007100f97800,U,000008, -0x0000007100f97808,U,000012, -0x0000007100f97814,U,000016, -0x0000007100f97824,U,000008, -0x0000007100f9782c,U,000008, -0x0000007100f97834,U,000068, -0x0000007100f97878,U,000288, -0x0000007100f97998,U,000092, +0x0000007100f975ec,O,000088,_ZN4ksys4phys17BoxWaterRigidBodyC1EP12hkpRigidBodyPNS0_13BoxWaterShapeENS0_16ContactLayerTypeERKN4sead14SafeStringBaseIcEEbPNS7_4HeapE +0x0000007100f97644,O,000076,_ZN4ksys4phys17BoxWaterRigidBodyD1Ev +0x0000007100f97690,O,000076,_ZThn32_N4ksys4phys17BoxWaterRigidBodyD1Ev +0x0000007100f976dc,O,000084,_ZN4ksys4phys17BoxWaterRigidBodyD0Ev +0x0000007100f97730,O,000084,_ZThn32_N4ksys4phys17BoxWaterRigidBodyD0Ev +0x0000007100f97784,O,000056,_ZN4ksys4phys17BoxWaterRigidBody10setExtentsERKN4sead7Vector3IfEE +0x0000007100f977bc,O,000056,_ZN4ksys4phys17BoxWaterRigidBody12setTranslateERKN4sead7Vector3IfEE +0x0000007100f977f4,O,000012,_ZNK4ksys4phys17BoxWaterRigidBody10getExtentsEv +0x0000007100f97800,O,000008,_ZN4ksys4phys17BoxWaterRigidBody15setMaterialMaskERKNS0_12MaterialMaskE +0x0000007100f97808,O,000012,_ZNK4ksys4phys17BoxWaterRigidBody15getMaterialMaskEv +0x0000007100f97814,O,000016,_ZN4ksys4phys17BoxWaterRigidBody9getVolumeEv +0x0000007100f97824,O,000008,_ZN4ksys4phys17BoxWaterRigidBody9getShape_Ev +0x0000007100f9782c,O,000008,_ZNK4ksys4phys17BoxWaterRigidBody9getShape_Ev +0x0000007100f97834,O,000068,_ZN4ksys4phys17BoxWaterRigidBody17getCollisionMasksEPNS0_9RigidBody14CollisionMasksE +0x0000007100f97878,O,000288,_ZNK4ksys4phys17BoxWaterRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE +0x0000007100f97998,O,000092,_ZNK4ksys4phys17BoxWaterRigidBody18getRuntimeTypeInfoEv 0x0000007100f979f4,U,000004,j__ZN4ksys4phys16RigidBodyFactory13createCapsuleEPNS0_18RigidBodyParamViewEPN4sead4HeapE 0x0000007100f979f8,U,000084, 0x0000007100f97a4c,U,000088, diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 8d235b74..90628486 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -40,12 +40,14 @@ target_sources(uking PRIVATE RigidBody/physRigidBodySetParam.cpp RigidBody/physRigidBodySetParam.h - RigidBody/Shape/physBoxShape.cpp - RigidBody/Shape/physBoxShape.h - RigidBody/Shape/physBoxWaterShape.cpp - RigidBody/Shape/physBoxWaterShape.h RigidBody/Shape/physBoxRigidBody.cpp RigidBody/Shape/physBoxRigidBody.h + RigidBody/Shape/physBoxShape.cpp + RigidBody/Shape/physBoxShape.h + RigidBody/Shape/physBoxWaterRigidBody.cpp + RigidBody/Shape/physBoxWaterRigidBody.h + RigidBody/Shape/physBoxWaterShape.cpp + RigidBody/Shape/physBoxWaterShape.h RigidBody/Shape/physCapsuleShape.cpp RigidBody/Shape/physCapsuleShape.h RigidBody/Shape/physCharacterPrismShape.cpp diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp new file mode 100644 index 00000000..13ab6a92 --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp @@ -0,0 +1,60 @@ +#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h" +#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterShape.h" + +namespace ksys::phys { + +BoxWaterRigidBody::BoxWaterRigidBody(hkpRigidBody* hk_body, BoxWaterShape* shape, + ContactLayerType layer_type, const sead::SafeString& name, + bool unused, sead::Heap* heap) + : RigidBodyFromShape(hk_body, layer_type, name, true, heap), mShape(shape) {} + +BoxWaterRigidBody::~BoxWaterRigidBody() { + delete mShape; +} + +void BoxWaterRigidBody::setExtents(const sead::Vector3f& extents) { + if (mShape->setExtents(extents)) + updateShape(); +} + +void BoxWaterRigidBody::setTranslate(const sead::Vector3f& translate) { + if (mShape->setTranslate(translate)) + updateShape(); +} + +const sead::Vector3f& BoxWaterRigidBody::getExtents() const { + return mShape->mExtents; +} + +const sead::Vector3f& BoxWaterRigidBody::getTranslate() const { + return mShape->mTranslate; +} + +void BoxWaterRigidBody::setMaterialMask(const MaterialMask& mask) { + mShape->setMaterialMask(mask); +} + +const MaterialMask& BoxWaterRigidBody::getMaterialMask() const { + return mShape->mMaterialMask; +} + +float BoxWaterRigidBody::getVolume() { + return mShape->getVolume(); +} + +Shape* BoxWaterRigidBody::getShape_() { + return mShape; +} + +const Shape* BoxWaterRigidBody::getShape_() const { + return mShape; +} + +u32 BoxWaterRigidBody::getCollisionMasks(RigidBody::CollisionMasks* masks) { + masks->ignored_layers = ~mContactMask.getDirect(); + masks->collision_filter_info = getCollisionFilterInfo(); + masks->material_mask = getMaterialMask().getRawData(); + return 0; +} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h new file mode 100644 index 00000000..031040cf --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h @@ -0,0 +1,40 @@ +#pragma once + +#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h" + +namespace ksys::phys { + +class BoxWaterShape; + +class BoxWaterRigidBody : public RigidBodyFromShape { + SEAD_RTTI_OVERRIDE(BoxWaterRigidBody, RigidBodyFromShape) +public: + static BoxWaterRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap); + + BoxWaterRigidBody(hkpRigidBody* hk_body, BoxWaterShape* shape, ContactLayerType layer_type, + const sead::SafeString& name, bool unused, sead::Heap* heap); + ~BoxWaterRigidBody() override; + + /// Set the box extents and trigger a shape update. + void setExtents(const sead::Vector3f& extents); + /// Set the box translation and trigger a shape update. + void setTranslate(const sead::Vector3f& translate); + + const sead::Vector3f& getExtents() const; + const sead::Vector3f& getTranslate() const; + + void setMaterialMask(const MaterialMask& mask); + const MaterialMask& getMaterialMask() const; + + float getVolume() override; + +protected: + Shape* getShape_() override; + const Shape* getShape_() const override; + u32 getCollisionMasks(CollisionMasks* masks) override; + + BoxWaterShape* mShape; + u32 _d8{}; +}; + +} // namespace ksys::phys