ksys/phys: Declare factory functions for SphereShape/SphereRigidBody

This commit is contained in:
Léo Lam 2022-02-12 10:51:02 +01:00
parent cc3d3ad03d
commit 4a1bb88bd5
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
7 changed files with 27 additions and 16 deletions

View File

@ -68,6 +68,8 @@ target_sources(uking PRIVATE
RigidBody/Shape/Polytope/physPolytopeRigidBody.h
RigidBody/Shape/Polytope/physPolytopeShape.cpp
RigidBody/Shape/Polytope/physPolytopeShape.h
RigidBody/Shape/Sphere/physSphereRigidBody.cpp
RigidBody/Shape/Sphere/physSphereRigidBody.h
RigidBody/Shape/Sphere/physSphereShape.cpp
RigidBody/Shape/Sphere/physSphereShape.h
RigidBody/Shape/physShape.h

View File

@ -0,0 +1 @@
#include "KingSystem/Physics/RigidBody/Shape/Sphere/physSphereRigidBody.h"

View File

@ -0,0 +1,13 @@
#pragma once
#include "KingSystem/Physics/RigidBody/physRigidBodyFromShape.h"
namespace ksys::phys {
class SphereRigidBody : public RigidBodyFromShape {
SEAD_RTTI_OVERRIDE(SphereRigidBody, RigidBodyFromShape)
public:
static SphereRigidBody* make(RigidBodyInstanceParam* param, sead::Heap* heap);
};
} // namespace ksys::phys

View File

@ -0,0 +1 @@
#include "KingSystem/Physics/RigidBody/Shape/Sphere/physSphereShape.h"

View File

@ -9,20 +9,18 @@ namespace ksys::phys {
class SphereParam;
struct SphereShape {
virtual ~SphereShape();
RigidBody* createBody(bool flag, const RigidBodyInstanceParam& params, sead::Heap* heap);
};
struct SphereShapeParam {
SphereShape* createShape(sead::Heap* heap);
sead::Vector3f translate;
float radius;
CommonShapeParam common;
};
class SphereShape : public Shape {
SEAD_RTTI_OVERRIDE(SphereShape, Shape)
public:
static SphereShape* make(const SphereShapeParam& param, sead::Heap* heap);
};
class SphereParam : public RigidBodyInstanceParam {
SEAD_RTTI_OVERRIDE(SphereParam, RigidBodyInstanceParam)
public:

View File

@ -23,13 +23,8 @@ static RigidBodyType* createRigidBody(RigidBodyInstanceParam* param, sead::Heap*
return RigidBodyFromShape::make<RigidBodyType, ShapeType>(*shape, true, *param, heap);
}
RigidBody* RigidBodyFactory::createSphere(RigidBodyInstanceParam* params, sead::Heap* heap) {
if (params->isDynamicSensor())
params->motion_type = MotionType::Keyframed;
auto* v = sead::DynamicCast<SphereParam>(params);
auto* shape = v->shape.createShape(heap);
return shape->createBody(true, *params, heap);
SphereRigidBody* RigidBodyFactory::createSphere(RigidBodyInstanceParam* params, sead::Heap* heap) {
return createRigidBody<SphereRigidBody, SphereShape, SphereParam>(params, heap);
}
CapsuleRigidBody* RigidBodyFactory::createCapsule(RigidBodyInstanceParam* params,

View File

@ -16,10 +16,11 @@ class CylinderWaterRigidBody;
class PolytopeRigidBody;
class RigidBody;
struct RigidBodyInstanceParam;
class SphereRigidBody;
class RigidBodyFactory {
public:
static RigidBody* createSphere(RigidBodyInstanceParam* params, sead::Heap* heap);
static SphereRigidBody* createSphere(RigidBodyInstanceParam* params, sead::Heap* heap);
static CapsuleRigidBody* createCapsule(RigidBodyInstanceParam* params, sead::Heap* heap);
static CylinderRigidBody* createCylinder(RigidBodyInstanceParam* params, sead::Heap* heap);
static CylinderWaterRigidBody* createCylinderWater(RigidBodyInstanceParam* params,