Skip to content

Commit a0e5e8d

Browse files
committed
Review
1 parent fb20c88 commit a0e5e8d

File tree

4 files changed

+23
-28
lines changed

4 files changed

+23
-28
lines changed

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4672,10 +4672,10 @@ bool CClientPed::IsOnGround(bool checkVehicles)
46724672
GetPosition(vecPosition);
46734673
float fGroundLevel = static_cast<float>(g_pGame->GetWorld()->FindGroundZFor3DPosition(&vecPosition));
46744674

4675-
if (definitelyLessThan(vecPosition.fZ, fGroundLevel))
4675+
if (DefinitelyLessThan(vecPosition.fZ, fGroundLevel))
46764676
return false;
46774677

4678-
bool isOnGround = definitelyLessThan((vecPosition.fZ - fGroundLevel), 1.0f) || essentiallyEqual((vecPosition.fZ - fGroundLevel), 1.0f);
4678+
bool isOnGround = DefinitelyLessThan((vecPosition.fZ - fGroundLevel), 1.0f) || EssentiallyEqual((vecPosition.fZ - fGroundLevel), 1.0f);
46794679
if (!isOnGround && checkVehicles && m_pPlayerPed)
46804680
return m_pPlayerPed->IsStandingOnEntity();
46814681

Shared/mods/deathmatch/logic/Utils.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,23 +1102,3 @@ CVector ConvertEulerRotationOrder(const CVector& a_vRotation, eEulerRotationOrde
11021102
return a_vRotation;
11031103
}
11041104
}
1105-
1106-
bool approximatelyEqual(float a, float b, float epsilon)
1107-
{
1108-
return std::fabs(a - b) <= std::max(std::fabs(a), std::fabs(b)) * epsilon;
1109-
}
1110-
1111-
bool essentiallyEqual(float a, float b, float epsilon)
1112-
{
1113-
return std::fabs(a - b) <= std::min(std::fabs(a), std::fabs(b)) * epsilon;
1114-
}
1115-
1116-
bool definitelyGreaterThan(float a, float b, float epsilon)
1117-
{
1118-
return (a - b) > std::max(std::fabs(a), std::fabs(b)) * epsilon;
1119-
}
1120-
1121-
bool definitelyLessThan(float a, float b, float epsilon)
1122-
{
1123-
return (b - a) > std::max(std::fabs(a), std::fabs(b)) * epsilon;
1124-
}

Shared/mods/deathmatch/logic/Utils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,3 @@ void DeletePointersAndClearList(T& elementList)
336336
delete *iter;
337337
}
338338
}
339-
340-
// Comparing floating point numbers
341-
bool approximatelyEqual(float a, float b, float epsilon = FLOAT_EPSILON);
342-
bool essentiallyEqual(float a, float b, float epsilon = FLOAT_EPSILON);
343-
bool definitelyGreaterThan(float a, float b, float epsilon = FLOAT_EPSILON);
344-
bool definitelyLessThan(float a, float b, float epsilon = FLOAT_EPSILON);

Shared/sdk/SharedUtil.Math.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,25 @@ namespace SharedUtil
118118
{
119119
return std::fabs(a - b) <= epsilon;
120120
}
121+
122+
inline bool ApproximatelyEqual(float a, float b, float epsilon = std::numeric_limits<float>().epsilon()) noexcept
123+
{
124+
return std::fabs(a - b) <= std::max(std::fabs(a), std::fabs(b)) * epsilon;
125+
}
126+
127+
inline bool EssentiallyEqual(float a, float b, float epsilon = std::numeric_limits<float>().epsilon()) noexcept
128+
{
129+
return std::fabs(a - b) <= std::min(std::fabs(a), std::fabs(b)) * epsilon;
130+
}
131+
132+
inline bool DefinitelyGreaterThan(float a, float b, float epsilon = std::numeric_limits<float>().epsilon()) noexcept
133+
{
134+
return (a - b) > std::max(std::fabs(a), std::fabs(b)) * epsilon;
135+
}
136+
137+
inline bool DefinitelyLessThan(float a, float b, float epsilon = std::numeric_limits<float>().epsilon()) noexcept
138+
{
139+
return (b - a) > std::max(std::fabs(a), std::fabs(b)) * epsilon;
140+
}
141+
121142
} // namespace SharedUtil

0 commit comments

Comments
 (0)