ksys/phys: Add RigidBodySetParam

This commit is contained in:
Léo Lam 2021-04-22 18:37:38 +02:00
parent cbe711e595
commit f6e4643808
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 85 additions and 5 deletions

View File

@ -95375,11 +95375,11 @@
0x00000071012b037c,sub_71012B037C,220, 0x00000071012b037c,sub_71012B037C,220,
0x00000071012b0458,sub_71012B0458,36, 0x00000071012b0458,sub_71012B0458,36,
0x00000071012b047c,sub_71012B047C,356, 0x00000071012b047c,sub_71012B047C,356,
0x00000071012b05e0,sub_71012B05E0,476, 0x00000071012b05e0,sub_71012B05E0,476,_ZN4ksys4phys17RigidBodySetParamC1Ev
0x00000071012b07bc,sub_71012B07BC,176, 0x00000071012b07bc,sub_71012B07BC,176,_ZN4ksys4phys17RigidBodySetParamD1Ev
0x00000071012b086c,sub_71012B086C,112, 0x00000071012b086c,sub_71012B086C,112,_ZN4ksys4phys17RigidBodySetParamD0Ev
0x00000071012b08dc,sub_71012B08DC,460, 0x00000071012b08dc,sub_71012B08DC,460,_ZN4ksys4phys17RigidBodySetParam5parseEN3agl3utl16ResParameterListEPN4sead4HeapE
0x00000071012b0aa8,sub_71012B0AA8,8, 0x00000071012b0aa8,sub_71012B0AA8,8,_ZNK4ksys4phys17RigidBodySetParam17getNumRigidBodiesEv
0x00000071012b0ab0,sub_71012B0AB0,992, 0x00000071012b0ab0,sub_71012B0AB0,992,
0x00000071012b0e90,sub_71012B0E90,240, 0x00000071012b0e90,sub_71012B0E90,240,
0x00000071012b0f80,sub_71012B0F80,12, 0x00000071012b0f80,sub_71012B0F80,12,

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

View File

@ -9,6 +9,8 @@ target_sources(uking PRIVATE
RigidBody/physEdgeRigidBodyParam.h RigidBody/physEdgeRigidBodyParam.h
RigidBody/physRigidBodyParam.cpp RigidBody/physRigidBodyParam.cpp
RigidBody/physRigidBodyParam.h RigidBody/physRigidBodyParam.h
RigidBody/physRigidBodySetParam.cpp
RigidBody/physRigidBodySetParam.h
SupportBone/physSupportBoneParam.cpp SupportBone/physSupportBoneParam.cpp
SupportBone/physSupportBoneParam.h SupportBone/physSupportBoneParam.h
System/physCharacterControllerParam.cpp System/physCharacterControllerParam.cpp

View File

@ -0,0 +1,42 @@
#include "KingSystem/Physics/RigidBody/physRigidBodySetParam.h"
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
namespace ksys::phys {
RigidBodySetParam::RigidBodySetParam()
: set_name(sead::SafeString::cEmptyString, "set_name", &obj),
type(sead::SafeString::cEmptyString, "type", &obj), num(1, "num", &obj),
setup_file_path(sead::SafeString::cEmptyString, "setup_file_path", &obj) {}
RigidBodySetParam::~RigidBodySetParam() {
rigid_bodies.freeBuffer();
}
bool RigidBodySetParam::parse(agl::utl::ResParameterList res_list, sead::Heap* heap) {
if (!res_list)
return false;
obj.applyResParameterObj(res_list.getResParameterObj(0), nullptr);
if (*type == "from_shape_type")
type_val = Type::FromShapeType;
else
type_val = Type::Other;
const int num_bodies = *num;
if (num_bodies == 0 || res_list.getResParameterListNum() != num_bodies)
return false;
rigid_bodies.allocBufferAssert(num_bodies, heap);
for (int i = 0; i < num_bodies; ++i) {
rigid_bodies[i].parse(res_list.getResParameterList(i), heap);
}
return true;
}
int RigidBodySetParam::getNumRigidBodies() const {
return *num;
}
} // namespace ksys::phys

View File

@ -0,0 +1,36 @@
#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 RigidBodyParam;
struct RigidBodySetParam : agl::utl::ParameterList {
enum class Type {
Invalid = 0,
FromShapeType = 1,
Other = 2,
};
RigidBodySetParam();
~RigidBodySetParam() override;
RigidBodySetParam(const RigidBodySetParam&) = delete;
auto operator=(const RigidBodySetParam&) = delete;
bool parse(agl::utl::ResParameterList res_list, sead::Heap* heap);
int getNumRigidBodies() const;
Type type_val = Type::Invalid;
agl::utl::ParameterObj obj;
agl::utl::Parameter<sead::SafeString> set_name;
agl::utl::Parameter<sead::SafeString> type;
agl::utl::Parameter<int> num;
agl::utl::Parameter<sead::SafeString> setup_file_path;
sead::Buffer<RigidBodyParam> rigid_bodies;
};
} // namespace ksys::phys