ksys/phys: Add BoxWaterRigidBody::make

This commit is contained in:
Léo Lam 2022-02-02 15:52:26 +01:00
parent 55164640d5
commit 5d3fd32988
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
5 changed files with 33 additions and 11 deletions

View File

@ -83166,7 +83166,7 @@ Address,Quality,Size,Name
0x0000007100f97428,O,000068,_ZN4ksys4phys12BoxRigidBody17getCollisionMasksEPNS0_9RigidBody14CollisionMasksE
0x0000007100f9746c,O,000288,_ZNK4ksys4phys12BoxRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x0000007100f9758c,O,000092,_ZNK4ksys4phys12BoxRigidBody18getRuntimeTypeInfoEv
0x0000007100f975e8,U,000004,
0x0000007100f975e8,O,000004,_ZN4ksys4phys17BoxWaterRigidBody4makeEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f975ec,O,000088,_ZN4ksys4phys17BoxWaterRigidBodyC1EP12hkpRigidBodyPNS0_13BoxWaterShapeENS0_16ContactLayerTypeERKN4sead14SafeStringBaseIcEEbPNS7_4HeapE
0x0000007100f97644,O,000076,_ZN4ksys4phys17BoxWaterRigidBodyD1Ev
0x0000007100f97690,O,000076,_ZThn32_N4ksys4phys17BoxWaterRigidBodyD1Ev
@ -83277,7 +83277,7 @@ Address,Quality,Size,Name
0x0000007100f992f8,O,000188,_ZN4ksys4phys16RigidBodyFactory14createCylinderEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f993b4,O,000188,_ZN4ksys4phys16RigidBodyFactory19createCylinderWaterEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f99470,O,000188,_ZN4ksys4phys16RigidBodyFactory9createBoxEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f9952c,U,000188,
0x0000007100f9952c,O,000188,_ZN4ksys4phys16RigidBodyFactory14createBoxWaterEPNS0_22RigidBodyInstanceParamEPN4sead4HeapE
0x0000007100f995e8,U,000188,
0x0000007100f996a4,U,000188,
0x0000007100f99760,U,000264,
@ -83547,7 +83547,7 @@ Address,Quality,Size,Name
0x0000007100fa9fac,O,000120,_ZNK4ksys4phys17RigidBodyAccessor16getPointVelocityEPN4sead7Vector3IfEERKS4_
0x0000007100faa024,O,000020,_ZNK4ksys4phys17RigidBodyAccessor13getTimeFactorEv
0x0000007100faa038,O,000064,_ZNK4ksys4phys17RigidBodyAccessor20getDeltaCenterOfMassEPN4sead7Vector3IfEES5_
0x0000007100faa078,O,000564,_ZNK4ksys4phys13BoxShapeParam11createShapeEPN4sead4HeapE
0x0000007100faa078,O,000564,_ZN4ksys4phys8BoxShape4makeERKNS0_13BoxShapeParamEPN4sead4HeapE
0x0000007100faa2ac,O,000224,_ZNK4ksys4phys8BoxShape5cloneEPN4sead4HeapE
0x0000007100faa38c,O,000048,_ZN4ksys4phys8BoxShape15setMaterialMaskERKNS0_12MaterialMaskE
0x0000007100faa3bc,O,000364,_ZN4ksys4phys8BoxShapeC1ERKNS0_13BoxShapeParamEP11hkpBoxShapeP23hkpConvexTransformShape

Can't render this file because it is too large.

View File

@ -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)

View File

@ -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

View File

@ -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);
};

View File

@ -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;