mirror of
https://github.com/slendidev/smath.git
synced 2026-08-06 10:49:39 +03:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c390ef3761 | ||
|
|
4a6f7df498 | ||
|
|
720d3edfe3 | ||
|
|
14873489ed | ||
|
|
01a917880f | ||
|
|
aea3be7158 |
@@ -0,0 +1,24 @@
|
|||||||
|
name: Format checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
format:
|
||||||
|
name: Format
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: git checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Nix
|
||||||
|
uses: DeterminateSystems/nix-installer-action@main
|
||||||
|
- name: Check clang-format
|
||||||
|
run: |
|
||||||
|
nix develop -c sh -lc 'git ls-files "*.cpp" "*.hpp" "*.cppm" | xargs clang-format --dry-run --Werror'
|
||||||
|
- name: Check cmake-format
|
||||||
|
run: |
|
||||||
|
nix develop -c sh -lc 'cmake-format --check CMakeLists.txt src/modules/CMakeLists.txt cmake/smathConfig.cmake.in'
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
# AGENTS.md
|
||||||
|
|
||||||
|
Instructions for agents working in this repo.
|
||||||
|
|
||||||
|
See the [`CONTRIBUTING.md`](CONTRIBUTING.md) file. Said file **must** be read, examined,
|
||||||
|
and understood before any change is made by agents.
|
||||||
|
|
||||||
|
For agents that understand `@`-inclusion of other markdown files, said inclusion line for
|
||||||
|
`CONTRIBUTING.md` follows, such that explicit reading of the file is not necessary:
|
||||||
|
|
||||||
|
@CONTRIBUTING.md
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# CLAUDE.md
|
||||||
|
|
||||||
|
This project's agent guidance lives in [AGENTS.md](AGENTS.md), the single source of truth
|
||||||
|
shared with other tools. Claude Code does not load `AGENTS.md` automatically, so it is
|
||||||
|
imported here:
|
||||||
|
|
||||||
|
@AGENTS.md
|
||||||
+59
-71
@@ -1,5 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
project(SmathExamples LANGUAGES CXX VERSION 1.0.0)
|
project(
|
||||||
|
SmathExamples
|
||||||
|
LANGUAGES CXX
|
||||||
|
VERSION 1.0.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 23)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
@@ -11,105 +14,90 @@ option(SMATH_ENABLE_LEGACY_HEADER "Install legacy include <smath.hpp> shim" OFF)
|
|||||||
option(SMATH_INSTALL_INTEROP_HEADERS "Install interop headers" OFF)
|
option(SMATH_INSTALL_INTEROP_HEADERS "Install interop headers" OFF)
|
||||||
|
|
||||||
if(SMATH_BUILD_MODULES)
|
if(SMATH_BUILD_MODULES)
|
||||||
message(STATUS "Building smath C++ module")
|
message(STATUS "Building smath C++ module")
|
||||||
add_subdirectory(src/modules)
|
add_subdirectory(src/modules)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(smath INTERFACE)
|
add_library(smath INTERFACE)
|
||||||
target_include_directories(smath
|
target_include_directories(
|
||||||
INTERFACE
|
smath
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
INTERFACE
|
||||||
$<$<BOOL:${SMATH_ENABLE_LEGACY_HEADER}>:$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<$<BOOL:${SMATH_ENABLE_LEGACY_HEADER}>:$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>>
|
||||||
)
|
$<INSTALL_INTERFACE:include>)
|
||||||
add_library(smath::smath ALIAS smath)
|
add_library(smath::smath ALIAS smath)
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
install(TARGETS smath
|
install(TARGETS smath EXPORT smathTargets)
|
||||||
EXPORT smathTargets
|
|
||||||
)
|
|
||||||
install(FILES include/smath/smath.hpp DESTINATION include/smath)
|
install(FILES include/smath/smath.hpp DESTINATION include/smath)
|
||||||
|
|
||||||
if(SMATH_INSTALL_INTEROP_HEADERS)
|
if(SMATH_INSTALL_INTEROP_HEADERS)
|
||||||
install(DIRECTORY include/smath/interop DESTINATION include/smath)
|
install(DIRECTORY include/smath/interop DESTINATION include/smath)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SMATH_ENABLE_LEGACY_HEADER)
|
if(SMATH_ENABLE_LEGACY_HEADER)
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||||
configure_file(
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath_legacy_header.hpp.in"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath_legacy_header.hpp.in"
|
"${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp" @ONLY)
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp"
|
||||||
@ONLY
|
DESTINATION include)
|
||||||
)
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/smath.hpp" DESTINATION include)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(EXPORT smathTargets
|
install(
|
||||||
NAMESPACE smath::
|
EXPORT smathTargets
|
||||||
FILE smathTargets.cmake
|
NAMESPACE smath::
|
||||||
DESTINATION lib/cmake/smath
|
FILE smathTargets.cmake
|
||||||
)
|
DESTINATION lib/cmake/smath)
|
||||||
|
|
||||||
write_basic_package_version_file(
|
write_basic_package_version_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake"
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
COMPATIBILITY SameMajorVersion
|
COMPATIBILITY SameMajorVersion)
|
||||||
)
|
|
||||||
|
|
||||||
configure_package_config_file(
|
configure_package_config_file(
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/smathConfig.cmake.in"
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/smathConfig.cmake.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake"
|
||||||
INSTALL_DESTINATION "lib/cmake/smath"
|
INSTALL_DESTINATION "lib/cmake/smath")
|
||||||
)
|
|
||||||
|
|
||||||
configure_file(
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath.pc.in"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/smath.pc.in"
|
"${CMAKE_CURRENT_BINARY_DIR}/smath.pc" @ONLY)
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/smath.pc"
|
|
||||||
@ONLY
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smath.pc"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smath.pc" DESTINATION lib/pkgconfig)
|
||||||
DESTINATION lib/pkgconfig
|
|
||||||
)
|
|
||||||
|
|
||||||
install(FILES
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/smathConfig.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/smathConfigVersion.cmake"
|
DESTINATION lib/cmake/smath)
|
||||||
DESTINATION lib/cmake/smath
|
|
||||||
)
|
|
||||||
|
|
||||||
if(SMATH_BUILD_EXAMPLES)
|
if(SMATH_BUILD_EXAMPLES)
|
||||||
file(GLOB EXAMPLE_SOURCES "${CMAKE_SOURCE_DIR}/examples/*.cpp")
|
file(GLOB EXAMPLE_SOURCES "${CMAKE_SOURCE_DIR}/examples/*.cpp")
|
||||||
foreach(EXAMPLE_FILE ${EXAMPLE_SOURCES})
|
foreach(EXAMPLE_FILE ${EXAMPLE_SOURCES})
|
||||||
get_filename_component(EXAMPLE_NAME ${EXAMPLE_FILE} NAME_WE)
|
get_filename_component(EXAMPLE_NAME ${EXAMPLE_FILE} NAME_WE)
|
||||||
add_executable(${EXAMPLE_NAME} ${EXAMPLE_FILE})
|
add_executable(${EXAMPLE_NAME} ${EXAMPLE_FILE})
|
||||||
target_link_libraries(${EXAMPLE_NAME} PRIVATE smath::smath)
|
target_link_libraries(${EXAMPLE_NAME} PRIVATE smath::smath)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SMATH_BUILD_TESTS)
|
if(SMATH_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
find_package(GTest QUIET)
|
find_package(GTest QUIET)
|
||||||
|
|
||||||
if(NOT GTest_FOUND)
|
if(NOT GTest_FOUND)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
googletest
|
googletest
|
||||||
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
|
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip)
|
||||||
)
|
set(gtest_force_shared_crt
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
ON
|
||||||
FetchContent_MakeAvailable(googletest)
|
CACHE BOOL "" FORCE)
|
||||||
endif()
|
FetchContent_MakeAvailable(googletest)
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB TEST_SOURCES "${CMAKE_SOURCE_DIR}/tests/*.cpp")
|
file(GLOB TEST_SOURCES "${CMAKE_SOURCE_DIR}/tests/*.cpp")
|
||||||
|
|
||||||
add_executable(smath_tests ${TEST_SOURCES})
|
add_executable(smath_tests ${TEST_SOURCES})
|
||||||
target_link_libraries(smath_tests PRIVATE
|
target_link_libraries(smath_tests PRIVATE smath::smath GTest::gtest_main)
|
||||||
smath::smath
|
|
||||||
GTest::gtest_main
|
|
||||||
)
|
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
gtest_discover_tests(smath_tests)
|
gtest_discover_tests(smath_tests)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
+48
-1
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
Welcome to `smath` contributors!
|
Welcome to `smath` contributors!
|
||||||
|
|
||||||
This document contains a set of guidelines to contribute to the project. If you feel like there's a mistake or something can be improved to this document, feel free to propose changes in a pull request.
|
This document contains a set of guidelines to contribute to the project. If you
|
||||||
|
feel like there's a mistake or something can be improved to this document, feel
|
||||||
|
free to propose changes in a pull request.
|
||||||
|
|
||||||
## Philosophy
|
## Philosophy
|
||||||
|
|
||||||
@@ -52,6 +54,51 @@ This project uses `clang-format` to maintain a consistent code style. Before ope
|
|||||||
git ls-files '*.hpp' '*.cpp' | xargs clang-format -i
|
git ls-files '*.hpp' '*.cpp' | xargs clang-format -i
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Sign-off (DCO)
|
||||||
|
|
||||||
|
Every commit must be signed off by at least one (1) human contributor:
|
||||||
|
|
||||||
|
```
|
||||||
|
git commit -s
|
||||||
|
```
|
||||||
|
|
||||||
|
This adds a `Signed-off-by: Your Name <your@email>` trailer certifying that you
|
||||||
|
wrote the change (or otherwise have reviewed the commit and have the right to
|
||||||
|
submit it) and agree to contribute it under the project's license, per the
|
||||||
|
Developer Certificate of Origin (the DCO file in this repository - also at
|
||||||
|
https://developercertificate.org).
|
||||||
|
|
||||||
|
## AI-assisted contributions
|
||||||
|
|
||||||
|
AI-assisted contributions are allowed, subject to the following:
|
||||||
|
|
||||||
|
- A human must be in the loop at all times. AI tools may assist, but a human
|
||||||
|
contributor must drive the work, review and understand every generated
|
||||||
|
change, and take full responsibility for it. Do not submit code you have not
|
||||||
|
read and understood.
|
||||||
|
|
||||||
|
- The assistance must be disclosed. Any commit produced with material AI help
|
||||||
|
must carry an `Assisted-by:` trailer using a format similar to the Linux
|
||||||
|
kernel's AI coding assistant format:
|
||||||
|
|
||||||
|
```
|
||||||
|
Assisted-by: AGENT_NAME:MODEL_VERSION
|
||||||
|
```
|
||||||
|
|
||||||
|
`AGENT_NAME` is the AI tool or framework (e.g. Codex, Claude, ...).
|
||||||
|
`MODEL_VERSION` is the full model identifier, all lowercase, including any
|
||||||
|
numeric, snapshot, or version suffix. Do not shorten it to the model family
|
||||||
|
(e.g. use gpt-5-5, not gpt-5; use claude-opus-4-8, not claude-opus).
|
||||||
|
|
||||||
|
- Do not add `Co-authored-by:` trailers for the AI assistant. The
|
||||||
|
`Assisted-by:` trailer already serves that purpose.
|
||||||
|
|
||||||
|
- The human contributor still signs off (see above). `Signed-off-by:` is the
|
||||||
|
human's certification of, and responsibility for, the change.
|
||||||
|
`Assisted-by:` only records which tool helped. It does not replace the sign-off or the human review.
|
||||||
|
|
||||||
|
Unreviewed, bulk, or fully-automated submissions are not accepted.
|
||||||
|
|
||||||
## Pull requests
|
## Pull requests
|
||||||
|
|
||||||
- Keep changes focused and scoped to one topic.
|
- Keep changes focused and scoped to one topic.
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
Developer Certificate of Origin
|
||||||
|
Version 1.1
|
||||||
|
|
||||||
|
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
||||||
|
Developer's Certificate of Origin 1.1
|
||||||
|
|
||||||
|
By making a contribution to this project, I certify that:
|
||||||
|
|
||||||
|
(a) The contribution was created in whole or in part by me and I
|
||||||
|
have the right to submit it under the open source license
|
||||||
|
indicated in the file; or
|
||||||
|
|
||||||
|
(b) The contribution is based upon previous work that, to the best
|
||||||
|
of my knowledge, is covered under an appropriate open source
|
||||||
|
license and I have the right under that license to submit that
|
||||||
|
work with modifications, whether created in whole or in part
|
||||||
|
by me, under the same open source license (unless I am
|
||||||
|
permitted to submit under a different license), as indicated
|
||||||
|
in the file; or
|
||||||
|
|
||||||
|
(c) The contribution was provided directly to me by some other
|
||||||
|
person who certified (a), (b) or (c) and I have not modified
|
||||||
|
it.
|
||||||
|
|
||||||
|
(d) I understand and agree that this project and the contribution
|
||||||
|
are public and that a record of the contribution (including all
|
||||||
|
personal information I submit with it, including my sign-off) is
|
||||||
|
maintained indefinitely and may be redistributed consistent with
|
||||||
|
this project or the open source license(s) involved.
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
cmake
|
cmake
|
||||||
|
cmake-format
|
||||||
ninja
|
ninja
|
||||||
clang-tools
|
clang-tools
|
||||||
lldb
|
lldb
|
||||||
|
|||||||
@@ -5,4 +5,3 @@ target_sources(smath_modules PUBLIC FILE_SET CXX_MODULES FILES smath.cppm)
|
|||||||
target_link_libraries(smath_modules PUBLIC smath::smath)
|
target_link_libraries(smath_modules PUBLIC smath::smath)
|
||||||
|
|
||||||
target_compile_features(smath_modules PUBLIC cxx_std_20)
|
target_compile_features(smath_modules PUBLIC cxx_std_20)
|
||||||
|
|
||||||
|
|||||||
+38
-37
@@ -4,51 +4,52 @@ module;
|
|||||||
|
|
||||||
export module smath;
|
export module smath;
|
||||||
|
|
||||||
export namespace smath {
|
export namespace smath
|
||||||
export using ::smath::Vec;
|
{
|
||||||
export using ::smath::VecOrScalar;
|
using ::smath::Mat;
|
||||||
export using ::smath::Quaternion;
|
using ::smath::Quaternion;
|
||||||
export using ::smath::Mat;
|
using ::smath::Vec;
|
||||||
|
using ::smath::VecOrScalar;
|
||||||
|
|
||||||
export using ::smath::Vec2;
|
using ::smath::Vec2;
|
||||||
export using ::smath::Vec3;
|
using ::smath::Vec3;
|
||||||
export using ::smath::Vec4;
|
using ::smath::Vec4;
|
||||||
|
|
||||||
export using ::smath::Vec2d;
|
using ::smath::Vec2d;
|
||||||
export using ::smath::Vec3d;
|
using ::smath::Vec3d;
|
||||||
export using ::smath::Vec4d;
|
using ::smath::Vec4d;
|
||||||
|
|
||||||
export using ::smath::Mat2;
|
using ::smath::Mat2;
|
||||||
export using ::smath::Mat3;
|
using ::smath::Mat3;
|
||||||
export using ::smath::Mat4;
|
using ::smath::Mat4;
|
||||||
|
|
||||||
export using ::smath::Mat2d;
|
using ::smath::Mat2d;
|
||||||
export using ::smath::Mat3d;
|
using ::smath::Mat3d;
|
||||||
export using ::smath::Mat4d;
|
using ::smath::Mat4d;
|
||||||
|
|
||||||
export using ::smath::swizzle;
|
using ::smath::swizzle;
|
||||||
|
|
||||||
export using ::smath::deg;
|
using ::smath::deg;
|
||||||
export using ::smath::rad;
|
using ::smath::rad;
|
||||||
export using ::smath::turns;
|
using ::smath::turns;
|
||||||
|
|
||||||
export using ::smath::pack_unorm4x8;
|
using ::smath::pack_snorm4x8;
|
||||||
export using ::smath::pack_snorm4x8;
|
using ::smath::pack_unorm4x8;
|
||||||
export using ::smath::unpack_unorm4x8;
|
using ::smath::unpack_snorm4x8;
|
||||||
export using ::smath::unpack_snorm4x8;
|
using ::smath::unpack_unorm4x8;
|
||||||
|
|
||||||
export using ::smath::operator*;
|
using ::smath::operator*;
|
||||||
|
|
||||||
export using ::smath::translate;
|
using ::smath::rotate;
|
||||||
export using ::smath::rotate;
|
using ::smath::scale;
|
||||||
export using ::smath::scale;
|
using ::smath::translate;
|
||||||
|
|
||||||
export using ::smath::shear_x;
|
using ::smath::shear_x;
|
||||||
export using ::smath::shear_y;
|
using ::smath::shear_y;
|
||||||
export using ::smath::shear_z;
|
using ::smath::shear_z;
|
||||||
|
|
||||||
export using ::smath::matrix_ortho3d;
|
using ::smath::matrix_infinite_perspective;
|
||||||
export using ::smath::matrix_perspective;
|
using ::smath::matrix_look_at;
|
||||||
export using ::smath::matrix_infinite_perspective;
|
using ::smath::matrix_ortho3d;
|
||||||
export using ::smath::matrix_look_at;
|
using ::smath::matrix_perspective;
|
||||||
}
|
} // namespace smath
|
||||||
|
|||||||
Reference in New Issue
Block a user