diff options
| author | Léo Lam <leo@leolam.fr> | 2022-03-03 11:50:09 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2022-03-03 11:52:35 +0100 |
| commit | 26f4aea77c854ad4eff39e594de55345db4817c4 (patch) | |
| tree | 6092515090c2ea337e1a8c60a2327bb82939377f /src | |
| parent | b2a66ca8586d435dc417d0d9aa65e6b445fe9855 (diff) | |
ksys/phys: Fix accuracy issue for storeToVec3
Allows us to get rid of a bunch of local variables that only existed
to force the entire vector to be loaded.
Diffstat (limited to 'src')
4 files changed, 10 insertions, 17 deletions
diff --git a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp index 71746819..c76bb15c 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBody.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBody.cpp @@ -1312,8 +1312,7 @@ void RigidBody::getCenterOfMassInWorld(sead::Vector3f* center) const { center->setMul(transform, local_center); } else { - auto hk_center = getMotion()->getCenterOfMassInWorld(); - storeToVec3(center, hk_center); + storeToVec3(center, getMotion()->getCenterOfMassInWorld()); } } diff --git a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp index 264ba699..c0532fb6 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionEntity.cpp @@ -120,8 +120,7 @@ void RigidBodyMotionEntity::setCenterOfMassInLocal(const sead::Vector3f& center) } void RigidBodyMotionEntity::getCenterOfMassInLocal(sead::Vector3f* center) { - const auto hk_center = mMotion->getCenterOfMassLocal(); - storeToVec3(center, hk_center); + storeToVec3(center, mMotion->getCenterOfMassLocal()); } bool RigidBodyMotionEntity::setLinearVelocity(const sead::Vector3f& velocity, float epsilon) { @@ -147,8 +146,7 @@ bool RigidBodyMotionEntity::setLinearVelocity(const hkVector4f& velocity, float void RigidBodyMotionEntity::getLinearVelocity(sead::Vector3f* velocity) { auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyLinearVelocity); - const auto hk_vel = motion->getLinearVelocity(); - storeToVec3(velocity, hk_vel); + storeToVec3(velocity, motion->getLinearVelocity()); } bool RigidBodyMotionEntity::setAngularVelocity(const sead::Vector3f& velocity, float epsilon) { @@ -174,8 +172,7 @@ bool RigidBodyMotionEntity::setAngularVelocity(const hkVector4f& velocity, float void RigidBodyMotionEntity::getAngularVelocity(sead::Vector3f* velocity) { auto* motion = getHkBodyMotionOrLocalMotionIf(RigidBody::MotionFlag::DirtyAngularVelocity); - const auto hk_vel = motion->getAngularVelocity(); - storeToVec3(velocity, hk_vel); + storeToVec3(velocity, motion->getAngularVelocity()); } void RigidBodyMotionEntity::setMaxLinearVelocity(float max) { diff --git a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.cpp b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.cpp index 346ba356..d4c886e4 100644 --- a/src/KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.cpp +++ b/src/KingSystem/Physics/RigidBody/physRigidBodyMotionSensor.cpp @@ -156,8 +156,7 @@ void RigidBodyMotionSensor::getPosition(sead::Vector3f* position) { if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyTransform)) { mTransform.getTranslation(*position); } else { - const auto hk_position = getRigidBodyMotion()->getPosition(); - storeToVec3(position, hk_position); + storeToVec3(position, getRigidBodyMotion()->getPosition()); } } @@ -196,8 +195,7 @@ void RigidBodyMotionSensor::getCenterOfMassInLocal(sead::Vector3f* center) { if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyCenterOfMassLocal)) { center->e = mCenterOfMassInLocal.e; } else { - const auto hk_center = getRigidBodyMotion()->getCenterOfMassLocal(); - storeToVec3(center, hk_center); + storeToVec3(center, getRigidBodyMotion()->getCenterOfMassLocal()); } } @@ -220,8 +218,7 @@ void RigidBodyMotionSensor::getLinearVelocity(sead::Vector3f* velocity) { if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyLinearVelocity)) { velocity->e = mLinearVelocity.e; } else { - const auto hk_velocity = getRigidBodyMotion()->getLinearVelocity(); - storeToVec3(velocity, hk_velocity); + storeToVec3(velocity, getRigidBodyMotion()->getLinearVelocity()); } } @@ -244,8 +241,7 @@ void RigidBodyMotionSensor::getAngularVelocity(sead::Vector3f* velocity) { if (hasMotionFlagSet(RigidBody::MotionFlag::DirtyAngularVelocity)) { velocity->e = mAngularVelocity.e; } else { - const auto hk_velocity = getRigidBodyMotion()->getAngularVelocity(); - storeToVec3(velocity, hk_velocity); + storeToVec3(velocity, getRigidBodyMotion()->getAngularVelocity()); } } diff --git a/src/KingSystem/Physics/physConversions.h b/src/KingSystem/Physics/physConversions.h index 507bfe34..7957e16e 100644 --- a/src/KingSystem/Physics/physConversions.h +++ b/src/KingSystem/Physics/physConversions.h @@ -25,7 +25,8 @@ inline void toHkVec4(hkVector4f* out, const sead::Vector3f& vec) { return {vec.x, vec.y, vec.z}; } -inline void storeToVec3(sead::Vector3f* out, const hkVector4f& vec) { +// NOLINTNEXTLINE(performance-unnecessary-value-param) +inline void storeToVec3(sead::Vector3f* out, hkVector4f vec) { vec.store<3>(out->e.data()); } |
