From 1631e2aae326499a1eba3ca88b54241db13efa97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 21 Apr 2021 18:37:20 +0200 Subject: [PATCH] ksys/phys: Add ContactInfoParam --- data/uking_functions.csv | 20 ++++---- src/KingSystem/Physics/CMakeLists.txt | 2 + .../Physics/System/physContactInfoParam.cpp | 50 +++++++++++++++++++ .../Physics/System/physContactInfoParam.h | 40 +++++++++++++++ 4 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 src/KingSystem/Physics/System/physContactInfoParam.cpp create mode 100644 src/KingSystem/Physics/System/physContactInfoParam.h diff --git a/data/uking_functions.csv b/data/uking_functions.csv index e6b5d88e..8eba5b25 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -94777,16 +94777,16 @@ 0x00000071012829d0,_ZN4sead15FixedSafeStringILi87EEaSERKNS_14SafeStringBaseIcEE,240, 0x0000007101282ac0,j__ZdlPv_1281,4, 0x0000007101282ac4,_ZN4sead19FixedSafeStringBaseIcLi87EEaSERKNS_14SafeStringBaseIcEE,240, -0x0000007101282bb4,sub_7101282BB4,268, -0x0000007101282cc0,sub_7101282CC0,276, -0x0000007101282dd4,sub_7101282DD4,220, -0x0000007101282eb0,sub_7101282EB0,576, -0x00000071012830f0,sub_71012830F0,744, -0x00000071012833d8,sub_71012833D8,660, -0x000000710128366c,sub_710128366C,44, -0x0000007101283698,j__ZdlPv_1282,4, -0x000000710128369c,sub_710128369C,40, -0x00000071012836c4,j__ZdlPv_1283,4, +0x0000007101282bb4,sub_7101282BB4,268,_ZN4ksys4phys16ContactInfoParamC1Ev +0x0000007101282cc0,sub_7101282CC0,276,_ZN4ksys4phys16ContactInfoParamD1Ev +0x0000007101282dd4,sub_7101282DD4,220,_ZN4ksys4phys16ContactInfoParamD0Ev +0x0000007101282eb0,sub_7101282EB0,576,_ZN4ksys4phys16ContactInfoParam5parseERKN3agl3utl16ResParameterListEPN4sead4HeapE +0x00000071012830f0,sub_71012830F0,744,_ZN4ksys4phys21ContactPointInfoParamC1Ev +0x00000071012833d8,sub_71012833D8,660,_ZN4ksys4phys18CollisionInfoParamC1Ev +0x000000710128366c,sub_710128366C,44,_ZN4ksys4phys21ContactPointInfoParamD2Ev +0x0000007101283698,j__ZdlPv_1282,4,_ZN4ksys4phys21ContactPointInfoParamD0Ev +0x000000710128369c,sub_710128369C,40,_ZN4ksys4phys18CollisionInfoParamD2Ev +0x00000071012836c4,j__ZdlPv_1283,4,_ZN4ksys4phys18CollisionInfoParamD0Ev 0x00000071012836c8,bphysicsParseShapeParam,1996,_ZN4ksys4phys10ShapeParamC1Ev 0x0000007101283e94,sub_7101283E94,188,_ZN4ksys4phys10ShapeParamD1Ev 0x0000007101283f50,sub_7101283F50,108,_ZN4ksys4phys10ShapeParamD0Ev diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt index 3f551742..e6f1c01b 100644 --- a/src/KingSystem/Physics/CMakeLists.txt +++ b/src/KingSystem/Physics/CMakeLists.txt @@ -9,6 +9,8 @@ target_sources(uking PRIVATE RigidBody/physEdgeRigidBodyParam.h SupportBone/physSupportBoneParam.cpp SupportBone/physSupportBoneParam.h + System/physContactInfoParam.cpp + System/physContactInfoParam.h System/physDefines.cpp System/physDefines.h System/physParamSet.cpp diff --git a/src/KingSystem/Physics/System/physContactInfoParam.cpp b/src/KingSystem/Physics/System/physContactInfoParam.cpp new file mode 100644 index 00000000..e7f13709 --- /dev/null +++ b/src/KingSystem/Physics/System/physContactInfoParam.cpp @@ -0,0 +1,50 @@ +#include "KingSystem/Physics/System/physContactInfoParam.h" + +namespace ksys::phys { + +ContactInfoParam::ContactInfoParam() + : contact_point_info_num(0, "contact_point_info_num", &obj), + collision_info_num(0, "collision_info_num", &obj) {} + +ContactInfoParam::~ContactInfoParam() { + contact_point_info.freeBuffer(); + collision_info.freeBuffer(); +} + +bool ContactInfoParam::parse(const agl::utl::ResParameterList& res_list, sead::Heap* heap) { + if (!res_list || res_list.getResParameterObjNum() < 1) + return false; + + obj.applyResParameterObj(res_list.getResParameterObj(0), nullptr); + + const int num_contact_point_info = *contact_point_info_num; + const int num_collision_info = *collision_info_num; + + if (num_contact_point_info > 0) { + contact_point_info.allocBufferAssert(num_contact_point_info, heap); + for (int i = 0; i < num_contact_point_info; ++i) { + addObj(&contact_point_info[i], + sead::FormatFixedSafeString<32>("ContactPointInfo_%d", i)); + } + } + + if (num_collision_info > 0) { + collision_info.allocBufferAssert(num_collision_info, heap); + for (int i = 0; i < num_collision_info; ++i) { + addObj(&collision_info[i], sead::FormatFixedSafeString<32>("CollisionInfo_%d", i)); + } + } + + applyResParameterList(res_list); + return true; +} + +ContactPointInfoParam::ContactPointInfoParam() + : name(sead::SafeString::cEmptyString, "name", this), + type(sead::SafeString::cEmptyString, "type", this), num(0x80, "num", this) {} + +CollisionInfoParam::CollisionInfoParam() + : name(sead::SafeString::cEmptyString, "name", this), + type(sead::SafeString::cEmptyString, "type", this) {} + +} // namespace ksys::phys diff --git a/src/KingSystem/Physics/System/physContactInfoParam.h b/src/KingSystem/Physics/System/physContactInfoParam.h new file mode 100644 index 00000000..b6c60095 --- /dev/null +++ b/src/KingSystem/Physics/System/physContactInfoParam.h @@ -0,0 +1,40 @@ +#pragma once + +#include +#include +#include +#include + +namespace ksys::phys { + +struct ContactPointInfoParam : agl::utl::ParameterObj { + ContactPointInfoParam(); + + agl::utl::Parameter> name; + agl::utl::Parameter> type; + agl::utl::Parameter num; +}; + +struct CollisionInfoParam : agl::utl::ParameterObj { + CollisionInfoParam(); + + agl::utl::Parameter> name; + agl::utl::Parameter> type; +}; + +struct ContactInfoParam : agl::utl::ParameterList { + ContactInfoParam(); + ~ContactInfoParam() override; + ContactInfoParam(const ContactInfoParam&) = delete; + auto operator=(const ContactInfoParam&) = delete; + + bool parse(const agl::utl::ResParameterList& res_list, sead::Heap* heap); + + sead::Buffer contact_point_info; + sead::Buffer collision_info; + agl::utl::ParameterObj obj; + agl::utl::Parameter contact_point_info_num; + agl::utl::Parameter collision_info_num; +}; + +} // namespace ksys::phys