ksys/phys: Start adding physics parameter structs

* SupportBoneParam
* RagdollParam
* ClothSetParam, ClothSubWindParam, ClothParam
* EdgeRigidBodySetParam, EdgeRigidBody
* ParamSet (only the header for now)
This commit is contained in:
Léo Lam 2021-04-20 23:16:53 +02:00
parent 63472349c7
commit f9d6eedc9f
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
14 changed files with 311 additions and 27 deletions

View File

@ -93530,17 +93530,17 @@
0x000000710121b3d8,sub_710121B3D8,444,
0x000000710121b594,sub_710121B594,3288,
0x000000710121c26c,sub_710121C26C,76,
0x000000710121c2b8,sub_710121C2B8,468,
0x000000710121c48c,sub_710121C48C,72,
0x000000710121c4d4,sub_710121C4D4,44,
0x000000710121c500,j__ZdlPv_1243,4,
0x000000710121c504,sub_710121C504,340,
0x000000710121c658,sub_710121C658,352,
0x000000710121c7b8,sub_710121C7B8,812,
0x000000710121cae4,sub_710121CAE4,332,
0x000000710121cc30,sub_710121CC30,72,
0x000000710121cc78,j__ZdlPv_1244,4,
0x000000710121cc7c,j__ZdlPv_1245,4,
0x000000710121c2b8,sub_710121C2B8,468,_ZN4ksys4phys13ClothSetParamC1Ev
0x000000710121c48c,sub_710121C48C,72,_ZN4ksys4phys13ClothSetParamD1Ev
0x000000710121c4d4,sub_710121C4D4,44,_ZN4ksys4phys17ClothSubWindParamD2Ev
0x000000710121c500,j__ZdlPv_1243,4,_ZN4ksys4phys13ClothSetParamD0Ev
0x000000710121c504,sub_710121C504,340,_ZN4ksys4phys13ClothSetParam5parseERKN3agl3utl16ResParameterListEPN4sead4HeapE
0x000000710121c658,sub_710121C658,352,_ZNK4ksys4phys13ClothSetParam8getClothERKN4sead14SafeStringBaseIcEE
0x000000710121c7b8,sub_710121C7B8,812,_ZN4ksys4phys10ClothParamC1Ev
0x000000710121cae4,sub_710121CAE4,332,_ZN4ksys4phys17ClothSubWindParamC1Ev
0x000000710121cc30,sub_710121CC30,72,_ZN4ksys4phys10ClothParamD2Ev
0x000000710121cc78,j__ZdlPv_1244,4,_ZN4ksys4phys10ClothParamD0Ev
0x000000710121cc7c,j__ZdlPv_1245,4,_ZN4ksys4phys17ClothSubWindParamD0Ev
0x000000710121cc80,sub_710121CC80,152,
0x000000710121cd18,sub_710121CD18,356,
0x000000710121ce7c,sub_710121CE7C,36,
@ -93607,10 +93607,10 @@
0x0000007101223230,sub_7101223230,32,
0x0000007101223250,sub_7101223250,208,
0x0000007101223320,sub_7101223320,536,
0x0000007101223538,sub_7101223538,440,
0x00000071012236f0,sub_71012236F0,44,
0x000000710122371c,j__ZdlPv_1246,4,
0x0000007101223720,sub_7101223720,324,
0x0000007101223538,sub_7101223538,440,_ZN4ksys4phys12RagdollParamC1Ev
0x00000071012236f0,sub_71012236F0,44,_ZN4ksys4phys12RagdollParamD1Ev
0x000000710122371c,j__ZdlPv_1246,4,_ZN4ksys4phys12RagdollParamD0Ev
0x0000007101223720,sub_7101223720,324,_ZN4ksys4phys12RagdollParam9postRead_Ev
0x0000007101223864,sub_7101223864,128,
0x00000071012238e4,sub_71012238E4,1504,
0x0000007101223ec4,xxxxx,52,
@ -93667,9 +93667,9 @@
0x00000071012283a4,sub_71012283A4,592,
0x00000071012285f4,sub_71012285F4,692,
0x00000071012288a8,sub_71012288A8,380,
0x0000007101228a24,sub_7101228A24,208,
0x0000007101228af4,sub_7101228AF4,48,
0x0000007101228b24,j__ZdlPv_1247,4,
0x0000007101228a24,sub_7101228A24,208,_ZN4ksys4phys16SupportBoneParamC1Ev
0x0000007101228af4,sub_7101228AF4,48,_ZN4ksys4phys16SupportBoneParamD2Ev
0x0000007101228b24,j__ZdlPv_1247,4,_ZN4ksys4phys16SupportBoneParamD0Ev
0x0000007101228b28,sub_7101228B28,876,
0x0000007101228e94,sub_7101228E94,164,
0x0000007101228f38,sub_7101228F38,688,
@ -95335,13 +95335,13 @@
0x00000071012ad4f0,sub_71012AD4F0,112,
0x00000071012ad560,sub_71012AD560,92,
0x00000071012ad5bc,nullsub_4774,4,
0x00000071012ad5c0,sub_71012AD5C0,368,
0x00000071012ad730,sub_71012AD730,44,
0x00000071012ad75c,j__ZdlPv_1289,4,
0x00000071012ad760,sub_71012AD760,56,
0x00000071012ad798,sub_71012AD798,152,
0x00000071012ad830,sub_71012AD830,132,
0x00000071012ad8b4,sub_71012AD8B4,280,
0x00000071012ad5c0,sub_71012AD5C0,368,_ZN4ksys4phys18EdgeRigidBodyParamC1Ev
0x00000071012ad730,sub_71012AD730,44,_ZN4ksys4phys18EdgeRigidBodyParamD1Ev
0x00000071012ad75c,j__ZdlPv_1289,4,_ZN4ksys4phys18EdgeRigidBodyParamD0Ev
0x00000071012ad760,sub_71012AD760,56,_ZN4ksys4phys21EdgeRigidBodySetParamC1Ev
0x00000071012ad798,sub_71012AD798,152,_ZN4ksys4phys21EdgeRigidBodySetParamD1Ev
0x00000071012ad830,sub_71012AD830,132,_ZN4ksys4phys21EdgeRigidBodySetParamD0Ev
0x00000071012ad8b4,sub_71012AD8B4,280,_ZN4ksys4phys21EdgeRigidBodySetParam5parseEiPN4sead4HeapE
0x00000071012ad9cc,sub_71012AD9CC,1924,
0x00000071012ae150,sub_71012AE150,436,
0x00000071012ae304,sub_71012AE304,1324,

