mirror of
https://github.com/zeldaret/botw
synced 2026-05-26 07:38:50 -04:00
ksys/phys: Start adding BoxRigidBody
This commit is contained in:
@@ -42,6 +42,8 @@ target_sources(uking PRIVATE
|
||||
|
||||
RigidBody/Shape/physBoxShape.cpp
|
||||
RigidBody/Shape/physBoxShape.h
|
||||
RigidBody/Shape/physBoxRigidBody.cpp
|
||||
RigidBody/Shape/physBoxRigidBody.h
|
||||
RigidBody/Shape/physCapsuleShape.cpp
|
||||
RigidBody/Shape/physCapsuleShape.h
|
||||
RigidBody/Shape/physCharacterPrismShape.cpp
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxRigidBody.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/physBoxShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
BoxRigidBody* BoxRigidBody::make(RigidBodyInstanceParam* param, sead::Heap* heap) {
|
||||
return RigidBodyFactory::createBox(param, heap);
|
||||
}
|
||||
|
||||
BoxRigidBody::BoxRigidBody(hkpRigidBody* hk_body, BoxShape* 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) {}
|
||||
|
||||
BoxRigidBody::~BoxRigidBody() {
|
||||
if (hasFlag(RigidBody::Flag::_10) && mShape) {
|
||||
delete mShape;
|
||||
mShape = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
float BoxRigidBody::getVolume() {
|
||||
return mShape->getVolume();
|
||||
}
|
||||
|
||||
Shape* BoxRigidBody::getShape_() {
|
||||
return mShape;
|
||||
}
|
||||
|
||||
const Shape* BoxRigidBody::getShape_() const {
|
||||
return mShape;
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
struct BoxShape;
|
||||
struct RigidBodyInstanceParam;
|
||||
|
||||
class BoxRigidBody : public RigidBodyFromShape {
|
||||
SEAD_RTTI_OVERRIDE(BoxRigidBody, RigidBodyFromShape)
|
||||
public:
|
||||
static BoxRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
|
||||
|
||||
BoxRigidBody(hkpRigidBody* hk_body, BoxShape* shape, ContactLayerType layer_type,
|
||||
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
|
||||
~BoxRigidBody() override;
|
||||
|
||||
float getVolume() override;
|
||||
|
||||
protected:
|
||||
Shape* getShape_() override;
|
||||
const Shape* getShape_() const override;
|
||||
void m9() override;
|
||||
|
||||
BoxShape* mShape;
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
@@ -8,11 +8,12 @@
|
||||
namespace ksys::phys {
|
||||
|
||||
class BoxParam;
|
||||
class BoxRigidBody;
|
||||
|
||||
struct BoxShape {
|
||||
virtual ~BoxShape();
|
||||
struct BoxShape : Shape {
|
||||
~BoxShape() override;
|
||||
|
||||
RigidBody* createBody(bool flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
BoxRigidBody* createBody(bool flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
struct BoxShapeParam {
|
||||
|
||||
@@ -1486,7 +1486,7 @@ float RigidBody::updateScale_(float scale, float old_scale) {
|
||||
return old_scale;
|
||||
}
|
||||
|
||||
float RigidBody::m4() {
|
||||
float RigidBody::getVolume() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
const sead::SafeString& name, sead::Heap* heap, bool set_flag_10);
|
||||
~RigidBody() override;
|
||||
|
||||
virtual float m4();
|
||||
virtual float getVolume();
|
||||
|
||||
bool initMotionAccessorForDynamicMotion(sead::Heap* heap);
|
||||
bool initMotionAccessor(const RigidBodyInstanceParam& param, sead::Heap* heap,
|
||||
|
||||
@@ -44,7 +44,7 @@ RigidBody* RigidBodyFactory::createCylinderWater(RigidBodyInstanceParam* params,
|
||||
return shape->createBody(true, *params, heap);
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
BoxRigidBody* RigidBodyFactory::createBox(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
if (params->isDynamicSensor())
|
||||
params->motion_type = MotionType::Keyframed;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ class Heap;
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
class BoxRigidBody;
|
||||
class RigidBody;
|
||||
struct RigidBodyInstanceParam;
|
||||
|
||||
@@ -17,7 +18,7 @@ public:
|
||||
static RigidBody* createCapsule(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCylinder(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCylinderWater(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static BoxRigidBody* createBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createWaterBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createPolytope(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCollection(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
|
||||
Reference in New Issue
Block a user