summaryrefslogtreecommitdiff
path: root/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2022-02-01 17:08:03 +0100
committerLéo Lam <leo@leolam.fr>2022-02-01 17:08:03 +0100
commitd277eac80e1bc2fb9874120ee63b1a55956db2d9 (patch)
treeea6e9c660d2617b756ee208574c0bb855cc6ddd8 /src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp
parent2cd2d9dc69ca2da025b8a5a350f57fe343998650 (diff)
ksys/phys: Move BoxShapeParam::createShape to BoxShape::make
The same BoxShapeParam class is used for two different shape classes (BoxShape and BoxWaterShape) so it's more natural to move the factory function to the shape class itself
Diffstat (limited to 'src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp')
-rw-r--r--src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp b/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp
index b123276e..7e0e9444 100644
--- a/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp
+++ b/src/KingSystem/Physics/RigidBody/Shape/physBoxShape.cpp
@@ -7,21 +7,21 @@
namespace ksys::phys {
-BoxShape* BoxShapeParam::createShape(sead::Heap* heap) const {
+BoxShape* BoxShape::make(const BoxShapeParam& param, sead::Heap* heap) {
hkpBoxShape* box = nullptr;
if (auto* storage = util::allocStorage<hkpBoxShape>(heap)) {
- const auto radius = convex_radius;
- const hkVector4f half_extents{sead::Mathf::max(extents.x / 2 - radius, 0.001),
- sead::Mathf::max(extents.y / 2 - radius, 0.001),
- sead::Mathf::max(extents.z / 2 - radius, 0.001)};
+ const auto radius = param.convex_radius;
+ const hkVector4f half_extents{sead::Mathf::max(param.extents.x / 2 - radius, 0.001),
+ sead::Mathf::max(param.extents.y / 2 - radius, 0.001),
+ sead::Mathf::max(param.extents.z / 2 - radius, 0.001)};
box = new (storage) hkpBoxShape(half_extents, radius);
}
hkpConvexTransformShape* transform_shape = nullptr;
if (auto* storage = util::allocStorage<hkpConvexTransformShape>(heap)) {
sead::Quatf rotation;
- rotation.setRPY(rotate.x, rotate.y, rotate.z);
- hkQsTransformf transform{toHkVec4(translate), toHkQuat(rotation)};
+ rotation.setRPY(param.rotate.x, param.rotate.y, param.rotate.z);
+ hkQsTransformf transform{toHkVec4(param.translate), toHkQuat(rotation)};
transform_shape = new (storage) hkpConvexTransformShape(box, transform);
}
@@ -33,7 +33,7 @@ BoxShape* BoxShapeParam::createShape(sead::Heap* heap) const {
return nullptr;
}
- return new (heap) BoxShape(*this, box, transform_shape);
+ return new (heap) BoxShape(param, box, transform_shape);
}
BoxShape* BoxShape::clone(sead::Heap* heap) const {
@@ -41,7 +41,7 @@ BoxShape* BoxShape::clone(sead::Heap* heap) const {
param.extents = mExtents;
param.translate = mTranslate;
param.rotate = mRotate;
- auto* cloned = param.createShape(heap);
+ auto* cloned = make(param, heap);
cloned->setMaterialMask(mMaterialMask);
return cloned;
}