ksys/phys: Start merging physShapeParam with RigidBody/Shape

Turns out we already have a bunch of ShapeParam classes in
physShapeParam and parts of RigidBody/Shape are just
duplicates -- whoops.

ShapeParam is renamed to ShapeParamObj to avoid any confusion
with the (.*)ShapeParam classes.
This commit is contained in:
Léo Lam 2022-01-30 16:48:26 +01:00
parent 6263107301
commit 6519cce927
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
10 changed files with 61 additions and 56 deletions

View File

@ -94809,17 +94809,17 @@ Address,Quality,Size,Name
0x0000007101283698,O,000004,_ZN4ksys4phys21ContactPointInfoParamD0Ev
0x000000710128369c,O,000040,_ZN4ksys4phys18CollisionInfoParamD2Ev
0x00000071012836c4,O,000004,_ZN4ksys4phys18CollisionInfoParamD0Ev
0x00000071012836c8,O,001996,_ZN4ksys4phys10ShapeParamC1Ev
0x0000007101283e94,O,000188,_ZN4ksys4phys10ShapeParamD1Ev
0x0000007101283f50,O,000108,_ZN4ksys4phys10ShapeParamD0Ev
0x0000007101283fbc,O,000508,_ZN4ksys4phys10ShapeParam5parseERKN3agl3utl15ResParameterObjEPN4sead4HeapE
0x00000071012841b8,O,000664,_ZNK4ksys4phys10ShapeParam8getShapeEv
0x0000007101284450,O,000132,_ZNK4ksys4phys10ShapeParam9getSphereEPNS0_11SphereParamE
0x00000071012844d4,O,000156,_ZNK4ksys4phys10ShapeParam10getCapsuleEPNS0_12CapsuleParamE
0x0000007101284570,O,000164,_ZNK4ksys4phys10ShapeParam11getCylinderEPNS0_13CylinderParamE
0x0000007101284614,O,000180,_ZNK4ksys4phys10ShapeParam6getBoxEPNS0_8BoxParamE
0x00000071012846c8,O,000108,_ZNK4ksys4phys10ShapeParam11getPolytopeEPNS0_13PolytopeParamE
0x0000007101284734,O,000156,_ZNK4ksys4phys10ShapeParam17getCharacterPrismEPNS0_19CharacterPrismParamE
0x00000071012836c8,O,001996,_ZN4ksys4phys13ShapeParamObjC1Ev
0x0000007101283e94,O,000188,_ZN4ksys4phys13ShapeParamObjD1Ev
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
0x00000071012847d0,U,000032,
0x00000071012847f0,U,000004,nullsub_4756
0x00000071012847f4,U,000004,j__ZdlPv_1284

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

View File

