ksys/phys: Add BoxWaterRigidBody

This commit is contained in:
Léo Lam
2022-02-02 15:09:28 +01:00
parent 2af9e079d0
commit 55164640d5
4 changed files with 122 additions and 20 deletions
+6 -4
View File
@@ -40,12 +40,14 @@ target_sources(uking PRIVATE
RigidBody/physRigidBodySetParam.cpp
RigidBody/physRigidBodySetParam.h
RigidBody/Shape/physBoxShape.cpp
RigidBody/Shape/physBoxShape.h
RigidBody/Shape/physBoxWaterShape.cpp
RigidBody/Shape/physBoxWaterShape.h
RigidBody/Shape/physBoxRigidBody.cpp
RigidBody/Shape/physBoxRigidBody.h
RigidBody/Shape/physBoxShape.cpp
RigidBody/Shape/physBoxShape.h
RigidBody/Shape/physBoxWaterRigidBody.cpp
RigidBody/Shape/physBoxWaterRigidBody.h
RigidBody/Shape/physBoxWaterShape.cpp
RigidBody/Shape/physBoxWaterShape.h
RigidBody/Shape/physCapsuleShape.cpp
RigidBody/Shape/physCapsuleShape.h
RigidBody/Shape/physCharacterPrismShape.cpp
@@ -0,0 +1,60 @@
#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h"
#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterShape.h"
namespace ksys::phys {
BoxWaterRigidBody::BoxWaterRigidBody(hkpRigidBody* hk_body, BoxWaterShape* shape,
ContactLayerType layer_type, const sead::SafeString& name,
bool unused, sead::Heap* heap)
: RigidBodyFromShape(hk_body, layer_type, name, true, heap), mShape(shape) {}
BoxWaterRigidBody::~BoxWaterRigidBody() {
delete mShape;
}
void BoxWaterRigidBody::setExtents(const sead::Vector3f& extents) {
if (mShape->setExtents(extents))
updateShape();
}
void BoxWaterRigidBody::setTranslate(const sead::Vector3f& translate) {
if (mShape->setTranslate(translate))
updateShape();
}
const sead::Vector3f& BoxWaterRigidBody::getExtents() const {
return mShape->mExtents;
}
const sead::Vector3f& BoxWaterRigidBody::getTranslate() const {
return mShape->mTranslate;
}
void BoxWaterRigidBody::setMaterialMask(const MaterialMask& mask) {
mShape->setMaterialMask(mask);
}
const MaterialMask& BoxWaterRigidBody::getMaterialMask() const {
return mShape->mMaterialMask;
}
float BoxWaterRigidBody::getVolume() {
return mShape->getVolume();
}
Shape* BoxWaterRigidBody::getShape_() {
return mShape;
}
const Shape* BoxWaterRigidBody::getShape_() const {
return mShape;
}
u32 BoxWaterRigidBody::getCollisionMasks(RigidBody::CollisionMasks* masks) {
masks->ignored_layers = ~mContactMask.getDirect();
masks->collision_filter_info = getCollisionFilterInfo();
masks->material_mask = getMaterialMask().getRawData();
return 0;
}
} // namespace ksys::phys
@@ -0,0 +1,40 @@
#pragma once
#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h"
namespace ksys::phys {
class BoxWaterShape;
class BoxWaterRigidBody : public RigidBodyFromShape {
SEAD_RTTI_OVERRIDE(BoxWaterRigidBody, RigidBodyFromShape)
public:
static BoxWaterRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
BoxWaterRigidBody(hkpRigidBody* hk_body, BoxWaterShape* shape, ContactLayerType layer_type,
const sead::SafeString& name, bool unused, sead::Heap* heap);
~BoxWaterRigidBody() override;
/// Set the box extents and trigger a shape update.
void setExtents(const sead::Vector3f& extents);
/// Set the box translation and trigger a shape update.
void setTranslate(const sead::Vector3f& translate);
const sead::Vector3f& getExtents() const;
const sead::Vector3f& getTranslate() 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;
BoxWaterShape* mShape;
u32 _d8{};
};
} // namespace ksys::phys