From 075c553521725b87d3ef10f24e8e66cae2bbc99a Mon Sep 17 00:00:00 2001 From: Saikari Date: Tue, 17 Dec 2024 04:55:13 +0300 Subject: [PATCH 1/5] Export --- CMakeLists.txt | 12 +++++++--- include/omath/Angle.hpp | 4 ++-- include/omath/Angles.hpp | 1 - include/omath/Color.hpp | 6 ++--- include/omath/Mat.hpp | 6 ++--- include/omath/Matrix.hpp | 3 ++- include/omath/Triangle3d.hpp | 3 ++- include/omath/Vector2.hpp | 4 ++-- include/omath/Vector3.hpp | 4 ++-- include/omath/Vector4.hpp | 4 ++-- include/omath/ViewAngles.hpp | 4 +++- include/omath/collision/LineTracer.hpp | 6 ++--- include/omath/engines/Source/Camera.hpp | 3 ++- include/omath/omath_export.h | 24 ++++++++++++++++++++ include/omath/pathfinding/Astar.hpp | 4 ++-- include/omath/pathfinding/NavigationMesh.hpp | 4 ++-- include/omath/prediction/Engine.hpp | 4 ++-- include/omath/prediction/Projectile.hpp | 4 ++-- include/omath/prediction/Target.hpp | 4 ++-- include/omath/projection/Camera.hpp | 6 ++--- 20 files changed, 72 insertions(+), 38 deletions(-) create mode 100644 include/omath/omath_export.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f79bac9..23713a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.26) project(omath VERSION 1.0.0) - +include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD 26) @@ -19,10 +19,16 @@ else() add_library(omath STATIC source/Vector3.cpp) endif() +target_compile_definitions(omath PUBLIC OMATH_EXPORT) + +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(omath PRIVATE /Zc:static_assert-) +endif() + add_subdirectory(source) -add_subdirectory(extlibs) if(OMATH_BUILD_TESTS) + add_subdirectory(extlibs) add_subdirectory(tests) endif() @@ -79,4 +85,4 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/omathConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/omathConfigVersion.cmake" DESTINATION lib/cmake/omath -) \ No newline at end of file +) diff --git a/include/omath/Angle.hpp b/include/omath/Angle.hpp index 26c6ebf..3622a1c 100644 --- a/include/omath/Angle.hpp +++ b/include/omath/Angle.hpp @@ -6,7 +6,7 @@ #include "omath/Angles.hpp" #include - +#include "omath_export.h" namespace omath { @@ -18,7 +18,7 @@ namespace omath template requires std::is_arithmetic_v - class Angle + class OMATH_API Angle { Type m_angle; constexpr Angle(const Type& degrees) diff --git a/include/omath/Angles.hpp b/include/omath/Angles.hpp index 47a287a..c578afb 100644 --- a/include/omath/Angles.hpp +++ b/include/omath/Angles.hpp @@ -6,7 +6,6 @@ #include #include - namespace omath::angles { template diff --git a/include/omath/Color.hpp b/include/omath/Color.hpp index 4625545..cf4644b 100644 --- a/include/omath/Color.hpp +++ b/include/omath/Color.hpp @@ -7,11 +7,11 @@ #include "omath/Vector3.hpp" #include #include "omath/Vector4.hpp" - +#include "omath_export.h" namespace omath { - struct HSV + struct OMATH_API HSV { float m_hue{}; float m_saturation{}; @@ -19,7 +19,7 @@ namespace omath }; - class Color final : public Vector4 + class OMATH_API Color final : public Vector4 { public: constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a) diff --git a/include/omath/Mat.hpp b/include/omath/Mat.hpp index 3cb6f91..3adb480 100644 --- a/include/omath/Mat.hpp +++ b/include/omath/Mat.hpp @@ -8,11 +8,11 @@ #include #include #include "Vector3.hpp" - +#include "omath_export.h" namespace omath { - struct MatSize + struct OMATH_API MatSize { size_t rows, columns; }; @@ -25,7 +25,7 @@ namespace omath template requires std::is_arithmetic_v - class Mat final + class OMATH_API Mat final { public: constexpr Mat() diff --git a/include/omath/Matrix.hpp b/include/omath/Matrix.hpp index 1fbdb4b..fc1e296 100644 --- a/include/omath/Matrix.hpp +++ b/include/omath/Matrix.hpp @@ -2,12 +2,13 @@ #include #include #include +#include "omath_export.h" namespace omath { class Vector3; - class Matrix final + class OMATH_API Matrix final { public: Matrix(); diff --git a/include/omath/Triangle3d.hpp b/include/omath/Triangle3d.hpp index 370aa95..826e4fc 100644 --- a/include/omath/Triangle3d.hpp +++ b/include/omath/Triangle3d.hpp @@ -3,10 +3,11 @@ // #pragma once #include "omath/Vector3.hpp" +#include "omath_export.h" namespace omath { - class Triangle3d final + class OMATH_API Triangle3d final { public: Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3); diff --git a/include/omath/Vector2.hpp b/include/omath/Vector2.hpp index 46bc467..a4cf0af 100644 --- a/include/omath/Vector2.hpp +++ b/include/omath/Vector2.hpp @@ -5,11 +5,11 @@ #pragma once #include #include - +#include "omath_export.h" namespace omath { - class Vector2 + class OMATH_API Vector2 { public: float x = 0.f; diff --git a/include/omath/Vector3.hpp b/include/omath/Vector3.hpp index e22d815..c0521b3 100644 --- a/include/omath/Vector3.hpp +++ b/include/omath/Vector3.hpp @@ -7,11 +7,11 @@ #include #include #include "omath/Vector2.hpp" - +#include "omath_export.h" namespace omath { - class Vector3 : public Vector2 + class OMATH_API Vector3 : public Vector2 { public: float z = 0.f; diff --git a/include/omath/Vector4.hpp b/include/omath/Vector4.hpp index 4b43501..8a3c84f 100644 --- a/include/omath/Vector4.hpp +++ b/include/omath/Vector4.hpp @@ -5,11 +5,11 @@ #include #include - +#include "omath_export.h" namespace omath { - class Vector4 : public Vector3 + class OMATH_API Vector4 : public Vector3 { public: float w; diff --git a/include/omath/ViewAngles.hpp b/include/omath/ViewAngles.hpp index d744f6b..e3ef7a8 100644 --- a/include/omath/ViewAngles.hpp +++ b/include/omath/ViewAngles.hpp @@ -3,10 +3,12 @@ // #pragma once +#include "omath_export.h" + namespace omath { template - struct ViewAngles + struct OMATH_API ViewAngles { PitchType pitch; YawType yaw; diff --git a/include/omath/collision/LineTracer.hpp b/include/omath/collision/LineTracer.hpp index fc1d7fa..2c42e60 100644 --- a/include/omath/collision/LineTracer.hpp +++ b/include/omath/collision/LineTracer.hpp @@ -5,11 +5,11 @@ #include "omath/Vector3.hpp" #include "omath/Triangle3d.hpp" - +#include "../omath_export.h" namespace omath::collision { - class Ray + class OMATH_API Ray { public: Vector3 start; @@ -21,7 +21,7 @@ namespace omath::collision [[nodiscard]] Vector3 DirectionVectorNormalized() const; }; - class LineTracer + class OMATH_API LineTracer { public: LineTracer() = delete; diff --git a/include/omath/engines/Source/Camera.hpp b/include/omath/engines/Source/Camera.hpp index aca13cf..4ebe113 100644 --- a/include/omath/engines/Source/Camera.hpp +++ b/include/omath/engines/Source/Camera.hpp @@ -4,10 +4,11 @@ #pragma once #include "Constants.h" #include "omath/projection/Camera.hpp" +#include "../../omath_export.h" namespace omath::source { - class Camera final : public projection::Camera + class OMATH_API Camera final : public projection::Camera { public: Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort, diff --git a/include/omath/omath_export.h b/include/omath/omath_export.h new file mode 100644 index 0000000..091fd56 --- /dev/null +++ b/include/omath/omath_export.h @@ -0,0 +1,24 @@ +#pragma once + +/* Export prefix for functions */ +#ifdef _MSC_VER + /* MSVC */ +# define OMATH_API_EXPORT __declspec(dllexport) +#else + /* GCC/Clang */ +# define OMATH_API_EXPORT __attribute__((visibility("default"))) +#endif + +/* Import prefix for functions */ +#ifdef _MSC_VER +# define OMATH_API_IMPORT __declspec(dllimport) +#else +# define OMATH_API_IMPORT extern +#endif + +/* Resolve import/export */ +#ifdef OMATH_EXPORT +# define OMATH_API OMATH_API_EXPORT +#else +# define OMATH_API OMATH_API_IMPORT +#endif \ No newline at end of file diff --git a/include/omath/pathfinding/Astar.hpp b/include/omath/pathfinding/Astar.hpp index 0609850..07d7323 100644 --- a/include/omath/pathfinding/Astar.hpp +++ b/include/omath/pathfinding/Astar.hpp @@ -6,11 +6,11 @@ #include #include "NavigationMesh.hpp" #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::pathfinding { - class Astar final + class OMATH_API Astar final { public: [[nodiscard]] diff --git a/include/omath/pathfinding/NavigationMesh.hpp b/include/omath/pathfinding/NavigationMesh.hpp index 525cbc4..325fe9d 100644 --- a/include/omath/pathfinding/NavigationMesh.hpp +++ b/include/omath/pathfinding/NavigationMesh.hpp @@ -8,7 +8,7 @@ #include #include #include - +#include "../omath_export.h" namespace omath::pathfinding { @@ -18,7 +18,7 @@ namespace omath::pathfinding }; - class NavigationMesh final + class OMATH_API NavigationMesh final { public: diff --git a/include/omath/prediction/Engine.hpp b/include/omath/prediction/Engine.hpp index 6d8e617..d81eea0 100644 --- a/include/omath/prediction/Engine.hpp +++ b/include/omath/prediction/Engine.hpp @@ -8,11 +8,11 @@ #include "omath/Vector3.hpp" #include "omath/prediction/Projectile.hpp" #include "omath/prediction/Target.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Engine final + class OMATH_API Engine final { public: explicit Engine(float gravityConstant, float simulationTimeStep, diff --git a/include/omath/prediction/Projectile.hpp b/include/omath/prediction/Projectile.hpp index 93ded29..51da5ae 100644 --- a/include/omath/prediction/Projectile.hpp +++ b/include/omath/prediction/Projectile.hpp @@ -4,11 +4,11 @@ #pragma once #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Projectile final + class OMATH_API Projectile final { public: diff --git a/include/omath/prediction/Target.hpp b/include/omath/prediction/Target.hpp index a2b37ce..2f062d0 100644 --- a/include/omath/prediction/Target.hpp +++ b/include/omath/prediction/Target.hpp @@ -4,11 +4,11 @@ #pragma once #include "omath/Vector3.hpp" - +#include "../omath_export.h" namespace omath::prediction { - class Target final + class OMATH_API Target final { public: diff --git a/include/omath/projection/Camera.hpp b/include/omath/projection/Camera.hpp index 15db451..2254d4c 100644 --- a/include/omath/projection/Camera.hpp +++ b/include/omath/projection/Camera.hpp @@ -10,11 +10,11 @@ #include "ErrorCodes.hpp" #include #include - +#include "../omath_export.h" namespace omath::projection { - class ViewPort final + class OMATH_API ViewPort final { public: float m_width; @@ -28,7 +28,7 @@ namespace omath::projection using FieldOfView = const Angle; template - class Camera + class OMATH_API Camera { public: From 193e87847ad1a7480e89c29d4f19d4c6c9c698a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=95=E3=81=8F=E3=82=89=E3=81=BF=E3=81=93?= Date: Tue, 17 Dec 2024 07:24:44 +0300 Subject: [PATCH 2/5] fixup --- include/omath/Angle.hpp | 2 +- include/omath/Color.hpp | 2 +- include/omath/Mat.hpp | 2 +- include/omath/Matrix.hpp | 2 +- include/omath/Triangle3d.hpp | 2 +- include/omath/Vector2.hpp | 2 +- include/omath/Vector3.hpp | 2 +- include/omath/Vector4.hpp | 2 +- include/omath/ViewAngles.hpp | 2 +- include/omath/collision/LineTracer.hpp | 2 +- include/omath/engines/Source/Camera.hpp | 2 +- .../{omath_export.h => omath_export.hpp} | 46 +++++++++---------- include/omath/pathfinding/Astar.hpp | 2 +- include/omath/pathfinding/NavigationMesh.hpp | 2 +- include/omath/prediction/Engine.hpp | 2 +- include/omath/prediction/Projectile.hpp | 2 +- include/omath/prediction/Target.hpp | 2 +- include/omath/projection/Camera.hpp | 2 +- 18 files changed, 40 insertions(+), 40 deletions(-) rename include/omath/{omath_export.h => omath_export.hpp} (95%) diff --git a/include/omath/Angle.hpp b/include/omath/Angle.hpp index 3622a1c..9b66495 100644 --- a/include/omath/Angle.hpp +++ b/include/omath/Angle.hpp @@ -6,7 +6,7 @@ #include "omath/Angles.hpp" #include -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Color.hpp b/include/omath/Color.hpp index cf4644b..19185e8 100644 --- a/include/omath/Color.hpp +++ b/include/omath/Color.hpp @@ -7,7 +7,7 @@ #include "omath/Vector3.hpp" #include #include "omath/Vector4.hpp" -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Mat.hpp b/include/omath/Mat.hpp index 3adb480..2b99de5 100644 --- a/include/omath/Mat.hpp +++ b/include/omath/Mat.hpp @@ -8,7 +8,7 @@ #include #include #include "Vector3.hpp" -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Matrix.hpp b/include/omath/Matrix.hpp index fc1e296..3cac39b 100644 --- a/include/omath/Matrix.hpp +++ b/include/omath/Matrix.hpp @@ -2,7 +2,7 @@ #include #include #include -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Triangle3d.hpp b/include/omath/Triangle3d.hpp index 826e4fc..af94482 100644 --- a/include/omath/Triangle3d.hpp +++ b/include/omath/Triangle3d.hpp @@ -3,7 +3,7 @@ // #pragma once #include "omath/Vector3.hpp" -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Vector2.hpp b/include/omath/Vector2.hpp index a4cf0af..7c49135 100644 --- a/include/omath/Vector2.hpp +++ b/include/omath/Vector2.hpp @@ -5,7 +5,7 @@ #pragma once #include #include -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Vector3.hpp b/include/omath/Vector3.hpp index c0521b3..9b80bc3 100644 --- a/include/omath/Vector3.hpp +++ b/include/omath/Vector3.hpp @@ -7,7 +7,7 @@ #include #include #include "omath/Vector2.hpp" -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/Vector4.hpp b/include/omath/Vector4.hpp index 8a3c84f..2a6fc32 100644 --- a/include/omath/Vector4.hpp +++ b/include/omath/Vector4.hpp @@ -5,7 +5,7 @@ #include #include -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/ViewAngles.hpp b/include/omath/ViewAngles.hpp index e3ef7a8..164feb4 100644 --- a/include/omath/ViewAngles.hpp +++ b/include/omath/ViewAngles.hpp @@ -3,7 +3,7 @@ // #pragma once -#include "omath_export.h" +#include "omath/omath_export.hpp" namespace omath { diff --git a/include/omath/collision/LineTracer.hpp b/include/omath/collision/LineTracer.hpp index 2c42e60..d067562 100644 --- a/include/omath/collision/LineTracer.hpp +++ b/include/omath/collision/LineTracer.hpp @@ -5,7 +5,7 @@ #include "omath/Vector3.hpp" #include "omath/Triangle3d.hpp" -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::collision { diff --git a/include/omath/engines/Source/Camera.hpp b/include/omath/engines/Source/Camera.hpp index 4ebe113..b942909 100644 --- a/include/omath/engines/Source/Camera.hpp +++ b/include/omath/engines/Source/Camera.hpp @@ -4,7 +4,7 @@ #pragma once #include "Constants.h" #include "omath/projection/Camera.hpp" -#include "../../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::source { diff --git a/include/omath/omath_export.h b/include/omath/omath_export.hpp similarity index 95% rename from include/omath/omath_export.h rename to include/omath/omath_export.hpp index 091fd56..199e78f 100644 --- a/include/omath/omath_export.h +++ b/include/omath/omath_export.hpp @@ -1,24 +1,24 @@ -#pragma once - -/* Export prefix for functions */ -#ifdef _MSC_VER - /* MSVC */ -# define OMATH_API_EXPORT __declspec(dllexport) -#else - /* GCC/Clang */ -# define OMATH_API_EXPORT __attribute__((visibility("default"))) -#endif - -/* Import prefix for functions */ -#ifdef _MSC_VER -# define OMATH_API_IMPORT __declspec(dllimport) -#else -# define OMATH_API_IMPORT extern -#endif - -/* Resolve import/export */ -#ifdef OMATH_EXPORT -# define OMATH_API OMATH_API_EXPORT -#else -# define OMATH_API OMATH_API_IMPORT +#pragma once + +/* Export prefix for functions */ +#ifdef _MSC_VER + /* MSVC */ +# define OMATH_API_EXPORT __declspec(dllexport) +#else + /* GCC/Clang */ +# define OMATH_API_EXPORT __attribute__((visibility("default"))) +#endif + +/* Import prefix for functions */ +#ifdef _MSC_VER +# define OMATH_API_IMPORT __declspec(dllimport) +#else +# define OMATH_API_IMPORT extern +#endif + +/* Resolve import/export */ +#ifdef OMATH_EXPORT +# define OMATH_API OMATH_API_EXPORT +#else +# define OMATH_API OMATH_API_IMPORT #endif \ No newline at end of file diff --git a/include/omath/pathfinding/Astar.hpp b/include/omath/pathfinding/Astar.hpp index 07d7323..435bd5d 100644 --- a/include/omath/pathfinding/Astar.hpp +++ b/include/omath/pathfinding/Astar.hpp @@ -6,7 +6,7 @@ #include #include "NavigationMesh.hpp" #include "omath/Vector3.hpp" -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::pathfinding { diff --git a/include/omath/pathfinding/NavigationMesh.hpp b/include/omath/pathfinding/NavigationMesh.hpp index 325fe9d..39cc2ea 100644 --- a/include/omath/pathfinding/NavigationMesh.hpp +++ b/include/omath/pathfinding/NavigationMesh.hpp @@ -8,7 +8,7 @@ #include #include #include -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::pathfinding { diff --git a/include/omath/prediction/Engine.hpp b/include/omath/prediction/Engine.hpp index d81eea0..c48456c 100644 --- a/include/omath/prediction/Engine.hpp +++ b/include/omath/prediction/Engine.hpp @@ -8,7 +8,7 @@ #include "omath/Vector3.hpp" #include "omath/prediction/Projectile.hpp" #include "omath/prediction/Target.hpp" -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::prediction { diff --git a/include/omath/prediction/Projectile.hpp b/include/omath/prediction/Projectile.hpp index 51da5ae..51f6ebc 100644 --- a/include/omath/prediction/Projectile.hpp +++ b/include/omath/prediction/Projectile.hpp @@ -4,7 +4,7 @@ #pragma once #include "omath/Vector3.hpp" -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::prediction { diff --git a/include/omath/prediction/Target.hpp b/include/omath/prediction/Target.hpp index 2f062d0..083d3bd 100644 --- a/include/omath/prediction/Target.hpp +++ b/include/omath/prediction/Target.hpp @@ -4,7 +4,7 @@ #pragma once #include "omath/Vector3.hpp" -#include "../omath_export.h" +#include "omath/omath_export.hpp" namespace omath::prediction { diff --git a/include/omath/projection/Camera.hpp b/include/omath/projection/Camera.hpp index 2254d4c..7a374ba 100644 --- a/include/omath/projection/Camera.hpp +++ b/include/omath/projection/Camera.hpp @@ -10,7 +10,7 @@ #include "ErrorCodes.hpp" #include #include -#include "../omath_export.h" +#include namespace omath::projection { From 58fb6a030477718a324ec13fd15ff16dee76e9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=95=E3=81=8F=E3=82=89=E3=81=BF=E3=81=93?= Date: Tue, 17 Dec 2024 08:40:48 +0300 Subject: [PATCH 3/5] clean --- include/omath/omath_export.hpp | 2 +- include/omath/projection/Camera.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/omath/omath_export.hpp b/include/omath/omath_export.hpp index 199e78f..b0949e7 100644 --- a/include/omath/omath_export.hpp +++ b/include/omath/omath_export.hpp @@ -21,4 +21,4 @@ # define OMATH_API OMATH_API_EXPORT #else # define OMATH_API OMATH_API_IMPORT -#endif \ No newline at end of file +#endif diff --git a/include/omath/projection/Camera.hpp b/include/omath/projection/Camera.hpp index 7a374ba..59f6fe8 100644 --- a/include/omath/projection/Camera.hpp +++ b/include/omath/projection/Camera.hpp @@ -10,7 +10,7 @@ #include "ErrorCodes.hpp" #include #include -#include +#include "omath/omath_export.hpp" namespace omath::projection { From fc164b339bfbf4ff33e15158261d5e67d283101d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=95=E3=81=8F=E3=82=89=E3=81=BF=E3=81=93?= Date: Tue, 17 Dec 2024 12:08:18 +0300 Subject: [PATCH 4/5] fix --- include/omath/Mat.hpp | 74 ++++++++++---------- include/omath/Matrix.hpp | 72 +++++++++---------- include/omath/pathfinding/NavigationMesh.hpp | 10 +-- 3 files changed, 78 insertions(+), 78 deletions(-) diff --git a/include/omath/Mat.hpp b/include/omath/Mat.hpp index 2b99de5..7b05f42 100644 --- a/include/omath/Mat.hpp +++ b/include/omath/Mat.hpp @@ -25,18 +25,18 @@ namespace omath template requires std::is_arithmetic_v - class OMATH_API Mat final + class Mat final { public: - constexpr Mat() + OMATH_API constexpr Mat() { Clear(); } - constexpr static MatStoreType GetStoreOrdering() + OMATH_API constexpr static MatStoreType GetStoreOrdering() { return StoreType; } - constexpr Mat(const std::initializer_list>& rows) + OMATH_API constexpr Mat(const std::initializer_list>& rows) { if (rows.size() != Rows) throw std::invalid_argument("Initializer list rows size does not match template parameter Rows"); @@ -56,40 +56,40 @@ namespace omath } } - constexpr explicit Mat(const Type* rawData) + OMATH_API constexpr explicit Mat(const Type* rawData) { std::copy_n(rawData, Rows * Columns, m_data.begin()); } - constexpr Mat(const Mat& other) noexcept + OMATH_API constexpr Mat(const Mat& other) noexcept { m_data = other.m_data; } - constexpr Mat(Mat&& other) noexcept + OMATH_API constexpr Mat(Mat&& other) noexcept { m_data = std::move(other.m_data); } [[nodiscard]] - static constexpr size_t RowCount() noexcept + OMATH_API static constexpr size_t RowCount() noexcept { return Rows; } [[nodiscard]] - static constexpr size_t ColumnsCount() noexcept + OMATH_API static constexpr size_t ColumnsCount() noexcept { return Columns; } [[nodiscard]] - static consteval MatSize Size() noexcept + OMATH_API static consteval MatSize Size() noexcept { return {Rows, Columns}; } - [[nodiscard]] constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const + [[nodiscard]] OMATH_API constexpr const Type& At(const size_t rowIndex, const size_t columnIndex) const { if (rowIndex >= Rows || columnIndex >= Columns) throw std::out_of_range("Index out of range"); @@ -107,13 +107,13 @@ namespace omath } } - [[nodiscard]] constexpr Type& At(const size_t rowIndex, const size_t columnIndex) + [[nodiscard]] OMATH_API constexpr Type& At(const size_t rowIndex, const size_t columnIndex) { return const_cast(std::as_const(*this).At(rowIndex, columnIndex)); } [[nodiscard]] - constexpr Type Sum() const noexcept + OMATH_API constexpr Type Sum() const noexcept { Type sum = 0; for (size_t i = 0; i < Rows; ++i) @@ -123,12 +123,12 @@ namespace omath return sum; } - constexpr void Clear() noexcept + OMATH_API constexpr void Clear() noexcept { Set(0); } - constexpr void Set(const Type& value) noexcept + OMATH_API constexpr void Set(const Type& value) noexcept { std::ranges::fill(m_data, value); } @@ -136,7 +136,7 @@ namespace omath // Operator overloading for multiplication with another Mat template constexpr Mat - operator*(const Mat& other) const + OMATH_API operator*(const Mat& other) const { Mat result; @@ -151,7 +151,7 @@ namespace omath return result; } - constexpr Mat& operator*=(const Type& f) noexcept + OMATH_API constexpr Mat& operator*=(const Type& f) noexcept { for (size_t i = 0; i < Rows; ++i) for (size_t j = 0; j < Columns; ++j) @@ -161,19 +161,19 @@ namespace omath template constexpr Mat - operator*=(const Mat& other) + OMATH_API operator*=(const Mat& other) { return *this = *this * other; } - constexpr Mat operator*(const Type& f) const noexcept + OMATH_API constexpr Mat operator*(const Type& f) const noexcept { Mat result(*this); result *= f; return result; } - constexpr Mat& operator/=(const Type& f) noexcept + OMATH_API constexpr Mat& operator/=(const Type& f) noexcept { for (size_t i = 0; i < Rows; ++i) for (size_t j = 0; j < Columns; ++j) @@ -181,14 +181,14 @@ namespace omath return *this; } - constexpr Mat operator/(const Type& f) const noexcept + OMATH_API constexpr Mat operator/(const Type& f) const noexcept { Mat result(*this); result /= f; return result; } - constexpr Mat& operator=(const Mat& other) noexcept + OMATH_API constexpr Mat& operator=(const Mat& other) noexcept { if (this == &other) return *this; @@ -198,7 +198,7 @@ namespace omath return *this; } - constexpr Mat& operator=(Mat&& other) noexcept + OMATH_API constexpr Mat& operator=(Mat&& other) noexcept { if (this == &other) return *this; @@ -211,7 +211,7 @@ namespace omath } [[nodiscard]] - constexpr Mat Transposed() const noexcept + OMATH_API constexpr Mat Transposed() const noexcept { Mat transposed; for (size_t i = 0; i < Rows; ++i) @@ -222,7 +222,7 @@ namespace omath } [[nodiscard]] - constexpr Type Determinant() const + OMATH_API constexpr Type Determinant() const { static_assert(Rows == Columns, "Determinant is only defined for square matrices."); @@ -244,7 +244,7 @@ namespace omath } [[nodiscard]] - constexpr Mat Minor(const size_t row, const size_t column) const + OMATH_API constexpr Mat Minor(const size_t row, const size_t column) const { Mat result; for (size_t i = 0, m = 0; i < Rows; ++i) @@ -264,19 +264,19 @@ namespace omath } [[nodiscard]] - constexpr const std::array& RawArray() const + OMATH_API constexpr const std::array& RawArray() const { return m_data; } [[nodiscard]] - constexpr std::array& RawArray() + OMATH_API constexpr std::array& RawArray() { return const_cast>(std::as_const(*this).RawArray()); } [[nodiscard]] - std::string ToString() const noexcept + OMATH_API std::string ToString() const noexcept { std::ostringstream oss; for (size_t i = 0; i < Rows; ++i) @@ -293,20 +293,20 @@ namespace omath } [[nodiscard]] - bool operator==(const Mat& mat) const + OMATH_API bool operator==(const Mat& mat) const { return m_data == mat.m_data; } [[nodiscard]] - bool operator!=(const Mat& mat) const + OMATH_API bool operator!=(const Mat& mat) const { return !operator==(mat); } // Static methods that return fixed-size matrices [[nodiscard]] - constexpr static Mat<4, 4> ToScreenMat(const Type& screenWidth, const Type& screenHeight) noexcept + OMATH_API constexpr static Mat<4, 4> ToScreenMat(const Type& screenWidth, const Type& screenHeight) noexcept { return { {screenWidth / 2, 0, 0, 0}, @@ -336,7 +336,7 @@ namespace omath template [[nodiscard]] - constexpr Mat<4, 4, Type, St> MatTranslation(const Vector3& diff) noexcept + OMATH_API constexpr Mat<4, 4, Type, St> MatTranslation(const Vector3& diff) noexcept { return { @@ -349,7 +349,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> MatRotationAxisX(const Angle& angle) noexcept + OMATH_API Mat<4, 4, Type, St> MatRotationAxisX(const Angle& angle) noexcept { return { @@ -362,7 +362,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> MatRotationAxisY(const Angle& angle) noexcept + OMATH_API Mat<4, 4, Type, St> MatRotationAxisY(const Angle& angle) noexcept { return { @@ -375,7 +375,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> MatRotationAxisZ(const Angle& angle) noexcept + OMATH_API Mat<4, 4, Type, St> MatRotationAxisZ(const Angle& angle) noexcept { return { @@ -403,7 +403,7 @@ namespace omath template [[nodiscard]] - Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept + OMATH_API Mat<4, 4, Type, St> MatRotation(const ViewAngles& angles) noexcept { return MatRotationAxisZ(angles.yaw) * MatRotationAxisY(angles.pitch) * MatRotationAxisX(angles.roll); } diff --git a/include/omath/Matrix.hpp b/include/omath/Matrix.hpp index 3cac39b..3ffe5ec 100644 --- a/include/omath/Matrix.hpp +++ b/include/omath/Matrix.hpp @@ -8,94 +8,94 @@ namespace omath { class Vector3; - class OMATH_API Matrix final + class Matrix final { public: - Matrix(); - Matrix(size_t rows, size_t columns); + OMATH_API Matrix(); + OMATH_API Matrix(size_t rows, size_t columns); - Matrix(const std::initializer_list>& rows); + OMATH_API Matrix(const std::initializer_list>& rows); [[nodiscard]] - static Matrix ToScreenMatrix(float screenWidth, float screenHeight); + OMATH_API static Matrix ToScreenMatrix(float screenWidth, float screenHeight); [[nodiscard]] - static Matrix TranslationMatrix(const Vector3& diff); + OMATH_API static Matrix TranslationMatrix(const Vector3& diff); [[nodiscard]] - static Matrix OrientationMatrix(const Vector3& forward, const Vector3& right, const Vector3& up); + OMATH_API static Matrix OrientationMatrix(const Vector3& forward, const Vector3& right, const Vector3& up); [[nodiscard]] - static Matrix ProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far); + OMATH_API static Matrix ProjectionMatrix(float fieldOfView, float aspectRatio, float near, float far); - Matrix(const Matrix& other); + OMATH_API Matrix(const Matrix& other); - Matrix(size_t rows, size_t columns, const float* pRaw); + OMATH_API Matrix(size_t rows, size_t columns, const float* pRaw); - Matrix(Matrix&& other) noexcept; + OMATH_API Matrix(Matrix&& other) noexcept; [[nodiscard]] - size_t RowCount() const noexcept; + OMATH_API size_t RowCount() const noexcept; [[nodiscard]] - size_t ColumnsCount() const noexcept; + OMATH_API size_t ColumnsCount() const noexcept; [[nodiscard]] - std::pair Size() const noexcept; + OMATH_API std::pair Size() const noexcept; [[nodiscard]] - float& At(size_t iRow, size_t iCol); + OMATH_API float& At(size_t iRow, size_t iCol); [[nodiscard]] - float Sum(); + OMATH_API float Sum(); - void SetDataFromRaw(const float* pRawMatrix); + OMATH_API void SetDataFromRaw(const float* pRawMatrix); [[nodiscard]] - Matrix Transpose() const; + OMATH_API Matrix Transpose() const; - void Set(float val); + OMATH_API void Set(float val); [[nodiscard]] - const float& At(size_t iRow, size_t iCol) const; + OMATH_API const float& At(size_t iRow, size_t iCol) const; - Matrix operator*(const Matrix& other) const; + OMATH_API Matrix operator*(const Matrix& other) const; - Matrix& operator*=(const Matrix& other); + OMATH_API Matrix& operator*=(const Matrix& other); - Matrix operator*(float f) const; + OMATH_API Matrix operator*(float f) const; - Matrix& operator*=(float f); + OMATH_API Matrix& operator*=(float f); - Matrix& operator/=(float f); + OMATH_API Matrix& operator/=(float f); - void Clear(); + OMATH_API void Clear(); [[nodiscard]] - Matrix Strip(size_t row, size_t column) const; + OMATH_API Matrix Strip(size_t row, size_t column) const; [[nodiscard]] - float Minor(size_t i, size_t j) const; + OMATH_API float Minor(size_t i, size_t j) const; [[nodiscard]] - float AlgComplement(size_t i, size_t j) const; + OMATH_API float AlgComplement(size_t i, size_t j) const; [[nodiscard]] - float Determinant() const; + OMATH_API float Determinant() const; [[nodiscard]] - const float* Raw() const; + OMATH_API const float* Raw() const; - Matrix& operator=(const Matrix& other); + OMATH_API Matrix& operator=(const Matrix& other); - Matrix& operator=(Matrix&& other) noexcept; + OMATH_API Matrix& operator=(Matrix&& other) noexcept; - Matrix operator/(float f) const; + OMATH_API Matrix operator/(float f) const; [[nodiscard]] - std::string ToString() const; + OMATH_API std::string ToString() const; - ~Matrix(); + OMATH_API ~Matrix(); private: size_t m_rows; diff --git a/include/omath/pathfinding/NavigationMesh.hpp b/include/omath/pathfinding/NavigationMesh.hpp index 39cc2ea..8ab5c24 100644 --- a/include/omath/pathfinding/NavigationMesh.hpp +++ b/include/omath/pathfinding/NavigationMesh.hpp @@ -18,21 +18,21 @@ namespace omath::pathfinding }; - class OMATH_API NavigationMesh final + class NavigationMesh final { public: [[nodiscard]] - std::expected GetClosestVertex(const Vector3& point) const; + OMATH_API std::expected GetClosestVertex(const Vector3& point) const; [[nodiscard]] - const std::vector& GetNeighbors(const Vector3& vertex) const; + OMATH_API const std::vector& GetNeighbors(const Vector3& vertex) const; [[nodiscard]] - bool Empty() const; + OMATH_API bool Empty() const; [[nodiscard]] std::vector Serialize() const; - void Deserialize(const std::vector& raw); + OMATH_API void Deserialize(const std::vector& raw); std::unordered_map> m_verTextMap; }; From 221fd54f5afdb39f00b82590e0c67b5f5c8345ea Mon Sep 17 00:00:00 2001 From: Orange Date: Tue, 17 Dec 2024 12:30:05 +0300 Subject: [PATCH 5/5] fixed warning related with clang --- include/omath/engines/Source/Camera.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/omath/engines/Source/Camera.hpp b/include/omath/engines/Source/Camera.hpp index b942909..1250d96 100644 --- a/include/omath/engines/Source/Camera.hpp +++ b/include/omath/engines/Source/Camera.hpp @@ -12,7 +12,7 @@ namespace omath::source { public: Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort, - const Angle& fov, float near, float far); + const Angle& fov, float near, float far); void LookAt(const Vector3& target) override; [[nodiscard]] Mat4x4 GetViewMatrix() const override; [[nodiscard]] Mat4x4 GetProjectionMatrix() const override;