Can't render this file because it is too large.

@ -1 +1 @@
Subproject commit 24e9d779f586bb9ba37aa8b901d458a5e5721b24
Subproject commit 69c2ac1c2180c9ce8e7446cc1b81919dfaf5be56

@ -1 +1 @@
Subproject commit 207bf6c8cf91148a629d666637ca84ac311e9ff6
Subproject commit 7b9f11e3880789dff46aa834c0f42c5c2328fb8e

View File

@ -1,4 +1,14 @@
target_sources(uking PRIVATE
Cloth/physClothParam.cpp
Cloth/physClothParam.h
Ragdoll/physRagdollConfig.cpp
Ragdoll/physRagdollConfig.h
Ragdoll/physRagdollParam.cpp
Ragdoll/physRagdollParam.h
RigidBody/physEdgeRigidBodyParam.cpp
RigidBody/physEdgeRigidBodyParam.h
SupportBone/physSupportBoneParam.cpp
SupportBone/physSupportBoneParam.h
System/physParamSet.cpp
System/physParamSet.h
)

View File

@ -0,0 +1,60 @@
#include "KingSystem/Physics/Cloth/physClothParam.h"
#include <filedevice/seadPath.h>
namespace ksys::phys {
ClothSetParam::ClothSetParam()
: cloth_setup_file_path(sead::SafeString::cEmptyString, "cloth_setup_file_path",
"Clothセットアップファイル(.hkt)", &cloth_header_obj),
cloth_num(0, "cloth_num", "cloth_num", &cloth_header_obj) {
addObj(&cloth_header_obj, "ClothHeader");
addObj(&sub_wind, "ClothSubWind");
}
ClothSetParam::~ClothSetParam() = default;
bool ClothSetParam::parse(const agl::utl::ResParameterList& res_list, sead::Heap* heap) {
if (!res_list)
return false;
cloth_header_obj.applyResParameterObj(res_list.getResParameterObj(0), nullptr);
const int num_cloths = cloth_num.ref();
if (num_cloths <= 0)
return false;
cloths.allocBufferAssert(num_cloths, heap);
for (int i = 0; i < num_cloths; ++i) {
addObj(&cloths[i], sead::FormatFixedSafeString<32>("Cloth_%d", i));
}
sead::Path::getFileName(&cloth_setup_file_name, cloth_setup_file_path.ref());
return true;
}
const ClothParam* ClothSetParam::getCloth(const sead::SafeString& name) const {
int index = -1;
for (int i = 0, n = *cloth_num; i < n; ++i) {
if (name == *cloths[i].name) {
index = i;
break;
}
}
return index >= 0 && index < *cloth_num ? &cloths[index] : nullptr;
}
ClothParam::ClothParam()
: wind_drag(5.0, "wind_drag", this), wind_frequency(5.0, "wind_frequency", this),
wind_min_speed(-4.0, "wind_mind_speed", this), wind_max_speed(10.0, "wind_max_speed", this),
sub_wind_factor_main(1.0, "sub_wind_factor_main", this),
sub_wind_factor_add(0.0, "sub_wind_factor_add", this), wind_enable(true, "wind_enable", this),
writeback_to_local(false, "writeback_to_local", this),
name(sead::SafeString::cEmptyString, "name", this), base_bone("Root", "base_bone", this) {}
ClothSubWindParam::ClothSubWindParam()
: sub_wind_direction(sead::Vector3f::ey, "sub_wind_direction", this),
sub_wind_frequency(0.2, "sub_wind_frequency", this),
sub_wind_speed(0.0, "sub_wind_speed", this) {}
} // namespace ksys::phys

