mirror of https://github.com/zeldaret/botw.git
ksys/phys: Start adding RigidBodyMotionProxy
This commit is contained in:
parent
e897b1d5fa
commit
2b83356056
|
@ -82971,9 +82971,9 @@ Address,Quality,Size,Name
|
||||||
0x0000007100f8cfa0,U,000424,phys::RigidBody::x_0
|
0x0000007100f8cfa0,U,000424,phys::RigidBody::x_0
|
||||||
0x0000007100f8d148,O,000144,_ZN4ksys4phys9RigidBody13setMotionFlagENS1_10MotionFlagE
|
0x0000007100f8d148,O,000144,_ZN4ksys4phys9RigidBody13setMotionFlagENS1_10MotionFlagE
|
||||||
0x0000007100f8d1d8,O,000032,_ZNK4ksys4phys9RigidBody8isActiveEv
|
0x0000007100f8d1d8,O,000032,_ZNK4ksys4phys9RigidBody8isActiveEv
|
||||||
0x0000007100f8d1f8,O,000012,_ZNK4ksys4phys9RigidBody14sub_7100F8D1F8Ev
|
0x0000007100f8d1f8,O,000012,_ZNK4ksys4phys9RigidBody10isFlag8SetEv
|
||||||
0x0000007100f8d204,O,000012,_ZNK4ksys4phys9RigidBody14sub_7100F8D204Ev
|
0x0000007100f8d204,O,000012,_ZNK4ksys4phys9RigidBody16isMotionFlag1SetEv
|
||||||
0x0000007100f8d210,O,000012,_ZNK4ksys4phys9RigidBody14sub_7100F8D210Ev
|
0x0000007100f8d210,O,000012,_ZNK4ksys4phys9RigidBody16isMotionFlag2SetEv
|
||||||
0x0000007100f8d21c,O,000236,_ZN4ksys4phys9RigidBody14sub_7100F8D21CEv
|
0x0000007100f8d21c,O,000236,_ZN4ksys4phys9RigidBody14sub_7100F8D21CEv
|
||||||
0x0000007100f8d308,U,000888,phys::RigidBody::x_6
|
0x0000007100f8d308,U,000888,phys::RigidBody::x_6
|
||||||
0x0000007100f8d680,U,000140,phys::RigidBody::getMotionAccessorType1
|
0x0000007100f8d680,U,000140,phys::RigidBody::getMotionAccessorType1
|
||||||
|
@ -83144,7 +83144,7 @@ Address,Quality,Size,Name
|
||||||
0x0000007100f96e84,U,000384,
|
0x0000007100f96e84,U,000384,
|
||||||
0x0000007100f97004,U,000112,phys::RigidBody::rtti1
|
0x0000007100f97004,U,000112,phys::RigidBody::rtti1
|
||||||
0x0000007100f97074,U,000092,phys::RigidBody::rtti2
|
0x0000007100f97074,U,000092,phys::RigidBody::rtti2
|
||||||
0x0000007100f970d0,U,000140,
|
0x0000007100f970d0,O,000140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys4phys14MotionAccessorEE9isDerivedEPKNS0_9InterfaceE
|
||||||
0x0000007100f9715c,U,000004,j__ZN4ksys4phys16RigidBodyFactory9createBoxEPNS0_18RigidBodyParamViewEPN4sead4HeapE
|
0x0000007100f9715c,U,000004,j__ZN4ksys4phys16RigidBodyFactory9createBoxEPNS0_18RigidBodyParamViewEPN4sead4HeapE
|
||||||
0x0000007100f97160,U,000084,
|
0x0000007100f97160,U,000084,
|
||||||
0x0000007100f971b4,U,000088,
|
0x0000007100f971b4,U,000088,
|
||||||
|
@ -83408,40 +83408,40 @@ Address,Quality,Size,Name
|
||||||
0x0000007100fa3d50,U,000092,phys::MotionAccessor1::rtti2
|
0x0000007100fa3d50,U,000092,phys::MotionAccessor1::rtti2
|
||||||
0x0000007100fa3dac,U,000020,
|
0x0000007100fa3dac,U,000020,
|
||||||
0x0000007100fa3dc0,U,000088,
|
0x0000007100fa3dc0,U,000088,
|
||||||
0x0000007100fa3e18,U,000220,MotionAccessorMassScaling::ctor
|
0x0000007100fa3e18,O,000220,_ZN4ksys4phys20RigidBodyMotionProxyC1EPNS0_9RigidBodyE
|
||||||
0x0000007100fa3ef4,U,000152,
|
0x0000007100fa3ef4,U,000152,
|
||||||
0x0000007100fa3f8c,U,000144,
|
0x0000007100fa3f8c,U,000144,
|
||||||
0x0000007100fa401c,U,000036,
|
0x0000007100fa401c,U,000036,
|
||||||
0x0000007100fa4040,U,000032,
|
0x0000007100fa4040,O,000032,_ZN4ksys4phys20RigidBodyMotionProxy4initERKNS0_22RigidBodyInstanceParamEPN4sead4HeapE
|
||||||
0x0000007100fa4060,U,000332,
|
0x0000007100fa4060,O,000332,_ZN4ksys4phys20RigidBodyMotionProxy12setTransformERKN4sead8Matrix34IfEEb
|
||||||
0x0000007100fa41ac,U,000364,
|
0x0000007100fa41ac,O,000364,_ZN4ksys4phys20RigidBodyMotionProxy11setPositionERKN4sead7Vector3IfEEb
|
||||||
0x0000007100fa4318,U,000636,
|
0x0000007100fa4318,U,000636,
|
||||||
0x0000007100fa4594,U,000920,
|
0x0000007100fa4594,U,000920,
|
||||||
0x0000007100fa492c,U,000096,
|
0x0000007100fa492c,O,000096,_ZN4ksys4phys20RigidBodyMotionProxy11getPositionEPN4sead7Vector3IfEE
|
||||||
0x0000007100fa498c,U,000260,
|
0x0000007100fa498c,O,000260,_ZN4ksys4phys20RigidBodyMotionProxy11getRotationEPN4sead4QuatIfEE
|
||||||
0x0000007100fa4a90,U,000188,
|
0x0000007100fa4a90,O,000188,_ZN4ksys4phys20RigidBodyMotionProxy12getTransformEPN4sead8Matrix34IfEE
|
||||||
0x0000007100fa4b4c,U,000132,
|
0x0000007100fa4b4c,O,000132,_ZN4ksys4phys20RigidBodyMotionProxy22setCenterOfMassInLocalERKN4sead7Vector3IfEE
|
||||||
0x0000007100fa4bd0,U,000088,
|
0x0000007100fa4bd0,O,000088,_ZN4ksys4phys20RigidBodyMotionProxy22getCenterOfMassInLocalEPN4sead7Vector3IfEE
|
||||||
0x0000007100fa4c28,U,000132,
|
0x0000007100fa4c28,O,000132,_ZN4ksys4phys20RigidBodyMotionProxy17setLinearVelocityERKN4sead7Vector3IfEEf
|
||||||
0x0000007100fa4cac,U,000064,
|
0x0000007100fa4cac,O,000064,_ZN4ksys4phys20RigidBodyMotionProxy17setLinearVelocityERK10hkVector4ff
|
||||||
0x0000007100fa4cec,U,000088,
|
0x0000007100fa4cec,O,000088,_ZN4ksys4phys20RigidBodyMotionProxy17getLinearVelocityEPN4sead7Vector3IfEE
|
||||||
0x0000007100fa4d44,U,000156,
|
0x0000007100fa4d44,O,000156,_ZN4ksys4phys20RigidBodyMotionProxy18setAngularVelocityERKN4sead7Vector3IfEEf
|
||||||
0x0000007100fa4de0,U,000064,
|
0x0000007100fa4de0,O,000064,_ZN4ksys4phys20RigidBodyMotionProxy18setAngularVelocityERK10hkVector4ff
|
||||||
0x0000007100fa4e20,U,000088,
|
0x0000007100fa4e20,O,000088,_ZN4ksys4phys20RigidBodyMotionProxy18getAngularVelocityEPN4sead7Vector3IfEE
|
||||||
0x0000007100fa4e78,U,000012,
|
0x0000007100fa4e78,O,000012,_ZN4ksys4phys20RigidBodyMotionProxy20setMaxLinearVelocityEf
|
||||||
0x0000007100fa4e84,U,000092,
|
0x0000007100fa4e84,O,000092,_ZN4ksys4phys20RigidBodyMotionProxy20getMaxLinearVelocityEv
|
||||||
0x0000007100fa4ee0,U,000012,
|
0x0000007100fa4ee0,O,000012,_ZN4ksys4phys20RigidBodyMotionProxy21setMaxAngularVelocityEf
|
||||||
0x0000007100fa4eec,U,000092,
|
0x0000007100fa4eec,O,000092,_ZN4ksys4phys20RigidBodyMotionProxy21getMaxAngularVelocityEv
|
||||||
0x0000007100fa4f48,U,000252,
|
0x0000007100fa4f48,U,000252,
|
||||||
0x0000007100fa5044,U,000008,
|
0x0000007100fa5044,O,000008,_ZNK4ksys4phys20RigidBodyMotionProxy18getLinkedRigidBodyEv
|
||||||
0x0000007100fa504c,U,000012,
|
0x0000007100fa504c,O,000012,_ZNK4ksys4phys20RigidBodyMotionProxy14isFlag40000SetEv
|
||||||
0x0000007100fa5058,U,000812,
|
0x0000007100fa5058,U,000812,
|
||||||
0x0000007100fa5384,U,000088,
|
0x0000007100fa5384,O,000088,_ZN4ksys4phys20RigidBodyMotionProxy11getRotationEP13hkQuaternionf
|
||||||
0x0000007100fa53dc,U,000012,
|
0x0000007100fa53dc,O,000012,_ZN4ksys4phys20RigidBodyMotionProxy13setTimeFactorEf
|
||||||
0x0000007100fa53e8,U,000008,
|
0x0000007100fa53e8,O,000008,_ZN4ksys4phys20RigidBodyMotionProxy13getTimeFactorEv
|
||||||
0x0000007100fa53f0,U,000184,
|
0x0000007100fa53f0,U,000184,
|
||||||
0x0000007100fa54a8,U,000204,phys::MotionAccessorMassScaling::rtti1
|
0x0000007100fa54a8,O,000204,_ZNK4ksys4phys20RigidBodyMotionProxy27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||||
0x0000007100fa5574,U,000092,phys::MotionAccessorMassScaling::rtti2
|
0x0000007100fa5574,O,000092,_ZNK4ksys4phys20RigidBodyMotionProxy18getRuntimeTypeInfoEv
|
||||||
0x0000007100fa55d0,U,000012,
|
0x0000007100fa55d0,U,000012,
|
||||||
0x0000007100fa55dc,U,000332,phys::RigidBodyRequestMgr::ctor
|
0x0000007100fa55dc,U,000332,phys::RigidBodyRequestMgr::ctor
|
||||||
0x0000007100fa5728,U,000484,phys::RigidBodyRequestMgr::x
|
0x0000007100fa5728,U,000484,phys::RigidBodyRequestMgr::x
|
||||||
|
@ -95368,7 +95368,7 @@ Address,Quality,Size,Name
|
||||||
0x00000071012ae830,U,001508,
|
0x00000071012ae830,U,001508,
|
||||||
0x00000071012aee14,U,002304,
|
0x00000071012aee14,U,002304,
|
||||||
0x00000071012af714,U,001036,
|
0x00000071012af714,U,001036,
|
||||||
0x00000071012afb20,O,000028,_ZN4ksys4phys14MotionAccessorC1EPNS0_9RigidBodyE
|
0x00000071012afb20,O,000028,_ZN4ksys4phys14MotionAccessorC2EPNS0_9RigidBodyE
|
||||||
0x00000071012afb3c,O,000004,_ZN4ksys4phys14MotionAccessorD1Ev
|
0x00000071012afb3c,O,000004,_ZN4ksys4phys14MotionAccessorD1Ev
|
||||||
0x00000071012afb40,O,000004,_ZN4ksys4phys14MotionAccessorD0Ev
|
0x00000071012afb40,O,000004,_ZN4ksys4phys14MotionAccessorD0Ev
|
||||||
0x00000071012afb44,O,000008,_ZNK4ksys4phys14MotionAccessor13getMotionInfoEv
|
0x00000071012afb44,O,000008,_ZNK4ksys4phys14MotionAccessor13getMotionInfoEv
|
||||||
|
@ -95377,8 +95377,8 @@ Address,Quality,Size,Name
|
||||||
0x00000071012afb5c,O,000020,_ZNK4ksys4phys14MotionAccessor16hasMotionFlagSetENS0_9RigidBody10MotionFlagE
|
0x00000071012afb5c,O,000020,_ZNK4ksys4phys14MotionAccessor16hasMotionFlagSetENS0_9RigidBody10MotionFlagE
|
||||||
0x00000071012afb70,O,000020,_ZNK4ksys4phys14MotionAccessor21hasMotionFlagDisabledENS0_9RigidBody10MotionFlagE
|
0x00000071012afb70,O,000020,_ZNK4ksys4phys14MotionAccessor21hasMotionFlagDisabledENS0_9RigidBody10MotionFlagE
|
||||||
0x00000071012afb84,O,000032,_ZN4ksys4phys14MotionAccessor17disableMotionFlagENS0_9RigidBody10MotionFlagE
|
0x00000071012afb84,O,000032,_ZN4ksys4phys14MotionAccessor17disableMotionFlagENS0_9RigidBody10MotionFlagE
|
||||||
0x00000071012afba4,U,000112,
|
0x00000071012afba4,O,000112,_ZNK4ksys4phys14MotionAccessor27checkDerivedRuntimeTypeInfoEPKN4sead15RuntimeTypeInfo9InterfaceE
|
||||||
0x00000071012afc14,U,000092,
|
0x00000071012afc14,O,000092,_ZNK4ksys4phys14MotionAccessor18getRuntimeTypeInfoEv
|
||||||
0x00000071012afc70,O,000048,_ZN4ksys4phys17RigidBodyResourceC1Ev
|
0x00000071012afc70,O,000048,_ZN4ksys4phys17RigidBodyResourceC1Ev
|
||||||
0x00000071012afca0,O,000004,_ZN4ksys4phys17RigidBodyResourceD1Ev
|
0x00000071012afca0,O,000004,_ZN4ksys4phys17RigidBodyResourceD1Ev
|
||||||
0x00000071012afca4,O,000036,_ZN4ksys4phys17RigidBodyResourceD0Ev
|
0x00000071012afca4,O,000036,_ZN4ksys4phys17RigidBodyResourceD0Ev
|
||||||
|
|
Can't render this file because it is too large.
|
|
@ -23,6 +23,10 @@ target_sources(uking PRIVATE
|
||||||
RigidBody/physRigidBodyAccessor.h
|
RigidBody/physRigidBodyAccessor.h
|
||||||
RigidBody/physRigidBodyFactory.cpp
|
RigidBody/physRigidBodyFactory.cpp
|
||||||
RigidBody/physRigidBodyFactory.h
|
RigidBody/physRigidBodyFactory.h
|
||||||
|
RigidBody/physRigidBodyMotion.cpp
|
||||||
|
RigidBody/physRigidBodyMotion.h
|
||||||
|
RigidBody/physRigidBodyMotionProxy.cpp
|
||||||
|
RigidBody/physRigidBodyMotionProxy.h
|
||||||
RigidBody/physRigidBodyParam.cpp
|
RigidBody/physRigidBodyParam.cpp
|
||||||
RigidBody/physRigidBodyParam.h
|
RigidBody/physRigidBodyParam.h
|
||||||
RigidBody/physRigidBodyResource.cpp
|
RigidBody/physRigidBodyResource.cpp
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <basis/seadTypes.h>
|
#include <basis/seadTypes.h>
|
||||||
|
#include <math/seadMatrix.h>
|
||||||
|
#include <math/seadQuat.h>
|
||||||
|
#include <math/seadVector.h>
|
||||||
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
#include "KingSystem/Physics/RigidBody/physRigidBody.h"
|
||||||
|
|
||||||
|
class hkQuaternionf;
|
||||||
|
class hkVector4f;
|
||||||
class hkpMotion;
|
class hkpMotion;
|
||||||
|
|
||||||
namespace ksys::phys {
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
struct RigidBodyInstanceParam;
|
||||||
|
|
||||||
class MotionAccessor {
|
class MotionAccessor {
|
||||||
SEAD_RTTI_BASE(MotionAccessor)
|
SEAD_RTTI_BASE(MotionAccessor)
|
||||||
public:
|
public:
|
||||||
explicit MotionAccessor(RigidBody* body);
|
explicit MotionAccessor(RigidBody* body);
|
||||||
virtual ~MotionAccessor();
|
|
||||||
|
|
||||||
MotionType getMotionInfo() const;
|
MotionType getMotionInfo() const;
|
||||||
hkpMotion* getMotion() const;
|
hkpMotion* getMotion() const;
|
||||||
|
@ -20,9 +26,40 @@ public:
|
||||||
bool hasMotionFlagDisabled(RigidBody::MotionFlag flag) const;
|
bool hasMotionFlagDisabled(RigidBody::MotionFlag flag) const;
|
||||||
void disableMotionFlag(RigidBody::MotionFlag flag);
|
void disableMotionFlag(RigidBody::MotionFlag flag);
|
||||||
|
|
||||||
private:
|
virtual void setTransform(const sead::Matrix34f& mtx, bool notify) = 0;
|
||||||
RigidBody* mBody;
|
virtual void setPosition(const sead::Vector3f& position, bool notify) = 0;
|
||||||
void* _10 = nullptr;
|
virtual void getPosition(sead::Vector3f* position) = 0;
|
||||||
|
virtual void getRotation(sead::Quatf* rotation) = 0;
|
||||||
|
virtual void getTransform(sead::Matrix34f* mtx) = 0;
|
||||||
|
|
||||||
|
virtual void setCenterOfMassInLocal(const sead::Vector3f& center) = 0;
|
||||||
|
virtual void getCenterOfMassInLocal(sead::Vector3f* center) = 0;
|
||||||
|
|
||||||
|
virtual bool setLinearVelocity(const sead::Vector3f& velocity, float epsilon) = 0;
|
||||||
|
virtual bool setLinearVelocity(const hkVector4f& velocity, float epsilon) = 0;
|
||||||
|
virtual void getLinearVelocity(sead::Vector3f* velocity) = 0;
|
||||||
|
virtual bool setAngularVelocity(const sead::Vector3f& velocity, float epsilon) = 0;
|
||||||
|
virtual bool setAngularVelocity(const hkVector4f& velocity, float epsilon) = 0;
|
||||||
|
virtual void getAngularVelocity(sead::Vector3f* velocity) = 0;
|
||||||
|
|
||||||
|
virtual void setMaxLinearVelocity(float max) = 0;
|
||||||
|
virtual float getMaxLinearVelocity() = 0;
|
||||||
|
virtual void setMaxAngularVelocity(float max) = 0;
|
||||||
|
virtual float getMaxAngularVelocity() = 0;
|
||||||
|
|
||||||
|
virtual ~MotionAccessor();
|
||||||
|
|
||||||
|
virtual bool init(const RigidBodyInstanceParam& params, sead::Heap* heap) = 0;
|
||||||
|
virtual void getRotation(hkQuaternionf* quat) = 0;
|
||||||
|
virtual void setTimeFactor(float factor) = 0;
|
||||||
|
virtual float getTimeFactor() = 0;
|
||||||
|
virtual void m25(bool a, bool b, bool c) = 0;
|
||||||
|
virtual void m26() = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RigidBody* mBody = nullptr;
|
||||||
|
u32 _10 = 0;
|
||||||
|
u32 _14 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
||||||
|
|
|
@ -49,15 +49,15 @@ bool RigidBody::isActive() const {
|
||||||
return mHkBody->isActive();
|
return mHkBody->isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RigidBody::sub_7100F8D1F8() const {
|
bool RigidBody::isFlag8Set() const {
|
||||||
return mFlags.isOn(Flag::_8);
|
return mFlags.isOn(Flag::_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RigidBody::sub_7100F8D204() const {
|
bool RigidBody::isMotionFlag1Set() const {
|
||||||
return mMotionFlags.isOn(MotionFlag::_1);
|
return mMotionFlags.isOn(MotionFlag::_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RigidBody::sub_7100F8D210() const {
|
bool RigidBody::isMotionFlag2Set() const {
|
||||||
return mMotionFlags.isOn(MotionFlag::_2);
|
return mMotionFlags.isOn(MotionFlag::_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,12 @@ public:
|
||||||
Keyframed = 1 << 3,
|
Keyframed = 1 << 3,
|
||||||
Fixed = 1 << 4,
|
Fixed = 1 << 4,
|
||||||
_20 = 1 << 5,
|
_20 = 1 << 5,
|
||||||
|
_40 = 1 << 6,
|
||||||
|
_80 = 1 << 7,
|
||||||
|
_100 = 1 << 8,
|
||||||
|
_200 = 1 << 9,
|
||||||
|
_400 = 1 << 10,
|
||||||
|
_800 = 1 << 11,
|
||||||
};
|
};
|
||||||
|
|
||||||
RigidBody(u32 a, u32 mass_scaling, hkpRigidBody* hk_body, const sead::SafeString& name,
|
RigidBody(u32 a, u32 mass_scaling, hkpRigidBody* hk_body, const sead::SafeString& name,
|
||||||
|
@ -84,11 +90,11 @@ public:
|
||||||
bool isActive() const;
|
bool isActive() const;
|
||||||
|
|
||||||
// 0x0000007100f8d1f8
|
// 0x0000007100f8d1f8
|
||||||
bool sub_7100F8D1F8() const;
|
bool isFlag8Set() const;
|
||||||
// 0x0000007100f8d204
|
// 0x0000007100f8d204
|
||||||
bool sub_7100F8D204() const;
|
bool isMotionFlag1Set() const;
|
||||||
// 0x0000007100f8d210
|
// 0x0000007100f8d210
|
||||||
bool sub_7100F8D210() const;
|
bool isMotionFlag2Set() const;
|
||||||
// 0x0000007100f8d21c
|
// 0x0000007100f8d21c
|
||||||
void sub_7100F8D21C();
|
void sub_7100F8D21C();
|
||||||
// 0x0000007100f8d308
|
// 0x0000007100f8d308
|
||||||
|
@ -149,6 +155,8 @@ public:
|
||||||
const auto& getMotionFlags() const { return mMotionFlags; }
|
const auto& getMotionFlags() const { return mMotionFlags; }
|
||||||
void resetMotionFlagDirect(const MotionFlag flag) { mMotionFlags.reset(flag); }
|
void resetMotionFlagDirect(const MotionFlag flag) { mMotionFlags.reset(flag); }
|
||||||
|
|
||||||
|
hkpRigidBody* getHkBody() const { return mHkBody; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sead::CriticalSection mCS;
|
sead::CriticalSection mCS;
|
||||||
sead::TypedBitFlag<Flag, sead::Atomic<u32>> mFlags{};
|
sead::TypedBitFlag<Flag, sead::Atomic<u32>> mFlags{};
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "KingSystem/Physics/RigidBody/physRigidBodyMotion.h"
|
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "KingSystem/Physics/RigidBody/physMotionAccessor.h"
|
||||||
|
|
||||||
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
class RigidBodyMotion : public MotionAccessor {
|
||||||
|
SEAD_RTTI_OVERRIDE(RigidBodyMotion, MotionAccessor)
|
||||||
|
public:
|
||||||
|
explicit RigidBodyMotion(RigidBody* body);
|
||||||
|
|
||||||
|
bool applyLinearImpulse(const sead::Vector3f& impulse);
|
||||||
|
bool applyAngularImpulse(const sead::Vector3f& impulse);
|
||||||
|
bool applyPointImpulse(const sead::Vector3f& impulse, const sead::Vector3f& point);
|
||||||
|
|
||||||
|
void setMass(float mass);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ksys::phys
|
|
@ -0,0 +1,186 @@
|
||||||
|
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionProxy.h"
|
||||||
|
#include <Havok/Common/Base/hkBase.h>
|
||||||
|
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
|
||||||
|
#include "KingSystem/Physics/physConversions.h"
|
||||||
|
|
||||||
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
RigidBodyMotionProxy::RigidBodyMotionProxy(RigidBody* body) : MotionAccessor(body) {}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::init(const RigidBodyInstanceParam& params, sead::Heap* heap) {
|
||||||
|
mMaxLinearVelocity = params.max_linear_velocity;
|
||||||
|
mMaxAngularVelocity = params.max_angular_velocity_rad;
|
||||||
|
mTimeFactor = params.time_factor;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
KSYS_ALWAYS_INLINE void RigidBodyMotionProxy::setTransformImpl(const sead::Matrix34f& mtx) {
|
||||||
|
if (mBody->isFlag8Set()) { // flag 8 = block updates?
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_20);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hkTransformf transform;
|
||||||
|
toHkTransform(&transform, mtx);
|
||||||
|
mBody->getHkBody()->getMotion()->setTransform(transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setTransform(const sead::Matrix34f& mtx, bool notify) {
|
||||||
|
mTransform = mtx;
|
||||||
|
setTransformImpl(mtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setPosition(const sead::Vector3f& position, bool notify) {
|
||||||
|
if (hasMotionFlagDisabled(RigidBody::MotionFlag::_20)) {
|
||||||
|
getTransform(&mTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
mTransform.setTranslation(position);
|
||||||
|
setTransformImpl(mTransform);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getPosition(sead::Vector3f* position) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_20)) {
|
||||||
|
mTransform.getTranslation(*position);
|
||||||
|
} else {
|
||||||
|
const auto hk_position = getMotion()->getPosition();
|
||||||
|
storeToVec3(position, hk_position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getRotation(sead::Quatf* rotation) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_20)) {
|
||||||
|
mTransform.toQuat(*rotation);
|
||||||
|
} else {
|
||||||
|
toQuat(rotation, getMotion()->getRotation());
|
||||||
|
}
|
||||||
|
|
||||||
|
rotation->normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getTransform(sead::Matrix34f* mtx) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_20)) {
|
||||||
|
*mtx = mTransform;
|
||||||
|
} else {
|
||||||
|
const auto& transform = getMotion()->getTransform();
|
||||||
|
setMtxRotation(mtx, transform.getRotation());
|
||||||
|
setMtxTranslation(mtx, transform.getTranslation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||||
|
mCenterOfMassInLocal.e = center.e;
|
||||||
|
|
||||||
|
if (mBody->isFlag8Set()) {
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_800);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mBody->getHkBody()->setCenterOfMassLocal(toHkVec4(center));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_800)) {
|
||||||
|
center->e = mCenterOfMassInLocal.e;
|
||||||
|
} else {
|
||||||
|
const auto hk_center = getMotion()->getCenterOfMassLocal();
|
||||||
|
storeToVec3(center, hk_center);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||||
|
if (velocity.equals(mLinearVelocity, epsilon))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mLinearVelocity.e = velocity.e;
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_40);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::setLinearVelocity(const hkVector4f& velocity, float epsilon) {
|
||||||
|
sead::Vector3f vec;
|
||||||
|
storeToVec3(&vec, velocity);
|
||||||
|
return setLinearVelocity(vec, epsilon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getLinearVelocity(sead::Vector3f* velocity) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_40)) {
|
||||||
|
velocity->e = mLinearVelocity.e;
|
||||||
|
} else {
|
||||||
|
const auto hk_velocity = getMotion()->getLinearVelocity();
|
||||||
|
storeToVec3(velocity, hk_velocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||||
|
if (velocity.equals(mAngularVelocity, sead::Mathf::epsilon()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
mAngularVelocity.e = velocity.e;
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_80);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::setAngularVelocity(const hkVector4f& velocity, float epsilon) {
|
||||||
|
sead::Vector3f vec;
|
||||||
|
storeToVec3(&vec, velocity);
|
||||||
|
return setAngularVelocity(vec, epsilon);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getAngularVelocity(sead::Vector3f* velocity) {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_80)) {
|
||||||
|
velocity->e = mAngularVelocity.e;
|
||||||
|
} else {
|
||||||
|
const auto hk_velocity = getMotion()->getAngularVelocity();
|
||||||
|
storeToVec3(velocity, hk_velocity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setMaxLinearVelocity(float max) {
|
||||||
|
mMaxLinearVelocity = max;
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_100);
|
||||||
|
}
|
||||||
|
|
||||||
|
float RigidBodyMotionProxy::getMaxLinearVelocity() {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_100))
|
||||||
|
return mMaxLinearVelocity;
|
||||||
|
|
||||||
|
return getMotion()->getMotionState()->m_maxLinearVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setMaxAngularVelocity(float max) {
|
||||||
|
mMaxAngularVelocity = max;
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_100);
|
||||||
|
}
|
||||||
|
|
||||||
|
float RigidBodyMotionProxy::getMaxAngularVelocity() {
|
||||||
|
if (hasMotionFlagSet(RigidBody::MotionFlag::_100))
|
||||||
|
return mMaxAngularVelocity;
|
||||||
|
|
||||||
|
return getMotion()->getMotionState()->m_maxAngularVelocity;
|
||||||
|
}
|
||||||
|
|
||||||
|
RigidBody* RigidBodyMotionProxy::getLinkedRigidBody() const {
|
||||||
|
return mLinkedRigidBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RigidBodyMotionProxy::isFlag40000Set() const {
|
||||||
|
return mFlags.isOn(Flag::_40000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::getRotation(hkQuaternionf* quat) {
|
||||||
|
sead::Quatf rotation;
|
||||||
|
getRotation(&rotation);
|
||||||
|
toHkQuat(quat, rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RigidBodyMotionProxy::setTimeFactor(float factor) {
|
||||||
|
mTimeFactor = factor;
|
||||||
|
setMotionFlag(RigidBody::MotionFlag::_100);
|
||||||
|
}
|
||||||
|
|
||||||
|
float RigidBodyMotionProxy::getTimeFactor() {
|
||||||
|
return mTimeFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace ksys::phys
|
|
@ -0,0 +1,80 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <prim/seadTypedBitFlag.h>
|
||||||
|
#include <thread/seadAtomic.h>
|
||||||
|
#include "KingSystem/Physics/RigidBody/physMotionAccessor.h"
|
||||||
|
|
||||||
|
namespace ksys::phys {
|
||||||
|
|
||||||
|
/// A MotionAccessor that uses the RigidBody's internal motion instance directly.
|
||||||
|
class RigidBodyMotionProxy : public MotionAccessor {
|
||||||
|
SEAD_RTTI_OVERRIDE(RigidBodyMotionProxy, MotionAccessor)
|
||||||
|
public:
|
||||||
|
enum class Flag {
|
||||||
|
_40000 = 1 << 18,
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit RigidBodyMotionProxy(RigidBody* body);
|
||||||
|
|
||||||
|
void setTransform(const sead::Matrix34f& mtx, bool notify) override;
|
||||||
|
void setPosition(const sead::Vector3f& position, bool notify) override;
|
||||||
|
// 0x0000007100fa4318
|
||||||
|
void setTransformMaybe(const sead::Matrix34f& mtx);
|
||||||
|
// 0x0000007100fa4594
|
||||||
|
void setTransformMaybe(const hkVector4f& translate, const hkQuaternionf& rotate);
|
||||||
|
void getPosition(sead::Vector3f* position) override;
|
||||||
|
void getRotation(sead::Quatf* rotation) override;
|
||||||
|
void getTransform(sead::Matrix34f* mtx) override;
|
||||||
|
|
||||||
|
void setCenterOfMassInLocal(const sead::Vector3f& center) override;
|
||||||
|
void getCenterOfMassInLocal(sead::Vector3f* center) override;
|
||||||
|
|
||||||
|
bool setLinearVelocity(const sead::Vector3f& velocity, float epsilon) override;
|
||||||
|
bool setLinearVelocity(const hkVector4f& velocity, float epsilon) override;
|
||||||
|
void getLinearVelocity(sead::Vector3f* velocity) override;
|
||||||
|
bool setAngularVelocity(const sead::Vector3f& velocity, float epsilon) override;
|
||||||
|
bool setAngularVelocity(const hkVector4f& velocity, float epsilon) override;
|
||||||
|
void getAngularVelocity(sead::Vector3f* velocity) override;
|
||||||
|
|
||||||
|
void setMaxLinearVelocity(float max) override;
|
||||||
|
float getMaxLinearVelocity() override;
|
||||||
|
void setMaxAngularVelocity(float max) override;
|
||||||
|
float getMaxAngularVelocity() override;
|
||||||
|
|
||||||
|
// 0x0000007100fa4f48 - called from RigidBody, sets a secondary rigid body
|
||||||
|
void setLinkedRigidBody(RigidBody* body);
|
||||||
|
// 0x0000007100fa3f8c - called from RigidBody and inlined by the destructor
|
||||||
|
void resetLinkedRigidBody();
|
||||||
|
RigidBody* getLinkedRigidBody() const;
|
||||||
|
bool isFlag40000Set() const;
|
||||||
|
// 0x0000007100fa5058 - main update function? triggers shape, position, velocity updates
|
||||||
|
void update();
|
||||||
|
|
||||||
|
~RigidBodyMotionProxy() override;
|
||||||
|
|
||||||
|
bool init(const RigidBodyInstanceParam& params, sead::Heap* heap) override;
|
||||||
|
void getRotation(hkQuaternionf* quat) override;
|
||||||
|
void setTimeFactor(float factor) override;
|
||||||
|
float getTimeFactor() override;
|
||||||
|
void m25(bool a, bool b, bool c) override;
|
||||||
|
void m26() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setTransformImpl(const sead::Matrix34f& mtx);
|
||||||
|
|
||||||
|
sead::Vector3f _18 = sead::Vector3f::zero;
|
||||||
|
sead::Vector3f _24 = sead::Vector3f::zero;
|
||||||
|
sead::Vector3f mLinearVelocity = sead::Vector3f::zero;
|
||||||
|
float mMaxLinearVelocity{};
|
||||||
|
sead::Vector3f mAngularVelocity = sead::Vector3f::zero;
|
||||||
|
float mMaxAngularVelocity{};
|
||||||
|
sead::Vector3f mCenterOfMassInLocal = sead::Vector3f::zero;
|
||||||
|
RigidBody* mLinkedRigidBody{};
|
||||||
|
sead::Matrix34f mTransform = sead::Matrix34f::ident;
|
||||||
|
float mTimeFactor = 1.0f;
|
||||||
|
sead::Vector3f _9c = sead::Vector3f::zero;
|
||||||
|
sead::Quatf _a8 = sead::Quatf::unit;
|
||||||
|
sead::TypedBitFlag<Flag, sead::Atomic<u32>> mFlags{};
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace ksys::phys
|
|
@ -58,7 +58,7 @@ public:
|
||||||
float linear_damping = 0.0f;
|
float linear_damping = 0.0f;
|
||||||
float angular_damping = 0.05f;
|
float angular_damping = 0.05f;
|
||||||
f32 _3c = 1.0f;
|
f32 _3c = 1.0f;
|
||||||
f32 _40 = 1.0f;
|
f32 time_factor = 1.0f;
|
||||||
float max_linear_velocity = 200.0f;
|
float max_linear_velocity = 200.0f;
|
||||||
float max_angular_velocity_rad = 200.0f;
|
float max_angular_velocity_rad = 200.0f;
|
||||||
float max_impulse = -1.0f;
|
float max_impulse = -1.0f;
|
||||||
|
|
|
@ -17,6 +17,10 @@ inline void toVec3(sead::Vector3f* out, const hkVector4f& vec) {
|
||||||
return {vec.getX(), vec.getY(), vec.getZ()};
|
return {vec.getX(), vec.getY(), vec.getZ()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void storeToVec3(sead::Vector3f* out, const hkVector4f& vec) {
|
||||||
|
vec.store<3>(out->e.data());
|
||||||
|
}
|
||||||
|
|
||||||
inline void toHkVec4(hkVector4f* out, const sead::Vector3f& vec) {
|
inline void toHkVec4(hkVector4f* out, const sead::Vector3f& vec) {
|
||||||
out->set(vec.x, vec.y, vec.z);
|
out->set(vec.x, vec.y, vec.z);
|
||||||
}
|
}
|
||||||
|
@ -59,4 +63,27 @@ inline void toMtx34(sead::Matrix34f* out, const hkTransformf& transform) {
|
||||||
mtx[2].store<4>(out->m[2]);
|
mtx[2].store<4>(out->m[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void toHkTransform(hkTransformf* out, const sead::Matrix34f& mtx) {
|
||||||
|
sead::Quatf rotate;
|
||||||
|
mtx.toQuat(rotate);
|
||||||
|
rotate.normalize();
|
||||||
|
|
||||||
|
sead::Vector3f translate;
|
||||||
|
mtx.getTranslation(translate);
|
||||||
|
|
||||||
|
out->set(toHkQuat(rotate), toHkVec4(translate));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consider using toMtx34 if you have an hkTransform and wish to set both rotation and translation.
|
||||||
|
inline void setMtxRotation(sead::Matrix34f* mtx, const hkRotationf& rotation) {
|
||||||
|
mtx->setBase(0, toVec3(rotation.getColumn(0)));
|
||||||
|
mtx->setBase(1, toVec3(rotation.getColumn(1)));
|
||||||
|
mtx->setBase(2, toVec3(rotation.getColumn(2)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Consider using toMtx34 if you have an hkTransform and wish to set both rotation and translation.
|
||||||
|
inline void setMtxTranslation(sead::Matrix34f* mtx, const hkVector4f& translation) {
|
||||||
|
mtx->setTranslation(toVec3(translation));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ksys::phys
|
} // namespace ksys::phys
|
||||||
|
|
Loading…
Reference in New Issue