mirror of
https://github.com/zeldaret/botw
synced 2026-09-09 03:40:22 -04:00
ksys/phys: Add BoxWaterRigidBody::make
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterRigidBody.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
BoxWaterRigidBody* BoxWaterRigidBody::make(RigidBodyInstanceParam* param, sead::Heap* heap) {
|
||||
return RigidBodyFactory::createBoxWater(param, heap);
|
||||
}
|
||||
|
||||
BoxWaterRigidBody::BoxWaterRigidBody(hkpRigidBody* hk_body, BoxWaterShape* shape,
|
||||
ContactLayerType layer_type, const sead::SafeString& name,
|
||||
bool unused, sead::Heap* heap)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
|
||||
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxWaterShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physCapsuleShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physCylinderShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physCylinderWaterShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physSphereShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
@@ -44,13 +45,23 @@ RigidBody* RigidBodyFactory::createCylinderWater(RigidBodyInstanceParam* params,
|
||||
return shape->createBody(true, *params, heap);
|
||||
}
|
||||
|
||||
BoxRigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
if (params->isDynamicSensor())
|
||||
params->motion_type = MotionType::Keyframed;
|
||||
template <typename RigidBodyType, typename ShapeType, typename ParamType>
|
||||
static RigidBodyType* createRigidBody(RigidBodyInstanceParam* param, sead::Heap* heap) {
|
||||
if (param->isDynamicSensor())
|
||||
param->motion_type = MotionType::Keyframed;
|
||||
|
||||
auto* v = sead::DynamicCast<BoxParam>(params);
|
||||
auto* shape = BoxShape::make(v->shape, heap);
|
||||
return shape->createBody(true, *params, heap);
|
||||
auto* v = sead::DynamicCast<ParamType>(param);
|
||||
auto* shape = ShapeType::make(v->shape, heap);
|
||||
return RigidBodyFromShape::make<RigidBodyType, ShapeType>(*shape, true, *param, heap);
|
||||
}
|
||||
|
||||
BoxRigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
return createRigidBody<BoxRigidBody, BoxShape, BoxParam>(params, heap);
|
||||
}
|
||||
|
||||
BoxWaterRigidBody* RigidBodyFactory::createBoxWater(RigidBodyInstanceParam* params,
|
||||
sead::Heap* heap) {
|
||||
return createRigidBody<BoxWaterRigidBody, BoxWaterShape, BoxParam>(params, heap);
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
@@ -9,6 +9,7 @@ class Heap;
|
||||
namespace ksys::phys {
|
||||
|
||||
class BoxRigidBody;
|
||||
class BoxWaterRigidBody;
|
||||
class RigidBody;
|
||||
struct RigidBodyInstanceParam;
|
||||
|
||||
@@ -19,7 +20,7 @@ public:
|
||||
static RigidBody* createCylinder(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCylinderWater(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static BoxRigidBody* createBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createWaterBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static BoxWaterRigidBody* createBoxWater(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createPolytope(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCollection(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
@@ -10,6 +10,11 @@ class Shape;
|
||||
class RigidBodyFromShape : public RigidBody {
|
||||
SEAD_RTTI_OVERRIDE(RigidBodyFromShape, RigidBody)
|
||||
public:
|
||||
// TODO
|
||||
template <typename RigidBodyType, typename ShapeType>
|
||||
static RigidBodyType* make(const ShapeType& shape, bool set_flag_10,
|
||||
const RigidBodyInstanceParam& param, sead::Heap* heap);
|
||||
|
||||
RigidBodyFromShape(hkpRigidBody* hkp_rigid_body, ContactLayerType layer_type,
|
||||
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
|
||||
~RigidBodyFromShape() override;
|
||||
|
||||
Reference in New Issue
Block a user