From 30533da83d194984713639863323eb071cd58125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 30 Jan 2022 17:34:19 +0100 Subject: [PATCH] ksys/phys: Merge physShapeParam param classes with RigidBody/Shape --- data/uking_functions.csv | 12 +-- src/KingSystem/Physics/CMakeLists.txt | 6 ++ .../Physics/RigidBody/Shape/physBoxShape.h | 8 ++ .../RigidBody/Shape/physCapsuleShape.cpp | 5 +- .../RigidBody/Shape/physCapsuleShape.h | 7 +- .../Shape/physCharacterPrismShape.cpp | 1 + .../RigidBody/Shape/physCharacterPrismShape.h | 15 ++++ .../RigidBody/Shape/physCylinderShape.h | 8 ++ .../RigidBody/Shape/physPolytopeShape.cpp | 1 + .../RigidBody/Shape/physPolytopeShape.h | 13 ++++ .../Physics/RigidBody/Shape/physShape.h | 10 +++ .../RigidBody/Shape/physShapeParamObj.cpp | 22 ++++-- .../RigidBody/Shape/physShapeParamObj.h | 74 ++++--------------- .../Physics/RigidBody/Shape/physSphereShape.h | 6 ++ 14 files changed, 105 insertions(+), 83 deletions(-) create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.cpp create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.cpp create mode 100644 src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index d00a1ae4..1211e6e9 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -94814,12 +94814,12 @@ Address,Quality,Size,Name 0x0000007101283f50,O,000108,_ZN4ksys4phys13ShapeParamObjD0Ev 0x0000007101283fbc,O,000508,_ZN4ksys4phys13ShapeParamObj5parseERKN3agl3utl15ResParameterObjEPN4sead4HeapE 0x00000071012841b8,O,000664,_ZNK4ksys4phys13ShapeParamObj12getShapeTypeEv -0x0000007101284450,O,000132,_ZNK4ksys4phys13ShapeParamObj9getSphereEPNS0_11SphereParamE -0x00000071012844d4,O,000156,_ZNK4ksys4phys13ShapeParamObj10getCapsuleEPNS0_12CapsuleParamE -0x0000007101284570,O,000164,_ZNK4ksys4phys13ShapeParamObj11getCylinderEPNS0_13CylinderParamE -0x0000007101284614,O,000180,_ZNK4ksys4phys13ShapeParamObj6getBoxEPNS0_8BoxParamE -0x00000071012846c8,O,000108,_ZNK4ksys4phys13ShapeParamObj11getPolytopeEPNS0_13PolytopeParamE -0x0000007101284734,O,000156,_ZNK4ksys4phys13ShapeParamObj17getCharacterPrismEPNS0_19CharacterPrismParamE +0x0000007101284450,O,000132,_ZNK4ksys4phys13ShapeParamObj9getSphereEPNS0_16SphereShapeParamE +0x00000071012844d4,O,000156,_ZNK4ksys4phys13ShapeParamObj10getCapsuleEPNS0_17CapsuleShapeParamE +0x0000007101284570,O,000164,_ZNK4ksys4phys13ShapeParamObj11getCylinderEPNS0_18CylinderShapeParamE +0x0000007101284614,O,000180,_ZNK4ksys4phys13ShapeParamObj6getBoxEPNS0_13BoxShapeParamE +0x00000071012846c8,O,000108,_ZNK4ksys4phys13ShapeParamObj11getPolytopeEPNS0_18PolytopeShapeParamE +0x0000007101284734,O,000156,_ZNK4ksys4phys13ShapeParamObj17getCharacterPrismEPNS0_24CharacterPrismShapeParamE 0x00000071012847d0,U,000032, 0x00000071012847f0,U,000004,nullsub_4756 0x00000071012847f4,U,000004,j__ZdlPv_1284 diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 4e849abb..0458f14b 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -39,12 +39,17 @@ target_sources(uking PRIVATE RigidBody/physRigidBodySet.h RigidBody/physRigidBodySetParam.cpp RigidBody/physRigidBodySetParam.h + RigidBody/Shape/physBoxShape.cpp RigidBody/Shape/physBoxShape.h RigidBody/Shape/physCapsuleShape.cpp RigidBody/Shape/physCapsuleShape.h + RigidBody/Shape/physCharacterPrismShape.cpp + RigidBody/Shape/physCharacterPrismShape.h RigidBody/Shape/physCylinderShape.cpp RigidBody/Shape/physCylinderShape.h + RigidBody/Shape/physPolytopeShape.cpp + RigidBody/Shape/physPolytopeShape.h RigidBody/Shape/physShape.h RigidBody/Shape/physShapeParamObj.cpp RigidBody/Shape/physShapeParamObj.h @@ -52,6 +57,7 @@ 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 diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.h b/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.h index 8fa686e0..fbaa11e4 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.h @@ -1,5 +1,7 @@ #pragma once +#include +#include "KingSystem/Physics/RigidBody/Shape/physShape.h" #include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/RigidBody/physRigidBodyParam.h" @@ -15,6 +17,12 @@ struct BoxShape { struct BoxShapeParam { BoxShape* createShape(sead::Heap* heap); + + sead::Vector3f translate_1; + sead::Vector3f translate_0; + sead::Vector3f rotate; + float convex_radius; + CommonShapeParam common; }; class BoxParam : public RigidBodyInstanceParam { diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp index 60963fd0..383f9beb 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp +++ b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.cpp @@ -8,9 +8,10 @@ namespace ksys::phys { CapsuleShape::CapsuleShape(const CapsuleShapeParam& shape_, hkpShape* hkp_shape_) : vertex_a(shape_.vertex_a), vertex_b(shape_.vertex_b), radius(shape_.radius), - material_mask(shape_.material, shape_.sub_material, shape_.floor_code, shape_.wall_code), + material_mask(shape_.common.material, shape_.common.sub_material, shape_.common.floor_code, + shape_.common.wall_code), shape(hkp_shape_) { - if (shape_._38) + if (shape_.common.item_code_disable_stick) material_mask.getData().setCustomFlag(MaterialMaskData::CustomFlag::_0); setMaterialMask(material_mask); } diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h index 5609f224..3fb26bf9 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h @@ -23,12 +23,7 @@ struct CapsuleShapeParam { sead::Vector3f vertex_a; sead::Vector3f vertex_b; f32 radius; - u32 _1c; - Material material; - const char* sub_material = sead::SafeString::cEmptyString.cstr(); - FloorCode floor_code; - WallCode wall_code; - bool _38 = false; + CommonShapeParam common; }; struct CapsuleShape : Shape { diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.cpp new file mode 100644 index 00000000..347059b7 --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.cpp @@ -0,0 +1 @@ +#include "KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h" diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h b/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h new file mode 100644 index 00000000..737026cf --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include "KingSystem/Physics/RigidBody/Shape/physShape.h" + +namespace ksys::phys { + +struct CharacterPrismShapeParam { + float radius; + sead::Vector3f translate_0; + sead::Vector3f translate_1; + CommonShapeParam common; +}; + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/RigidBody/Shape/physCylinderShape.h b/src/KingSystem/Physics/RigidBody/Shape/physCylinderShape.h index d68ebdb9..3f38af9e 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physCylinderShape.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physCylinderShape.h @@ -1,5 +1,7 @@ #pragma once +#include +#include "KingSystem/Physics/RigidBody/Shape/physShape.h" #include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/RigidBody/physRigidBodyParam.h" @@ -15,6 +17,12 @@ struct CylinderShape { struct CylinderShapeParam { CylinderShape* createShape(sead::Heap* heap); + + sead::Vector3f translate_0; + float radius; + sead::Vector3f translate_1; + float convex_radius; + CommonShapeParam common; }; class CylinderParam : public RigidBodyInstanceParam { diff --git a/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.cpp new file mode 100644 index 00000000..216aee40 --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.cpp @@ -0,0 +1 @@ +#include "KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h" diff --git a/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h b/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h new file mode 100644 index 00000000..9aee9be2 --- /dev/null +++ b/src/KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include "KingSystem/Physics/RigidBody/Shape/physShape.h" + +namespace ksys::phys { + +struct PolytopeShapeParam { + u16 vertex_num; + CommonShapeParam common; +}; + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/RigidBody/Shape/physShape.h b/src/KingSystem/Physics/RigidBody/Shape/physShape.h index c84175ea..2bc8c973 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physShape.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physShape.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include "KingSystem/Physics/System/physDefines.h" class hkpShape; @@ -29,4 +31,12 @@ public: virtual void setScale(float scale) = 0; }; +struct CommonShapeParam { + Material material; + const char* sub_material = sead::SafeString::cEmptyString.cstr(); + FloorCode floor_code; + WallCode wall_code; + bool item_code_disable_stick = false; +}; + } // namespace ksys::phys diff --git a/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.cpp b/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.cpp index 5b7d89e4..0667af93 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.cpp +++ b/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.cpp @@ -1,5 +1,11 @@ #include "KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h" +#include "KingSystem/Physics/RigidBody/Shape/physBoxShape.h" +#include "KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h" +#include "KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h" +#include "KingSystem/Physics/RigidBody/Shape/physCylinderShape.h" +#include "KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h" #include "KingSystem/Physics/RigidBody/Shape/physShape.h" +#include "KingSystem/Physics/RigidBody/Shape/physSphereShape.h" namespace ksys::phys { @@ -62,20 +68,20 @@ void ShapeParamObj::getCommon(CommonShapeParam* param) const { param->item_code_disable_stick = *item_code_disable_stick; } -void ShapeParamObj::getSphere(SphereParam* param) const { +void ShapeParamObj::getSphere(SphereShapeParam* param) const { param->radius = *radius; param->translate = *translate_0; getCommon(¶m->common); } -void ShapeParamObj::getCapsule(CapsuleParam* param) const { +void ShapeParamObj::getCapsule(CapsuleShapeParam* param) const { param->radius = *radius; - param->translate_0 = *translate_0; - param->translate_1 = *translate_1; + param->vertex_a = *translate_0; + param->vertex_b = *translate_1; getCommon(¶m->common); } -void ShapeParamObj::getCylinder(CylinderParam* param) const { +void ShapeParamObj::getCylinder(CylinderShapeParam* param) const { param->radius = *radius; param->convex_radius = *convex_radius; param->translate_0 = *translate_0; @@ -83,7 +89,7 @@ void ShapeParamObj::getCylinder(CylinderParam* param) const { getCommon(¶m->common); } -void ShapeParamObj::getBox(BoxParam* param) const { +void ShapeParamObj::getBox(BoxShapeParam* param) const { param->translate_0 = *translate_0; param->translate_1 = *translate_1; param->rotate = *rotate; @@ -91,12 +97,12 @@ void ShapeParamObj::getBox(BoxParam* param) const { getCommon(¶m->common); } -void ShapeParamObj::getPolytope(PolytopeParam* param) const { +void ShapeParamObj::getPolytope(PolytopeShapeParam* param) const { param->vertex_num = *vertex_num; getCommon(¶m->common); } -void ShapeParamObj::getCharacterPrism(CharacterPrismParam* param) const { +void ShapeParamObj::getCharacterPrism(CharacterPrismShapeParam* param) const { param->radius = *radius; param->translate_0 = *translate_0; param->translate_1 = *translate_1; diff --git a/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h b/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h index 6193ba0a..7f781502 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h @@ -5,66 +5,18 @@ #include #include #include "KingSystem/Physics/System/physDefines.h" -#include "KingSystem/Utils/Types.h" namespace ksys::phys { enum class ShapeType; -struct CommonShapeParam { - Material material; - const char* sub_material; - FloorCode floor_code; - WallCode wall_code; - bool item_code_disable_stick; -}; - -struct SphereParam { - sead::Vector3f translate; - float radius; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(SphereParam, 0x30); - -struct CapsuleParam { - sead::Vector3f translate_0; - sead::Vector3f translate_1; - float radius; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(CapsuleParam, 0x40); - -struct CylinderParam { - sead::Vector3f translate_0; - float radius; - sead::Vector3f translate_1; - float convex_radius; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(CylinderParam, 0x40); - -struct BoxParam { - sead::Vector3f translate_1; - sead::Vector3f translate_0; - sead::Vector3f rotate; - float convex_radius; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(BoxParam, 0x48); - -struct PolytopeParam { - u16 vertex_num; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(PolytopeParam, 0x28); - -struct CharacterPrismParam { - float radius; - sead::Vector3f translate_0; - sead::Vector3f translate_1; - CommonShapeParam common; -}; -KSYS_CHECK_SIZE_NX150(CharacterPrismParam, 0x40); +struct BoxShapeParam; +struct CapsuleShapeParam; +struct CharacterPrismShapeParam; +struct CommonShapeParam; +struct CylinderShapeParam; +struct PolytopeShapeParam; +struct SphereShapeParam; struct ShapeParamObj : agl::utl::ParameterObj { ShapeParamObj(); @@ -76,12 +28,12 @@ struct ShapeParamObj : agl::utl::ParameterObj { ShapeType getShapeType() const; void getCommon(CommonShapeParam* param) const; - void getSphere(SphereParam* param) const; - void getCapsule(CapsuleParam* param) const; - void getCylinder(CylinderParam* param) const; - void getBox(BoxParam* param) const; - void getPolytope(PolytopeParam* param) const; - void getCharacterPrism(CharacterPrismParam* param) const; + void getSphere(SphereShapeParam* param) const; + void getCapsule(CapsuleShapeParam* param) const; + void getCylinder(CylinderShapeParam* param) const; + void getBox(BoxShapeParam* param) const; + void getPolytope(PolytopeShapeParam* param) const; + void getCharacterPrism(CharacterPrismShapeParam* param) const; agl::utl::Parameter> shape_type; agl::utl::Parameter radius; diff --git a/src/KingSystem/Physics/RigidBody/Shape/physSphereShape.h b/src/KingSystem/Physics/RigidBody/Shape/physSphereShape.h index 0fd05a09..497f4a3f 100644 --- a/src/KingSystem/Physics/RigidBody/Shape/physSphereShape.h +++ b/src/KingSystem/Physics/RigidBody/Shape/physSphereShape.h @@ -1,5 +1,7 @@ #pragma once +#include +#include "KingSystem/Physics/RigidBody/Shape/physShape.h" #include "KingSystem/Physics/RigidBody/physRigidBody.h" #include "KingSystem/Physics/RigidBody/physRigidBodyParam.h" @@ -15,6 +17,10 @@ struct SphereShape { struct SphereShapeParam { SphereShape* createShape(sead::Heap* heap); + + sead::Vector3f translate; + float radius; + CommonShapeParam common; }; class SphereParam : public RigidBodyInstanceParam {