View File

@ -0,0 +1,51 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterList.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
#include <prim/seadSafeString.h>
namespace ksys::phys {
struct ClothSubWindParam : agl::utl::ParameterObj {
ClothSubWindParam();
agl::utl::Parameter<sead::Vector3f> sub_wind_direction;
agl::utl::Parameter<float> sub_wind_frequency;
agl::utl::Parameter<float> sub_wind_speed;
};
struct ClothParam : agl::utl::ParameterObj {
ClothParam();
agl::utl::Parameter<float> wind_drag;
agl::utl::Parameter<float> wind_frequency;
agl::utl::Parameter<float> wind_min_speed;
agl::utl::Parameter<float> wind_max_speed;
agl::utl::Parameter<float> sub_wind_factor_main;
agl::utl::Parameter<float> sub_wind_factor_add;
agl::utl::Parameter<bool> wind_enable;
agl::utl::Parameter<bool> writeback_to_local;
agl::utl::Parameter<sead::SafeString> name;
agl::utl::Parameter<sead::SafeString> base_bone;
};
struct ClothSetParam : agl::utl::ParameterList {
ClothSetParam();
~ClothSetParam() override;
ClothSetParam(const ClothSetParam&) = delete;
auto operator=(const ClothSetParam&) = delete;
bool parse(const agl::utl::ResParameterList& res_list, sead::Heap* heap);
const ClothParam* getCloth(const sead::SafeString& name) const;
agl::utl::ParameterObj cloth_header_obj;
agl::utl::Parameter<sead::SafeString> cloth_setup_file_path;
agl::utl::Parameter<int> cloth_num;
sead::FixedSafeString<64> cloth_setup_file_name;
ClothSubWindParam sub_wind;
sead::Buffer<ClothParam> cloths;
};
} // namespace ksys::phys

View File

@ -0,0 +1,18 @@
#include "KingSystem/Physics/Ragdoll/physRagdollParam.h"
#include <filedevice/seadPath.h>
namespace ksys::phys {
RagdollParam::RagdollParam()
: contact_point_info(sead::SafeString::cEmptyString, "contact_point_info", this),
collision_info(sead::SafeString::cEmptyString, "collision_info", this),
ragdoll_setup_file_path(sead::SafeString::cEmptyString, "ragdoll_setup_file_path", this) {}
RagdollParam::~RagdollParam() = default;
void RagdollParam::postRead_() {
sead::Path::getFileName(&ragdoll_setup_file_stem, ragdoll_setup_file_path.ref());
ragdoll_setup_file_stem.removeSuffix(".hkrg");
}
} // namespace ksys::phys

View File

@ -0,0 +1,23 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterList.h>
#include <agl/Utils/aglParameterObj.h>
#include <prim/seadSafeString.h>
namespace ksys::phys {
struct RagdollParam : agl::utl::ParameterObj {
RagdollParam();
~RagdollParam() override;
agl::utl::Parameter<sead::SafeString> contact_point_info;
agl::utl::Parameter<sead::SafeString> collision_info;
agl::utl::Parameter<sead::SafeString> ragdoll_setup_file_path;
sead::FixedSafeString<32> ragdoll_setup_file_stem;
protected:
void postRead_() override;
};
} // namespace ksys::phys

