ksys/phys: Finish BoxRigidBody

This commit is contained in:
Léo Lam 2022-01-31 20:09:32 +01:00
parent a8915c9b05
commit 6b302518fb
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
6 changed files with 76 additions and 12 deletions

View File

@ -83153,17 +83153,17 @@ Address,Quality,Size,Name
0x0000007100f9720c,O,000088,_ZThn32_N4ksys4phys12BoxRigidBodyD1Ev
0x0000007100f97264,O,000096,_ZN4ksys4phys12BoxRigidBodyD0Ev
0x0000007100f972c4,O,000096,_ZThn32_N4ksys4phys12BoxRigidBodyD0Ev
0x0000007100f97324,U,000056,
0x0000007100f9735c,U,000056,
0x0000007100f97394,U,000012,
0x0000007100f973a0,U,000012,
0x0000007100f973ac,U,000072,
0x0000007100f973f4,U,000008,
0x0000007100f973fc,U,000012,
0x0000007100f97324,O,000056,_ZN4ksys4phys12BoxRigidBody10setExtentsERKN4sead7Vector3IfEE
0x0000007100f9735c,O,000056,_ZN4ksys4phys12BoxRigidBody12setTranslateERKN4sead7Vector3IfEE
0x0000007100f97394,O,000012,_ZNK4ksys4phys12BoxRigidBody10getExtentsEv
0x0000007100f973a0,O,000012,_ZNK4ksys4phys12BoxRigidBody12getTranslateEv
0x0000007100f973ac,O,000072,_ZN4ksys4phys12BoxRigidBody23getTransformedTranslateEPN4sead7Vector3IfEE
0x0000007100f973f4,O,000008,_ZN4ksys4phys12BoxRigidBody15setMaterialMaskERKNS0_12MaterialMaskE
0x0000007100f973fc,O,000012,_ZNK4ksys4phys12BoxRigidBody15getMaterialMaskEv
0x0000007100f97408,O,000016,_ZN4ksys4phys12BoxRigidBody9getVolumeEv
0x0000007100f97418,O,000008,_ZN4ksys4phys12BoxRigidBody9getShape_Ev
0x0000007100f97420,O,000008,_ZNK4ksys4phys12BoxRigidBody9getShape_Ev
0x0000007100f97428,U,000068,
0x0000007100f97428,O,000068,_ZN4ksys4phys12BoxRigidBody17getCollisionMasksEPNS0_9RigidBody14CollisionMasksE
0x0000007100f9746c,O,000288,_ZNK4ksys4phys12BoxRigidBody27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
0x0000007100f9758c,O,000092,_ZNK4ksys4phys12BoxRigidBody18getRuntimeTypeInfoEv
0x0000007100f975e8,U,000004,

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

View File

@ -1,4 +1,5 @@
#include "KingSystem/Physics/RigidBody/Shape/physBoxRigidBody.h"
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
#include "KingSystem/Physics/RigidBody/Shape/physBoxShape.h"
#include "KingSystem/Physics/RigidBody/physRigidBodyFactory.h"
@ -19,6 +20,39 @@ BoxRigidBody::~BoxRigidBody() {
}
}
void BoxRigidBody::setExtents(const sead::Vector3f& extents) {
if (mShape->setExtents(extents))
updateShape();
}
void BoxRigidBody::setTranslate(const sead::Vector3f& translate) {
if (mShape->setTranslate(translate))
updateShape();
}
const sead::Vector3f& BoxRigidBody::getExtents() const {
return mShape->mExtents;
}
const sead::Vector3f& BoxRigidBody::getTranslate() const {
return mShape->mTranslate;
}
void BoxRigidBody::getTransformedTranslate(sead::Vector3f* translate) {
lock();
const auto& transform = getHkBody()->getMotion()->getMotionState()->getTransform();
unlock();
mShape->getTranslate(translate, transform);
}
void BoxRigidBody::setMaterialMask(const MaterialMask& mask) {
mShape->setMaterialMask(mask);
}
const MaterialMask& BoxRigidBody::getMaterialMask() const {
return mShape->mMaterialMask;
}
float BoxRigidBody::getVolume() {
return mShape->getVolume();
}
@ -31,4 +65,11 @@ const Shape* BoxRigidBody::getShape_() const {
return mShape;
}
u32 BoxRigidBody::getCollisionMasks(RigidBody::CollisionMasks* masks) {
masks->ignored_layers = ~mContactMask.getDirect();
masks->collision_filter_info = getCollisionFilterInfo();
masks->material_mask = getMaterialMask().getRawData();
return 0;
}
} // namespace ksys::phys

View File

@ -16,12 +16,24 @@ public:
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
~BoxRigidBody() override;
/// Set the box extents and trigger a shape update.
void setExtents(const sead::Vector3f& extents);
/// Set the box translation and trigger a shape update.
void setTranslate(const sead::Vector3f& translate);
const sead::Vector3f& getExtents() const;
const sead::Vector3f& getTranslate() const;
void getTransformedTranslate(sead::Vector3f* translate);
void setMaterialMask(const MaterialMask& mask);
const MaterialMask& getMaterialMask() const;
float getVolume() override;
protected:
Shape* getShape_() override;
const Shape* getShape_() const override;
void m9() override;
u32 getCollisionMasks(CollisionMasks* masks) override;
BoxShape* mShape;
};

View File

@ -9,7 +9,7 @@ class TeraMeshRigidBody : public RigidBody {
public:
TeraMeshRigidBody(hkpRigidBody* hk_body, sead::Heap* heap);
void m9() override;
u32 getCollisionMasks(CollisionMasks* masks) override;
};
} // namespace ksys::phys

View File

@ -40,6 +40,16 @@ public:
class RigidBody : public sead::IDisposer, public RigidBase {
SEAD_RTTI_BASE(RigidBody)
public:
struct CollisionMasks {
/// See MaterialMaskData.
u32 material_mask;
/// EntityCollisionFilterInfo or ReceiverMask.
u32 collision_filter_info;
/// Contact layers we do not collide with.
/// One bit per ContactLayer -- layers are relative to the layer base value.
u32 ignored_layers;
};
enum class Type {
FromShape = 0,
_1 = 1,
@ -509,7 +519,8 @@ public:
bool isEntityMotionFlag200On() const;
protected:
virtual void m9() = 0;
// FIXME: return type
virtual u32 getCollisionMasks(CollisionMasks* masks) = 0;
/// Called whenever a shape update is requested.
/// @return the new shape to use for the Havok rigid body or null to keep the current hkpShape

View File

@ -14,7 +14,7 @@ public:
const sead::SafeString& name, bool set_flag_10, sead::Heap* heap);
~RigidBodyFromShape() override;
const MaterialMask* getMaterialMask() const;
const MaterialMask* tryGetMaterialMask() const;
protected:
const hkpShape* getNewHavokShape_() override;