diff --git a/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h b/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h index 8a6ef47c..2af0be92 100644 --- a/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h +++ b/lib/hkStubs/Havok/Common/Base/Types/hkBaseTypes.h @@ -61,6 +61,19 @@ public: void setOne() { m_value = 0x3F80; } + template + void set(const float& r) { + union { + float f; + int i; + } u; + if constexpr (Round) + u.f = r * (1.0f + 1.0f / 256.f); + else + u.f = r; + m_value = hkInt16(u.i >> 16); + } + operator float() const { union { int i; diff --git a/lib/hkStubs/Havok/Physics2012/Dynamics/Motion/hkpMotion.h b/lib/hkStubs/Havok/Physics2012/Dynamics/Motion/hkpMotion.h index 78446db9..84dd8f89 100644 --- a/lib/hkStubs/Havok/Physics2012/Dynamics/Motion/hkpMotion.h +++ b/lib/hkStubs/Havok/Physics2012/Dynamics/Motion/hkpMotion.h @@ -192,7 +192,7 @@ inline hkReal hkpMotion::getLinearDamping() const { } inline void hkpMotion::setLinearDamping(hkReal d) { - m_motionState.m_linearDamping = d; + m_motionState.m_linearDamping.set(d); } inline hkReal hkpMotion::getAngularDamping() const { @@ -200,7 +200,7 @@ inline hkReal hkpMotion::getAngularDamping() const { } inline void hkpMotion::setAngularDamping(hkReal d) { - m_motionState.m_angularDamping = d; + m_motionState.m_angularDamping.set(d); } inline hkReal hkpMotion::getTimeFactor() const { @@ -208,7 +208,7 @@ inline hkReal hkpMotion::getTimeFactor() const { } inline void hkpMotion::setTimeFactor(hkReal f) { - m_motionState.m_timeFactor = f; + m_motionState.m_timeFactor.set(f); } inline hkReal hkpMotion::getGravityFactor() const { @@ -216,7 +216,7 @@ inline hkReal hkpMotion::getGravityFactor() const { } inline void hkpMotion::setGravityFactor(hkReal gravityFactor) { - m_gravityFactor = gravityFactor; + m_gravityFactor.set(gravityFactor); } inline int hkpMotion::getDeactivationClass() const {