mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-15 16:53:26 +00:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 510e3d7d1c | |||
|
|
72404f2159 | ||
|
|
0e792c9b9c | ||
|
|
7e9151084e | ||
|
|
43c8f2e6a5 | ||
| b0fd8d42f4 | |||
| b5229f72d5 | |||
| d5233dd00b | |||
| bd1d437d7d | |||
| f67ad8ef42 | |||
| acc24f8438 | |||
| 8bccbdb620 | |||
| 91a96fb97a | |||
| 5fcac74a25 | |||
| d2cf62bdbe | |||
| 2a2832c75f | |||
| 26fda5402e | |||
| 906ddd75d4 | |||
| 68505a77ae | |||
| d6746f6243 | |||
| ee2f084e0b | |||
| 9bd42d9c8c | |||
| 47d82fe083 | |||
|
|
217fc108c2 | ||
|
|
9c1c4fe6f3 | ||
| 958156e6b7 | |||
|
|
450f3a3ab0 | ||
|
|
8159686658 | ||
| 9fc31d03e5 | |||
| 6017d40579 | |||
| 618d4aa1c0 | |||
| 8366c48965 | |||
| d2e418c50b | |||
| eae10d92ca | |||
| 3f940c8e35 | |||
| 0846022f8a | |||
| 8812abdf33 | |||
| d56d05f01e | |||
| aabdebbbbe | |||
| 2b75b33d60 | |||
| 9a3f5abb7c | |||
| be1049db93 | |||
| 525b273a84 |
25
.cmake-format
Normal file
25
.cmake-format
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
format:
|
||||||
|
line_width: 100
|
||||||
|
tab_size: 4
|
||||||
|
use_tabchars: false
|
||||||
|
max_subgroups_hwrap: 3
|
||||||
|
max_pargs_hwrap: 5
|
||||||
|
separate_ctrl_name_with_space: false
|
||||||
|
separate_fn_name_with_space: false
|
||||||
|
dangle_parens: false
|
||||||
|
dangle_align: child
|
||||||
|
line_ending: unix
|
||||||
|
command_case: canonical
|
||||||
|
keyword_case: upper
|
||||||
|
enable_sort: true
|
||||||
|
autosort: true
|
||||||
|
markup:
|
||||||
|
bullet_char: "*"
|
||||||
|
enum_char: .
|
||||||
|
enable_markup: false
|
||||||
|
additional_commands:
|
||||||
|
target_link_libraries:
|
||||||
|
kwargs:
|
||||||
|
PUBLIC: "*"
|
||||||
|
SHARED: "*"
|
||||||
|
PRIVATE: "*"
|
||||||
2
.gitattributes
vendored
Normal file
2
.gitattributes
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# SCM syntax highlighting & preventing 3-way merges
|
||||||
|
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -6,3 +6,9 @@
|
|||||||
/build/
|
/build/
|
||||||
/clang-coverage/
|
/clang-coverage/
|
||||||
*.gcov
|
*.gcov
|
||||||
|
*.bin
|
||||||
|
# pixi lock
|
||||||
|
pixi.lock
|
||||||
|
# pixi environments
|
||||||
|
.pixi/*
|
||||||
|
!.pixi/config.toml
|
||||||
|
|||||||
@@ -17,17 +17,20 @@ endif ()
|
|||||||
|
|
||||||
option(OMATH_BUILD_TESTS "Build unit tests" OFF)
|
option(OMATH_BUILD_TESTS "Build unit tests" OFF)
|
||||||
option(OMATH_BUILD_BENCHMARK "Build benchmarks" OFF)
|
option(OMATH_BUILD_BENCHMARK "Build benchmarks" OFF)
|
||||||
option(OMATH_THREAT_WARNING_AS_ERROR "Set highest level of warnings and force compiler to treat them as errors" ON)
|
option(OMATH_THREAT_WARNING_AS_ERROR
|
||||||
|
"Set highest level of warnings and force compiler to treat them as errors" ON)
|
||||||
option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF)
|
option(OMATH_BUILD_AS_SHARED_LIBRARY "Build Omath as .so or .dll" OFF)
|
||||||
option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ${COMPILER_SUPPORTS_AVX2})
|
option(OMATH_USE_AVX2 "Omath will use AVX2 to boost performance" ${COMPILER_SUPPORTS_AVX2})
|
||||||
option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF)
|
option(OMATH_IMGUI_INTEGRATION "Omath will define method to convert omath types to imgui types" OFF)
|
||||||
option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" OFF)
|
option(OMATH_BUILD_EXAMPLES "Build example projects with you can learn & play" OFF)
|
||||||
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
|
option(OMATH_STATIC_MSVC_RUNTIME_LIBRARY "Force Omath to link static runtime" OFF)
|
||||||
option(OMATH_SUPRESS_SAFETY_CHECKS "Supress some safety checks in release build to improve general performance" ON)
|
option(OMATH_ENABLE_LEGACY
|
||||||
option(OMATH_USE_UNITY_BUILD "Will enable unity build to speed up compilation" OFF)
|
"Will enable legacy classes that MUST be used ONLY for backward compatibility" ON)
|
||||||
option(OMATH_ENABLE_LEGACY "Will enable legacy classes that MUST be used ONLY for backward compatibility" ON)
|
option(OMATH_SUPRESS_SAFETY_CHECKS
|
||||||
|
"Supress some safety checks in release build to improve general performance" ON)
|
||||||
option(OMATH_ENABLE_COVERAGE "Enable coverage" OFF)
|
option(OMATH_ENABLE_COVERAGE "Enable coverage" OFF)
|
||||||
|
option(OMATH_ENABLE_FORCE_INLINE
|
||||||
|
"Will for compiler to make some functions to be force inlined no matter what" ON)
|
||||||
if(VCPKG_MANIFEST_FEATURES)
|
if(VCPKG_MANIFEST_FEATURES)
|
||||||
foreach(omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
foreach(omath_feature IN LISTS VCPKG_MANIFEST_FEATURES)
|
||||||
if(omath_feature STREQUAL "imgui")
|
if(omath_feature STREQUAL "imgui")
|
||||||
@@ -46,12 +49,16 @@ if (VCPKG_MANIFEST_FEATURES)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2)
|
if(OMATH_USE_AVX2 AND NOT COMPILER_SUPPORTS_AVX2)
|
||||||
message(WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.")
|
message(
|
||||||
|
WARNING "OMATH_USE_AVX2 requested, but compiler/target does not support AVX2. Disabling.")
|
||||||
set(OMATH_USE_AVX2 OFF CACHE BOOL "Omath will use AVX2 to boost performance" FORCE)
|
set(OMATH_USE_AVX2 OFF CACHE BOOL "Omath will use AVX2 to boost performance" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(${PROJECT_IS_TOP_LEVEL})
|
if(${PROJECT_IS_TOP_LEVEL})
|
||||||
message(STATUS "[${PROJECT_NAME}]: Building on ${CMAKE_HOST_SYSTEM_NAME}, compiler ${CMAKE_CXX_COMPILER_ID}")
|
message(
|
||||||
|
STATUS
|
||||||
|
"[${PROJECT_NAME}]: Building on ${CMAKE_HOST_SYSTEM_NAME}, compiler ${CMAKE_CXX_COMPILER_ID}"
|
||||||
|
)
|
||||||
message(STATUS "[${PROJECT_NAME}]: Warnings as errors ${OMATH_THREAT_WARNING_AS_ERROR}")
|
message(STATUS "[${PROJECT_NAME}]: Warnings as errors ${OMATH_THREAT_WARNING_AS_ERROR}")
|
||||||
message(STATUS "[${PROJECT_NAME}]: Build unit tests ${OMATH_BUILD_TESTS}")
|
message(STATUS "[${PROJECT_NAME}]: Build unit tests ${OMATH_BUILD_TESTS}")
|
||||||
message(STATUS "[${PROJECT_NAME}]: Build benchmark ${OMATH_BUILD_BENCHMARK}")
|
message(STATUS "[${PROJECT_NAME}]: Build benchmark ${OMATH_BUILD_BENCHMARK}")
|
||||||
@@ -76,7 +83,6 @@ else ()
|
|||||||
add_library(${PROJECT_NAME} STATIC ${OMATH_SOURCES} ${OMATH_HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${OMATH_SOURCES} ${OMATH_HEADERS})
|
||||||
endif()
|
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}")
|
||||||
@@ -87,7 +93,8 @@ if (OMATH_IMGUI_INTEGRATION)
|
|||||||
# IMGUI is being linked as submodule
|
# IMGUI is being linked as submodule
|
||||||
if(TARGET imgui)
|
if(TARGET imgui)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC imgui)
|
target_link_libraries(${PROJECT_NAME} PUBLIC imgui)
|
||||||
install(TARGETS imgui
|
install(
|
||||||
|
TARGETS imgui
|
||||||
EXPORT omathTargets
|
EXPORT omathTargets
|
||||||
ARCHIVE DESTINATION lib
|
ARCHIVE DESTINATION lib
|
||||||
LIBRARY DESTINATION lib
|
LIBRARY DESTINATION lib
|
||||||
@@ -112,18 +119,17 @@ if (OMATH_ENABLE_LEGACY)
|
|||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
|
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_ENABLE_LEGACY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
if(OMATH_ENABLE_FORCE_INLINE)
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_ENABLE_FORCE_INLINE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
${PROJECT_NAME}
|
||||||
|
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
CXX_STANDARD 23
|
CXX_STANDARD 23
|
||||||
CXX_STANDARD_REQUIRED ON)
|
CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
if (OMATH_USE_UNITY_BUILD)
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
||||||
UNITY_BUILD ON
|
|
||||||
UNITY_BUILD_BATCH_SIZE 20)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
if (OMATH_STATIC_MSVC_RUNTIME_LIBRARY)
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
|
||||||
@@ -147,7 +153,6 @@ endif()
|
|||||||
|
|
||||||
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_23)
|
||||||
|
|
||||||
|
|
||||||
if(OMATH_BUILD_TESTS)
|
if(OMATH_BUILD_TESTS)
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_BUILD_TESTS)
|
target_compile_definitions(${PROJECT_NAME} PUBLIC OMATH_BUILD_TESTS)
|
||||||
@@ -164,7 +169,6 @@ if (OMATH_BUILD_EXAMPLES)
|
|||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND OMATH_THREAT_WARNING_AS_ERROR)
|
||||||
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
|
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
|
||||||
elseif(OMATH_THREAT_WARNING_AS_ERROR)
|
elseif(OMATH_THREAT_WARNING_AS_ERROR)
|
||||||
@@ -176,50 +180,52 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|||||||
target_compile_definitions(${PROJECT_NAME} INTERFACE NOMINMAX)
|
target_compile_definitions(${PROJECT_NAME} INTERFACE NOMINMAX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME}
|
target_include_directories(
|
||||||
PUBLIC
|
${PROJECT_NAME}
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Use this path when building the project
|
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> # Use this path
|
||||||
$<INSTALL_INTERFACE:include> # Use this path when the project is installed
|
# when building
|
||||||
|
# the project
|
||||||
|
$<INSTALL_INTERFACE:include> # Use this path when the project is
|
||||||
|
# installed
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Installation rules
|
# Installation rules
|
||||||
|
|
||||||
# Install the library
|
# Install the library
|
||||||
install(TARGETS ${PROJECT_NAME}
|
install(
|
||||||
|
TARGETS ${PROJECT_NAME}
|
||||||
EXPORT ${PROJECT_NAME}Targets
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
ARCHIVE DESTINATION lib COMPONENT ${PROJECT_NAME} # For static libraries
|
ARCHIVE DESTINATION lib COMPONENT ${PROJECT_NAME} # For static libraries
|
||||||
LIBRARY DESTINATION lib COMPONENT ${PROJECT_NAME} # For shared libraries
|
LIBRARY DESTINATION lib COMPONENT ${PROJECT_NAME} # For shared libraries
|
||||||
RUNTIME DESTINATION bin COMPONENT ${PROJECT_NAME} # For executables (on Windows)
|
RUNTIME DESTINATION bin COMPONENT ${PROJECT_NAME} # For executables (on
|
||||||
|
# Windows)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install headers as part of omath_component
|
# Install headers as part of omath_component
|
||||||
install(DIRECTORY include/ DESTINATION include COMPONENT ${PROJECT_NAME})
|
install(DIRECTORY include/ DESTINATION include COMPONENT ${PROJECT_NAME})
|
||||||
|
|
||||||
# Export omath target for CMake find_package support, also under omath_component
|
# Export omath target for CMake find_package support, also under omath_component
|
||||||
install(EXPORT ${PROJECT_NAME}Targets
|
install(
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
FILE ${PROJECT_NAME}Targets.cmake
|
FILE ${PROJECT_NAME}Targets.cmake
|
||||||
NAMESPACE ${PROJECT_NAME}::
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME} COMPONENT ${PROJECT_NAME}
|
DESTINATION lib/cmake/${PROJECT_NAME}
|
||||||
)
|
COMPONENT ${PROJECT_NAME})
|
||||||
|
|
||||||
# Generate the omathConfigVersion.cmake file
|
# Generate the omathConfigVersion.cmake file
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
|
VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion)
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
COMPATIBILITY AnyNewerVersion
|
|
||||||
)
|
|
||||||
|
|
||||||
# Generate the omathConfig.cmake file from the template (which is in the cmake/ folder)
|
# Generate the omathConfig.cmake file from the template (which is in the cmake/
|
||||||
|
# folder)
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/omathConfig.cmake.in" # Path to the .in file
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/omathConfig.cmake.in" # Path to the .in
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" # Output path for the generated file
|
# file
|
||||||
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
|
"${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" # Output path for the
|
||||||
)
|
# generated file
|
||||||
|
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
# Install the generated config files
|
# Install the generated config files
|
||||||
install(FILES
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake"
|
||||||
DESTINATION lib/cmake/${PROJECT_NAME}
|
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
)
|
|
||||||
|
|||||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
|||||||
Copyright (C) 2023-2025 Orange++ orange_github@proton.me
|
Copyright (C) 2023-2026 Orange++ orange_github@proton.me
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
project(omath_benchmark)
|
project(omath_benchmark)
|
||||||
|
|
||||||
|
|
||||||
file(GLOB_RECURSE OMATH_BENCHMARK_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
file(GLOB_RECURSE OMATH_BENCHMARK_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
||||||
add_executable(${PROJECT_NAME} ${OMATH_BENCHMARK_SOURCES})
|
add_executable(${PROJECT_NAME} ${OMATH_BENCHMARK_SOURCES})
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
${PROJECT_NAME}
|
||||||
|
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
CXX_STANDARD 23
|
CXX_STANDARD 23
|
||||||
@@ -14,7 +14,8 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
|
|||||||
if(TARGET benchmark::benchmark) # Benchmark is being linked as submodule
|
if(TARGET benchmark::benchmark) # Benchmark is being linked as submodule
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
||||||
else()
|
else()
|
||||||
find_package(benchmark CONFIG REQUIRED) # Benchmark is being linked as vcpkg package
|
find_package(benchmark CONFIG REQUIRED) # Benchmark is being linked as vcpkg
|
||||||
|
# package
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
target_link_libraries(${PROJECT_NAME} PRIVATE benchmark::benchmark omath)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -7,38 +7,23 @@ function(omath_setup_coverage TARGET_NAME)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping
|
||||||
-fprofile-instr-generate
|
/Zi)
|
||||||
-fcoverage-mapping
|
target_link_options(
|
||||||
/Zi
|
${TARGET_NAME}
|
||||||
)
|
PRIVATE
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
|
||||||
-fprofile-instr-generate
|
-fprofile-instr-generate
|
||||||
-fcoverage-mapping
|
-fcoverage-mapping
|
||||||
/DEBUG:FULL
|
/DEBUG:FULL
|
||||||
/INCREMENTAL:NO
|
/INCREMENTAL:NO
|
||||||
/PROFILE
|
/PROFILE)
|
||||||
)
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping
|
||||||
-fprofile-instr-generate
|
-g -O0)
|
||||||
-fcoverage-mapping
|
target_link_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
|
||||||
-g
|
|
||||||
-O0
|
|
||||||
)
|
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
|
||||||
-fprofile-instr-generate
|
|
||||||
-fcoverage-mapping
|
|
||||||
)
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
target_compile_options(${TARGET_NAME} PRIVATE
|
target_compile_options(${TARGET_NAME} PRIVATE --coverage -g -O0)
|
||||||
--coverage
|
target_link_options(${TARGET_NAME} PRIVATE --coverage)
|
||||||
-g
|
|
||||||
-O0
|
|
||||||
)
|
|
||||||
target_link_options(${TARGET_NAME} PRIVATE
|
|
||||||
--coverage
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TARGET coverage)
|
if(TARGET coverage)
|
||||||
@@ -47,40 +32,36 @@ function(omath_setup_coverage TARGET_NAME)
|
|||||||
|
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
||||||
message(STATUS "MSVC detected: Use VS Code Coverage from CI workflow")
|
message(STATUS "MSVC detected: Use VS Code Coverage from CI workflow")
|
||||||
add_custom_target(coverage
|
add_custom_target(
|
||||||
|
coverage
|
||||||
DEPENDS unit_tests
|
DEPENDS unit_tests
|
||||||
COMMAND $<TARGET_FILE:unit_tests>
|
COMMAND $<TARGET_FILE:unit_tests>
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
COMMENT "Running tests for coverage (use VS Code Coverage from CI)"
|
COMMENT "Running tests for coverage (use VS Code Coverage from CI)")
|
||||||
)
|
|
||||||
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang")
|
||||||
add_custom_target(coverage
|
add_custom_target(
|
||||||
|
coverage
|
||||||
DEPENDS unit_tests
|
DEPENDS unit_tests
|
||||||
COMMAND bash "${CMAKE_SOURCE_DIR}/scripts/coverage-llvm.sh"
|
COMMAND bash "${CMAKE_SOURCE_DIR}/scripts/coverage-llvm.sh" "${CMAKE_SOURCE_DIR}"
|
||||||
"${CMAKE_SOURCE_DIR}"
|
"${CMAKE_BINARY_DIR}" "$<TARGET_FILE:unit_tests>" "${CMAKE_BINARY_DIR}/coverage"
|
||||||
"${CMAKE_BINARY_DIR}"
|
|
||||||
"$<TARGET_FILE:unit_tests>"
|
|
||||||
"${CMAKE_BINARY_DIR}/coverage"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
COMMENT "Running LLVM coverage"
|
COMMENT "Running LLVM coverage")
|
||||||
)
|
|
||||||
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
add_custom_target(coverage
|
add_custom_target(
|
||||||
|
coverage
|
||||||
DEPENDS unit_tests
|
DEPENDS unit_tests
|
||||||
COMMAND $<TARGET_FILE:unit_tests> || true
|
COMMAND $<TARGET_FILE:unit_tests> || true
|
||||||
COMMAND lcov --capture --directory "${CMAKE_BINARY_DIR}"
|
COMMAND lcov --capture --directory "${CMAKE_BINARY_DIR}" --output-file
|
||||||
--output-file "${CMAKE_BINARY_DIR}/coverage.info"
|
"${CMAKE_BINARY_DIR}/coverage.info" --ignore-errors mismatch,gcov
|
||||||
--ignore-errors mismatch,gcov
|
COMMAND
|
||||||
COMMAND lcov --remove "${CMAKE_BINARY_DIR}/coverage.info"
|
lcov --remove "${CMAKE_BINARY_DIR}/coverage.info" "*/tests/*" "*/gtest/*"
|
||||||
"*/tests/*" "*/gtest/*" "*/googletest/*" "*/_deps/*" "/usr/*"
|
"*/googletest/*" "*/_deps/*" "/usr/*" --output-file
|
||||||
--output-file "${CMAKE_BINARY_DIR}/coverage.info"
|
"${CMAKE_BINARY_DIR}/coverage.info" --ignore-errors unused
|
||||||
--ignore-errors unused
|
COMMAND genhtml "${CMAKE_BINARY_DIR}/coverage.info" --output-directory
|
||||||
COMMAND genhtml "${CMAKE_BINARY_DIR}/coverage.info"
|
"${CMAKE_BINARY_DIR}/coverage"
|
||||||
--output-directory "${CMAKE_BINARY_DIR}/coverage"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||||
COMMENT "Running lcov/genhtml"
|
COMMENT "Running lcov/genhtml")
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -22,23 +22,19 @@ function(omath_setup_valgrind TARGET_NAME)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(VALGRIND_FLAGS
|
set(VALGRIND_FLAGS --leak-check=full --show-leak-kinds=all --track-origins=yes
|
||||||
--leak-check=full
|
--error-exitcode=99)
|
||||||
--show-leak-kinds=all
|
|
||||||
--track-origins=yes
|
|
||||||
--error-exitcode=99
|
|
||||||
)
|
|
||||||
|
|
||||||
set(VALGRIND_TARGET "valgrind_${TARGET_NAME}")
|
set(VALGRIND_TARGET "valgrind_${TARGET_NAME}")
|
||||||
|
|
||||||
if(NOT TARGET ${VALGRIND_TARGET})
|
if(NOT TARGET ${VALGRIND_TARGET})
|
||||||
add_custom_target(${VALGRIND_TARGET}
|
add_custom_target(
|
||||||
|
${VALGRIND_TARGET}
|
||||||
DEPENDS ${TARGET_NAME}
|
DEPENDS ${TARGET_NAME}
|
||||||
COMMAND ${VALGRIND_EXECUTABLE} ${VALGRIND_FLAGS} $<TARGET_FILE:${TARGET_NAME}>
|
COMMAND ${VALGRIND_EXECUTABLE} ${VALGRIND_FLAGS} $<TARGET_FILE:${TARGET_NAME}>
|
||||||
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
|
WORKING_DIRECTORY $<TARGET_FILE_DIR:${TARGET_NAME}>
|
||||||
COMMENT "Running Valgrind memory check on ${TARGET_NAME}..."
|
COMMENT "Running Valgrind memory check on ${TARGET_NAME}..."
|
||||||
USES_TERMINAL
|
USES_TERMINAL)
|
||||||
)
|
|
||||||
|
|
||||||
add_dependencies(valgrind_all ${VALGRIND_TARGET})
|
add_dependencies(valgrind_all ${VALGRIND_TARGET})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,34 +1,35 @@
|
|||||||
project(examples)
|
project(examples)
|
||||||
|
|
||||||
add_executable(example_projection_matrix_builder example_proj_mat_builder.cpp)
|
add_executable(example_projection_matrix_builder example_proj_mat_builder.cpp)
|
||||||
set_target_properties(example_projection_matrix_builder PROPERTIES
|
set_target_properties(
|
||||||
CXX_STANDARD 26
|
example_projection_matrix_builder
|
||||||
|
PROPERTIES CXX_STANDARD 23
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}")
|
||||||
)
|
|
||||||
target_link_libraries(example_projection_matrix_builder PRIVATE omath::omath)
|
target_link_libraries(example_projection_matrix_builder PRIVATE omath::omath)
|
||||||
|
|
||||||
add_executable(example_signature_scan example_signature_scan.cpp)
|
add_executable(example_signature_scan example_signature_scan.cpp)
|
||||||
set_target_properties(example_signature_scan PROPERTIES
|
set_target_properties(
|
||||||
CXX_STANDARD 26
|
example_signature_scan
|
||||||
|
PROPERTIES CXX_STANDARD 23
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}")
|
||||||
)
|
|
||||||
target_link_libraries(example_signature_scan PRIVATE omath::omath)
|
target_link_libraries(example_signature_scan PRIVATE omath::omath)
|
||||||
|
|
||||||
|
|
||||||
add_executable(example_glfw3 example_glfw3.cpp)
|
add_executable(example_glfw3 example_glfw3.cpp)
|
||||||
set_target_properties(example_glfw3 PROPERTIES CXX_STANDARD 26
|
set_target_properties(
|
||||||
|
example_glfw3
|
||||||
|
PROPERTIES CXX_STANDARD 23
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}")
|
||||||
)
|
|
||||||
|
|
||||||
|
find_package(OpenGL)
|
||||||
find_package(GLEW REQUIRED)
|
find_package(GLEW REQUIRED)
|
||||||
find_package(glfw3 CONFIG REQUIRED)
|
find_package(glfw3 CONFIG REQUIRED)
|
||||||
target_link_libraries(example_glfw3 PRIVATE omath::omath GLEW::GLEW glfw)
|
target_link_libraries(example_glfw3 PRIVATE omath::omath GLEW::GLEW glfw OpenGL::OpenGL)
|
||||||
|
|
||||||
if(OMATH_ENABLE_VALGRIND)
|
if(OMATH_ENABLE_VALGRIND)
|
||||||
omath_setup_valgrind(example_projection_matrix_builder)
|
omath_setup_valgrind(example_projection_matrix_builder)
|
||||||
|
|||||||
@@ -120,9 +120,14 @@ int main()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "GLFW Version: " << glfwGetVersionString() << "\n";
|
||||||
|
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
// Force GLX context creation API to ensure compatibility with GLEW
|
||||||
|
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_NATIVE_CONTEXT_API);
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
|
||||||
#endif
|
#endif
|
||||||
@@ -141,16 +146,31 @@ int main()
|
|||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
|
// Check if context is valid using standard GL
|
||||||
|
const GLubyte* renderer = glGetString(GL_RENDERER);
|
||||||
|
const GLubyte* version = glGetString(GL_VERSION);
|
||||||
|
if (renderer && version) {
|
||||||
|
std::cout << "Renderer: " << renderer << "\n";
|
||||||
|
std::cout << "OpenGL version supported: " << version << "\n";
|
||||||
|
} else {
|
||||||
|
std::cerr << "Failed to get GL_RENDERER or GL_VERSION. Context might be invalid.\n";
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- GLEW init ----------
|
// ---------- GLEW init ----------
|
||||||
glewExperimental = GL_TRUE;
|
glewExperimental = GL_TRUE;
|
||||||
GLenum glewErr = glewInit();
|
GLenum glewErr = glewInit();
|
||||||
if (glewErr != GLEW_OK)
|
if (glewErr != GLEW_OK)
|
||||||
{
|
{
|
||||||
|
// Ignore NO_GLX_DISPLAY if we have a valid context
|
||||||
|
if (glewErr == GLEW_ERROR_NO_GLX_DISPLAY && renderer) {
|
||||||
|
std::cerr << "GLEW warning: " << glewGetErrorString(glewErr) << " (Ignored because context seems valid)\n";
|
||||||
|
} else {
|
||||||
std::cerr << "Failed to initialize GLEW: " << reinterpret_cast<const char*>(glewGetErrorString(glewErr))
|
std::cerr << "Failed to initialize GLEW: " << reinterpret_cast<const char*>(glewGetErrorString(glewErr))
|
||||||
<< "\n";
|
<< "\n";
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- GL state ----------
|
// ---------- GL state ----------
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|||||||
@@ -3,14 +3,60 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/camera.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/traits/mesh_trait.hpp"
|
||||||
#include "omath/linear_algebra/triangle.hpp"
|
#include "omath/linear_algebra/triangle.hpp"
|
||||||
#include "omath/linear_algebra/vector3.hpp"
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace omath::primitives
|
namespace omath::primitives
|
||||||
{
|
{
|
||||||
|
template<class BoxMeshType>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
|
BoxMeshType create_box(const Vector3<float>& top, const Vector3<float>& bottom, const Vector3<float>& dir_forward,
|
||||||
const Vector3<float>& dir_forward, const Vector3<float>& dir_right,
|
const Vector3<float>& dir_right, const float ratio = 4.f) noexcept
|
||||||
float ratio = 4.f) noexcept;
|
{
|
||||||
|
const auto height = top.distance_to(bottom);
|
||||||
|
const auto side_size = height / ratio;
|
||||||
|
|
||||||
|
// corner layout (0‑3 bottom, 4‑7 top)
|
||||||
|
std::array<Vector3<float>, 8> p;
|
||||||
|
p[0] = bottom + (dir_forward + dir_right) * side_size; // front‑right‑bottom
|
||||||
|
p[1] = bottom + (dir_forward - dir_right) * side_size; // front‑left‑bottom
|
||||||
|
p[2] = bottom + (-dir_forward + dir_right) * side_size; // back‑right‑bottom
|
||||||
|
p[3] = bottom + (-dir_forward - dir_right) * side_size; // back‑left‑bottom
|
||||||
|
p[4] = top + (dir_forward + dir_right) * side_size; // front‑right‑top
|
||||||
|
p[5] = top + (dir_forward - dir_right) * side_size; // front‑left‑top
|
||||||
|
p[6] = top + (-dir_forward + dir_right) * side_size; // back‑right‑top
|
||||||
|
p[7] = top + (-dir_forward - dir_right) * side_size; // back‑left‑top
|
||||||
|
|
||||||
|
std::array<Vector3<std::uint32_t>, 12> poly;
|
||||||
|
|
||||||
|
// bottom face (+Y up ⇒ wind CW when viewed from above)
|
||||||
|
poly[0] = {0, 2, 3};
|
||||||
|
poly[1] = {0, 3, 1};
|
||||||
|
|
||||||
|
// top face
|
||||||
|
poly[2] = {4, 7, 6};
|
||||||
|
poly[3] = {4, 5, 7};
|
||||||
|
|
||||||
|
// front face
|
||||||
|
poly[4] = {0, 5, 1};
|
||||||
|
poly[5] = {0, 4, 5};
|
||||||
|
|
||||||
|
// right face
|
||||||
|
poly[6] = {0, 6, 2};
|
||||||
|
poly[7] = {0, 4, 6};
|
||||||
|
|
||||||
|
// back face
|
||||||
|
poly[8] = {2, 7, 3};
|
||||||
|
poly[9] = {2, 6, 7};
|
||||||
|
|
||||||
|
// left face
|
||||||
|
poly[10] = {1, 7, 5};
|
||||||
|
poly[11] = {1, 3, 7};
|
||||||
|
|
||||||
|
return BoxMeshType{std::move(p), std::move(poly)};
|
||||||
}
|
}
|
||||||
|
} // namespace omath::primitives
|
||||||
|
|||||||
@@ -25,16 +25,17 @@ namespace omath::primitives
|
|||||||
template<typename T> concept HasNormal = requires(T vertex) { vertex.normal; };
|
template<typename T> concept HasNormal = requires(T vertex) { vertex.normal; };
|
||||||
template<typename T> concept HasUv = requires(T vertex) { vertex.uv; };
|
template<typename T> concept HasUv = requires(T vertex) { vertex.uv; };
|
||||||
|
|
||||||
template<class Mat4X4, class RotationAngles, class MeshTypeTrait, class VertType = Vertex<>>
|
template<class Mat4X4, class RotationAngles, class MeshTypeTrait, class VertType = Vertex<>,
|
||||||
|
class VboType = std::vector<VertType>, class EboType = std::vector<Vector3<std::uint32_t>>>
|
||||||
class Mesh final
|
class Mesh final
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using VectorType = VertType::VectorType;
|
using VectorType = VertType::VectorType;
|
||||||
using VertexType = VertType;
|
using VertexType = VboType::value_type;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using Vbo = std::vector<VertexType>;
|
using Vbo = VboType;
|
||||||
using Ebo = std::vector<Vector3<std::uint32_t>>;
|
using Ebo = EboType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vbo m_vertex_buffer;
|
Vbo m_vertex_buffer;
|
||||||
@@ -100,21 +101,27 @@ namespace omath::primitives
|
|||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
VectorType vertex_position_to_world_space(const Vector3<float>& vertex_position) const
|
VectorType vertex_position_to_world_space(const Vector3<float>& vertex_position) const
|
||||||
requires HasPosition<VertexType>
|
|
||||||
{
|
{
|
||||||
auto abs_vec = get_to_world_matrix() * mat_column_from_vector<typename Mat4X4::ContainedType, Mat4X4::get_store_ordering()>(vertex_position);
|
auto abs_vec = get_to_world_matrix()
|
||||||
|
* mat_column_from_vector<typename Mat4X4::ContainedType, Mat4X4::get_store_ordering()>(
|
||||||
|
vertex_position);
|
||||||
|
|
||||||
return {abs_vec.at(0, 0), abs_vec.at(1, 0), abs_vec.at(2, 0)};
|
return {abs_vec.at(0, 0), abs_vec.at(1, 0), abs_vec.at(2, 0)};
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
Triangle<VectorType> make_face_in_world_space(const Ebo::const_iterator vao_iterator) const
|
Triangle<VectorType> make_face_in_world_space(const Ebo::const_iterator vao_iterator) const
|
||||||
requires HasPosition<VertexType>
|
{
|
||||||
|
if constexpr (HasPosition<VertexType>)
|
||||||
{
|
{
|
||||||
return {vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->x).position),
|
return {vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->x).position),
|
||||||
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->y).position),
|
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->y).position),
|
||||||
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->z).position)};
|
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->z).position)};
|
||||||
}
|
}
|
||||||
|
return {vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->x)),
|
||||||
|
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->y)),
|
||||||
|
vertex_position_to_world_space(m_vertex_buffer.at(vao_iterator->z))};
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VectorType m_origin;
|
VectorType m_origin;
|
||||||
|
|||||||
@@ -3,14 +3,30 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/camera.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/mesh.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/traits/mesh_trait.hpp"
|
||||||
#include "omath/linear_algebra/triangle.hpp"
|
#include "omath/linear_algebra/triangle.hpp"
|
||||||
#include "omath/linear_algebra/vector3.hpp"
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace omath::primitives
|
namespace omath::primitives
|
||||||
{
|
{
|
||||||
|
template<class PlaneMeshType>
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
std::array<Triangle<Vector3<float>>, 2> create_plane(const Vector3<float>& vertex_a,
|
PlaneMeshType create_plane(const Vector3<float>& vertex_a, const Vector3<float>& vertex_b,
|
||||||
const Vector3<float>& vertex_b,
|
const Vector3<float>& direction, const float size) noexcept
|
||||||
const Vector3<float>& direction, float size) noexcept;
|
{
|
||||||
|
const auto second_vertex_a = vertex_a + direction * size;
|
||||||
|
const auto second_vertex_b = vertex_b + direction * size;
|
||||||
|
|
||||||
|
std::array<Vector3<float>, 4> grid = {vertex_a, vertex_b, second_vertex_a, second_vertex_b};
|
||||||
|
|
||||||
|
std::array<Vector3<std::uint32_t>, 2> poly;
|
||||||
|
poly[0] = {1, 1, 2};
|
||||||
|
poly[1] = {0, 1, 3};
|
||||||
|
|
||||||
|
return PlaneMeshType(std::move(grid), std::move(poly));
|
||||||
}
|
}
|
||||||
|
} // namespace omath::primitives
|
||||||
|
|||||||
@@ -33,5 +33,25 @@ namespace omath::collision
|
|||||||
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
|
// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
|
static Vector3<float> get_ray_hit_point(const Ray& ray, const Triangle<Vector3<float>>& triangle) noexcept;
|
||||||
|
|
||||||
|
template<class MeshType>
|
||||||
|
[[nodiscard]]
|
||||||
|
static Vector3<float> get_ray_hit_point(const Ray& ray, const MeshType& mesh) noexcept
|
||||||
|
{
|
||||||
|
Vector3<float> mesh_hit = ray.end;
|
||||||
|
|
||||||
|
auto begin = mesh.m_element_buffer_object.cbegin();
|
||||||
|
auto end = mesh.m_element_buffer_object.cend();
|
||||||
|
for (auto current = begin; current < end; current = std::next(current))
|
||||||
|
{
|
||||||
|
auto face = mesh.make_face_in_world_space(current);
|
||||||
|
|
||||||
|
auto ray_stop_point = get_ray_hit_point(ray, face);
|
||||||
|
if (ray_stop_point.distance_to(ray.start) < mesh_hit.distance_to(ray.start))
|
||||||
|
mesh_hit = ray_stop_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mesh_hit;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
} // namespace omath::collision
|
} // namespace omath::collision
|
||||||
|
|||||||
201
include/omath/containers/encrypted_variable.hpp
Normal file
201
include/omath/containers/encrypted_variable.hpp
Normal file
@@ -0,0 +1,201 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 04.01.2026.
|
||||||
|
//
|
||||||
|
#pragma once
|
||||||
|
#include <array>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <span>
|
||||||
|
#ifdef OMATH_ENABLE_FORCE_INLINE
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define OMATH_FORCE_INLINE __forceinline
|
||||||
|
#else
|
||||||
|
#define OMATH_FORCE_INLINE __attribute__((always_inline)) inline
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define OMATH_FORCE_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace omath::detail
|
||||||
|
{
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t fnv1a_64(const char* s)
|
||||||
|
{
|
||||||
|
std::uint64_t h = 14695981039346656037ull;
|
||||||
|
while (*s)
|
||||||
|
{
|
||||||
|
h ^= static_cast<unsigned char>(*s++);
|
||||||
|
h *= 1099511628211ull;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SplitMix64 mixer (good quality for seeding / scrambling)
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t splitmix64(std::uint64_t x)
|
||||||
|
{
|
||||||
|
x += 0x9E3779B97F4A7C15ull;
|
||||||
|
x = (x ^ (x >> 30)) * 0xBF58476D1CE4E5B9ull;
|
||||||
|
x = (x ^ (x >> 27)) * 0x94D049BB133111EBull;
|
||||||
|
return x ^ (x >> 31);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Choose your policy:
|
||||||
|
// - If you want reproducible builds, REMOVE __DATE__/__TIME__.
|
||||||
|
// - If you want "different each build", keep them.
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t base_seed()
|
||||||
|
{
|
||||||
|
std::uint64_t h = 0;
|
||||||
|
h ^= fnv1a_64(__FILE__);
|
||||||
|
h ^= splitmix64(fnv1a_64(__DATE__));
|
||||||
|
h ^= splitmix64(fnv1a_64(__TIME__));
|
||||||
|
return splitmix64(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Produce a "random" 64-bit value for a given stream index (compile-time)
|
||||||
|
template<std::uint64_t Stream>
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t rand_u64()
|
||||||
|
{
|
||||||
|
// Stream is usually __COUNTER__ so each call site differs
|
||||||
|
return splitmix64(base_seed() + 0xD1B54A32D192ED03ull * (Stream + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t bounded_u64(const std::uint64_t x, const std::uint64_t bound)
|
||||||
|
{
|
||||||
|
return (x * bound) >> 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::int64_t Lo, std::int64_t Hi, std::uint64_t Stream>
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::int64_t rand_uint8_t()
|
||||||
|
{
|
||||||
|
static_assert(Lo <= Hi);
|
||||||
|
const std::uint64_t span = static_cast<std::uint64_t>(Hi - Lo) + 1ull;
|
||||||
|
const std::uint64_t r = rand_u64<Stream>();
|
||||||
|
return static_cast<std::int64_t>(bounded_u64(r, span)) + Lo;
|
||||||
|
}
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint64_t rand_u64(const std::uint64_t seed, const std::uint64_t i)
|
||||||
|
{
|
||||||
|
return splitmix64(seed + 0xD1B54A32D192ED03ull * (i + 1ull));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to int (uses low 32 bits; you can also use high bits if you prefer)
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::uint8_t rand_uint8t(const std::uint64_t seed, const std::uint64_t i)
|
||||||
|
{
|
||||||
|
return static_cast<std::uint8_t>(rand_u64(seed, i)); // narrowing is fine/deterministic
|
||||||
|
}
|
||||||
|
template<std::size_t N, std::uint64_t Seed, std::size_t... I>
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::array<std::uint8_t, N> make_array_impl(std::index_sequence<I...>)
|
||||||
|
{
|
||||||
|
return {rand_uint8t(Seed, static_cast<std::uint64_t>(I))...};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<std::size_t N, std::uint64_t Seed>
|
||||||
|
[[nodiscard]]
|
||||||
|
consteval std::array<std::uint8_t, N> make_array()
|
||||||
|
{
|
||||||
|
return make_array_impl<N, Seed>(std::make_index_sequence<N>{});
|
||||||
|
}
|
||||||
|
} // namespace omath::detail
|
||||||
|
|
||||||
|
namespace omath
|
||||||
|
{
|
||||||
|
template<class T>
|
||||||
|
class VarAnchor;
|
||||||
|
|
||||||
|
template<class T, std::size_t key_size, std::array<std::uint8_t, key_size> key>
|
||||||
|
class EncryptedVariable final
|
||||||
|
{
|
||||||
|
using value_type = std::remove_cvref_t<T>;
|
||||||
|
|
||||||
|
bool m_is_encrypted{};
|
||||||
|
value_type m_data{};
|
||||||
|
|
||||||
|
OMATH_FORCE_INLINE constexpr void xor_contained_var_by_key()
|
||||||
|
{
|
||||||
|
// Safe, keeps const-correctness, and avoids reinterpret_cast issues
|
||||||
|
auto bytes = std::as_writable_bytes(std::span<value_type, 1>{&m_data, 1});
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < bytes.size(); ++i)
|
||||||
|
{
|
||||||
|
const std::uint8_t k = static_cast<std::uint8_t>(key[i % key_size] + (i * key_size));
|
||||||
|
bytes[i] ^= static_cast<std::byte>(k);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
OMATH_FORCE_INLINE constexpr explicit EncryptedVariable(const value_type& data)
|
||||||
|
: m_is_encrypted(false), m_data(data)
|
||||||
|
{
|
||||||
|
encrypt();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr bool is_encrypted() const
|
||||||
|
{
|
||||||
|
return m_is_encrypted;
|
||||||
|
}
|
||||||
|
|
||||||
|
OMATH_FORCE_INLINE constexpr void decrypt()
|
||||||
|
{
|
||||||
|
if (!m_is_encrypted)
|
||||||
|
return;
|
||||||
|
xor_contained_var_by_key();
|
||||||
|
m_is_encrypted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OMATH_FORCE_INLINE constexpr void encrypt()
|
||||||
|
{
|
||||||
|
if (m_is_encrypted)
|
||||||
|
return;
|
||||||
|
xor_contained_var_by_key();
|
||||||
|
m_is_encrypted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] OMATH_FORCE_INLINE constexpr value_type& value()
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
[[nodiscard]] OMATH_FORCE_INLINE constexpr const value_type& value() const
|
||||||
|
{
|
||||||
|
return m_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr OMATH_FORCE_INLINE ~EncryptedVariable()
|
||||||
|
{
|
||||||
|
decrypt();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] constexpr OMATH_FORCE_INLINE auto drop_anchor()
|
||||||
|
{
|
||||||
|
return VarAnchor{*this};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class EncryptedVarType>
|
||||||
|
class VarAnchor final
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ReSharper disable once CppNonExplicitConvertingConstructor
|
||||||
|
OMATH_FORCE_INLINE constexpr VarAnchor(EncryptedVarType& var): m_var(var)
|
||||||
|
{
|
||||||
|
m_var.decrypt();
|
||||||
|
}
|
||||||
|
OMATH_FORCE_INLINE constexpr ~VarAnchor()
|
||||||
|
{
|
||||||
|
m_var.encrypt();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
EncryptedVarType& m_var;
|
||||||
|
};
|
||||||
|
} // namespace omath
|
||||||
|
|
||||||
|
#define OMATH_CT_RAND_ARRAY_BYTE(N) \
|
||||||
|
(::omath::detail::make_array<(N), (::omath::detail::base_seed() ^ static_cast<std::uint64_t>(__COUNTER__))>())
|
||||||
|
#define OMATH_DEF_CRYPT_VAR(TYPE, KEY_SIZE) omath::EncryptedVariable<TYPE, KEY_SIZE, OMATH_CT_RAND_ARRAY_BYTE(KEY_SIZE)>
|
||||||
17
include/omath/engines/frostbite_engine/primitives.hpp
Normal file
17
include/omath/engines/frostbite_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/frostbite_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::frostbite_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::frostbite_engine
|
||||||
17
include/omath/engines/iw_engine/primitives.hpp
Normal file
17
include/omath/engines/iw_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/iw_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::iw_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::iw_engine
|
||||||
17
include/omath/engines/opengl_engine/primitives.hpp
Normal file
17
include/omath/engines/opengl_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::opengl_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::opengl_engine
|
||||||
17
include/omath/engines/source_engine/primitives.hpp
Normal file
17
include/omath/engines/source_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/source_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::source_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::source_engine
|
||||||
17
include/omath/engines/unity_engine/primitives.hpp
Normal file
17
include/omath/engines/unity_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/unity_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::unity_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::unity_engine
|
||||||
17
include/omath/engines/unreal_engine/primitives.hpp
Normal file
17
include/omath/engines/unreal_engine/primitives.hpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 27.01.2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "mesh.hpp"
|
||||||
|
#include "omath/engines/unreal_engine/traits/mesh_trait.hpp"
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <array>
|
||||||
|
namespace omath::unreal_engine
|
||||||
|
{
|
||||||
|
using BoxMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>, std::array<Vector3<float>, 8>,
|
||||||
|
std::array<Vector3<std::uint32_t>, 12>>;
|
||||||
|
|
||||||
|
using PlaneMesh = primitives::Mesh<Mat4X4, ViewAngles, MeshTrait, primitives::Vertex<>,
|
||||||
|
std::array<Vector3<float>, 4>, std::array<Vector3<std::uint32_t>, 2>>;
|
||||||
|
} // namespace omath::unreal_engine
|
||||||
69
pixi.toml
Normal file
69
pixi.toml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
[workspace]
|
||||||
|
name = "omath"
|
||||||
|
version = "5.7.0"
|
||||||
|
description = "Cross-platform modern general purpose math library written in C++23 that suitable for cheat/game development."
|
||||||
|
authors = [
|
||||||
|
"orange-cpp <orange_github@proton.me>"
|
||||||
|
]
|
||||||
|
|
||||||
|
license = "Zlib"
|
||||||
|
license-file = "LICENSE"
|
||||||
|
readme = "README.md"
|
||||||
|
documentation = "http://libomath.org"
|
||||||
|
repository = "https://github.com/orange-cpp/omath"
|
||||||
|
|
||||||
|
channels = ["conda-forge"]
|
||||||
|
platforms = ["win-64", "linux-64", "linux-aarch64", "osx-64", "osx-arm64"]
|
||||||
|
|
||||||
|
[tasks]
|
||||||
|
format = { cwd = "pixi", cmd = "cmake -P fmt.cmake" }
|
||||||
|
configure = { cmd = "cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DOMATH_USE_AVX2=OFF -DOMATH_IMGUI_INTEGRATION=ON -DOMATH_BUILD_TESTS=ON -DOMATH_BUILD_BENCHMARK=ON -DOMATH_BUILD_EXAMPLES=ON .", depends-on = ["format"] }
|
||||||
|
build = { cmd = "cmake --build build --config Debug -j", depends-on = ["configure"] }
|
||||||
|
examples = { cwd = "pixi", cmd = "cmake -DCMAKE_BUILD_TYPE=Debug -P run.examples.cmake", depends-on = ["build"] }
|
||||||
|
tests = { cwd = "pixi", cmd = "cmake -DCMAKE_BUILD_TYPE=Debug -P run.unit.tests.cmake", depends-on = ["build"] }
|
||||||
|
benchmark = { cwd = "pixi", cmd = "cmake -DCMAKE_BUILD_TYPE=Debug -P run.benchmark.cmake", depends-on = ["build"] }
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
benchmark = ">=1.9.5,<2"
|
||||||
|
ccache = ">=4.12.2,<5"
|
||||||
|
cmake = ">=4.2.3,<5"
|
||||||
|
cmake-format = ">=0.6.13,<0.7"
|
||||||
|
cxx-compiler = ">=1.11.0,<2"
|
||||||
|
imgui = ">=1.92.3,<2"
|
||||||
|
gtest = ">=1.17.0,<2"
|
||||||
|
glew = ">=2.3.0,<3"
|
||||||
|
glfw = ">=3.4,<4"
|
||||||
|
ninja = ">=1.13.2,<2"
|
||||||
|
|
||||||
|
[target.linux-64.dependencies]
|
||||||
|
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
||||||
|
xorg-x11-server-xvfb-cos7-x86_64 = ">=1.20.4,<2"
|
||||||
|
|
||||||
|
[target.linux-64.activation.env]
|
||||||
|
__GLX_VENDOR_LIBRARY_NAME = "mesa"
|
||||||
|
EGL_PLATFORM = "x11"
|
||||||
|
GLFW_PLATFORM = "x11"
|
||||||
|
|
||||||
|
[target.linux-64.tasks]
|
||||||
|
examples = { cwd = "pixi", cmd = "xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX +render' cmake -DCMAKE_BUILD_TYPE=Debug -P run.examples.cmake", depends-on = ["build"] }
|
||||||
|
|
||||||
|
[target.win-64.dependencies]
|
||||||
|
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
||||||
|
|
||||||
|
[target.osx-64.dependencies]
|
||||||
|
mesa-libgl-devel-cos7-x86_64 = ">=18.3.4,<19"
|
||||||
|
|
||||||
|
[target.osx-arm64.dependencies]
|
||||||
|
mesa-libgl-devel-cos7-aarch64 = ">=18.3.4,<19"
|
||||||
|
|
||||||
|
[target.linux-aarch64.dependencies]
|
||||||
|
mesa-libgl-devel-cos7-aarch64 = ">=18.3.4,<19"
|
||||||
|
xorg-x11-server-xvfb-cos7-aarch64 = ">=1.20.4,<2"
|
||||||
|
|
||||||
|
[target.linux-aarch64.activation.env]
|
||||||
|
__GLX_VENDOR_LIBRARY_NAME = "mesa"
|
||||||
|
EGL_PLATFORM = "x11"
|
||||||
|
GLFW_PLATFORM = "x11"
|
||||||
|
|
||||||
|
[target.linux-aarch64.tasks]
|
||||||
|
examples = { cwd = "pixi", cmd = "xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX +render' cmake -DCMAKE_BUILD_TYPE=Debug -P run.examples.cmake", depends-on = ["build"] }
|
||||||
36
pixi/fmt.cmake
Normal file
36
pixi/fmt.cmake
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# cmake/Format.cmake
|
||||||
|
|
||||||
|
# Find cmake-format executable
|
||||||
|
find_program(CMAKE_FORMAT_EXECUTABLE NAMES cmake-format)
|
||||||
|
|
||||||
|
if(NOT CMAKE_FORMAT_EXECUTABLE)
|
||||||
|
message(FATAL_ERROR "cmake-format not found. Please install it first.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Get the project root directory (assuming this script is in cmake/
|
||||||
|
# subdirectory)
|
||||||
|
get_filename_component(PROJECT_ROOT "../${CMAKE_CURRENT_LIST_DIR}" ABSOLUTE)
|
||||||
|
|
||||||
|
# Iterate over all files in the project root
|
||||||
|
file(GLOB_RECURSE ALL_FILES "${PROJECT_ROOT}/*")
|
||||||
|
|
||||||
|
foreach(FILE ${ALL_FILES})
|
||||||
|
# Basic ignores for common directories to avoid formatting external/build
|
||||||
|
# files Note: We check for substrings in the full path
|
||||||
|
if("${FILE}" MATCHES "/\\.git/"
|
||||||
|
OR "${FILE}" MATCHES "/build/"
|
||||||
|
OR "${FILE}" MATCHES "/cmake-build/"
|
||||||
|
OR "${FILE}" MATCHES "/\\.pixi/"
|
||||||
|
OR "${FILE}" MATCHES "/vcpkg_installed/")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(FILENAME "${FILE}" NAME)
|
||||||
|
|
||||||
|
# Check if file ends with .cmake or matches exactly to CMakeLists.txt
|
||||||
|
if("${FILENAME}" STREQUAL "CMakeLists.txt" OR "${FILENAME}" MATCHES "\\.cmake$")
|
||||||
|
message(STATUS "Formatting ${FILE}")
|
||||||
|
execute_process(COMMAND ${CMAKE_FORMAT_EXECUTABLE} --config-files
|
||||||
|
"${PROJECT_ROOT}/.cmake-format" -i "${FILE}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
63
pixi/run.benchmark.cmake
Normal file
63
pixi/run.benchmark.cmake
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# cmake/run.examples.cmake
|
||||||
|
|
||||||
|
# Get the project root directory (assuming this script is in cmake/ subdirectory)
|
||||||
|
get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||||
|
|
||||||
|
# Default to Debug if CMAKE_BUILD_TYPE is not specified
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
else()
|
||||||
|
message(STATUS "CMAKE_BUILD_TYPE is set to: ${CMAKE_BUILD_TYPE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define the directory where executables are located
|
||||||
|
# Based on CMakeLists.txt: "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
|
set(EXAMPLES_BIN_DIR "${PROJECT_ROOT}/out/${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${EXAMPLES_BIN_DIR}")
|
||||||
|
message(FATAL_ERROR "Examples binary directory not found: ${EXAMPLES_BIN_DIR}. Please build the project first.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Looking for benchmark executables in: ${EXAMPLES_BIN_DIR}")
|
||||||
|
|
||||||
|
# Find all files starting with "omath_benchmark"
|
||||||
|
file(GLOB EXAMPLE_FILES "${EXAMPLES_BIN_DIR}/omath_benchmark*")
|
||||||
|
|
||||||
|
foreach(EXAMPLE_PATH ${EXAMPLE_FILES})
|
||||||
|
# Skip directories
|
||||||
|
if(IS_DIRECTORY "${EXAMPLE_PATH}")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(FILENAME "${EXAMPLE_PATH}" NAME)
|
||||||
|
get_filename_component(EXTENSION "${EXAMPLE_PATH}" EXT)
|
||||||
|
|
||||||
|
# Filter out potential debug symbols or non-executable artifacts
|
||||||
|
if(EXTENSION STREQUAL ".pdb" OR EXTENSION STREQUAL ".ilk" OR EXTENSION STREQUAL ".obj")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Windows, we expect .exe
|
||||||
|
if(MSVC AND NOT EXTENSION STREQUAL ".exe")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Linux/macOS, check permissions or just try to run it.
|
||||||
|
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
message(STATUS "Running benchmark: ${FILENAME}")
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${EXAMPLE_PATH}"
|
||||||
|
WORKING_DIRECTORY "${PROJECT_ROOT}"
|
||||||
|
RESULT_VARIABLE EXIT_CODE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT EXIT_CODE EQUAL 0)
|
||||||
|
message(WARNING "Benchmark ${FILENAME} exited with error code: ${EXIT_CODE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Benchmark ${FILENAME} completed successfully.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
63
pixi/run.examples.cmake
Normal file
63
pixi/run.examples.cmake
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# cmake/run.examples.cmake
|
||||||
|
|
||||||
|
# Get the project root directory (assuming this script is in cmake/ subdirectory)
|
||||||
|
get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||||
|
|
||||||
|
# Default to Debug if CMAKE_BUILD_TYPE is not specified
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
else()
|
||||||
|
message(STATUS "CMAKE_BUILD_TYPE is set to: ${CMAKE_BUILD_TYPE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define the directory where executables are located
|
||||||
|
# Based on CMakeLists.txt: "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
|
set(EXAMPLES_BIN_DIR "${PROJECT_ROOT}/out/${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${EXAMPLES_BIN_DIR}")
|
||||||
|
message(FATAL_ERROR "Examples binary directory not found: ${EXAMPLES_BIN_DIR}. Please build the project first.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Looking for example executables in: ${EXAMPLES_BIN_DIR}")
|
||||||
|
|
||||||
|
# Find all files starting with "example_"
|
||||||
|
file(GLOB EXAMPLE_FILES "${EXAMPLES_BIN_DIR}/example_*")
|
||||||
|
|
||||||
|
foreach(EXAMPLE_PATH ${EXAMPLE_FILES})
|
||||||
|
# Skip directories
|
||||||
|
if(IS_DIRECTORY "${EXAMPLE_PATH}")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(FILENAME "${EXAMPLE_PATH}" NAME)
|
||||||
|
get_filename_component(EXTENSION "${EXAMPLE_PATH}" EXT)
|
||||||
|
|
||||||
|
# Filter out potential debug symbols or non-executable artifacts
|
||||||
|
if(EXTENSION STREQUAL ".pdb" OR EXTENSION STREQUAL ".ilk" OR EXTENSION STREQUAL ".obj")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Windows, we expect .exe
|
||||||
|
if(MSVC AND NOT EXTENSION STREQUAL ".exe")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Linux/macOS, check permissions or just try to run it.
|
||||||
|
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
message(STATUS "Running example: ${FILENAME}")
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${EXAMPLE_PATH}"
|
||||||
|
WORKING_DIRECTORY "${PROJECT_ROOT}"
|
||||||
|
RESULT_VARIABLE EXIT_CODE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT EXIT_CODE EQUAL 0)
|
||||||
|
message(WARNING "Example ${FILENAME} exited with error code: ${EXIT_CODE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Example ${FILENAME} completed successfully.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
63
pixi/run.unit.tests.cmake
Normal file
63
pixi/run.unit.tests.cmake
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# cmake/run.examples.cmake
|
||||||
|
|
||||||
|
# Get the project root directory (assuming this script is in cmake/ subdirectory)
|
||||||
|
get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||||
|
|
||||||
|
# Default to Debug if CMAKE_BUILD_TYPE is not specified
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE "Debug")
|
||||||
|
else()
|
||||||
|
message(STATUS "CMAKE_BUILD_TYPE is set to: ${CMAKE_BUILD_TYPE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Define the directory where executables are located
|
||||||
|
# Based on CMakeLists.txt: "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
|
set(EXAMPLES_BIN_DIR "${PROJECT_ROOT}/out/${CMAKE_BUILD_TYPE}")
|
||||||
|
|
||||||
|
if(NOT EXISTS "${EXAMPLES_BIN_DIR}")
|
||||||
|
message(FATAL_ERROR "Examples binary directory not found: ${EXAMPLES_BIN_DIR}. Please build the project first.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Looking for unit test executables in: ${EXAMPLES_BIN_DIR}")
|
||||||
|
|
||||||
|
# Find all files starting with "unit_tests"
|
||||||
|
file(GLOB EXAMPLE_FILES "${EXAMPLES_BIN_DIR}/unit_tests*")
|
||||||
|
|
||||||
|
foreach(EXAMPLE_PATH ${EXAMPLE_FILES})
|
||||||
|
# Skip directories
|
||||||
|
if(IS_DIRECTORY "${EXAMPLE_PATH}")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(FILENAME "${EXAMPLE_PATH}" NAME)
|
||||||
|
get_filename_component(EXTENSION "${EXAMPLE_PATH}" EXT)
|
||||||
|
|
||||||
|
# Filter out potential debug symbols or non-executable artifacts
|
||||||
|
if(EXTENSION STREQUAL ".pdb" OR EXTENSION STREQUAL ".ilk" OR EXTENSION STREQUAL ".obj")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Windows, we expect .exe
|
||||||
|
if(MSVC AND NOT EXTENSION STREQUAL ".exe")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# On Linux/macOS, check permissions or just try to run it.
|
||||||
|
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
message(STATUS "Running unit_tests: ${FILENAME}")
|
||||||
|
message(STATUS "-------------------------------------------------")
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${EXAMPLE_PATH}"
|
||||||
|
WORKING_DIRECTORY "${PROJECT_ROOT}"
|
||||||
|
RESULT_VARIABLE EXIT_CODE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT EXIT_CODE EQUAL 0)
|
||||||
|
message(WARNING "Example ${FILENAME} exited with error code: ${EXIT_CODE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "Example ${FILENAME} completed successfully.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endforeach()
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Vlad on 4/18/2025.
|
|
||||||
//
|
|
||||||
#include "omath/3d_primitives/box.hpp"
|
|
||||||
|
|
||||||
namespace omath::primitives
|
|
||||||
{
|
|
||||||
std::array<Triangle<Vector3<float>>, 12> create_box(const Vector3<float>& top, const Vector3<float>& bottom,
|
|
||||||
const Vector3<float>& dir_forward,
|
|
||||||
const Vector3<float>& dir_right, const float ratio) noexcept
|
|
||||||
{
|
|
||||||
const auto height = top.distance_to(bottom);
|
|
||||||
const auto side_size = height / ratio;
|
|
||||||
|
|
||||||
// corner layout (0‑3 bottom, 4‑7 top)
|
|
||||||
std::array<Vector3<float>, 8> p;
|
|
||||||
p[0] = bottom + (dir_forward + dir_right) * side_size; // front‑right‑bottom
|
|
||||||
p[1] = bottom + (dir_forward - dir_right) * side_size; // front‑left‑bottom
|
|
||||||
p[2] = bottom + (-dir_forward + dir_right) * side_size; // back‑right‑bottom
|
|
||||||
p[3] = bottom + (-dir_forward - dir_right) * side_size; // back‑left‑bottom
|
|
||||||
p[4] = top + (dir_forward + dir_right) * side_size; // front‑right‑top
|
|
||||||
p[5] = top + (dir_forward - dir_right) * side_size; // front‑left‑top
|
|
||||||
p[6] = top + (-dir_forward + dir_right) * side_size; // back‑right‑top
|
|
||||||
p[7] = top + (-dir_forward - dir_right) * side_size; // back‑left‑top
|
|
||||||
|
|
||||||
std::array<Triangle<Vector3<float>>, 12> poly;
|
|
||||||
|
|
||||||
// bottom face (+Y up ⇒ wind CW when viewed from above)
|
|
||||||
poly[0] = {p[0], p[2], p[3]};
|
|
||||||
poly[1] = {p[0], p[3], p[1]};
|
|
||||||
|
|
||||||
// top face
|
|
||||||
poly[2] = {p[4], p[7], p[6]};
|
|
||||||
poly[3] = {p[4], p[5], p[7]};
|
|
||||||
|
|
||||||
// front face
|
|
||||||
poly[4] = {p[0], p[5], p[1]};
|
|
||||||
poly[5] = {p[0], p[4], p[5]};
|
|
||||||
|
|
||||||
// right face
|
|
||||||
poly[6] = {p[0], p[6], p[2]};
|
|
||||||
poly[7] = {p[0], p[4], p[6]};
|
|
||||||
|
|
||||||
// back face
|
|
||||||
poly[8] = {p[2], p[7], p[3]};
|
|
||||||
poly[9] = {p[2], p[6], p[7]};
|
|
||||||
|
|
||||||
// left face
|
|
||||||
poly[10] = {p[1], p[7], p[5]};
|
|
||||||
poly[11] = {p[1], p[3], p[7]};
|
|
||||||
|
|
||||||
return poly;
|
|
||||||
}
|
|
||||||
} // namespace omath::primitives
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by Vlad on 8/28/2025.
|
|
||||||
//
|
|
||||||
#include "omath/3d_primitives/plane.hpp"
|
|
||||||
|
|
||||||
namespace omath::primitives
|
|
||||||
{
|
|
||||||
std::array<Triangle<Vector3<float>>, 2> create_plane(const Vector3<float>& vertex_a,
|
|
||||||
const Vector3<float>& vertex_b,
|
|
||||||
const Vector3<float>& direction, const float size) noexcept
|
|
||||||
{
|
|
||||||
const auto second_vertex_a = vertex_a + direction * size;
|
|
||||||
return std::array
|
|
||||||
{
|
|
||||||
Triangle{second_vertex_a, vertex_a, vertex_b},
|
|
||||||
Triangle{second_vertex_a, vertex_b + direction * size, vertex_b}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
} // namespace omath::primitives
|
|
||||||
@@ -237,7 +237,7 @@ namespace
|
|||||||
variant);
|
variant);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ExtractedSection
|
struct ExtractedSection final
|
||||||
{
|
{
|
||||||
std::uintptr_t virtual_base_addr;
|
std::uintptr_t virtual_base_addr;
|
||||||
std::uintptr_t raw_base_addr;
|
std::uintptr_t raw_base_addr;
|
||||||
|
|||||||
@@ -7,8 +7,9 @@ include(GoogleTest)
|
|||||||
file(GLOB_RECURSE UNIT_TESTS_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
file(GLOB_RECURSE UNIT_TESTS_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
|
||||||
add_executable(${PROJECT_NAME} ${UNIT_TESTS_SOURCES})
|
add_executable(${PROJECT_NAME} ${UNIT_TESTS_SOURCES})
|
||||||
|
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
set_target_properties(
|
||||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
${PROJECT_NAME}
|
||||||
|
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/out/${CMAKE_BUILD_TYPE}"
|
||||||
CXX_STANDARD 23
|
CXX_STANDARD 23
|
||||||
@@ -30,7 +31,8 @@ if(OMATH_ENABLE_VALGRIND)
|
|||||||
omath_setup_valgrind(${PROJECT_NAME})
|
omath_setup_valgrind(${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Skip test discovery for Android/iOS builds or when cross-compiling - binaries cannot run on host
|
# Skip test discovery for Android/iOS builds or when cross-compiling - binaries
|
||||||
|
# cannot run on host
|
||||||
if(NOT (ANDROID OR IOS OR EMSCRIPTEN))
|
if(NOT (ANDROID OR IOS OR EMSCRIPTEN))
|
||||||
gtest_discover_tests(${PROJECT_NAME})
|
gtest_discover_tests(${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
16
tests/general/unit_test_primitive_box.cpp
Normal file
16
tests/general/unit_test_primitive_box.cpp
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 11.01.2026.
|
||||||
|
//
|
||||||
|
#include "omath/3d_primitives/box.hpp"
|
||||||
|
#include "omath/collision/line_tracer.hpp"
|
||||||
|
#include "omath/engines/opengl_engine/primitives.hpp"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
TEST(test, test)
|
||||||
|
{
|
||||||
|
auto result = omath::primitives::create_box<omath::opengl_engine::BoxMesh>(
|
||||||
|
{0.f, 30.f, 0.f}, {}, omath::opengl_engine::k_abs_forward, omath::opengl_engine::k_abs_right);
|
||||||
|
|
||||||
|
omath::collision::Ray ray{.start = {0, 0, 0}, .end = {-100, 0, 0}};
|
||||||
|
std::ignore = omath::collision::LineTracer::get_ray_hit_point(ray, result);
|
||||||
|
}
|
||||||
17
tests/general/unit_test_var_encryption.cpp
Normal file
17
tests/general/unit_test_var_encryption.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by Vladislav on 04.01.2026.
|
||||||
|
//
|
||||||
|
#include "omath/linear_algebra/vector3.hpp"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <omath/containers/encrypted_variable.hpp>
|
||||||
|
TEST(Enc, Test)
|
||||||
|
{
|
||||||
|
constexpr omath::Vector3<float> original = {1.f, 2.f, 3.f};
|
||||||
|
OMATH_DEF_CRYPT_VAR(omath::Vector3<float>, 128) var{original};
|
||||||
|
{
|
||||||
|
omath::VarAnchor _ = var.drop_anchor();
|
||||||
|
|
||||||
|
EXPECT_EQ(original, var.value());
|
||||||
|
}
|
||||||
|
EXPECT_NE(original, var.value());
|
||||||
|
}
|
||||||
8
tests/main.cpp
Normal file
8
tests/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
113
xmake.lua
Normal file
113
xmake.lua
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
add_rules("mode.debug", "mode.release")
|
||||||
|
|
||||||
|
add_rules("utils.install.cmake_importfiles")
|
||||||
|
add_rules("utils.install.pkgconfig_importfiles")
|
||||||
|
|
||||||
|
set_version("4.6.1", {soname = "4.6"})
|
||||||
|
set_languages("cxx23")
|
||||||
|
set_warnings("all")
|
||||||
|
|
||||||
|
option("avx2")
|
||||||
|
set_default(true)
|
||||||
|
set_showmenu(true)
|
||||||
|
|
||||||
|
after_check(function (option)
|
||||||
|
import("core.base.cpu")
|
||||||
|
option:enable(cpu.has_feature("avx2"))
|
||||||
|
end)
|
||||||
|
option_end()
|
||||||
|
|
||||||
|
option("imgui")
|
||||||
|
set_default(true)
|
||||||
|
set_showmenu(true)
|
||||||
|
option_end()
|
||||||
|
|
||||||
|
option("examples")
|
||||||
|
set_default(true)
|
||||||
|
set_showmenu(true)
|
||||||
|
option_end()
|
||||||
|
|
||||||
|
option("tests")
|
||||||
|
set_default(true)
|
||||||
|
set_showmenu(true)
|
||||||
|
option_end()
|
||||||
|
|
||||||
|
if has_config("avx2") then
|
||||||
|
add_defines("OMATH_ENABLE_AVX2")
|
||||||
|
add_vectorexts("avx2")
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_config("imgui") then
|
||||||
|
add_defines("OMATH_IMGUI_INTEGRATION")
|
||||||
|
add_requires("imgui")
|
||||||
|
add_packages("imgui")
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_config("examples") then
|
||||||
|
add_requires("glew", "glfw")
|
||||||
|
end
|
||||||
|
|
||||||
|
if has_config("tests") then
|
||||||
|
add_requires("gtest")
|
||||||
|
end
|
||||||
|
|
||||||
|
target("omath")
|
||||||
|
set_kind("static")
|
||||||
|
add_files("source/**.cpp")
|
||||||
|
add_includedirs("include", {public = true})
|
||||||
|
add_headerfiles("include/(**.hpp)", {prefixdir = "omath"})
|
||||||
|
on_config(function (target)
|
||||||
|
if has_config("avx2") then
|
||||||
|
cprint("${green} ✔️ AVX2 supported")
|
||||||
|
else
|
||||||
|
cprint("${red} ❌ AVX2 not supported")
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
target("example_projection_matrix_builder")
|
||||||
|
set_languages("cxx26")
|
||||||
|
set_kind("binary")
|
||||||
|
add_files("examples/example_proj_mat_builder.cpp")
|
||||||
|
add_deps("omath")
|
||||||
|
set_enabled(has_config("examples"))
|
||||||
|
|
||||||
|
target("example_signature_scan")
|
||||||
|
set_languages("cxx26")
|
||||||
|
set_kind("binary")
|
||||||
|
add_files("examples/example_signature_scan.cpp")
|
||||||
|
add_deps("omath")
|
||||||
|
set_enabled(has_config("examples"))
|
||||||
|
|
||||||
|
target("example_glfw3")
|
||||||
|
set_languages("cxx26")
|
||||||
|
set_kind("binary")
|
||||||
|
add_files("examples/example_glfw3.cpp")
|
||||||
|
add_deps("omath")
|
||||||
|
add_packages("glew", "glfw")
|
||||||
|
set_enabled(has_config("examples"))
|
||||||
|
|
||||||
|
for _, file in ipairs(os.files("tests/**.cpp")) do
|
||||||
|
local name = path.basename(file)
|
||||||
|
target(name)
|
||||||
|
set_languages("cxx23")
|
||||||
|
set_kind("binary")
|
||||||
|
add_files(file, "tests/main.cpp")
|
||||||
|
add_deps("omath")
|
||||||
|
add_packages("gtest")
|
||||||
|
add_defines("OMATH_BUILD_TESTS")
|
||||||
|
add_tests("default")
|
||||||
|
set_default(false)
|
||||||
|
set_enabled(has_config("tests"))
|
||||||
|
end
|
||||||
|
|
||||||
|
task("check")
|
||||||
|
on_run(function ()
|
||||||
|
import("core.project.task")
|
||||||
|
for _, file in ipairs(os.files("tests/**.cpp")) do
|
||||||
|
local name = path.basename(file)
|
||||||
|
task.run("run", {target = name})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
set_menu {
|
||||||
|
usage = "xmake check", description = "Run tests !", options = {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user