ksys/phys: Add CylinderRigidBody

This commit is contained in:
Léo Lam 2022-02-03 13:17:51 +01:00
parent 7875b0ad55
commit 872d02a037
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
3 changed files with 122 additions and 20 deletions

View File

@ -83221,25 +83221,25 @@ Address,Quality,Size,Name
0x0000007100f980ac,U,000100,
0x0000007100f98110,U,000288,
0x0000007100f98230,U,000092,
0x0000007100f9828c,U,000004,j__ZN4ksys4phys16RigidBodyFactory14createCylinderEPNS0_18RigidBodyParamViewEPN4sead4HeapE
0x0000007100f98290,U,000084,
0x0000007100f982e4,U,000088,
0x0000007100f9833c,U,000088,
0x0000007100f98394,U,000096,
0x0000007100f983f4,U,000096,
0x0000007100f98454,U,000056,
0x0000007100f9848c,U,000056,
0x0000007100f984c4,U,000008,
0x0000007100f984cc,U,000008,
0x0000007100f984d4,U,000080,
0x0000007100f98524,U,000008,
0x0000007100f9852c,U,000012,
0x0000007100f98538,U,000016,
0x0000007100f98548,U,000008,
0x0000007100f98550,U,000008,
0x0000007100f98558,U,000068,
0x0000007100f9859c,U,000288,
0x0000007100f986bc,U,000092,
0x0000007100f9828c,O,000004,_ZN4ksys4phys17CylinderRigidBody4makeEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f98290,O,000084,_ZN4ksys4phys17CylinderRigidBodyC1EP12hkpRigidBodyPNS0_13CylinderShapeENS0_16ContactLayerTypeERKN4sead14SafeStringBaseIcEEbPNS7_4HeapE
0x0000007100f982e4,O,000088,_ZN4ksys4phys17CylinderRigidBodyD1Ev
0x0000007100f9833c,O,000088,_ZThn32_N4ksys4phys17CylinderRigidBodyD1Ev
0x0000007100f98394,O,000096,_ZN4ksys4phys17CylinderRigidBodyD0Ev
0x0000007100f983f4,O,000096,_ZThn32_N4ksys4phys17CylinderRigidBodyD0Ev
0x0000007100f98454,O,000056,_ZN4ksys4phys17CylinderRigidBody9setRadiusEf
0x0000007100f9848c,O,000056,_ZN4ksys4phys17CylinderRigidBody11setVerticesERKN4sead7Vector3IfEES6_
0x0000007100f984c4,O,000008,_ZNK4ksys4phys17CylinderRigidBody9getRadiusEv
0x0000007100f984cc,O,000008,_ZNK4ksys4phys17CylinderRigidBody11getVerticesEPN4sead7Vector3IfEES5_
0x0000007100f984d4,O,000080,_ZN4ksys4phys17CylinderRigidBody17transformVerticesEPN4sead7Vector3IfEES5_
0x0000007100f98524,O,000008,_ZN4ksys4phys17CylinderRigidBody15setMaterialMaskERKNS0_12MaterialMaskE
0x0000007100f9852c,O,000012,_ZNK4ksys4phys17CylinderRigidBody15getMaterialMaskEv
0x0000007100f98538,O,000016,_ZN4ksys4phys17CylinderRigidBody9getVolumeEv
0x0000007100f98548,O,000008,_ZN4ksys4phys17CylinderRigidBody9getShape_Ev
0x0000007100f98550,O,000008,_ZNK4ksys4phys17CylinderRigidBody9getShape_Ev
0x0000007100f98558,O,000068,_ZN4ksys4phys17CylinderRigidBody17getCollisionMasksEPNS0_9RigidBody14CollisionMasksE
0x0000007100f9859c,O,000288,_ZNK4ksys4phys17CylinderRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x0000007100f986bc,O,000092,_ZNK4ksys4phys17CylinderRigidBody18getRuntimeTypeInfoEv
0x0000007100f98718,U,000004,j__ZN4ksys4phys16RigidBodyFactory19createWaterCylinderEPNS0_18RigidBodyParamViewEPN4sead4HeapE
0x0000007100f9871c,U,000092,
0x0000007100f98778,U,000088,
@ -83625,6 +83625,7 @@ Address,Quality,Size,Name
0x0000007100fad8b0,U,000092,
0x0000007100fad90c,U,000008,
0x0000007100fad914,O,000344,_ZN4ksys4phys13CylinderShape4makeERKNS0_18CylinderShapeParamEPN4sead4HeapE
0x0000007100fada6c,O,000032,_ZN4ksys4phys13CylinderShape15setMaterialMaskERKNS0_12MaterialMaskE
0x0000007100fada8c,O,000064,_ZN4ksys4phys13CylinderShapeD1Ev
0x0000007100fadacc,O,000072,_ZN4ksys4phys13CylinderShapeD0Ev
0x0000007100fadb14,O,000052,_ZN4ksys4phys13CylinderShape9setRadiusEf

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

