mirror of
https://github.com/zeldaret/botw
synced 2026-08-17 13:09:22 -04:00
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:
@@ -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 {
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
#include "KingSystem/Physics/System/physShapeParam.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
ShapeParam::ShapeParam()
|
||||
: 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),
|
||||
translate_1(sead::Vector3f::zero, "translate_1", this),
|
||||
rotate(sead::Vector3f::zero, "rotate", this), vertex_num(0, "vertex_num", this),
|
||||
material(sead::SafeString::cEmptyString, "material", this),
|
||||
sub_material(sead::SafeString::cEmptyString, "sub_material", this),
|
||||
wall_code({"None"}, "wall_code", this), floor_code({"None"}, "floor_code", this),
|
||||
item_code_disable_stick(false, "item_code_disable_stick", this) {}
|
||||
|
||||
ShapeParam::~ShapeParam() {
|
||||
vertices.freeBuffer();
|
||||
}
|
||||
|
||||
bool ShapeParam::parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* heap) {
|
||||
vertices.freeBuffer();
|
||||
|
||||
applyResParameterObj(res_obj);
|
||||
|
||||
const int num_vertices = vertex_num.ref();
|
||||
if (num_vertices > 0) {
|
||||
vertices.allocBufferAssert(num_vertices, heap);
|
||||
for (int i = 0; i < num_vertices; ++i) {
|
||||
sead::FormatFixedSafeString<32> name("vertex_%d", i);
|
||||
vertices[i].init(sead::Vector3f::zero, name, "頂点", this);
|
||||
}
|
||||
|
||||
applyResParameterObj(res_obj);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ShapeParam::Shape ShapeParam::getShape() const {
|
||||
if (*shape_type == "sphere")
|
||||
return Shape::Sphere;
|
||||
if (*shape_type == "capsule")
|
||||
return Shape::Capsule;
|
||||
if (*shape_type == "cylinder")
|
||||
return Shape::Cylinder;
|
||||
if (*shape_type == "box")
|
||||
return Shape::Box;
|
||||
if (*shape_type == "polytope")
|
||||
return Shape::Polytope;
|
||||
if (*shape_type == "character_prism")
|
||||
return Shape::CharacterPrism;
|
||||
|
||||
return Shape::Unknown;
|
||||
}
|
||||
|
||||
void ShapeParam::getCommon(CommonShapeParam* param) const {
|
||||
param->material = materialFromText(*material);
|
||||
param->sub_material = sub_material->cstr();
|
||||
param->floor_code = floorCodeFromText(*floor_code);
|
||||
param->wall_code = wallCodeFromText(*wall_code);
|
||||
param->item_code_disable_stick = *item_code_disable_stick;
|
||||
}
|
||||
|
||||
void ShapeParam::getSphere(SphereParam* param) const {
|
||||
param->radius = *radius;
|
||||
param->translate = *translate_0;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
void ShapeParam::getCapsule(CapsuleParam* param) const {
|
||||
param->radius = *radius;
|
||||
param->translate_0 = *translate_0;
|
||||
param->translate_1 = *translate_1;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
void ShapeParam::getCylinder(CylinderParam* param) const {
|
||||
param->radius = *radius;
|
||||
param->convex_radius = *convex_radius;
|
||||
param->translate_0 = *translate_0;
|
||||
param->translate_1 = *translate_1;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
void ShapeParam::getBox(BoxParam* param) const {
|
||||
param->translate_0 = *translate_0;
|
||||
param->translate_1 = *translate_1;
|
||||
param->rotate = *rotate;
|
||||
param->convex_radius = *convex_radius;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
void ShapeParam::getPolytope(PolytopeParam* param) const {
|
||||
param->vertex_num = *vertex_num;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
void ShapeParam::getCharacterPrism(CharacterPrismParam* param) const {
|
||||
param->radius = *radius;
|
||||
param->translate_0 = *translate_0;
|
||||
param->translate_1 = *translate_1;
|
||||
getCommon(¶m->common);
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -1,109 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include <agl/Utils/aglParameterObj.h>
|
||||
#include <container/seadBuffer.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include "KingSystem/Physics/System/physDefines.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
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 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;
|
||||
|
||||
bool parse(const agl::utl::ResParameterObj& res_obj, sead::Heap* heap);
|
||||
|
||||
Shape getShape() 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;
|
||||
|
||||
agl::utl::Parameter<sead::FixedSafeString<32>> shape_type;
|
||||
agl::utl::Parameter<float> radius;
|
||||
agl::utl::Parameter<float> convex_radius;
|
||||
agl::utl::Parameter<sead::Vector3f> translate_0;
|
||||
agl::utl::Parameter<sead::Vector3f> translate_1;
|
||||
agl::utl::Parameter<sead::Vector3f> rotate;
|
||||
agl::utl::Parameter<int> vertex_num;
|
||||
sead::Buffer<agl::utl::Parameter<sead::Vector3f>> vertices;
|
||||
agl::utl::Parameter<sead::FixedSafeString<32>> material;
|
||||
agl::utl::Parameter<sead::FixedSafeString<32>> sub_material;
|
||||
agl::utl::Parameter<sead::FixedSafeString<32>> wall_code;
|
||||
agl::utl::Parameter<sead::FixedSafeString<32>> floor_code;
|
||||
agl::utl::Parameter<bool> item_code_disable_stick;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
Reference in New Issue
Block a user