From 7b712ed96039469490f40d86e7de2b4b9446aeb1 Mon Sep 17 00:00:00 2001 From: Orange Date: Sat, 5 Apr 2025 13:00:00 +0300 Subject: [PATCH] fixed for clang --- .gitignore | 1 + CMakeLists.txt | 7 ++-- CMakePresets.json | 32 +++++++++++++++++++ include/omath/vector2.hpp | 4 +-- include/omath/vector3.hpp | 4 +-- .../proj_pred_engine_avx2.cpp | 6 +++- 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 98568e7..e0999e5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /cmake-build/ /.idea /out +*.DS_Store \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index c495eef..a693502 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,12 @@ option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" O option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF) if (OMATH_BUILD_AS_SHARED_LIBRARY) - add_library(omath SHARED source/Matrix.cpp) + add_library(omath SHARED source/matrix.cpp) else() - add_library(omath STATIC source/Matrix.cpp) + add_library(omath STATIC source/matrix.cpp + source/matrix.cpp) endif() - +message(STATUS "Building on ${CMAKE_HOST_SYSTEM_NAME}") add_library(omath::omath ALIAS omath) if (OMATH_IMGUI_INTEGRATION) diff --git a/CMakePresets.json b/CMakePresets.json index d67436b..1f5ceda 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -64,6 +64,38 @@ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" } + }, + { + "name": "darwin-base", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/cmake-build/build/${presetName}", + "installDir": "${sourceDir}/cmake-build/install/${presetName}", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Darwin" + } + }, + { + "name": "darwin-debug", + "displayName": "Darwin Debug", + "inherits": "darwin-base", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "darwin-release", + "displayName": "Darwin Release", + "inherits": "darwin-debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } } ] } \ No newline at end of file diff --git a/include/omath/vector2.hpp b/include/omath/vector2.hpp index f2ae0c3..5753f60 100644 --- a/include/omath/vector2.hpp +++ b/include/omath/vector2.hpp @@ -124,9 +124,9 @@ namespace omath } #ifndef _MSC_VER - [[nodiscard]] constexpr Type& Length() const + [[nodiscard]] constexpr Type Length() const { - return std::hypot(x, y); + return std::hypot(this->x, this->y); } [[nodiscard]] constexpr Vector2 Normalized() const diff --git a/include/omath/vector3.hpp b/include/omath/vector3.hpp index 6b76907..683e4f4 100644 --- a/include/omath/vector3.hpp +++ b/include/omath/vector3.hpp @@ -121,12 +121,12 @@ namespace omath #ifndef _MSC_VER [[nodiscard]] constexpr Type Length() const { - return std::hypot(x, y, z); + return std::hypot(this->x, this->y, z); } [[nodiscard]] constexpr Type Length2D() const { - return Vector2::Length(); + return Vector2::Length(); } [[nodiscard]] Type DistTo(const Vector3& vOther) const { diff --git a/source/projectile_prediction/proj_pred_engine_avx2.cpp b/source/projectile_prediction/proj_pred_engine_avx2.cpp index 771c8e0..9b5f6b6 100644 --- a/source/projectile_prediction/proj_pred_engine_avx2.cpp +++ b/source/projectile_prediction/proj_pred_engine_avx2.cpp @@ -4,13 +4,17 @@ #include "omath/projectile_prediction/proj_pred_engine_avx2.hpp" #include "source_location" +#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__) +#include +#endif + namespace omath::projectile_prediction { std::optional> ProjPredEngineAVX2::MaybeCalculateAimPoint([[maybe_unused]] const Projectile& projectile, [[maybe_unused]] const Target& target) const { -#ifdef OMATH_USE_AVX2 +#if defined(OMATH_USE_AVX2) && defined(__i386__) && defined(__x86_64__) const float bulletGravity = m_gravityConstant * projectile.m_gravityScale; const float v0 = projectile.m_launchSpeed; const float v0Sqr = v0 * v0;