mirror of https://github.com/zeldaret/botw.git
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.
This commit is contained in:
parent
b2a66ca858
commit
26f4aea77c
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue