summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-02-02 15:09:28 +0100
committerLéo Lam <leo@leolam.fr>2022-02-02 15:36:30 +0100
commit55164640d52ed76d16bdbacffb882e3d9ccdd30a (patch)
tree9c3fa61c47f11b6da3b7e9b4c8f1575285267def /src
parent2af9e079d04cfbc274917d43c90c9d040efa3f0c (diff)
ksys/phys: Add BoxWaterRigidBody
Diffstat (limited to 'src')
-rw-r--r--src/KingSystem/Physics/CMakeLists.txt6
-rw-r--r--src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp60
-rw-r--r--src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h40
3 files changed, 104 insertions, 2 deletions
diff --git a/src/KingSystem/Physics/CMakeLists.txt b/src/KingSystem/Physics/CMakeLists.txt
index 8d235b74..90628486 100644
--- a/src/KingSystem/Physics/CMakeLists.txt
+++ b/src/KingSystem/Physics/CMakeLists.txt
@@ -40,12 +40,14 @@ target_sources(uking PRIVATE
RigidBody/physRigidBodySetParam.cpp
RigidBody/physRigidBodySetParam.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/physBoxRigidBody.cpp
- RigidBody/Shape/physBoxRigidBody.h
RigidBody/Shape/physCapsuleShape.cpp
RigidBody/Shape/physCapsuleShape.h
RigidBody/Shape/physCharacterPrismShape.cpp
diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.cpp
new file mode 100644
index 00000000..13ab6a92
--- /dev/null
+++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.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
diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h
new file mode 100644
index 00000000..031040cf
--- /dev/null
+++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h
@@ -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