mirror of https://github.com/zeldaret/botw.git
ksys/phys: Match CapsuleShape::init
This commit is contained in:
parent
7791352833
commit
6511ecd711
|
@ -83569,7 +83569,7 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fab688,U,000276,
|
0x0000007100fab688,U,000276,
|
||||||
0x0000007100fab79c,U,000008,
|
0x0000007100fab79c,U,000008,
|
||||||
0x0000007100fab7a4,U,000184,
|
0x0000007100fab7a4,U,000184,
|
||||||
0x0000007100fab85c,W,000332,_ZN4ksys4phys12CapsuleShape4initEPN4sead4HeapE
|
0x0000007100fab85c,O,000332,_ZN4ksys4phys12CapsuleShape4initEPN4sead4HeapE
|
||||||
0x0000007100fab9a8,O,000184,_ZN4ksys4phys11CapsuleBody5cloneEPN4sead4HeapE
|
0x0000007100fab9a8,O,000184,_ZN4ksys4phys11CapsuleBody5cloneEPN4sead4HeapE
|
||||||
0x0000007100faba60,O,000008,_ZNK4ksys4phys11CapsuleBody9getRadiusEv
|
0x0000007100faba60,O,000008,_ZNK4ksys4phys11CapsuleBody9getRadiusEv
|
||||||
0x0000007100faba68,O,000060,_ZNK4ksys4phys11CapsuleBody11getVerticesEPN4sead7Vector3IfEES5_
|
0x0000007100faba68,O,000060,_ZNK4ksys4phys11CapsuleBody11getVerticesEPN4sead7Vector3IfEES5_
|
||||||
|
|
Can't render this file because it is too large.
|
|
@ -5,6 +5,21 @@
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
CapsuleBody::CapsuleBody(const CapsuleShape& 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),
|
||||||
|
shape(hkp_shape_) {
|
||||||
|
if (shape_._38)
|
||||||
|
material_mask.getData().setCustomFlag(MaterialMaskData::CustomFlag::_0);
|
||||||
|
setMaterialMask(material_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CapsuleBody::setMaterialMask(const MaterialMask& mask) {
|
||||||
|
material_mask = mask;
|
||||||
|
if (shape)
|
||||||
|
shape->setUserData(mask.getRawData());
|
||||||
|
}
|
||||||
|
|
||||||
CapsuleBody* CapsuleShape::init(sead::Heap* heap) {
|
CapsuleBody* CapsuleShape::init(sead::Heap* heap) {
|
||||||
void* ptr = heap->tryAlloc(sizeof(hkpCapsuleShape), 0x10);
|
void* ptr = heap->tryAlloc(sizeof(hkpCapsuleShape), 0x10);
|
||||||
if (ptr == nullptr)
|
if (ptr == nullptr)
|
||||||
|
@ -13,14 +28,7 @@ CapsuleBody* CapsuleShape::init(sead::Heap* heap) {
|
||||||
auto* hk_shape =
|
auto* hk_shape =
|
||||||
new (ptr) hkpCapsuleShape(hkVector4(vertex_a.x, vertex_a.y, vertex_a.z),
|
new (ptr) hkpCapsuleShape(hkVector4(vertex_a.x, vertex_a.y, vertex_a.z),
|
||||||
hkVector4(vertex_b.x, vertex_b.y, vertex_b.z), radius);
|
hkVector4(vertex_b.x, vertex_b.y, vertex_b.z), radius);
|
||||||
auto* body = new (heap) CapsuleBody(vertex_a, vertex_b, radius, material, sub_material,
|
return new (heap) CapsuleBody(*this, hk_shape);
|
||||||
floor_code, wall_code, hk_shape);
|
|
||||||
if (_38) {
|
|
||||||
body->material_mask.getData().flag_23 = true;
|
|
||||||
}
|
|
||||||
body->material_mask.clearSubMaterialNameCache();
|
|
||||||
hk_shape->setUserData(body->material_mask.getRawData());
|
|
||||||
return body;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CapsuleBody* CapsuleBody::clone(sead::Heap* heap) {
|
CapsuleBody* CapsuleBody::clone(sead::Heap* heap) {
|
||||||
|
|
|
@ -13,41 +13,7 @@ class hkpShape;
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
class CapsuleView;
|
class CapsuleView;
|
||||||
struct CapsuleShape;
|
struct CapsuleBody;
|
||||||
|
|
||||||
struct CapsuleBody {
|
|
||||||
enum class Flag {
|
|
||||||
Modified = 1 << 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
CapsuleBody(const sead::Vector3f& va, const sead::Vector3f& vb, f32 r, Material material,
|
|
||||||
const char* sub_material, FloorCode floor_code, WallCode wall_code,
|
|
||||||
hkpShape* shape_)
|
|
||||||
: vertex_a(va), vertex_b(vb), radius(r),
|
|
||||||
material_mask(material, sub_material, floor_code, wall_code, false), shape(shape_) {}
|
|
||||||
virtual ~CapsuleBody();
|
|
||||||
|
|
||||||
virtual hkpShape* getShape();
|
|
||||||
virtual const hkpShape* getShape() const;
|
|
||||||
virtual void updateChanges();
|
|
||||||
virtual void scaleVerts(f32 scale);
|
|
||||||
|
|
||||||
RigidBody* init(u32 flag, RigidBodyParamView* view, sead::Heap* heap);
|
|
||||||
CapsuleBody* clone(sead::Heap* heap);
|
|
||||||
f32 getRadius() const;
|
|
||||||
void getVertices(sead::Vector3f* va, sead::Vector3f* vb) const;
|
|
||||||
bool setRadius(f32 r);
|
|
||||||
bool setVertices(const sead::Vector3f& va, const sead::Vector3f& vb);
|
|
||||||
f32 getVolume() const;
|
|
||||||
void sub_7100FABE80(sead::Vector3f* veca, sead::Vector3f* vecb, const hkVector4& rb_vec);
|
|
||||||
|
|
||||||
sead::Vector3f vertex_a;
|
|
||||||
sead::TypedBitFlag<Flag, sead::Atomic<u32>> flags{};
|
|
||||||
sead::Vector3f vertex_b;
|
|
||||||
f32 radius;
|
|
||||||
MaterialMask material_mask;
|
|
||||||
hkpShape* shape;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CapsuleShape {
|
struct CapsuleShape {
|
||||||
CapsuleBody* init(sead::Heap* heap);
|
CapsuleBody* init(sead::Heap* heap);
|
||||||
|
@ -63,6 +29,37 @@ struct CapsuleShape {
|
||||||
bool _38 = false;
|
bool _38 = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct CapsuleBody {
|
||||||
|
enum class Flag {
|
||||||
|
Modified = 1 << 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
CapsuleBody(const CapsuleShape& shape_, hkpShape* hkp_shape_);
|
||||||
|
virtual ~CapsuleBody();
|
||||||
|
|
||||||
|
virtual hkpShape* getShape();
|
||||||
|
virtual const hkpShape* getShape() const;
|
||||||
|
virtual void updateChanges();
|
||||||
|
virtual void scaleVerts(f32 scale);
|
||||||
|
|
||||||
|
RigidBody* init(u32 flag, RigidBodyParamView* view, sead::Heap* heap);
|
||||||
|
CapsuleBody* clone(sead::Heap* heap);
|
||||||
|
f32 getRadius() const;
|
||||||
|
void getVertices(sead::Vector3f* va, sead::Vector3f* vb) const;
|
||||||
|
bool setRadius(f32 r);
|
||||||
|
bool setVertices(const sead::Vector3f& va, const sead::Vector3f& vb);
|
||||||
|
f32 getVolume() const;
|
||||||
|
void sub_7100FABE80(sead::Vector3f* veca, sead::Vector3f* vecb, const hkVector4& rb_vec);
|
||||||
|
void setMaterialMask(const MaterialMask& mask);
|
||||||
|
|
||||||
|
sead::Vector3f vertex_a;
|
||||||
|
sead::TypedBitFlag<Flag, sead::Atomic<u32>> flags{};
|
||||||
|
sead::Vector3f vertex_b;
|
||||||
|
f32 radius;
|
||||||
|
MaterialMask material_mask;
|
||||||
|
hkpShape* shape;
|
||||||
|
};
|
||||||
|
|
||||||
class CapsuleView : public RigidBodyParamView {
|
class CapsuleView : public RigidBodyParamView {
|
||||||
SEAD_RTTI_OVERRIDE(CapsuleView, RigidBodyParamView)
|
SEAD_RTTI_OVERRIDE(CapsuleView, RigidBodyParamView)
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <basis/seadTypes.h>
|
#include <basis/seadTypes.h>
|
||||||
|
#include <prim/seadEnum.h>
|
||||||
#include <prim/seadSafeString.h>
|
#include <prim/seadSafeString.h>
|
||||||
#include "KingSystem/Physics/System/physDefines.h"
|
#include "KingSystem/Physics/System/physDefines.h"
|
||||||
#include "KingSystem/Utils/BitField.h"
|
#include "KingSystem/Utils/BitField.h"
|
||||||
|
@ -8,6 +9,9 @@
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
union MaterialMaskData {
|
union MaterialMaskData {
|
||||||
|
// FIXME: incomplete
|
||||||
|
SEAD_ENUM(CustomFlag, _0)
|
||||||
|
|
||||||
constexpr explicit MaterialMaskData(u32 raw_ = 0) : raw(raw_) {}
|
constexpr explicit MaterialMaskData(u32 raw_ = 0) : raw(raw_) {}
|
||||||
constexpr MaterialMaskData(const MaterialMaskData&) = default;
|
constexpr MaterialMaskData(const MaterialMaskData&) = default;
|
||||||
constexpr MaterialMaskData& operator=(const MaterialMaskData& other) {
|
constexpr MaterialMaskData& operator=(const MaterialMaskData& other) {
|
||||||
|
@ -28,13 +32,16 @@ union MaterialMaskData {
|
||||||
void setFlag() { flag = 1; }
|
void setFlag() { flag = 1; }
|
||||||
void clearFlag() { flag = 0; }
|
void clearFlag() { flag = 0; }
|
||||||
|
|
||||||
|
void setCustomFlag(CustomFlag custom_flag) {
|
||||||
|
raw |= 1 << (decltype(custom_flags)::StartBit() + custom_flag);
|
||||||
|
}
|
||||||
|
|
||||||
u32 raw;
|
u32 raw;
|
||||||
util::BitField<0, 6, u32> material;
|
util::BitField<0, 6, u32> material;
|
||||||
util::BitField<6, 4, int, u32> sub_material;
|
util::BitField<6, 4, int, u32> sub_material;
|
||||||
util::BitField<10, 5, u32> floor;
|
util::BitField<10, 5, u32> floor;
|
||||||
util::BitField<15, 5, u32> wall;
|
util::BitField<15, 5, u32> wall;
|
||||||
// TODO: rename
|
util::BitField<23, 8, u32> custom_flags;
|
||||||
util::BitField<23, 1, u32> flag_23;
|
|
||||||
// TODO: rename once we figure out what this flag is
|
// TODO: rename once we figure out what this flag is
|
||||||
util::BitField<31, 1, u32> flag;
|
util::BitField<31, 1, u32> flag;
|
||||||
};
|
};
|
||||||
|
@ -44,9 +51,10 @@ class MaterialMask {
|
||||||
public:
|
public:
|
||||||
MaterialMask();
|
MaterialMask();
|
||||||
explicit MaterialMask(MaterialMaskData data);
|
explicit MaterialMask(MaterialMaskData data);
|
||||||
MaterialMask(Material mat, FloorCode floor, WallCode wall, bool flag);
|
MaterialMask(Material mat, FloorCode floor, WallCode wall, bool flag = false);
|
||||||
MaterialMask(Material mat, const char* submat_name, FloorCode floor, WallCode wall, bool flag);
|
MaterialMask(Material mat, const char* submat_name, FloorCode floor, WallCode wall,
|
||||||
MaterialMask(Material mat, int submat_idx, FloorCode floor, WallCode wall, bool flag);
|
bool flag = false);
|
||||||
|
MaterialMask(Material mat, int submat_idx, FloorCode floor, WallCode wall, bool flag = false);
|
||||||
MaterialMask(const MaterialMask& other) : mData(other.mData) {}
|
MaterialMask(const MaterialMask& other) : mData(other.mData) {}
|
||||||
|
|
||||||
// XXX: this doesn't need to be virtual.
|
// XXX: this doesn't need to be virtual.
|
||||||
|
@ -68,7 +76,6 @@ public:
|
||||||
const char* getSubMaterialName() const;
|
const char* getSubMaterialName() const;
|
||||||
|
|
||||||
void setMaterial(Material mat);
|
void setMaterial(Material mat);
|
||||||
void clearSubMaterialNameCache() { mSubMaterialNameCache = nullptr; }
|
|
||||||
|
|
||||||
static int getSubMaterialIdx(Material mat, const sead::SafeString& submat_name);
|
static int getSubMaterialIdx(Material mat, const sead::SafeString& submat_name);
|
||||||
static const sead::SafeString& getSubMaterialName(Material mat, int submat_idx);
|
static const sead::SafeString& getSubMaterialName(Material mat, int submat_idx);
|
||||||
|
|
Loading…
Reference in New Issue