This commit is contained in:
Saikari
2024-12-17 04:55:13 +03:00
committed by GitHub
parent c0efa35e8a
commit 075c553521
20 changed files with 72 additions and 38 deletions

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.26)
project(omath VERSION 1.0.0) project(omath VERSION 1.0.0)
include(CMakePackageConfigHelpers)
set(CMAKE_CXX_STANDARD 26) set(CMAKE_CXX_STANDARD 26)
@@ -19,10 +19,16 @@ else()
add_library(omath STATIC source/Vector3.cpp) add_library(omath STATIC source/Vector3.cpp)
endif() 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(source)
add_subdirectory(extlibs)
if(OMATH_BUILD_TESTS) if(OMATH_BUILD_TESTS)
add_subdirectory(extlibs)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
@@ -79,4 +85,4 @@ 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/omath DESTINATION lib/cmake/omath
) )

View File

@@ -6,7 +6,7 @@
#include "omath/Angles.hpp" #include "omath/Angles.hpp"
#include <algorithm> #include <algorithm>
#include "omath_export.h"
namespace omath namespace omath
{ {
@@ -18,7 +18,7 @@ namespace omath
template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized> template<class Type = float, Type min = Type(0), Type max = Type(360), AngleFlags flags = AngleFlags::Normalized>
requires std::is_arithmetic_v<Type> requires std::is_arithmetic_v<Type>
class Angle class OMATH_API Angle
{ {
Type m_angle; Type m_angle;
constexpr Angle(const Type& degrees) constexpr Angle(const Type& degrees)

View File

@@ -6,7 +6,6 @@
#include <numbers> #include <numbers>
#include <cmath> #include <cmath>
namespace omath::angles namespace omath::angles
{ {
template<class Type> template<class Type>

View File

@@ -7,11 +7,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include <cstdint> #include <cstdint>
#include "omath/Vector4.hpp" #include "omath/Vector4.hpp"
#include "omath_export.h"
namespace omath namespace omath
{ {
struct HSV struct OMATH_API HSV
{ {
float m_hue{}; float m_hue{};
float m_saturation{}; float m_saturation{};
@@ -19,7 +19,7 @@ namespace omath
}; };
class Color final : public Vector4 class OMATH_API Color final : public Vector4
{ {
public: public:
constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a) constexpr Color(float r, float g, float b, float a) : Vector4(r,g,b,a)

View File

@@ -8,11 +8,11 @@
#include <stdexcept> #include <stdexcept>
#include <utility> #include <utility>
#include "Vector3.hpp" #include "Vector3.hpp"
#include "omath_export.h"
namespace omath namespace omath
{ {
struct MatSize struct OMATH_API MatSize
{ {
size_t rows, columns; size_t rows, columns;
}; };
@@ -25,7 +25,7 @@ namespace omath
template<size_t Rows = 0, size_t Columns = 0, class Type = float, MatStoreType StoreType = MatStoreType::ROW_MAJOR> template<size_t Rows = 0, size_t Columns = 0, class Type = float, MatStoreType StoreType = MatStoreType::ROW_MAJOR>
requires std::is_arithmetic_v<Type> requires std::is_arithmetic_v<Type>
class Mat final class OMATH_API Mat final
{ {
public: public:
constexpr Mat() constexpr Mat()

View File

@@ -2,12 +2,13 @@
#include <initializer_list> #include <initializer_list>
#include <memory> #include <memory>
#include <string> #include <string>
#include "omath_export.h"
namespace omath namespace omath
{ {
class Vector3; class Vector3;
class Matrix final class OMATH_API Matrix final
{ {
public: public:
Matrix(); Matrix();

View File

@@ -3,10 +3,11 @@
// //
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath_export.h"
namespace omath namespace omath
{ {
class Triangle3d final class OMATH_API Triangle3d final
{ {
public: public:
Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3); Triangle3d(const Vector3& vertex1, const Vector3& vertex2, const Vector3& vertex3);

View File

@@ -5,11 +5,11 @@
#pragma once #pragma once
#include <tuple> #include <tuple>
#include <cmath> #include <cmath>
#include "omath_export.h"
namespace omath namespace omath
{ {
class Vector2 class OMATH_API Vector2
{ {
public: public:
float x = 0.f; float x = 0.f;

View File

@@ -7,11 +7,11 @@
#include <cstdint> #include <cstdint>
#include <functional> #include <functional>
#include "omath/Vector2.hpp" #include "omath/Vector2.hpp"
#include "omath_export.h"
namespace omath namespace omath
{ {
class Vector3 : public Vector2 class OMATH_API Vector3 : public Vector2
{ {
public: public:
float z = 0.f; float z = 0.f;

View File

@@ -5,11 +5,11 @@
#include <omath/Vector3.hpp> #include <omath/Vector3.hpp>
#include <algorithm> #include <algorithm>
#include "omath_export.h"
namespace omath namespace omath
{ {
class Vector4 : public Vector3 class OMATH_API Vector4 : public Vector3
{ {
public: public:
float w; float w;

View File

@@ -3,10 +3,12 @@
// //
#pragma once #pragma once
#include "omath_export.h"
namespace omath namespace omath
{ {
template<class PitchType, class YawType, class RollType> template<class PitchType, class YawType, class RollType>
struct ViewAngles struct OMATH_API ViewAngles
{ {
PitchType pitch; PitchType pitch;
YawType yaw; YawType yaw;

View File

@@ -5,11 +5,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/Triangle3d.hpp" #include "omath/Triangle3d.hpp"
#include "../omath_export.h"
namespace omath::collision namespace omath::collision
{ {
class Ray class OMATH_API Ray
{ {
public: public:
Vector3 start; Vector3 start;
@@ -21,7 +21,7 @@ namespace omath::collision
[[nodiscard]] [[nodiscard]]
Vector3 DirectionVectorNormalized() const; Vector3 DirectionVectorNormalized() const;
}; };
class LineTracer class OMATH_API LineTracer
{ {
public: public:
LineTracer() = delete; LineTracer() = delete;

View File

@@ -4,10 +4,11 @@
#pragma once #pragma once
#include "Constants.h" #include "Constants.h"
#include "omath/projection/Camera.hpp" #include "omath/projection/Camera.hpp"
#include "../../omath_export.h"
namespace omath::source namespace omath::source
{ {
class Camera final : public projection::Camera<Mat4x4, ViewAngles> class OMATH_API Camera final : public projection::Camera<Mat4x4, ViewAngles>
{ {
public: public:
Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort, Camera(const Vector3& position, const ViewAngles& viewAngles, const projection::ViewPort& viewPort,

View File

@@ -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

View File

@@ -6,11 +6,11 @@
#include <vector> #include <vector>
#include "NavigationMesh.hpp" #include "NavigationMesh.hpp"
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "../omath_export.h"
namespace omath::pathfinding namespace omath::pathfinding
{ {
class Astar final class OMATH_API Astar final
{ {
public: public:
[[nodiscard]] [[nodiscard]]

View File

@@ -8,7 +8,7 @@
#include <expected> #include <expected>
#include <vector> #include <vector>
#include <string> #include <string>
#include "../omath_export.h"
namespace omath::pathfinding namespace omath::pathfinding
{ {
@@ -18,7 +18,7 @@ namespace omath::pathfinding
}; };
class NavigationMesh final class OMATH_API NavigationMesh final
{ {
public: public:

View File

@@ -8,11 +8,11 @@
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "omath/prediction/Projectile.hpp" #include "omath/prediction/Projectile.hpp"
#include "omath/prediction/Target.hpp" #include "omath/prediction/Target.hpp"
#include "../omath_export.h"
namespace omath::prediction namespace omath::prediction
{ {
class Engine final class OMATH_API Engine final
{ {
public: public:
explicit Engine(float gravityConstant, float simulationTimeStep, explicit Engine(float gravityConstant, float simulationTimeStep,

View File

@@ -4,11 +4,11 @@
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "../omath_export.h"
namespace omath::prediction namespace omath::prediction
{ {
class Projectile final class OMATH_API Projectile final
{ {
public: public:

View File

@@ -4,11 +4,11 @@
#pragma once #pragma once
#include "omath/Vector3.hpp" #include "omath/Vector3.hpp"
#include "../omath_export.h"
namespace omath::prediction namespace omath::prediction
{ {
class Target final class OMATH_API Target final
{ {
public: public:

View File

@@ -10,11 +10,11 @@
#include "ErrorCodes.hpp" #include "ErrorCodes.hpp"
#include <omath/Angle.hpp> #include <omath/Angle.hpp>
#include <type_traits> #include <type_traits>
#include "../omath_export.h"
namespace omath::projection namespace omath::projection
{ {
class ViewPort final class OMATH_API ViewPort final
{ {
public: public:
float m_width; float m_width;
@@ -28,7 +28,7 @@ namespace omath::projection
using FieldOfView = const Angle<float, 0.f, 180.f, AngleFlags::Clamped>; using FieldOfView = const Angle<float, 0.f, 180.f, AngleFlags::Clamped>;
template<class Mat4x4Type, class ViewAnglesType> template<class Mat4x4Type, class ViewAnglesType>
class Camera class OMATH_API Camera
{ {
public: public: