mirror of
https://github.com/orange-cpp/omath.git
synced 2026-06-11 17:54:35 +00:00
Compare commits
1 Commits
main
...
feature/gcem
| Author | SHA1 | Date | |
|---|---|---|---|
| 00e7c564fd |
@@ -33,6 +33,7 @@ option(OMATH_ENABLE_FORCE_INLINE
|
|||||||
option(OMATH_ENABLE_LUA
|
option(OMATH_ENABLE_LUA
|
||||||
"omath bindings for lua" OFF)
|
"omath bindings for lua" OFF)
|
||||||
option(OMATH_ENABLE_HOOKING "omath will HooksManager that can hook DirectX/OpenGL automatically" 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)
|
if(VCPKG_MANIFEST_FEATURES)
|
||||||
foreach(omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
foreach(omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||||
@@ -50,6 +51,8 @@ if(VCPKG_MANIFEST_FEATURES)
|
|||||||
set(OMATH_ENABLE_LUA ON)
|
set(OMATH_ENABLE_LUA ON)
|
||||||
elseif(omath_feature STREQUAL "hooking")
|
elseif(omath_feature STREQUAL "hooking")
|
||||||
set(OMATH_ENABLE_HOOKING ON)
|
set(OMATH_ENABLE_HOOKING ON)
|
||||||
|
elseif (omath_feature STREQUAL "gcem")
|
||||||
|
set(OMATH_USE_GCEM ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -80,6 +83,7 @@ if(${PROJECT_IS_TOP_LEVEL})
|
|||||||
message(STATUS "[${PROJECT_NAME}]: Coverage feature status ${OMATH_ENABLE_COVERAGE}")
|
message(STATUS "[${PROJECT_NAME}]: Coverage feature status ${OMATH_ENABLE_COVERAGE}")
|
||||||
message(STATUS "[${PROJECT_NAME}]: Valgrind feature status ${OMATH_ENABLE_VALGRIND}")
|
message(STATUS "[${PROJECT_NAME}]: Valgrind feature status ${OMATH_ENABLE_VALGRIND}")
|
||||||
message(STATUS "[${PROJECT_NAME}]: Lua feature status ${OMATH_ENABLE_LUA}")
|
message(STATUS "[${PROJECT_NAME}]: Lua feature status ${OMATH_ENABLE_LUA}")
|
||||||
|
message(STATUS "[${PROJECT_NAME}]: Gcem feature status ${OMATH_USE_GCEM}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
if(OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
||||||
@@ -120,6 +124,12 @@ if (OMATH_ENABLE_HOOKING)
|
|||||||
endif ()
|
endif ()
|
||||||
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})
|
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_VERSION="${PROJECT_VERSION}")
|
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_VERSION="${PROJECT_VERSION}")
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@
|
|||||||
"inherits": ["windows-base", "vcpkg-base"],
|
"inherits": ["windows-base", "vcpkg-base"],
|
||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
|
"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"
|
"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 <algorithm>
|
||||||
#include <format>
|
#include <format>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include "omath/internal/optional_constexpr_math.hpp"
|
||||||
|
|
||||||
namespace omath
|
namespace omath
|
||||||
{
|
{
|
||||||
@@ -70,21 +71,36 @@ namespace omath
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[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());
|
return std::sin(as_radians());
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[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());
|
return std::cos(as_radians());
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[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());
|
return std::tan(as_radians());
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
|
|||||||
@@ -82,6 +82,13 @@
|
|||||||
"lua",
|
"lua",
|
||||||
"sol2"
|
"sol2"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"gcem":
|
||||||
|
{
|
||||||
|
"description": "Improve constexpr compatibility using gcem",
|
||||||
|
"dependencies": [
|
||||||
|
"gcem"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user