View File

@ -0,0 +1,28 @@
#include "KingSystem/Physics/RigidBody/physEdgeRigidBodyParam.h"
namespace ksys::phys {
EdgeRigidBodyParam::EdgeRigidBodyParam()
: set_name(sead::SafeString::cEmptyString, "set_name", this),
body_name(sead::SafeString::cEmptyString, "body_name", this),
edge_type(sead::SafeString::cEmptyString, "edge_type", this) {}
EdgeRigidBodyParam::~EdgeRigidBodyParam() = default;
EdgeRigidBodySetParam::EdgeRigidBodySetParam() = default;
EdgeRigidBodySetParam::~EdgeRigidBodySetParam() {
edge_rigid_bodies.freeBuffer();
}
void EdgeRigidBodySetParam::parse(int num, sead::Heap* heap) {
if (num <= 0)
return;
edge_rigid_bodies.allocBufferAssert(num, heap);
for (int i = 0; i < num; ++i) {
addObj(&edge_rigid_bodies[i], sead::FormatFixedSafeString<32>("EdgeRigidBody_%d", i));
}
}
} // namespace ksys::phys

View File

@ -0,0 +1,30 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterList.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
namespace ksys::phys {
struct EdgeRigidBodyParam : agl::utl::ParameterObj {
EdgeRigidBodyParam();
~EdgeRigidBodyParam() override;
agl::utl::Parameter<sead::SafeString> set_name;
agl::utl::Parameter<sead::SafeString> body_name;
agl::utl::Parameter<sead::SafeString> edge_type;
};
struct EdgeRigidBodySetParam : agl::utl::ParameterList {
EdgeRigidBodySetParam();
~EdgeRigidBodySetParam() override;
EdgeRigidBodySetParam(const EdgeRigidBodySetParam&) = delete;
auto operator=(const EdgeRigidBodySetParam&) = delete;
void parse(int num, sead::Heap* heap);
sead::Buffer<EdgeRigidBodyParam> edge_rigid_bodies;
};
} // namespace ksys::phys

View File

@ -0,0 +1,9 @@
#include "KingSystem/Physics/SupportBone/physSupportBoneParam.h"
namespace ksys::phys {
SupportBoneParam::SupportBoneParam()
: support_bone_setup_file_path(sead::SafeString::cEmptyString, "support_bone_setup_file_path",
"補助骨セットアップファイル(.psb)", this) {}
} // namespace ksys::phys

View File

@ -0,0 +1,15 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterObj.h>
#include <hostio/seadHostIONode.h>
namespace ksys::phys {
struct SupportBoneParam : agl::utl::ParameterObj, sead::hostio::Node {
SupportBoneParam();
agl::utl::Parameter<sead::SafeString> support_bone_setup_file_path;
};
} // namespace ksys::phys

View File

@ -0,0 +1 @@
#include "KingSystem/Physics/System/physParamSet.h"

View File

@ -0,0 +1,39 @@
#pragma once
#include <agl/Utils/aglParameter.h>
#include <agl/Utils/aglParameterList.h>
#include <agl/Utils/aglParameterObj.h>
#include <container/seadBuffer.h>
namespace ksys::phys {
struct RigidBodySetParam;
struct CharacterControllerParam;
struct ClothSetParam;
struct RagdollParam;
struct SupportBoneParam;
struct ContactInfoParam;
struct EdgeRigidBodySetParam;
struct ParamSet : public agl::utl::ParameterList {
sead::Buffer<RigidBodySetParam> rigid_body_sets{};
CharacterControllerParam* character_controller{};
ClothSetParam* cloth_set{};
RagdollParam* ragdoll{};
SupportBoneParam* support_bone{};
ContactInfoParam* contact_info{};
EdgeRigidBodySetParam* edge_rigid_body_sets{};
agl::utl::ParameterObj obj;
agl::utl::Parameter<int> use_rigid_body_set_num;
agl::utl::Parameter<bool> use_character_controller;
agl::utl::Parameter<bool> use_ragdoll;
agl::utl::Parameter<bool> use_support_bone;
agl::utl::Parameter<bool> use_cloth;
agl::utl::Parameter<bool> use_contact_info;
agl::utl::Parameter<bool> use_system_group_handler;
agl::utl::Parameter<int> use_edge_rigid_body_num;
int num_rigid_bodies_with_link_matrix = 0;
};
} // namespace ksys::phys