mirror of https://github.com/zeldaret/botw.git
ksys/phys: Rename Shape/Body classes to avoid confusion
What we currently call BoxBody, CapsuleBody, etc. is actually BoxShape, CapsuleShape, etc. (those classes encapsulate Havok shapes) So this commit renames Body -> Shape and Shape -> ShapeParam.
This commit is contained in:
parent
a1a283acf7
commit
60e2b1664f
|
@ -83585,21 +83585,21 @@ Address,Quality,Size,Name
|
|||
0x0000007100fab688,U,000276,
|
||||
0x0000007100fab79c,U,000008,
|
||||
0x0000007100fab7a4,U,000184,
|
||||
0x0000007100fab85c,O,000332,_ZN4ksys4phys12CapsuleShape4initEPN4sead4HeapE
|
||||
0x0000007100fab9a8,O,000184,_ZN4ksys4phys11CapsuleBody5cloneEPN4sead4HeapE
|
||||
0x0000007100faba60,O,000008,_ZNK4ksys4phys11CapsuleBody9getRadiusEv
|
||||
0x0000007100faba68,O,000060,_ZNK4ksys4phys11CapsuleBody11getVerticesEPN4sead7Vector3IfEES5_
|
||||
0x0000007100fab85c,O,000332,_ZN4ksys4phys17CapsuleShapeParam11createShapeEPN4sead4HeapE
|
||||
0x0000007100fab9a8,O,000184,_ZN4ksys4phys12CapsuleShape5cloneEPN4sead4HeapE
|
||||
0x0000007100faba60,O,000008,_ZNK4ksys4phys12CapsuleShape9getRadiusEv
|
||||
0x0000007100faba68,O,000060,_ZNK4ksys4phys12CapsuleShape11getVerticesEPN4sead7Vector3IfEES5_
|
||||
0x0000007100fabaa4,U,000032,
|
||||
0x0000007100fabac4,O,000064,_ZN4ksys4phys11CapsuleBodyD1Ev
|
||||
0x0000007100fabb04,O,000072,_ZN4ksys4phys11CapsuleBodyD0Ev
|
||||
0x0000007100fabb4c,O,000060,_ZN4ksys4phys11CapsuleBody9setRadiusEf
|
||||
0x0000007100fabb88,O,000192,_ZN4ksys4phys11CapsuleBody11setVerticesERKN4sead7Vector3IfEES6_
|
||||
0x0000007100fabc48,O,000140,_ZNK4ksys4phys11CapsuleBody9getVolumeEv
|
||||
0x0000007100fabcd4,O,000008,_ZN4ksys4phys11CapsuleBody8getShapeEv
|
||||
0x0000007100fabcdc,O,000008,_ZNK4ksys4phys11CapsuleBody8getShapeEv
|
||||
0x0000007100fabac4,O,000064,_ZN4ksys4phys12CapsuleShapeD1Ev
|
||||
0x0000007100fabb04,O,000072,_ZN4ksys4phys12CapsuleShapeD0Ev
|
||||
0x0000007100fabb4c,O,000060,_ZN4ksys4phys12CapsuleShape9setRadiusEf
|
||||
0x0000007100fabb88,O,000192,_ZN4ksys4phys12CapsuleShape11setVerticesERKN4sead7Vector3IfEES6_
|
||||
0x0000007100fabc48,O,000140,_ZNK4ksys4phys12CapsuleShape9getVolumeEv
|
||||
0x0000007100fabcd4,O,000008,_ZN4ksys4phys12CapsuleShape8getShapeEv
|
||||
0x0000007100fabcdc,O,000008,_ZNK4ksys4phys12CapsuleShape8getShapeEv
|
||||
0x0000007100fabce4,U,000252,
|
||||
0x0000007100fabde0,U,000160,
|
||||
0x0000007100fabe80,O,000192,_ZN4ksys4phys11CapsuleBody14sub_7100FABE80EPN4sead7Vector3IfEES5_RK12hkTransformf
|
||||
0x0000007100fabe80,O,000192,_ZN4ksys4phys12CapsuleShape14sub_7100FABE80EPN4sead7Vector3IfEES5_RK12hkTransformf
|
||||
0x0000007100fabf40,U,000204,
|
||||
0x0000007100fac00c,U,000092,
|
||||
0x0000007100fac068,U,000008,
|
||||
|
|
Can't render this file because it is too large.
|
|
@ -7,14 +7,14 @@ namespace ksys::phys {
|
|||
|
||||
class BoxParam;
|
||||
|
||||
struct BoxBody {
|
||||
virtual ~BoxBody();
|
||||
struct BoxShape {
|
||||
virtual ~BoxShape();
|
||||
|
||||
RigidBody* init(u32 flag, RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
RigidBody* createBody(u32 flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
struct BoxShape {
|
||||
BoxBody* init(sead::Heap* heap);
|
||||
struct BoxShapeParam {
|
||||
BoxShape* createShape(sead::Heap* heap);
|
||||
};
|
||||
|
||||
class BoxParam : public RigidBodyInstanceParam {
|
||||
|
@ -22,7 +22,7 @@ class BoxParam : public RigidBodyInstanceParam {
|
|||
public:
|
||||
u8 _90;
|
||||
float _94;
|
||||
BoxShape shape;
|
||||
BoxShapeParam shape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
namespace ksys::phys {
|
||||
|
||||
CapsuleBody::CapsuleBody(const CapsuleShape& shape_, hkpShape* hkp_shape_)
|
||||
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),
|
||||
shape(hkp_shape_) {
|
||||
|
@ -15,13 +15,13 @@ CapsuleBody::CapsuleBody(const CapsuleShape& shape_, hkpShape* hkp_shape_)
|
|||
setMaterialMask(material_mask);
|
||||
}
|
||||
|
||||
void CapsuleBody::setMaterialMask(const MaterialMask& mask) {
|
||||
void CapsuleShape::setMaterialMask(const MaterialMask& mask) {
|
||||
material_mask = mask;
|
||||
if (shape)
|
||||
shape->setUserData(mask.getRawData());
|
||||
}
|
||||
|
||||
CapsuleBody* CapsuleShape::init(sead::Heap* heap) {
|
||||
CapsuleShape* CapsuleShapeParam::createShape(sead::Heap* heap) {
|
||||
void* ptr = heap->tryAlloc(sizeof(hkpCapsuleShape), 0x10);
|
||||
if (ptr == nullptr)
|
||||
return nullptr;
|
||||
|
@ -29,41 +29,41 @@ CapsuleBody* CapsuleShape::init(sead::Heap* heap) {
|
|||
auto* hk_shape =
|
||||
new (ptr) hkpCapsuleShape(hkVector4(vertex_a.x, vertex_a.y, vertex_a.z),
|
||||
hkVector4(vertex_b.x, vertex_b.y, vertex_b.z), radius);
|
||||
return new (heap) CapsuleBody(*this, hk_shape);
|
||||
return new (heap) CapsuleShape(*this, hk_shape);
|
||||
}
|
||||
|
||||
CapsuleBody* CapsuleBody::clone(sead::Heap* heap) {
|
||||
CapsuleShape shape;
|
||||
shape.radius = radius;
|
||||
shape.vertex_a = vertex_a;
|
||||
shape.vertex_b = vertex_b;
|
||||
CapsuleShape* CapsuleShape::clone(sead::Heap* heap) {
|
||||
CapsuleShapeParam param_clone;
|
||||
param_clone.radius = radius;
|
||||
param_clone.vertex_a = vertex_a;
|
||||
param_clone.vertex_b = vertex_b;
|
||||
|
||||
CapsuleBody* body = shape.init(heap);
|
||||
body->material_mask = material_mask;
|
||||
if (body->shape != nullptr)
|
||||
body->shape->setUserData(material_mask.getRawData());
|
||||
return body;
|
||||
CapsuleShape* cloned = param_clone.createShape(heap);
|
||||
cloned->material_mask = material_mask;
|
||||
if (cloned->shape != nullptr)
|
||||
cloned->shape->setUserData(material_mask.getRawData());
|
||||
return cloned;
|
||||
}
|
||||
|
||||
f32 CapsuleBody::getRadius() const {
|
||||
f32 CapsuleShape::getRadius() const {
|
||||
return radius;
|
||||
}
|
||||
|
||||
void CapsuleBody::getVertices(sead::Vector3f* va, sead::Vector3f* vb) const {
|
||||
void CapsuleShape::getVertices(sead::Vector3f* va, sead::Vector3f* vb) const {
|
||||
if (va != nullptr)
|
||||
*va = vertex_a;
|
||||
if (vb != nullptr)
|
||||
*vb = vertex_b;
|
||||
}
|
||||
|
||||
CapsuleBody::~CapsuleBody() {
|
||||
CapsuleShape::~CapsuleShape() {
|
||||
if (shape != nullptr) {
|
||||
::operator delete(shape);
|
||||
shape = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool CapsuleBody::setRadius(f32 r) {
|
||||
bool CapsuleShape::setRadius(f32 r) {
|
||||
if (r == radius || r <= 0.0f) {
|
||||
return false;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ bool CapsuleBody::setRadius(f32 r) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CapsuleBody::setVertices(const sead::Vector3f& va, const sead::Vector3f& vb) {
|
||||
bool CapsuleShape::setVertices(const sead::Vector3f& va, const sead::Vector3f& vb) {
|
||||
if (vertex_a == va && vertex_b == vb) {
|
||||
return false;
|
||||
}
|
||||
|
@ -82,21 +82,21 @@ bool CapsuleBody::setVertices(const sead::Vector3f& va, const sead::Vector3f& vb
|
|||
return true;
|
||||
}
|
||||
|
||||
f32 CapsuleBody::getVolume() const {
|
||||
f32 CapsuleShape::getVolume() const {
|
||||
f32 dist = (vertex_a - vertex_b).length();
|
||||
return sead::Mathf::pi() * radius * radius * (dist + radius * 4.0f / 3.0f);
|
||||
}
|
||||
|
||||
hkpShape* CapsuleBody::getShape() {
|
||||
hkpShape* CapsuleShape::getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
const hkpShape* CapsuleBody::getShape() const {
|
||||
const hkpShape* CapsuleShape::getShape() const {
|
||||
return shape;
|
||||
}
|
||||
|
||||
void CapsuleBody::sub_7100FABE80(sead::Vector3f* veca, sead::Vector3f* vecb,
|
||||
const hkTransformf& rb_vec) {
|
||||
void CapsuleShape::sub_7100FABE80(sead::Vector3f* veca, sead::Vector3f* vecb,
|
||||
const hkTransformf& rb_vec) {
|
||||
if (veca != nullptr) {
|
||||
hkVector4 tmp;
|
||||
tmp.setTransformedPos(rb_vec, toHkVec4(vertex_a));
|
||||
|
|
|
@ -14,10 +14,10 @@ class hkpShape;
|
|||
namespace ksys::phys {
|
||||
|
||||
class CapsuleParam;
|
||||
struct CapsuleBody;
|
||||
struct CapsuleShape;
|
||||
|
||||
struct CapsuleShape {
|
||||
CapsuleBody* init(sead::Heap* heap);
|
||||
struct CapsuleShapeParam {
|
||||
CapsuleShape* createShape(sead::Heap* heap);
|
||||
|
||||
sead::Vector3f vertex_a;
|
||||
sead::Vector3f vertex_b;
|
||||
|
@ -30,21 +30,21 @@ struct CapsuleShape {
|
|||
bool _38 = false;
|
||||
};
|
||||
|
||||
struct CapsuleBody {
|
||||
struct CapsuleShape {
|
||||
enum class Flag {
|
||||
Modified = 1 << 0,
|
||||
};
|
||||
|
||||
CapsuleBody(const CapsuleShape& shape_, hkpShape* hkp_shape_);
|
||||
virtual ~CapsuleBody();
|
||||
CapsuleShape(const CapsuleShapeParam& shape_, hkpShape* hkp_shape_);
|
||||
virtual ~CapsuleShape();
|
||||
|
||||
virtual hkpShape* getShape();
|
||||
virtual const hkpShape* getShape() const;
|
||||
virtual void updateChanges();
|
||||
virtual void scaleVerts(f32 scale);
|
||||
|
||||
RigidBody* init(u32 flag, RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
CapsuleBody* clone(sead::Heap* heap);
|
||||
RigidBody* createBody(u32 flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
CapsuleShape* clone(sead::Heap* heap);
|
||||
f32 getRadius() const;
|
||||
void getVertices(sead::Vector3f* va, sead::Vector3f* vb) const;
|
||||
bool setRadius(f32 r);
|
||||
|
@ -66,7 +66,7 @@ class CapsuleParam : public RigidBodyInstanceParam {
|
|||
public:
|
||||
u8 _90;
|
||||
float _94;
|
||||
CapsuleShape shape;
|
||||
CapsuleShapeParam shape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
|
@ -7,14 +7,14 @@ namespace ksys::phys {
|
|||
|
||||
class CylinderParam;
|
||||
|
||||
struct CylinderBody {
|
||||
virtual ~CylinderBody();
|
||||
struct CylinderShape {
|
||||
virtual ~CylinderShape();
|
||||
|
||||
RigidBody* init(u32 flag, RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
RigidBody* createBody(u32 flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
struct CylinderShape {
|
||||
CylinderBody* init(sead::Heap* heap);
|
||||
struct CylinderShapeParam {
|
||||
CylinderShape* createShape(sead::Heap* heap);
|
||||
};
|
||||
|
||||
class CylinderParam : public RigidBodyInstanceParam {
|
||||
|
@ -22,7 +22,7 @@ class CylinderParam : public RigidBodyInstanceParam {
|
|||
public:
|
||||
u8 _90;
|
||||
float _94;
|
||||
CylinderShape shape;
|
||||
CylinderShapeParam shape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
|
@ -7,14 +7,14 @@ namespace ksys::phys {
|
|||
|
||||
class SphereParam;
|
||||
|
||||
struct SphereBody {
|
||||
virtual ~SphereBody();
|
||||
struct SphereShape {
|
||||
virtual ~SphereShape();
|
||||
|
||||
RigidBody* init(u32 flag, RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
RigidBody* createBody(u32 flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
struct SphereShape {
|
||||
SphereBody* init(sead::Heap* heap);
|
||||
struct SphereShapeParam {
|
||||
SphereShape* createShape(sead::Heap* heap);
|
||||
};
|
||||
|
||||
class SphereParam : public RigidBodyInstanceParam {
|
||||
|
@ -22,7 +22,7 @@ class SphereParam : public RigidBodyInstanceParam {
|
|||
public:
|
||||
u8 _90;
|
||||
float _94;
|
||||
SphereShape shape;
|
||||
SphereShapeParam shape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
|
@ -7,14 +7,14 @@ namespace ksys::phys {
|
|||
|
||||
class WaterCylinderParam;
|
||||
|
||||
struct WaterCylinderBody {
|
||||
virtual ~WaterCylinderBody();
|
||||
struct WaterCylinderShape {
|
||||
virtual ~WaterCylinderShape();
|
||||
|
||||
RigidBody* init(u32 flag, RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
RigidBody* createBody(u32 flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
struct WaterCylinderShape {
|
||||
WaterCylinderBody* init(sead::Heap* heap);
|
||||
struct WaterCylinderShapeParam {
|
||||
WaterCylinderShape* createShape(sead::Heap* heap);
|
||||
};
|
||||
|
||||
class WaterCylinderParam : public RigidBodyInstanceParam {
|
||||
|
@ -22,7 +22,7 @@ class WaterCylinderParam : public RigidBodyInstanceParam {
|
|||
public:
|
||||
u8 _90;
|
||||
float _94;
|
||||
WaterCylinderShape shape;
|
||||
WaterCylinderShapeParam shape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
|
@ -13,8 +13,8 @@ RigidBody* RigidBodyFactory::createSphere(RigidBodyInstanceParam* params, sead::
|
|||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<SphereParam>(params);
|
||||
SphereBody* body = v->shape.init(heap);
|
||||
return body->init(1, params, heap);
|
||||
auto* shape = v->shape.createShape(heap);
|
||||
return shape->createBody(1, *params, heap);
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyFactory::createCapsule(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
|
@ -22,8 +22,8 @@ RigidBody* RigidBodyFactory::createCapsule(RigidBodyInstanceParam* params, sead:
|
|||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<CapsuleParam>(params);
|
||||
CapsuleBody* body = v->shape.init(heap);
|
||||
return body->init(1, params, heap);
|
||||
auto* shape = v->shape.createShape(heap);
|
||||
return shape->createBody(1, *params, heap);
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyFactory::createCylinder(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
|
@ -31,8 +31,8 @@ RigidBody* RigidBodyFactory::createCylinder(RigidBodyInstanceParam* params, sead
|
|||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<CylinderParam>(params);
|
||||
CylinderBody* body = v->shape.init(heap);
|
||||
return body->init(1, params, heap);
|
||||
auto* shape = v->shape.createShape(heap);
|
||||
return shape->createBody(1, *params, heap);
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyFactory::createWaterCylinder(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
|
@ -40,8 +40,8 @@ RigidBody* RigidBodyFactory::createWaterCylinder(RigidBodyInstanceParam* params,
|
|||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<WaterCylinderParam>(params);
|
||||
WaterCylinderBody* body = v->shape.init(heap);
|
||||
return body->init(1, params, heap);
|
||||
auto* body = v->shape.createShape(heap);
|
||||
return body->createBody(1, *params, heap);
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
|
@ -49,8 +49,8 @@ RigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Hea
|
|||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<BoxParam>(params);
|
||||
BoxBody* body = v->shape.init(heap);
|
||||
return body->init(1, params, heap);
|
||||
auto* body = v->shape.createShape(heap);
|
||||
return body->createBody(1, *params, heap);
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
|
Loading…
Reference in New Issue