@ -46,6 +46,8 @@ target_sources(uking PRIVATE
RigidBody/Shape/physCylinderShape.cpp
RigidBody/Shape/physCylinderShape.h
RigidBody/Shape/physShape.h
RigidBody/Shape/physShapeParamObj.cpp
RigidBody/Shape/physShapeParamObj.h
RigidBody/Shape/physSphereShape.cpp
RigidBody/Shape/physSphereShape.h
RigidBody/Shape/physWaterCylinderShape.cpp
@ -99,8 +101,6 @@ target_sources(uking PRIVATE
System/physRigidContactPointsEx.h
System/physSensorGroupFilter.cpp
System/physSensorGroupFilter.h
System/physShapeParam.cpp
System/physShapeParam.h
System/physSystem.cpp
System/physSystem.h
System/physSystemData.cpp

View File

@ -6,6 +6,16 @@ class hkpShape;
namespace ksys::phys {
enum class ShapeType {
Sphere = 0,
Capsule = 1,
Box = 2,
Cylinder = 3,
Polytope = 4,
CharacterPrism = 6,
Unknown = -1,
};
class Shape {
SEAD_RTTI_BASE(Shape)

View File

@ -1,8 +1,9 @@
#include "KingSystem/Physics/System/physShapeParam.h"
#include "KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h"
#include "KingSystem/Physics/RigidBody/Shape/physShape.h"
namespace ksys::phys {
ShapeParam::ShapeParam()
ShapeParamObj::ShapeParamObj()
: shape_type(sead::SafeString::cEmptyString, "shape_type", this), radius(1.0, "radius", this),
convex_radius(0.05, "convex_radius", this),
translate_0(sead::Vector3f::zero, "translate_0", this),
@ -13,11 +14,11 @@ ShapeParam::ShapeParam()
wall_code({"None"}, "wall_code", this), floor_code({"None"}, "floor_code", this),
item_code_disable_stick(false, "item_code_disable_stick", this) {}
ShapeParam::~ShapeParam() {
ShapeParamObj::~ShapeParamObj() {
vertices.freeBuffer();
}
bool ShapeParam::parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* heap) {
bool ShapeParamObj::parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* heap) {
vertices.freeBuffer();
applyResParameterObj(res_obj);
@ -36,24 +37,24 @@ bool ShapeParam::parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* hea
return true;
}
ShapeParam::Shape ShapeParam::getShape() const {
ShapeType ShapeParamObj::getShapeType() const {
if (*shape_type == "sphere")
return Shape::Sphere;
return ShapeType::Sphere;
if (*shape_type == "capsule")
return Shape::Capsule;
return ShapeType::Capsule;
if (*shape_type == "cylinder")
return Shape::Cylinder;
return ShapeType::Cylinder;
if (*shape_type == "box")
return Shape::Box;
return ShapeType::Box;
if (*shape_type == "polytope")
return Shape::Polytope;
return ShapeType::Polytope;
if (*shape_type == "character_prism")
return Shape::CharacterPrism;
return ShapeType::CharacterPrism;
return Shape::Unknown;
return ShapeType::Unknown;
}
void ShapeParam::getCommon(CommonShapeParam* param) const {
void ShapeParamObj::getCommon(CommonShapeParam* param) const {
param->material = materialFromText(*material);
param->sub_material = sub_material->cstr();
param->floor_code = floorCodeFromText(*floor_code);
@ -61,20 +62,20 @@ void ShapeParam::getCommon(CommonShapeParam* param) const {
param->item_code_disable_stick = *item_code_disable_stick;
}
void ShapeParam::getSphere(SphereParam* param) const {
void ShapeParamObj::getSphere(SphereParam* param) const {
param->radius = *radius;
param->translate = *translate_0;
getCommon(&param->common);
}
void ShapeParam::getCapsule(CapsuleParam* param) const {
void ShapeParamObj::getCapsule(CapsuleParam* param) const {
param->radius = *radius;
param->translate_0 = *translate_0;
param->translate_1 = *translate_1;
getCommon(&param->common);
}
void ShapeParam::getCylinder(CylinderParam* param) const {
void ShapeParamObj::getCylinder(CylinderParam* param) const {
param->radius = *radius;
param->convex_radius = *convex_radius;
param->translate_0 = *translate_0;
@ -82,7 +83,7 @@ void ShapeParam::getCylinder(CylinderParam* param) const {
getCommon(&param->common);
}
void ShapeParam::getBox(BoxParam* param) const {
void ShapeParamObj::getBox(BoxParam* param) const {
param->translate_0 = *translate_0;
param->translate_1 = *translate_1;
param->rotate = *rotate;
@ -90,12 +91,12 @@ void ShapeParam::getBox(BoxParam* param) const {
getCommon(&param->common);
}
void ShapeParam::getPolytope(PolytopeParam* param) const {
void ShapeParamObj::getPolytope(PolytopeParam* param) const {
param->vertex_num = *vertex_num;
getCommon(&param->common);
}
void ShapeParam::getCharacterPrism(CharacterPrismParam* param) const {
void ShapeParamObj::getCharacterPrism(CharacterPrismParam* param) const {
param->radius = *radius;
param->translate_0 = *translate_0;
param->translate_1 = *translate_1;

View File

@ -9,6 +9,8 @@
namespace ksys::phys {
enum class ShapeType;
struct CommonShapeParam {
Material material;
const char* sub_material;
@ -64,25 +66,15 @@ struct CharacterPrismParam {
};
KSYS_CHECK_SIZE_NX150(CharacterPrismParam, 0x40);
struct ShapeParam : agl::utl::ParameterObj {
enum class Shape {
Sphere = 0,
Capsule = 1,
Box = 2,
Cylinder = 3,
Polytope = 4,
CharacterPrism = 6,
Unknown = -1,
};
ShapeParam();
~ShapeParam() override;
ShapeParam(const ShapeParam&) = delete;
auto operator=(const ShapeParam&) = delete;
struct ShapeParamObj : agl::utl::ParameterObj {
ShapeParamObj();
~ShapeParamObj() override;
ShapeParamObj(const ShapeParamObj&) = delete;
auto operator=(const ShapeParamObj&) = delete;
bool parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* heap);
Shape getShape() const;
ShapeType getShapeType() const;
void getCommon(CommonShapeParam* param) const;
void getSphere(SphereParam* param) const;
void getCapsule(CapsuleParam* param) const;

View File

@ -4,6 +4,8 @@
namespace ksys::phys {
class Shape;
class RigidBodyFromShape : public RigidBody {
SEAD_RTTI_OVERRIDE(RigidBodyFromShape, RigidBody)
public:
@ -15,8 +17,8 @@ protected:
const hkpShape* getNewHavokShape_() override;
float updateScale_(float scale, float old_scale) override;
virtual void m15() = 0;
virtual void m16() = 0;
virtual Shape* getShape_() = 0;
virtual const Shape* getShape_() const = 0;
};
} // namespace ksys::phys

View File

@ -1,6 +1,6 @@
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
#include "KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h"
#include "KingSystem/Physics/System/physEntityGroupFilter.h"
#include "KingSystem/Physics/System/physShapeParam.h"
namespace ksys::phys {

View File

@ -44,7 +44,7 @@ enum class NavMeshSubMaterial {
None = 0x15,
};
struct ShapeParam;
struct ShapeParamObj;
struct RigidBodyInstanceParam {
SEAD_RTTI_BASE(RigidBodyInstanceParam)
@ -161,7 +161,7 @@ struct RigidBodyParam : agl::utl::ParameterList {
MotionType getMotionType() const;
Info info;
sead::Buffer<ShapeParam> shapes;
sead::Buffer<ShapeParamObj> shapes;
};
} // namespace ksys::phys

View File

@ -1,5 +1,5 @@
#include "KingSystem/Physics/System/physCharacterControllerParam.h"
#include "KingSystem/Physics/System/physShapeParam.h"
#include "KingSystem/Physics/RigidBody/Shape/physShapeParamObj.h"
namespace ksys::phys {

View File

@ -8,7 +8,7 @@
namespace ksys::phys {
struct ShapeParam;
struct ShapeParamObj;
SEAD_ENUM(NavMeshCharacterType,
Player,
@ -56,7 +56,7 @@ struct CharacterControllerParam : agl::utl::ParameterList, ICharacterControllerP
agl::utl::ParameterObj form_header_obj;
agl::utl::Parameter<int> shape_num;
agl::utl::Parameter<sead::FixedSafeString<32>> form_type;
sead::Buffer<ShapeParam> shape_params;
sead::Buffer<ShapeParamObj> shape_params;
};
CharacterControllerParam();