This commit is contained in:
Vladislav Alpatov
2025-03-01 21:32:02 +03:00
parent 39ab9d065d
commit c3202a3bc3
2 changed files with 13 additions and 9 deletions

View File

@@ -8,8 +8,8 @@
"binaryDir": "${sourceDir}/cmake-build/build/${presetName}", "binaryDir": "${sourceDir}/cmake-build/build/${presetName}",
"installDir": "${sourceDir}/cmake-build/install/${presetName}", "installDir": "${sourceDir}/cmake-build/install/${presetName}",
"cacheVariables": { "cacheVariables": {
"CMAKE_C_COMPILER": "clang.exe", "CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "clang++.exe" "CMAKE_CXX_COMPILER": "cl.exe"
}, },
"condition": { "condition": {
"type": "equals", "type": "equals",

View File

@@ -6,8 +6,9 @@
namespace omath::projectile_prediction namespace omath::projectile_prediction
{ {
std::optional<Vector3<float>> ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile, std::optional<Vector3<float>>
[[maybe_unused]] const Target& target) const ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile,
[[maybe_unused]] const Target& target) const
{ {
#ifdef OMATH_USE_AVX2 #ifdef OMATH_USE_AVX2
const float bulletGravity = m_gravityConstant * projectile.m_gravityScale; const float bulletGravity = m_gravityConstant * projectile.m_gravityScale;
@@ -32,8 +33,8 @@ namespace omath::projectile_prediction
_mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.y), times, _mm256_set1_ps(target.m_origin.y)); _mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.y), times, _mm256_set1_ps(target.m_origin.y));
const __m256 timesSq = _mm256_mul_ps(times, times); const __m256 timesSq = _mm256_mul_ps(times, times);
const __m256 targetZ = _mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.z), times, const __m256 targetZ = _mm256_fmadd_ps(_mm256_set1_ps(target.m_velocity.z), times,
_mm256_fnmadd_ps(_mm256_set1_ps(0.5f * m_gravityConstant), timesSq, _mm256_fnmadd_ps(_mm256_set1_ps(0.5f * m_gravityConstant), timesSq,
_mm256_set1_ps(target.m_origin.z))); _mm256_set1_ps(target.m_origin.z)));
const __m256 deltaX = _mm256_sub_ps(targetX, _mm256_set1_ps(projOrigin.x)); const __m256 deltaX = _mm256_sub_ps(targetX, _mm256_set1_ps(projOrigin.x));
const __m256 deltaY = _mm256_sub_ps(targetY, _mm256_set1_ps(projOrigin.y)); const __m256 deltaY = _mm256_sub_ps(targetY, _mm256_set1_ps(projOrigin.y));
@@ -111,8 +112,9 @@ namespace omath::projectile_prediction
m_maximumSimulationTime(simulationTimeStep) m_maximumSimulationTime(simulationTimeStep)
{ {
} }
std::optional<float> ProjPredEngineAVX2::CalculatePitch(const Vector3<float>& projOrigin, const Vector3<float>& targetPos, std::optional<float> ProjPredEngineAVX2::CalculatePitch(const Vector3<float>& projOrigin,
const float bulletGravity, const float v0, const float time) const Vector3<float>& targetPos, const float bulletGravity,
const float v0, const float time)
{ {
if (time <= 0.0f) if (time <= 0.0f)
return std::nullopt; return std::nullopt;
@@ -135,7 +137,9 @@ namespace omath::projectile_prediction
const float d = std::sqrt(dSqr); const float d = std::sqrt(dSqr);
const float tanTheta = term / d; const float tanTheta = term / d;
return angles::RadiansToDegrees(std::atan(tanTheta)); return angles::RadiansToDegrees(std::atan(tanTheta));
#else
throw std::runtime_error(
std::format("{} AVX2 feature is not enabled!", std::source_location::current().function_name()));
#endif #endif
throw std::runtime_error(std::format("{} AVX2 feature is not enabled!", std::source_location::current().function_name()));
} }
} // namespace omath::projectile_prediction } // namespace omath::projectile_prediction