mirror of
https://github.com/zeldaret/botw
synced 2026-06-13 13:56:27 -04:00
ksys/phys: Implement ListShapeRigidBody
This commit is contained in:
@@ -100,7 +100,6 @@ private:
|
||||
class ListShapeRigidBodyParam : public RigidBodyInstanceParam {
|
||||
SEAD_RTTI_OVERRIDE(ListShapeRigidBodyParam, RigidBodyInstanceParam)
|
||||
public:
|
||||
u8 _90;
|
||||
ListShapeParam shape;
|
||||
};
|
||||
|
||||
|
||||
@@ -1 +1,81 @@
|
||||
#include "KingSystem/Physics/RigidBody/Shape/List/physListShapeRigidBody.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/List/physListShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
|
||||
#include "KingSystem/Utils/SafeDelete.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
ListShapeRigidBody* ListShapeRigidBody::make(RigidBodyInstanceParam* param, sead::Heap* heap) {
|
||||
return RigidBodyFactory::createList(param, heap);
|
||||
}
|
||||
|
||||
ListShapeRigidBody::ListShapeRigidBody(hkpRigidBody* hk_body, ListShape* 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) {}
|
||||
|
||||
ListShapeRigidBody::~ListShapeRigidBody() {
|
||||
if (hasFlag(RigidBody::Flag::_10) && mShape) {
|
||||
util::safeDelete(mShape);
|
||||
}
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewSphere(int index, const SphereShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewSphere(index, param, heap);
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewCapsule(int index, const CapsuleShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewCapsule(index, param, heap);
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewCylinder(int index, const CylinderShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewCylinder(index, param, heap);
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewBox(int index, const BoxShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewBox(index, param, heap);
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewPolytope(int index, const PolytopeShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewPolytope(index, param, heap);
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::replaceWithNewCharacterPrism(int index,
|
||||
const CharacterPrismShapeParam& param,
|
||||
sead::Heap* heap) {
|
||||
return mShape->replaceWithNewCharacterPrism(index, param, heap);
|
||||
}
|
||||
|
||||
void ListShapeRigidBody::setMaterialMask(const MaterialMask& mask, int index) {
|
||||
mShape->setMaterialMask(mask, index);
|
||||
}
|
||||
|
||||
const MaterialMask& ListShapeRigidBody::getMaterialMask(int index) const {
|
||||
return mShape->getMaterialMask(index);
|
||||
}
|
||||
|
||||
float ListShapeRigidBody::getVolume() {
|
||||
return mShape->getVolume();
|
||||
}
|
||||
|
||||
Shape* ListShapeRigidBody::getShape_() {
|
||||
return mShape;
|
||||
}
|
||||
|
||||
const Shape* ListShapeRigidBody::getShape_() const {
|
||||
return mShape;
|
||||
}
|
||||
|
||||
u32 ListShapeRigidBody::getCollisionMasks(RigidBody::CollisionMasks* masks, const u32* unk) {
|
||||
masks->ignored_layers = ~mContactMask;
|
||||
masks->collision_filter_info = getCollisionFilterInfo();
|
||||
masks->material_mask = getMaterialMask(unk != nullptr ? int(*unk) : 0).getRawData();
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
@@ -4,10 +4,64 @@
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
struct BoxShapeParam;
|
||||
struct CapsuleShapeParam;
|
||||
struct CharacterPrismShapeParam;
|
||||
struct CylinderShapeParam;
|
||||
struct PolytopeShapeParam;
|
||||
struct SphereShapeParam;
|
||||
|
||||
class ListShape;
|
||||
|
||||
class ListShapeRigidBody : public RigidBodyFromShape {
|
||||
SEAD_RTTI_OVERRIDE(ListShapeRigidBody, RigidBodyFromShape)
|
||||
public:
|
||||
static ListShapeRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
|
||||
|
||||
ListShapeRigidBody(hkpRigidBody* hk_body, ListShape* shape, ContactLayerType layer_type,
|
||||
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
|
||||
~ListShapeRigidBody() override;
|
||||
|
||||
/// Replace the shape at the specified index with a new sphere shape.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewSphere(int index, const SphereShapeParam& param, sead::Heap* heap);
|
||||
|
||||
/// Replace the shape at the specified index with a new capsule shape.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewCapsule(int index, const CapsuleShapeParam& param, sead::Heap* heap);
|
||||
|
||||
/// Replace the shape at the specified index with a new cylinder shape.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewCylinder(int index, const CylinderShapeParam& param, sead::Heap* heap);
|
||||
|
||||
/// Replace the shape at the specified index with a new box shape.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewBox(int index, const BoxShapeParam& param, sead::Heap* heap);
|
||||
|
||||
/// Replace the shape at the specified index with a new polytope shape.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewPolytope(int index, const PolytopeShapeParam& param, sead::Heap* heap);
|
||||
|
||||
/// Replace the shape at the specified index with a new character prism.
|
||||
/// The shape that is being replaced will be deleted.
|
||||
Shape* replaceWithNewCharacterPrism(int index, const CharacterPrismShapeParam& param,
|
||||
sead::Heap* heap);
|
||||
|
||||
/// Set the material mask for the shape at the specified index.
|
||||
void setMaterialMask(const MaterialMask& mask, int index);
|
||||
|
||||
/// Get the material mask for the shape at the specified index.
|
||||
const MaterialMask& getMaterialMask(int index) const;
|
||||
|
||||
float getVolume() override;
|
||||
|
||||
protected:
|
||||
Shape* getShape_() override;
|
||||
const Shape* getShape_() const override;
|
||||
u32 getCollisionMasks(RigidBody::CollisionMasks* masks, const u32* unk) override;
|
||||
|
||||
private:
|
||||
ListShape* mShape{};
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "KingSystem/Physics/RigidBody/Shape/Cylinder/physCylinderShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/CylinderWater/physCylinderWaterRigidBody.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/CylinderWater/physCylinderWaterShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/List/physListShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/Polytope/physPolytopeShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/Shape/Sphere/physSphereShape.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h"
|
||||
@@ -56,4 +57,8 @@ PolytopeRigidBody* RigidBodyFactory::createPolytope(RigidBodyInstanceParam* para
|
||||
return createRigidBody<PolytopeRigidBody, PolytopeShape, PolytopeParam>(params, heap);
|
||||
}
|
||||
|
||||
ListShapeRigidBody* RigidBodyFactory::createList(RigidBodyInstanceParam* params, sead::Heap* heap) {
|
||||
return createRigidBody<ListShapeRigidBody, ListShape, ListShapeRigidBodyParam>(params, heap);
|
||||
}
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
@@ -13,6 +13,7 @@ class BoxWaterRigidBody;
|
||||
class CapsuleRigidBody;
|
||||
class CylinderRigidBody;
|
||||
class CylinderWaterRigidBody;
|
||||
class ListShapeRigidBody;
|
||||
class PolytopeRigidBody;
|
||||
class RigidBody;
|
||||
struct RigidBodyInstanceParam;
|
||||
@@ -28,7 +29,7 @@ public:
|
||||
static BoxRigidBody* createBox(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static BoxWaterRigidBody* createBoxWater(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static PolytopeRigidBody* createPolytope(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static RigidBody* createCollection(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
static ListShapeRigidBody* createList(RigidBodyInstanceParam* params, sead::Heap* heap);
|
||||
};
|
||||
|
||||
} // namespace ksys::phys
|
||||
|
||||
Reference in New Issue
Block a user