mirror of
https://github.com/zeldaret/botw
synced 2026-08-11 11:32:48 -04:00
ksys/phys: Rename MotionAccessor classes to reflect entity/sensor split
This commit is contained in:
@@ -23,10 +23,10 @@ target_sources(uking PRIVATE
|
||||
RigidBody/physRigidBodyAccessor.h
|
||||
RigidBody/physRigidBodyFactory.cpp
|
||||
RigidBody/physRigidBodyFactory.h
|
||||
RigidBody/physRigidBodyMotion.cpp
|
||||
RigidBody/physRigidBodyMotion.h
|
||||
RigidBody/physRigidBodyMotionProxy.cpp
|
||||
RigidBody/physRigidBodyMotionProxy.h
|
||||
RigidBody/physRigidBodyMotionEntity.cpp
|
||||
RigidBody/physRigidBodyMotionEntity.h
|
||||
RigidBody/physRigidBodyMotionSensor.cpp
|
||||
RigidBody/physRigidBodyMotionSensor.h
|
||||
RigidBody/physRigidBodyParam.cpp
|
||||
RigidBody/physRigidBodyParam.h
|
||||
RigidBody/physRigidBodyRequestMgr.cpp
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include <Havok/Physics2012/Dynamics/Motion/Rigid/hkpKeyframedRigidMotion.h>
|
||||
#include <cmath>
|
||||
#include "KingSystem/Physics/RigidBody/physMotionAccessor.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotion.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionProxy.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyRequestMgr.h"
|
||||
#include "KingSystem/Physics/System/physMemSystem.h"
|
||||
@@ -61,9 +61,9 @@ RigidBody::~RigidBody() {
|
||||
|
||||
inline void RigidBody::createMotionAccessor(sead::Heap* heap) {
|
||||
if (isSensor())
|
||||
mMotionAccessor = new (heap) RigidBodyMotionProxy(this);
|
||||
mMotionAccessor = new (heap) RigidBodyMotionSensor(this);
|
||||
else
|
||||
mMotionAccessor = new (heap) RigidBodyMotion(this);
|
||||
mMotionAccessor = new (heap) RigidBodyMotionEntity(this);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -213,34 +213,34 @@ void RigidBody::sub_7100F8D21C() {
|
||||
}
|
||||
}
|
||||
|
||||
RigidBodyMotion* RigidBody::getMotionAccessor() const {
|
||||
return sead::DynamicCast<RigidBodyMotion>(mMotionAccessor);
|
||||
RigidBodyMotionEntity* RigidBody::getEntityMotionAccessor() const {
|
||||
return sead::DynamicCast<RigidBodyMotionEntity>(mMotionAccessor);
|
||||
}
|
||||
|
||||
RigidBodyMotion* RigidBody::getMotionAccessorForProxy() const {
|
||||
return getMotionAccessor();
|
||||
RigidBodyMotionEntity* RigidBody::getEntityMotionAccessorForSensor() const {
|
||||
return getEntityMotionAccessor();
|
||||
}
|
||||
|
||||
RigidBodyMotionProxy* RigidBody::getMotionProxy() const {
|
||||
RigidBodyMotionSensor* RigidBody::getSensorMotionAccessor() const {
|
||||
if (!isSensor())
|
||||
return nullptr;
|
||||
if (!mMotionAccessor)
|
||||
return nullptr;
|
||||
return sead::DynamicCast<RigidBodyMotionProxy>(mMotionAccessor);
|
||||
return sead::DynamicCast<RigidBodyMotionSensor>(mMotionAccessor);
|
||||
}
|
||||
|
||||
RigidBody* RigidBody::getLinkedRigidBody() const {
|
||||
auto* proxy = getMotionProxy();
|
||||
if (!proxy)
|
||||
auto* accessor = getSensorMotionAccessor();
|
||||
if (!accessor)
|
||||
return nullptr;
|
||||
return proxy->getLinkedRigidBody();
|
||||
return accessor->getLinkedRigidBody();
|
||||
}
|
||||
|
||||
void RigidBody::resetLinkedRigidBody() const {
|
||||
auto* proxy = getMotionProxy();
|
||||
if (!proxy)
|
||||
auto* accessor = getSensorMotionAccessor();
|
||||
if (!accessor)
|
||||
return;
|
||||
proxy->resetLinkedRigidBody();
|
||||
accessor->resetLinkedRigidBody();
|
||||
}
|
||||
|
||||
MotionType RigidBody::getMotionType() const {
|
||||
@@ -444,7 +444,7 @@ void RigidBody::applyLinearImpulse(const sead::Vector3f& impulse) {
|
||||
}
|
||||
|
||||
if (!isSensor())
|
||||
getMotionAccessor()->applyLinearImpulse(impulse);
|
||||
getEntityMotionAccessor()->applyLinearImpulse(impulse);
|
||||
}
|
||||
|
||||
void RigidBody::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||
@@ -460,7 +460,7 @@ void RigidBody::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||
}
|
||||
|
||||
if (!isSensor())
|
||||
getMotionAccessor()->applyAngularImpulse(impulse);
|
||||
getEntityMotionAccessor()->applyAngularImpulse(impulse);
|
||||
}
|
||||
|
||||
void RigidBody::applyPointImpulse(const sead::Vector3f& impulse, const sead::Vector3f& point) {
|
||||
@@ -481,25 +481,25 @@ void RigidBody::applyPointImpulse(const sead::Vector3f& impulse, const sead::Vec
|
||||
}
|
||||
|
||||
if (!isSensor())
|
||||
getMotionAccessor()->applyPointImpulse(impulse, point);
|
||||
getEntityMotionAccessor()->applyPointImpulse(impulse, point);
|
||||
}
|
||||
|
||||
void RigidBody::setMass(float mass) {
|
||||
if (isSensor())
|
||||
return;
|
||||
getMotionAccessor()->setMass(mass);
|
||||
getEntityMotionAccessor()->setMass(mass);
|
||||
}
|
||||
|
||||
float RigidBody::getMass() const {
|
||||
if (isSensor())
|
||||
return 0.0;
|
||||
return getMotionAccessor()->getMass();
|
||||
return getEntityMotionAccessor()->getMass();
|
||||
}
|
||||
|
||||
float RigidBody::getMassInv() const {
|
||||
if (isSensor())
|
||||
return 0.0;
|
||||
return getMotionAccessor()->getMassInv();
|
||||
return getEntityMotionAccessor()->getMassInv();
|
||||
}
|
||||
|
||||
void RigidBody::lock(bool also_lock_world) {
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace ksys::phys {
|
||||
|
||||
class MotionAccessor;
|
||||
struct RigidBodyInstanceParam;
|
||||
class RigidBodyMotion;
|
||||
class RigidBodyMotionProxy;
|
||||
class RigidBodyMotionEntity;
|
||||
class RigidBodyMotionSensor;
|
||||
class RigidContactPoints;
|
||||
class UserTag;
|
||||
|
||||
@@ -137,17 +137,17 @@ public:
|
||||
// 0x0000007100f8d308
|
||||
bool x_6();
|
||||
|
||||
/// Get the motion accessor if it is a RigidBodyMotion. Returns nullptr otherwise.
|
||||
RigidBodyMotion* getMotionAccessor() const;
|
||||
/// Get the motion accessor if it is a RigidBodyMotion. Returns nullptr otherwise.
|
||||
/// Get the motion accessor if it is a RigidBodyMotionEntity. Returns nullptr otherwise.
|
||||
RigidBodyMotionEntity* getEntityMotionAccessor() const;
|
||||
/// Get the motion accessor if it is a RigidBodyMotionEntity. Returns nullptr otherwise.
|
||||
/// For internal use by the physics system.
|
||||
RigidBodyMotion* getMotionAccessorForProxy() const;
|
||||
RigidBodyMotionEntity* getEntityMotionAccessorForSensor() const;
|
||||
|
||||
/// Get the motion accessor if it is a RigidBodyMotionProxy. Returns nullptr otherwise.
|
||||
RigidBodyMotionProxy* getMotionProxy() const;
|
||||
/// Get the linked rigid body from the motion proxy (or nullptr if there is none).
|
||||
/// Get the motion accessor if it is a RigidBodyMotionSensor. Returns nullptr otherwise.
|
||||
RigidBodyMotionSensor* getSensorMotionAccessor() const;
|
||||
/// Get the linked rigid body from the sensor motion accessor (or nullptr if there is none).
|
||||
RigidBody* getLinkedRigidBody() const;
|
||||
/// Reset the linked rigid body if we have a motion proxy.
|
||||
/// Reset the linked rigid body if we have a sensor motion accessor.
|
||||
void resetLinkedRigidBody() const;
|
||||
|
||||
// 0x0000007100f8d840
|
||||
|
||||
+56
-54
@@ -1,4 +1,4 @@
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotion.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.h"
|
||||
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
|
||||
#include <Havok/Physics2012/Dynamics/Motion/Rigid/hkpBoxMotion.h>
|
||||
#include <Havok/Physics2012/Dynamics/Motion/Rigid/hkpKeyframedRigidMotion.h>
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cstring>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include <prim/seadScopedLock.h>
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionProxy.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
|
||||
#include "KingSystem/Physics/physConversions.h"
|
||||
#include "KingSystem/Utils/Debug.h"
|
||||
@@ -18,16 +18,16 @@ namespace ksys::phys {
|
||||
static float sImpulseEpsilon = 1e-05;
|
||||
static float sMaxImpulse = 1700.0;
|
||||
|
||||
RigidBodyMotion::RigidBodyMotion(RigidBody* body) : MotionAccessor(body) {}
|
||||
RigidBodyMotionEntity::RigidBodyMotionEntity(RigidBody* body) : MotionAccessor(body) {}
|
||||
|
||||
RigidBodyMotion::~RigidBodyMotion() {
|
||||
RigidBodyMotionEntity::~RigidBodyMotionEntity() {
|
||||
if (mMotion) {
|
||||
delete[] reinterpret_cast<u8*>(mMotion);
|
||||
mMotion = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::init(const RigidBodyInstanceParam& params, sead::Heap* heap) {
|
||||
bool RigidBodyMotionEntity::init(const RigidBodyInstanceParam& params, sead::Heap* heap) {
|
||||
auto* motion_storage = new (heap, alignof(hkpMaxSizeMotion)) u8[sizeof(hkpMaxSizeMotion)];
|
||||
mMotion = new (motion_storage) hkpMaxSizeMotion;
|
||||
mBody->createMotion(static_cast<hkpMaxSizeMotion*>(mMotion), MotionType::Dynamic, params);
|
||||
@@ -41,7 +41,8 @@ bool RigidBodyMotion::init(const RigidBodyInstanceParam& params, sead::Heap* hea
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setTransform(const sead::Matrix34f& mtx, bool propagate_to_linked_motions) {
|
||||
void RigidBodyMotionEntity::setTransform(const sead::Matrix34f& mtx,
|
||||
bool propagate_to_linked_motions) {
|
||||
hkTransformf transform;
|
||||
toHkTransform(&transform, mtx);
|
||||
mMotion->setTransform(transform);
|
||||
@@ -62,8 +63,8 @@ void RigidBodyMotion::setTransform(const sead::Matrix34f& mtx, bool propagate_to
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setPosition(const sead::Vector3f& position,
|
||||
bool propagate_to_linked_motions) {
|
||||
void RigidBodyMotionEntity::setPosition(const sead::Vector3f& position,
|
||||
bool propagate_to_linked_motions) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyTransform);
|
||||
const auto hk_position = toHkVec4(position);
|
||||
const auto& hk_rotate = motion->getRotation();
|
||||
@@ -84,31 +85,31 @@ void RigidBodyMotion::setPosition(const sead::Vector3f& position,
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getPosition(sead::Vector3f* position) {
|
||||
void RigidBodyMotionEntity::getPosition(sead::Vector3f* position) {
|
||||
storeToVec3(position, getPosition());
|
||||
}
|
||||
|
||||
hkVector4f RigidBodyMotion::getPosition() const {
|
||||
hkVector4f RigidBodyMotionEntity::getPosition() const {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyTransform);
|
||||
return motion->getPosition();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getRotation(sead::Quatf* rotation) {
|
||||
void RigidBodyMotionEntity::getRotation(sead::Quatf* rotation) {
|
||||
toQuat(rotation, getRotation());
|
||||
}
|
||||
|
||||
hkQuaternionf RigidBodyMotion::getRotation() const {
|
||||
hkQuaternionf RigidBodyMotionEntity::getRotation() const {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyTransform);
|
||||
return motion->getRotation();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getTransform(sead::Matrix34f* mtx) {
|
||||
void RigidBodyMotionEntity::getTransform(sead::Matrix34f* mtx) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyTransform);
|
||||
setMtxRotation(mtx, motion->getTransform().getRotation());
|
||||
setMtxTranslation(mtx, motion->getTransform().getTranslation());
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||
void RigidBodyMotionEntity::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||
const auto hk_center = toHkVec4(center);
|
||||
mMotion->setCenterOfMassInLocal(hk_center);
|
||||
|
||||
@@ -118,12 +119,12 @@ void RigidBodyMotion::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||
getHkBody()->setCenterOfMassLocal(hk_center);
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||
void RigidBodyMotionEntity::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||
const auto hk_center = mMotion->getCenterOfMassLocal();
|
||||
storeToVec3(center, hk_center);
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionEntity::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
sead::Vector3f current_vel;
|
||||
getLinearVelocity(¤t_vel);
|
||||
if (current_vel.equals(velocity, epsilon))
|
||||
@@ -134,7 +135,7 @@ bool RigidBodyMotion::setLinearVelocity(const sead::Vector3f& velocity, float ep
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::setLinearVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionEntity::setLinearVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyLinearVelocity);
|
||||
if (velocity.allEqual<3>(motion->getLinearVelocity(), epsilon))
|
||||
return false;
|
||||
@@ -144,13 +145,13 @@ bool RigidBodyMotion::setLinearVelocity(const hkVector4f& velocity, float epsilo
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getLinearVelocity(sead::Vector3f* velocity) {
|
||||
void RigidBodyMotionEntity::getLinearVelocity(sead::Vector3f* velocity) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyLinearVelocity);
|
||||
const auto hk_vel = motion->getLinearVelocity();
|
||||
storeToVec3(velocity, hk_vel);
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionEntity::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
sead::Vector3f current_vel;
|
||||
getAngularVelocity(¤t_vel);
|
||||
if (current_vel.equals(velocity, epsilon))
|
||||
@@ -161,7 +162,7 @@ bool RigidBodyMotion::setAngularVelocity(const sead::Vector3f& velocity, float e
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::setAngularVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionEntity::setAngularVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyAngularVelocity);
|
||||
if (velocity.allEqual<3>(motion->getAngularVelocity(), epsilon))
|
||||
return false;
|
||||
@@ -171,31 +172,31 @@ bool RigidBodyMotion::setAngularVelocity(const hkVector4f& velocity, float epsil
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getAngularVelocity(sead::Vector3f* velocity) {
|
||||
void RigidBodyMotionEntity::getAngularVelocity(sead::Vector3f* velocity) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyAngularVelocity);
|
||||
const auto hk_vel = motion->getAngularVelocity();
|
||||
storeToVec3(velocity, hk_vel);
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setMaxLinearVelocity(float max) {
|
||||
void RigidBodyMotionEntity::setMaxLinearVelocity(float max) {
|
||||
mMotion->getMotionState()->m_maxLinearVelocity = max;
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getMaxLinearVelocity() {
|
||||
float RigidBodyMotionEntity::getMaxLinearVelocity() {
|
||||
return mMotion->getMotionState()->m_maxLinearVelocity;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setMaxAngularVelocity(float max) {
|
||||
void RigidBodyMotionEntity::setMaxAngularVelocity(float max) {
|
||||
mMotion->getMotionState()->m_maxAngularVelocity = max;
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getMaxAngularVelocity() {
|
||||
float RigidBodyMotionEntity::getMaxAngularVelocity() {
|
||||
return mMotion->getMotionState()->m_maxAngularVelocity;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::applyLinearImpulse(const sead::Vector3f& impulse) {
|
||||
bool RigidBodyMotionEntity::applyLinearImpulse(const sead::Vector3f& impulse) {
|
||||
if (getMotionType() != MotionType::Dynamic)
|
||||
return false;
|
||||
|
||||
@@ -214,7 +215,7 @@ bool RigidBodyMotion::applyLinearImpulse(const sead::Vector3f& impulse) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||
bool RigidBodyMotionEntity::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||
if (getMotionType() != MotionType::Dynamic)
|
||||
return false;
|
||||
|
||||
@@ -238,8 +239,8 @@ bool RigidBodyMotion::applyAngularImpulse(const sead::Vector3f& impulse) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::applyPointImpulse(const sead::Vector3f& impulse,
|
||||
const sead::Vector3f& point) {
|
||||
bool RigidBodyMotionEntity::applyPointImpulse(const sead::Vector3f& impulse,
|
||||
const sead::Vector3f& point) {
|
||||
if (getMotionType() != MotionType::Dynamic)
|
||||
return false;
|
||||
|
||||
@@ -275,7 +276,7 @@ bool RigidBodyMotion::applyPointImpulse(const sead::Vector3f& impulse,
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setMass(float mass) {
|
||||
void RigidBodyMotionEntity::setMass(float mass) {
|
||||
if (arePropertyChangesBlocked()) {
|
||||
mMass = mass;
|
||||
return;
|
||||
@@ -288,14 +289,14 @@ void RigidBodyMotion::setMass(float mass) {
|
||||
getHkBody()->getMotion()->setMass(mass);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getMass() const {
|
||||
float RigidBodyMotionEntity::getMass() const {
|
||||
if (arePropertyChangesBlocked())
|
||||
return mMass;
|
||||
|
||||
return mMotion->getMass();
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getMassInv() const {
|
||||
float RigidBodyMotionEntity::getMassInv() const {
|
||||
if (arePropertyChangesBlocked())
|
||||
return 1.0f / mMass;
|
||||
|
||||
@@ -310,7 +311,7 @@ static inline float min3(float a, float b, float c) {
|
||||
return sead::Mathf::min(a < b ? a : b, c);
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setInertiaLocal(const sead::Vector3f& inertia) {
|
||||
void RigidBodyMotionEntity::setInertiaLocal(const sead::Vector3f& inertia) {
|
||||
if (mBody->isCharacterControllerType())
|
||||
return;
|
||||
|
||||
@@ -383,7 +384,7 @@ void RigidBodyMotion::setInertiaLocal(const sead::Vector3f& inertia) {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getInertiaLocal(sead::Vector3f* inertia) const {
|
||||
void RigidBodyMotionEntity::getInertiaLocal(sead::Vector3f* inertia) const {
|
||||
if (arePropertyChangesBlocked()) {
|
||||
inertia->e = mInertiaLocal.e;
|
||||
return;
|
||||
@@ -396,7 +397,7 @@ void RigidBodyMotion::getInertiaLocal(sead::Vector3f* inertia) const {
|
||||
inertia->z = hk_inertia.getColumn(2).getZ();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setLinearDamping(float value) {
|
||||
void RigidBodyMotionEntity::setLinearDamping(float value) {
|
||||
if (arePropertyChangesBlocked()) {
|
||||
mLinearDamping = value;
|
||||
return;
|
||||
@@ -409,14 +410,14 @@ void RigidBodyMotion::setLinearDamping(float value) {
|
||||
getHkBody()->setLinearDamping(getTimeFactor() * value);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getLinearDamping() const {
|
||||
float RigidBodyMotionEntity::getLinearDamping() const {
|
||||
if (arePropertyChangesBlocked())
|
||||
return mLinearDamping;
|
||||
|
||||
return mMotion->getLinearDamping();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setAngularDamping(float value) {
|
||||
void RigidBodyMotionEntity::setAngularDamping(float value) {
|
||||
if (arePropertyChangesBlocked()) {
|
||||
mAngularDamping = value;
|
||||
return;
|
||||
@@ -429,14 +430,14 @@ void RigidBodyMotion::setAngularDamping(float value) {
|
||||
getHkBody()->setAngularDamping(getTimeFactor() * value);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getAngularDamping() const {
|
||||
float RigidBodyMotionEntity::getAngularDamping() const {
|
||||
if (arePropertyChangesBlocked())
|
||||
return mAngularDamping;
|
||||
|
||||
return mMotion->getAngularDamping();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setGravityFactor(float value) {
|
||||
void RigidBodyMotionEntity::setGravityFactor(float value) {
|
||||
if (arePropertyChangesBlocked()) {
|
||||
mGravityFactor = value;
|
||||
return;
|
||||
@@ -449,28 +450,28 @@ void RigidBodyMotion::setGravityFactor(float value) {
|
||||
getHkBody()->setGravityFactor(value);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getGravityFactor() const {
|
||||
float RigidBodyMotionEntity::getGravityFactor() const {
|
||||
if (arePropertyChangesBlocked())
|
||||
return mGravityFactor;
|
||||
|
||||
return mMotion->getGravityFactor();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setTimeFactor(float factor) {
|
||||
void RigidBodyMotionEntity::setTimeFactor(float factor) {
|
||||
mMotion->setTimeFactor(factor);
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotion::getTimeFactor() {
|
||||
float RigidBodyMotionEntity::getTimeFactor() {
|
||||
return mMotion->getTimeFactor();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::getRotation(hkQuaternionf* quat) {
|
||||
void RigidBodyMotionEntity::getRotation(hkQuaternionf* quat) {
|
||||
auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyTransform);
|
||||
*quat = motion->getRotation();
|
||||
}
|
||||
|
||||
void RigidBodyMotion::processUpdateFlags() {
|
||||
void RigidBodyMotionEntity::processUpdateFlags() {
|
||||
auto* body = getHkBody();
|
||||
auto* body_motion = body->getMotion();
|
||||
|
||||
@@ -507,7 +508,7 @@ void RigidBodyMotion::processUpdateFlags() {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::updateRigidBodyMotionExceptState() {
|
||||
void RigidBodyMotionEntity::updateRigidBodyMotionExceptState() {
|
||||
// Copy everything from our hkpMotion to the rigid body's internal motion
|
||||
// except the hkMotionState data.
|
||||
const hkMotionState state = *getHkBody()->getMotion()->getMotionState();
|
||||
@@ -547,7 +548,7 @@ void RigidBodyMotion::updateRigidBodyMotionExceptState() {
|
||||
getHkBody()->updateCachedShapeInfo(shape, extent_out);
|
||||
}
|
||||
|
||||
void RigidBodyMotion::updateRigidBodyMotionExceptStateAndVel() {
|
||||
void RigidBodyMotionEntity::updateRigidBodyMotionExceptStateAndVel() {
|
||||
// See updateRigidBodyMotionExceptState() for explanations.
|
||||
const hkMotionState state = *getHkBody()->getMotion()->getMotionState();
|
||||
const auto linear_vel = getHkBody()->getMotion()->getLinearVelocity();
|
||||
@@ -566,7 +567,7 @@ void RigidBodyMotion::updateRigidBodyMotionExceptStateAndVel() {
|
||||
getHkBody()->getMotion()->m_deactivationIntegrateCounter = deactivation_counter;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::registerAccessor(RigidBodyMotionProxy* accessor) {
|
||||
bool RigidBodyMotionEntity::registerAccessor(RigidBodyMotionSensor* accessor) {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
if (mLinkedAccessors.isFull()) {
|
||||
@@ -589,7 +590,7 @@ bool RigidBodyMotion::registerAccessor(RigidBodyMotionProxy* accessor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::deregisterAccessor(RigidBodyMotionProxy* accessor) {
|
||||
bool RigidBodyMotionEntity::deregisterAccessor(RigidBodyMotionSensor* accessor) {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
const int idx = mLinkedAccessors.indexOf(accessor);
|
||||
@@ -603,7 +604,7 @@ bool RigidBodyMotion::deregisterAccessor(RigidBodyMotionProxy* accessor) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotion::deregisterAllAccessors() {
|
||||
bool RigidBodyMotionEntity::deregisterAllAccessors() {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
// For efficiency reasons, deregister starting from the end of the array.
|
||||
@@ -618,7 +619,7 @@ bool RigidBodyMotion::deregisterAllAccessors() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::copyTransformToAllLinkedBodies() {
|
||||
void RigidBodyMotionEntity::copyTransformToAllLinkedBodies() {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
for (int i = 0, n = mLinkedAccessors.size(); i < n; ++i) {
|
||||
@@ -631,7 +632,7 @@ void RigidBodyMotion::copyTransformToAllLinkedBodies() {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::copyMotionToAllLinkedBodies() {
|
||||
void RigidBodyMotionEntity::copyMotionToAllLinkedBodies() {
|
||||
auto lock = sead::makeScopedLock(mCS);
|
||||
|
||||
for (int i = 0, n = mLinkedAccessors.size(); i < n; ++i) {
|
||||
@@ -639,7 +640,8 @@ void RigidBodyMotion::copyMotionToAllLinkedBodies() {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotion::freeze(bool freeze, bool preserve_velocities, bool preserve_max_impulse) {
|
||||
void RigidBodyMotionEntity::freeze(bool freeze, bool preserve_velocities,
|
||||
bool preserve_max_impulse) {
|
||||
if (!freeze) {
|
||||
setLinearVelocity(mLinearVelocity, sead::Mathf::epsilon());
|
||||
setAngularVelocity(mAngularVelocity, sead::Mathf::epsilon());
|
||||
@@ -682,11 +684,11 @@ void RigidBodyMotion::freeze(bool freeze, bool preserve_velocities, bool preserv
|
||||
mMaxImpulse = sMaxImpulse;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setImpulseEpsilon(float epsilon) {
|
||||
void RigidBodyMotionEntity::setImpulseEpsilon(float epsilon) {
|
||||
sImpulseEpsilon = epsilon;
|
||||
}
|
||||
|
||||
void RigidBodyMotion::setMaxImpulse(float max_impulse) {
|
||||
void RigidBodyMotionEntity::setMaxImpulse(float max_impulse) {
|
||||
sMaxImpulse = max_impulse;
|
||||
}
|
||||
|
||||
+8
-8
@@ -12,10 +12,10 @@ class hkpMotion;
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
class RigidBodyMotionProxy;
|
||||
class RigidBodyMotionSensor;
|
||||
|
||||
class RigidBodyMotion : public MotionAccessor {
|
||||
SEAD_RTTI_OVERRIDE(RigidBodyMotion, MotionAccessor)
|
||||
class RigidBodyMotionEntity : public MotionAccessor {
|
||||
SEAD_RTTI_OVERRIDE(RigidBodyMotionEntity, MotionAccessor)
|
||||
public:
|
||||
enum class Flag {
|
||||
_1 = 1 << 0,
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
_200 = 1 << 9,
|
||||
};
|
||||
|
||||
explicit RigidBodyMotion(RigidBody* body);
|
||||
explicit RigidBodyMotionEntity(RigidBody* body);
|
||||
|
||||
void setTransform(const sead::Matrix34f& mtx, bool propagate_to_linked_motions) override;
|
||||
void setPosition(const sead::Vector3f& position, bool propagate_to_linked_motions) override;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
void setMaxAngularVelocity(float max) override;
|
||||
float getMaxAngularVelocity() override;
|
||||
|
||||
~RigidBodyMotion() override;
|
||||
~RigidBodyMotionEntity() override;
|
||||
|
||||
bool init(const RigidBodyInstanceParam& params, sead::Heap* heap) override;
|
||||
void getRotation(hkQuaternionf* quat) override;
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
void updateRigidBodyMotionExceptState();
|
||||
void updateRigidBodyMotionExceptStateAndVel();
|
||||
|
||||
bool registerAccessor(RigidBodyMotionProxy* accessor);
|
||||
bool deregisterAccessor(RigidBodyMotionProxy* accessor);
|
||||
bool registerAccessor(RigidBodyMotionSensor* accessor);
|
||||
bool deregisterAccessor(RigidBodyMotionSensor* accessor);
|
||||
bool deregisterAllAccessors();
|
||||
void copyTransformToAllLinkedBodies();
|
||||
void copyMotionToAllLinkedBodies();
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
float mGravityFactor{};
|
||||
float mMaxImpulseCopy{};
|
||||
hkpMotion* mMotion{};
|
||||
sead::FixedPtrArray<RigidBodyMotionProxy, 8> mLinkedAccessors;
|
||||
sead::FixedPtrArray<RigidBodyMotionSensor, 8> mLinkedAccessors;
|
||||
float mWaterBuoyancyScale = 1.0f;
|
||||
float mWaterFlowEffectiveRate = 1.0f;
|
||||
float mMagneMassScalingFactor = 1.0f;
|
||||
+42
-42
@@ -1,26 +1,26 @@
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionProxy.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.h"
|
||||
#include <Havok/Common/Base/hkBase.h>
|
||||
#include <Havok/Physics2012/Dynamics/Entity/hkpRigidBody.h>
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotion.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.h"
|
||||
#include "KingSystem/Physics/RigidBody/physRigidBodyParam.h"
|
||||
#include "KingSystem/Physics/physConversions.h"
|
||||
|
||||
namespace ksys::phys {
|
||||
|
||||
RigidBodyMotionProxy::RigidBodyMotionProxy(RigidBody* body) : MotionAccessor(body) {}
|
||||
RigidBodyMotionSensor::RigidBodyMotionSensor(RigidBody* body) : MotionAccessor(body) {}
|
||||
|
||||
RigidBodyMotionProxy::~RigidBodyMotionProxy() {
|
||||
RigidBodyMotionSensor::~RigidBodyMotionSensor() {
|
||||
resetLinkedRigidBody();
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::init(const RigidBodyInstanceParam& params, sead::Heap* heap) {
|
||||
bool RigidBodyMotionSensor::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) {
|
||||
KSYS_ALWAYS_INLINE void RigidBodyMotionSensor::setTransformImpl(const sead::Matrix34f& mtx) {
|
||||
if (mBody->isFlag8Set()) { // flag 8 = block updates?
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyTransform);
|
||||
return;
|
||||
@@ -31,14 +31,14 @@ KSYS_ALWAYS_INLINE void RigidBodyMotionProxy::setTransformImpl(const sead::Matri
|
||||
mBody->getHkBody()->getMotion()->setTransform(transform);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setTransform(const sead::Matrix34f& mtx,
|
||||
bool propagate_to_linked_motions) {
|
||||
void RigidBodyMotionSensor::setTransform(const sead::Matrix34f& mtx,
|
||||
bool propagate_to_linked_motions) {
|
||||
mTransform = mtx;
|
||||
setTransformImpl(mtx);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setPosition(const sead::Vector3f& position,
|
||||
bool propagate_to_linked_motions) {
|
||||
void RigidBodyMotionSensor::setPosition(const sead::Vector3f& position,
|
||||
bool propagate_to_linked_motions) {
|
||||
if (hasMotionFlagDisabled(RigidBody::MotionFlag::DirtyTransform)) {
|
||||
getTransform(&mTransform);
|
||||
}
|
||||
@@ -47,7 +47,7 @@ void RigidBodyMotionProxy::setPosition(const sead::Vector3f& position,
|
||||
setTransformImpl(mTransform);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setTransformFromLinkedBody(const sead::Matrix34f& mtx) {
|
||||
void RigidBodyMotionSensor::setTransformFromLinkedBody(const sead::Matrix34f& mtx) {
|
||||
if (mFlags.isOff(Flag::HasExtraTranslateForLinkedRigidBody) &&
|
||||
mFlags.isOff(Flag::HasExtraRotateForLinkedRigidBody)) {
|
||||
setTransform(mtx, false);
|
||||
@@ -124,8 +124,8 @@ static sead::Matrix34f makeRT(const hkQuaternionf& r, const hkVector4f& t) {
|
||||
}
|
||||
|
||||
// NON_MATCHING: two fmul instructions reordered in sead::Matrix34f mtx = makeRT(...)
|
||||
void RigidBodyMotionProxy::setTransformFromLinkedBody(const hkVector4f& hk_translate,
|
||||
const hkQuaternionf& hk_rotate) {
|
||||
void RigidBodyMotionSensor::setTransformFromLinkedBody(const hkVector4f& hk_translate,
|
||||
const hkQuaternionf& hk_rotate) {
|
||||
if (mFlags.isOff(Flag::HasExtraTranslateForLinkedRigidBody) &&
|
||||
mFlags.isOff(Flag::HasExtraRotateForLinkedRigidBody)) {
|
||||
setTransform(makeRT(hk_rotate, hk_translate), false);
|
||||
@@ -152,7 +152,7 @@ void RigidBodyMotionProxy::setTransformFromLinkedBody(const hkVector4f& hk_trans
|
||||
setTransform(mtx, false);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getPosition(sead::Vector3f* position) {
|
||||
void RigidBodyMotionSensor::getPosition(sead::Vector3f* position) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyTransform)) {
|
||||
mTransform.getTranslation(*position);
|
||||
} else {
|
||||
@@ -161,7 +161,7 @@ void RigidBodyMotionProxy::getPosition(sead::Vector3f* position) {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getRotation(sead::Quatf* rotation) {
|
||||
void RigidBodyMotionSensor::getRotation(sead::Quatf* rotation) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyTransform)) {
|
||||
mTransform.toQuat(*rotation);
|
||||
} else {
|
||||
@@ -171,7 +171,7 @@ void RigidBodyMotionProxy::getRotation(sead::Quatf* rotation) {
|
||||
rotation->normalize();
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getTransform(sead::Matrix34f* mtx) {
|
||||
void RigidBodyMotionSensor::getTransform(sead::Matrix34f* mtx) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyTransform)) {
|
||||
*mtx = mTransform;
|
||||
} else {
|
||||
@@ -181,7 +181,7 @@ void RigidBodyMotionProxy::getTransform(sead::Matrix34f* mtx) {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||
void RigidBodyMotionSensor::setCenterOfMassInLocal(const sead::Vector3f& center) {
|
||||
mCenterOfMassInLocal.e = center.e;
|
||||
|
||||
if (mBody->isFlag8Set()) {
|
||||
@@ -192,7 +192,7 @@ void RigidBodyMotionProxy::setCenterOfMassInLocal(const sead::Vector3f& center)
|
||||
mBody->getHkBody()->setCenterOfMassLocal(toHkVec4(center));
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||
void RigidBodyMotionSensor::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyCenterOfMassLocal)) {
|
||||
center->e = mCenterOfMassInLocal.e;
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@ void RigidBodyMotionProxy::getCenterOfMassInLocal(sead::Vector3f* center) {
|
||||
}
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionSensor::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
if (velocity.equals(mLinearVelocity, epsilon))
|
||||
return false;
|
||||
|
||||
@@ -210,13 +210,13 @@ bool RigidBodyMotionProxy::setLinearVelocity(const sead::Vector3f& velocity, flo
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::setLinearVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionSensor::setLinearVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
sead::Vector3f vec;
|
||||
storeToVec3(&vec, velocity);
|
||||
return setLinearVelocity(vec, epsilon);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getLinearVelocity(sead::Vector3f* velocity) {
|
||||
void RigidBodyMotionSensor::getLinearVelocity(sead::Vector3f* velocity) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyLinearVelocity)) {
|
||||
velocity->e = mLinearVelocity.e;
|
||||
} else {
|
||||
@@ -225,7 +225,7 @@ void RigidBodyMotionProxy::getLinearVelocity(sead::Vector3f* velocity) {
|
||||
}
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionSensor::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) {
|
||||
if (velocity.equals(mAngularVelocity, sead::Mathf::epsilon()))
|
||||
return false;
|
||||
|
||||
@@ -234,13 +234,13 @@ bool RigidBodyMotionProxy::setAngularVelocity(const sead::Vector3f& velocity, fl
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::setAngularVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
bool RigidBodyMotionSensor::setAngularVelocity(const hkVector4f& velocity, float epsilon) {
|
||||
sead::Vector3f vec;
|
||||
storeToVec3(&vec, velocity);
|
||||
return setAngularVelocity(vec, epsilon);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getAngularVelocity(sead::Vector3f* velocity) {
|
||||
void RigidBodyMotionSensor::getAngularVelocity(sead::Vector3f* velocity) {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyAngularVelocity)) {
|
||||
velocity->e = mAngularVelocity.e;
|
||||
} else {
|
||||
@@ -249,31 +249,31 @@ void RigidBodyMotionProxy::getAngularVelocity(sead::Vector3f* velocity) {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setMaxLinearVelocity(float max) {
|
||||
void RigidBodyMotionSensor::setMaxLinearVelocity(float max) {
|
||||
mMaxLinearVelocity = max;
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotionProxy::getMaxLinearVelocity() {
|
||||
float RigidBodyMotionSensor::getMaxLinearVelocity() {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor))
|
||||
return mMaxLinearVelocity;
|
||||
|
||||
return getRigidBodyMotion()->getMotionState()->m_maxLinearVelocity;
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setMaxAngularVelocity(float max) {
|
||||
void RigidBodyMotionSensor::setMaxAngularVelocity(float max) {
|
||||
mMaxAngularVelocity = max;
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotionProxy::getMaxAngularVelocity() {
|
||||
float RigidBodyMotionSensor::getMaxAngularVelocity() {
|
||||
if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor))
|
||||
return mMaxAngularVelocity;
|
||||
|
||||
return getRigidBodyMotion()->getMotionState()->m_maxAngularVelocity;
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setLinkedRigidBody(RigidBody* body) {
|
||||
void RigidBodyMotionSensor::setLinkedRigidBody(RigidBody* body) {
|
||||
auto lock = mBody->makeScopedLock(mBody->isFlag8Set());
|
||||
|
||||
if (mLinkedRigidBody == body)
|
||||
@@ -281,13 +281,13 @@ void RigidBodyMotionProxy::setLinkedRigidBody(RigidBody* body) {
|
||||
|
||||
if (mLinkedRigidBody) {
|
||||
// If we already have a linked rigid body, unlink it first.
|
||||
mLinkedRigidBody->getMotionAccessorForProxy()->deregisterAccessor(this);
|
||||
mLinkedRigidBody->getEntityMotionAccessorForSensor()->deregisterAccessor(this);
|
||||
mLinkedRigidBody = nullptr;
|
||||
}
|
||||
|
||||
if (body) {
|
||||
if (!body->isSensor() && mFlags.isOff(Flag::HasLinkedRigidBodyWithoutFlag10)) {
|
||||
RigidBodyMotion* accessor = body->getMotionAccessorForProxy();
|
||||
RigidBodyMotionEntity* accessor = body->getEntityMotionAccessorForSensor();
|
||||
if (accessor && accessor->registerAccessor(this)) {
|
||||
mLinkedRigidBody = body;
|
||||
if (mBody->hasFlag(RigidBody::Flag::_10))
|
||||
@@ -302,30 +302,30 @@ void RigidBodyMotionProxy::setLinkedRigidBody(RigidBody* body) {
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::resetLinkedRigidBody() {
|
||||
void RigidBodyMotionSensor::resetLinkedRigidBody() {
|
||||
if (!mLinkedRigidBody)
|
||||
return;
|
||||
|
||||
auto lock = mBody->makeScopedLock(mBody->isFlag8Set());
|
||||
if (mLinkedRigidBody) {
|
||||
mLinkedRigidBody->getMotionAccessorForProxy()->deregisterAccessor(this);
|
||||
mLinkedRigidBody->getEntityMotionAccessorForSensor()->deregisterAccessor(this);
|
||||
mLinkedRigidBody = nullptr;
|
||||
mFlags.reset(Flag::HasLinkedRigidBodyWithoutFlag10);
|
||||
}
|
||||
}
|
||||
|
||||
RigidBody* RigidBodyMotionProxy::getLinkedRigidBody() const {
|
||||
RigidBody* RigidBodyMotionSensor::getLinkedRigidBody() const {
|
||||
return mLinkedRigidBody;
|
||||
}
|
||||
|
||||
bool RigidBodyMotionProxy::isFlag40000Set() const {
|
||||
bool RigidBodyMotionSensor::isFlag40000Set() const {
|
||||
return mFlags.isOn(Flag::_40000);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::copyMotionFromLinkedRigidBody() {
|
||||
void RigidBodyMotionSensor::copyMotionFromLinkedRigidBody() {
|
||||
auto lock = mBody->makeScopedLock(mBody->isFlag8Set());
|
||||
|
||||
auto* accessor = mLinkedRigidBody->getMotionAccessorForProxy();
|
||||
auto* accessor = mLinkedRigidBody->getEntityMotionAccessorForSensor();
|
||||
auto* linked_hk_body = mLinkedRigidBody->getHkBody();
|
||||
auto* this_hk_body = mBody->getHkBody();
|
||||
|
||||
@@ -399,23 +399,23 @@ void RigidBodyMotionProxy::copyMotionFromLinkedRigidBody() {
|
||||
hkpRigidBody::updateBroadphaseAndResetCollisionInformationOfWarpedBody(this_hk_body);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::getRotation(hkQuaternionf* quat) {
|
||||
void RigidBodyMotionSensor::getRotation(hkQuaternionf* quat) {
|
||||
sead::Quatf rotation;
|
||||
getRotation(&rotation);
|
||||
toHkQuat(quat, rotation);
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::setTimeFactor(float factor) {
|
||||
void RigidBodyMotionSensor::setTimeFactor(float factor) {
|
||||
mTimeFactor = factor;
|
||||
setMotionFlag(RigidBody::MotionFlag::DirtyMaxVelOrTimeFactor);
|
||||
}
|
||||
|
||||
float RigidBodyMotionProxy::getTimeFactor() {
|
||||
float RigidBodyMotionSensor::getTimeFactor() {
|
||||
return mTimeFactor;
|
||||
}
|
||||
|
||||
void RigidBodyMotionProxy::freeze(bool freeze, bool preserve_velocities,
|
||||
bool preserve_max_impulse) {
|
||||
void RigidBodyMotionSensor::freeze(bool freeze, bool preserve_velocities,
|
||||
bool preserve_max_impulse) {
|
||||
if (!freeze) {
|
||||
mBody->setLinearVelocity(mFrozenLinearVelocity);
|
||||
mBody->setAngularVelocity(mFrozenAngularVelocity);
|
||||
+4
-4
@@ -7,8 +7,8 @@
|
||||
namespace ksys::phys {
|
||||
|
||||
/// A MotionAccessor that uses the RigidBody's internal motion instance directly.
|
||||
class RigidBodyMotionProxy : public MotionAccessor {
|
||||
SEAD_RTTI_OVERRIDE(RigidBodyMotionProxy, MotionAccessor)
|
||||
class RigidBodyMotionSensor : public MotionAccessor {
|
||||
SEAD_RTTI_OVERRIDE(RigidBodyMotionSensor, MotionAccessor)
|
||||
public:
|
||||
enum class Flag {
|
||||
_40000 = 1 << 18,
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
HasLinkedRigidBodyWithoutFlag10 = 1 << 21,
|
||||
};
|
||||
|
||||
explicit RigidBodyMotionProxy(RigidBody* body);
|
||||
explicit RigidBodyMotionSensor(RigidBody* body);
|
||||
|
||||
void setTransform(const sead::Matrix34f& mtx, bool propagate_to_linked_motions) override;
|
||||
void setPosition(const sead::Vector3f& position, bool propagate_to_linked_motions) override;
|
||||
@@ -48,7 +48,7 @@ public:
|
||||
bool isFlag40000Set() const;
|
||||
void copyMotionFromLinkedRigidBody();
|
||||
|
||||
~RigidBodyMotionProxy() override;
|
||||
~RigidBodyMotionSensor() override;
|
||||
|
||||
bool init(const RigidBodyInstanceParam& params, sead::Heap* heap) override;
|
||||
void getRotation(hkQuaternionf* quat) override;
|
||||
Reference in New Issue
Block a user