ksys/phys: Implement CylinderWaterRigidBody

This commit is contained in:
Léo Lam 2022-02-03 23:33:46 +01:00
parent a6cf379d99
commit 154852b763
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
4 changed files with 116 additions and 19 deletions

View File

@ -83240,24 +83240,24 @@ Address,Quality,Size,Name
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,
0x0000007100f987d0,U,000088,
0x0000007100f98828,U,000096,
0x0000007100f98888,U,000096,
0x0000007100f988e8,U,000056,
0x0000007100f98920,U,000056,
0x0000007100f98958,U,000008,
0x0000007100f98960,U,000008,
0x0000007100f98968,U,000008,
0x0000007100f98970,U,000012,
0x0000007100f9897c,U,000016,
0x0000007100f9898c,U,000008,
0x0000007100f98994,U,000008,
0x0000007100f9899c,U,000068,
0x0000007100f989e0,U,000288,
0x0000007100f98b00,U,000092,
0x0000007100f98718,O,000004,_ZN4ksys4phys22CylinderWaterRigidBody4makeEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f9871c,O,000092,_ZN4ksys4phys22CylinderWaterRigidBodyC1EP12hkpRigidBodyPNS0_18CylinderWaterShapeENS0_16ContactLayerTypeERKN4sead14SafeStringBaseIcEEbPNS7_4HeapE
0x0000007100f98778,O,000088,_ZN4ksys4phys22CylinderWaterRigidBodyD1Ev
0x0000007100f987d0,O,000088,_ZThn32_N4ksys4phys22CylinderWaterRigidBodyD1Ev
0x0000007100f98828,O,000096,_ZN4ksys4phys22CylinderWaterRigidBodyD0Ev
0x0000007100f98888,O,000096,_ZThn32_N4ksys4phys22CylinderWaterRigidBodyD0Ev
0x0000007100f988e8,O,000056,_ZN4ksys4phys22CylinderWaterRigidBody9setRadiusEf
0x0000007100f98920,O,000056,_ZN4ksys4phys22CylinderWaterRigidBody9setHeightEf
0x0000007100f98958,O,000008,_ZNK4ksys4phys22CylinderWaterRigidBody9getRadiusEv
0x0000007100f98960,O,000008,_ZNK4ksys4phys22CylinderWaterRigidBody9getHeightEv
0x0000007100f98968,O,000008,_ZN4ksys4phys22CylinderWaterRigidBody15setMaterialMaskERKNS0_12MaterialMaskE
0x0000007100f98970,O,000012,_ZNK4ksys4phys22CylinderWaterRigidBody15getMaterialMaskEv
0x0000007100f9897c,O,000016,_ZN4ksys4phys22CylinderWaterRigidBody9getVolumeEv
0x0000007100f9898c,O,000008,_ZN4ksys4phys22CylinderWaterRigidBody9getShape_Ev
0x0000007100f98994,O,000008,_ZNK4ksys4phys22CylinderWaterRigidBody9getShape_Ev
0x0000007100f9899c,O,000068,_ZN4ksys4phys22CylinderWaterRigidBody17getCollisionMasksEPNS0_9RigidBody14CollisionMasksE
0x0000007100f989e0,O,000288,_ZNK4ksys4phys22CylinderWaterRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x0000007100f98b00,O,000092,_ZNK4ksys4phys22CylinderWaterRigidBody18getRuntimeTypeInfoEv
0x0000007100f98b5c,U,000168,RigidBodyFromResource::ctor
0x0000007100f98c04,U,000004,j_RigidBody::dtor_0
0x0000007100f98c08,U,000008,

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

View File

@ -1 +1,69 @@
#include "KingSystem/Physics/RigidBody/Shape/CylinderWater/physCylinderWaterRigidBody.h"
#include "KingSystem/Physics/RigidBody/Shape/CylinderWater/physCylinderWaterShape.h"
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
#include "KingSystem/Utils/SafeDelete.h"
namespace ksys::phys {
CylinderWaterRigidBody* CylinderWaterRigidBody::make(RigidBodyInstanceParam* param,
sead::Heap* heap) {
return RigidBodyFactory::createCylinderWater(param, heap);
}
CylinderWaterRigidBody::CylinderWaterRigidBody(hkpRigidBody* hk_body, CylinderWaterShape* 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) {}
CylinderWaterRigidBody::~CylinderWaterRigidBody() {
if (hasFlag(RigidBody::Flag::_10) && mShape)
util::safeDelete(mShape);
}
void CylinderWaterRigidBody::setRadius(float radius) {
if (mShape->setRadius(radius))
updateShape();
}
void CylinderWaterRigidBody::setHeight(float height) {
if (mShape->setHeight(height))
updateShape();
}
float CylinderWaterRigidBody::getRadius() const {
return mShape->getRadius();
}
float CylinderWaterRigidBody::getHeight() const {
return mShape->getHeight();
}
void CylinderWaterRigidBody::setMaterialMask(const MaterialMask& mask) {
mShape->setMaterialMask(mask);
}
const MaterialMask& CylinderWaterRigidBody::getMaterialMask() const {
return mShape->getMaterialMask();
}
float CylinderWaterRigidBody::getVolume() {
return mShape->getVolume();
}
Shape* CylinderWaterRigidBody::getShape_() {
return mShape;
}
const Shape* CylinderWaterRigidBody::getShape_() const {
return mShape;
}
u32 CylinderWaterRigidBody::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,37 @@
namespace ksys::phys {
// TODO
class CylinderWaterShape;
class CylinderWaterRigidBody : public RigidBodyFromShape {
SEAD_RTTI_OVERRIDE(CylinderWaterRigidBody, RigidBodyFromShape)
public:
static CylinderWaterRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
CylinderWaterRigidBody(hkpRigidBody* hk_body, CylinderWaterShape* shape,
ContactLayerType layer_type, const sead::SafeString& name,
bool set_flag_10, sead::Heap* heap);
~CylinderWaterRigidBody() override;
void setRadius(float radius);
void setHeight(float height);
float getRadius() const;
float getHeight() const;
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:
CylinderWaterShape* mShape{};
float _d8 = 1.0;
};
} // namespace ksys::phys

View File

@ -29,6 +29,7 @@ public:
CylinderWaterShape* clone(sead::Heap* heap) const;
const MaterialMask& getMaterialMask() const { return mMaterialMask; }
float getRadius() const;
float getHeight() const;