View File

@ -1 +1,75 @@
#include "KingSystem/Physics/RigidBody/Shape/Cylinder/physCylinderRigidBody.h"
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
#include "KingSystem/Physics/RigidBody/Shape/Cylinder/physCylinderShape.h"
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
#include "KingSystem/Utils/SafeDelete.h"
namespace ksys::phys {
CylinderRigidBody* CylinderRigidBody::make(RigidBodyInstanceParam* param, sead::Heap* heap) {
return RigidBodyFactory::createCylinder(param, heap);
}
CylinderRigidBody::CylinderRigidBody(hkpRigidBody* hk_body, CylinderShape* shape,
ContactLayerType layer_type, const sead::SafeString& name,
bool set_flag_10, sead::Heap* heap)
: RigidBodyFromShape(hk_body, layer_type, name, set_flag_10, heap), mShape(shape) {}
CylinderRigidBody::~CylinderRigidBody() {
if (hasFlag(RigidBody::Flag::_10) && mShape)
util::safeDelete(mShape);
}
void CylinderRigidBody::setRadius(float radius) {
if (mShape->setRadius(radius))
updateShape();
}
void CylinderRigidBody::setVertices(const sead::Vector3f& va, const sead::Vector3f& vb) {
if (mShape->setVertices(va, vb))
updateShape();
}
float CylinderRigidBody::getRadius() const {
return mShape->getRadius();
}
void CylinderRigidBody::getVertices(sead::Vector3f* va, sead::Vector3f* vb) const {
mShape->getVertices(va, vb);
}
void CylinderRigidBody::transformVertices(sead::Vector3f* va, sead::Vector3f* vb) {
lock();
const hkTransform& transform = getHkBody()->getMotion()->getTransform();
unlock();
mShape->transformVertices(va, vb, transform);
}
void CylinderRigidBody::setMaterialMask(const MaterialMask& mask) {
mShape->setMaterialMask(mask);
}
const MaterialMask& CylinderRigidBody::getMaterialMask() const {
return mShape->getMaterialMask();
}
float CylinderRigidBody::getVolume() {
return mShape->getVolume();
}
Shape* CylinderRigidBody::getShape_() {
return mShape;
}
const Shape* CylinderRigidBody::getShape_() const {
return mShape;
}
u32 CylinderRigidBody::getCollisionMasks(RigidBody::CollisionMasks* masks) {
masks->ignored_layers = ~mContactMask.getDirect();
masks->collision_filter_info = getCollisionFilterInfo();
masks->material_mask = getMaterialMask().getRawData();
return 0;
}
} // namespace ksys::phys

View File

@ -4,9 +4,36 @@
namespace ksys::phys {
// TODO
class CylinderShape;
class CylinderRigidBody : public RigidBodyFromShape {
SEAD_RTTI_OVERRIDE(CylinderRigidBody, RigidBodyFromShape)
public:
static CylinderRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
CylinderRigidBody(hkpRigidBody* hk_body, CylinderShape* shape, ContactLayerType layer_type,
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
~CylinderRigidBody() override;
void setRadius(float radius);
void setVertices(const sead::Vector3f& va, const sead::Vector3f& vb);
float getRadius() const;
void getVertices(sead::Vector3f* va, sead::Vector3f* vb) const;
void transformVertices(sead::Vector3f* va, sead::Vector3f* vb);
void setMaterialMask(const MaterialMask& mask);
const MaterialMask& getMaterialMask() const;
float getVolume() override;
protected:
Shape* getShape_() override;
const Shape* getShape_() const override;
u32 getCollisionMasks(CollisionMasks* masks) override;
private:
CylinderShape* mShape;
};
} // namespace ksys::phys