ksys/phys: Merge physShapeParam param classes with RigidBody/Shape

This commit is contained in:
Léo Lam
2022-01-30 17:34:19 +01:00
parent 6519cce927
commit 30533da83d
14 changed files with 105 additions and 83 deletions
+6 -6
View File
@@ -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
Can't render this file because it is too large.
+6
View File
@@ -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
@@ -1,5 +1,7 @@
#pragma once
#include <math/seadVector.h>
#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 {
@@ -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);
}
@@ -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 {
@@ -0,0 +1 @@
#include "KingSystem/Physics/RigidBody/Shape/physCharacterPrismShape.h"
@@ -0,0 +1,15 @@
#pragma once
#include <math/seadVector.h>
#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
@@ -1,5 +1,7 @@
#pragma once
#include <math/seadVector.h>
#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 {
@@ -0,0 +1 @@
#include "KingSystem/Physics/RigidBody/Shape/physPolytopeShape.h"
@@ -0,0 +1,13 @@
#pragma once
#include <basis/seadTypes.h>
#include "KingSystem/Physics/RigidBody/Shape/physShape.h"
namespace ksys::phys {
struct PolytopeShapeParam {
u16 vertex_num;
CommonShapeParam common;
};
} // namespace ksys::phys
@@ -1,6 +1,8 @@
#pragma once
#include <prim/seadRuntimeTypeInfo.h>
#include <prim/seadSafeString.h>
#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
@@ -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(&param->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(&param->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(&param->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(&param->common);
}
void ShapeParamObj::getPolytope(PolytopeParam* param) const {
void ShapeParamObj::getPolytope(PolytopeShapeParam* param) const {
param->vertex_num = *vertex_num;
getCommon(&param->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;
@@ -5,66 +5,18 @@
#include <container/seadBuffer.h>
#include <prim/seadSafeString.h>
#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<sead::FixedSafeString<32>> shape_type;
agl::utl::Parameter<float> radius;
@@ -1,5 +1,7 @@
#pragma once
#include <math/seadVector.h>
#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 {