mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-11 17:54:35 +00:00
added gcem
This commit is contained in:
@@ -33,6 +33,7 @@ option(OMATH_ENABLE_FORCE_INLINE
|
||||
option(OMATH_ENABLE_LUA
|
||||
"omath bindings for lua" OFF)
|
||||
option(OMATH_ENABLE_HOOKING "omath will HooksManager that can hook DirectX/OpenGL automatically" OFF)
|
||||
option(OMATH_USE_GCEM "omath will use gcem library to make more functions/methods constexpr" OFF)
|
||||
|
||||
if(VCPKG_MANIFEST_FEATURES)
|
||||
foreach(omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||
@@ -50,6 +51,8 @@ if(VCPKG_MANIFEST_FEATURES)
|
||||
set(OMATH_ENABLE_LUA ON)
|
||||
elseif(omath_feature STREQUAL "hooking")
|
||||
set(OMATH_ENABLE_HOOKING ON)
|
||||
elseif (omath_feature STREQUAL "gcem")
|
||||
set(OMATH_USE_GCEM ON)
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
@@ -80,6 +83,7 @@ if(${PROJECT_IS_TOP_LEVEL})
|
||||
message(STATUS "[${PROJECT_NAME}]: Coverage feature status ${OMATH_ENABLE_COVERAGE}")
|
||||
message(STATUS "[${PROJECT_NAME}]: Valgrind feature status ${OMATH_ENABLE_VALGRIND}")
|
||||
message(STATUS "[${PROJECT_NAME}]: Lua feature status ${OMATH_ENABLE_LUA}")
|
||||
message(STATUS "[${PROJECT_NAME}]: Gcem feature status ${OMATH_USE_GCEM}")
|
||||
endif()
|
||||
|
||||
if(OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
||||
@@ -120,6 +124,12 @@ if (OMATH_ENABLE_HOOKING)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
if (OMATH_USE_GCEM)
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_USE_GCEM)
|
||||
find_package(gcem CONFIG REQUIRED)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC gcem)
|
||||
endif ()
|
||||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_VERSION="${PROJECT_VERSION}")
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@
|
||||
"inherits": ["windows-base", "vcpkg-base"],
|
||||
"cacheVariables": {
|
||||
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
|
||||
"VCPKG_MANIFEST_FEATURES": "tests;imgui;avx2;examples;hooking",
|
||||
"VCPKG_MANIFEST_FEATURES": "tests;imgui;avx2;examples;hooking;gcem",
|
||||
"OMATH_STATIC_MSVC_RUNTIME_LIBRARY": "ON"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by orange on 6/11/2026.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
|
||||
#ifdef OMATH_USE_GCEM
|
||||
#include <gcem.hpp>
|
||||
#define OMATH_CONSTEXPR constexpr
|
||||
#else
|
||||
#define OMATH_CONSTEXPR
|
||||
#endif
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <utility>
|
||||
#include "omath/internal/optional_constexpr_math.hpp"
|
||||
|
||||
namespace omath
|
||||
{
|
||||
@@ -70,21 +71,36 @@ namespace omath
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Type sin() const noexcept
|
||||
OMATH_CONSTEXPR Type sin() const noexcept
|
||||
{
|
||||
#ifdef OMATH_USE_GCEM
|
||||
return gcem::sin(as_radians());
|
||||
#else
|
||||
return std::sin(as_radians());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Type cos() const noexcept
|
||||
OMATH_CONSTEXPR Type cos() const noexcept
|
||||
{
|
||||
#ifdef OMATH_USE_GCEM
|
||||
return gcem::cos(as_radians());
|
||||
#else
|
||||
return std::cos(as_radians());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
Type tan() const noexcept
|
||||
OMATH_CONSTEXPR Type tan() const noexcept
|
||||
{
|
||||
#ifdef OMATH_USE_GCEM
|
||||
return gcem::tan(as_radians());
|
||||
#else
|
||||
return std::tan(as_radians());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
|
||||
@@ -82,6 +82,13 @@
|
||||
"lua",
|
||||
"sol2"
|
||||
]
|
||||
},
|
||||
"gcem":
|
||||
{
|
||||
"description": "Improve constexpr compatibility using gcem",
|
||||
"dependencies": [
|
||||
"gcem"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user