Skip to content

Commit

Permalink
Math: fix DLL build
Browse files Browse the repository at this point in the history
  • Loading branch information
smilediver committed Aug 28, 2024
1 parent c76c322 commit 353e279
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 17 deletions.
8 changes: 8 additions & 0 deletions core/math/Mat4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@

NS_AX_MATH_BEGIN

#if defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
const Mat4 Mat4::IDENTITY =
Mat4(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);

const Mat4 Mat4::ZERO = Mat4(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
#endif


void Mat4::createLookAt(const Vec3& eyePosition, const Vec3& targetPosition, const Vec3& up, Mat4* dst)
{
createLookAt(eyePosition.x, eyePosition.y, eyePosition.z, targetPosition.x, targetPosition.y, targetPosition.z,
Expand Down
6 changes: 4 additions & 2 deletions core/math/Mat4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ inline Vec4 operator*(const Mat4& m, const Vec4& v)
return x;
}

inline constexpr Mat4 Mat4::IDENTITY(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
inline constexpr Mat4 Mat4::ZERO(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
#if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT))
inline constexpr Mat4 Mat4::IDENTITY(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
inline constexpr Mat4 Mat4::ZERO(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
#endif

NS_AX_MATH_END
5 changes: 5 additions & 0 deletions core/math/Quaternion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

NS_AX_MATH_BEGIN

#if defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
const Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
#endif


Quaternion::Quaternion(const Mat4& m)
{
set(m);
Expand Down
4 changes: 3 additions & 1 deletion core/math/Quaternion.inl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ inline Vec3 Quaternion::operator*(const Vec3& v) const
return v + uv + uuv;
}

inline constexpr Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
#if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT))
inline constexpr Quaternion Quaternion::ZERO(0.0f, 0.0f, 0.0f, 0.0f);
#endif

NS_AX_MATH_END
6 changes: 4 additions & 2 deletions core/math/Rect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ THE SOFTWARE.
#include <cmath>
#include "base/Macros.h"

// implementation of Vec2
namespace ax
{

// implementation of Rect
#if defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
const Rect Rect::ZERO = Rect(0, 0, 0, 0);
#endif


bool Rect::intersectsCircle(const Vec2& center, float radius) const
{
Expand Down
4 changes: 3 additions & 1 deletion core/math/Rect.inl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ inline bool Rect::intersectsRect(const Rect& rect) const
rect.getMaxY() < getMinY());
}

inline constexpr Rect Rect::ZERO(0, 0, 0, 0);
#if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT))
inline constexpr Rect Rect::ZERO(0, 0, 0, 0);
#endif

}
9 changes: 9 additions & 0 deletions core/math/Vec3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@

NS_AX_MATH_BEGIN

#if defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
const Vec3 Vec3::ZERO(0.0f, 0.0f, 0.0f);
const Vec3 Vec3::ONE(1.0f, 1.0f, 1.0f);
const Vec3 Vec3::UNIT_X(1.0f, 0.0f, 0.0f);
const Vec3 Vec3::UNIT_Y(0.0f, 1.0f, 0.0f);
const Vec3 Vec3::UNIT_Z(0.0f, 0.0f, 1.0f);
#endif


Vec3 Vec3::fromColor(unsigned int color)
{
float components[3];
Expand Down
12 changes: 7 additions & 5 deletions core/math/Vec3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,12 @@ inline Vec3 operator*(float x, const Vec3& v)
return result;
}

inline constexpr Vec3 Vec3::ZERO(0.0f, 0.0f, 0.0f);
inline constexpr Vec3 Vec3::ONE(1.0f, 1.0f, 1.0f);
inline constexpr Vec3 Vec3::UNIT_X(1.0f, 0.0f, 0.0f);
inline constexpr Vec3 Vec3::UNIT_Y(0.0f, 1.0f, 0.0f);
inline constexpr Vec3 Vec3::UNIT_Z(0.0f, 0.0f, 1.0f);
#if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT))
inline constexpr Vec3 Vec3::ZERO(0.0f, 0.0f, 0.0f);
inline constexpr Vec3 Vec3::ONE(1.0f, 1.0f, 1.0f);
inline constexpr Vec3 Vec3::UNIT_X(1.0f, 0.0f, 0.0f);
inline constexpr Vec3 Vec3::UNIT_Y(0.0f, 1.0f, 0.0f);
inline constexpr Vec3 Vec3::UNIT_Z(0.0f, 0.0f, 1.0f);
#endif

NS_AX_MATH_END
10 changes: 10 additions & 0 deletions core/math/Vec4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@

NS_AX_MATH_BEGIN

#if defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT)
const Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f);
const Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f);
const Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f);
const Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f);
const Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f);
const Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f);
#endif


Vec4 Vec4::fromColor(unsigned int color)
{
float components[4];
Expand Down
14 changes: 8 additions & 6 deletions core/math/Vec4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ inline constexpr void Vec4::setDirection(const Vec4& p1, const Vec4& p2)
w = p2.w - p1.w;
}

inline constexpr Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f);
inline constexpr Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f);
#if !(defined(AX_DLLEXPORT) || defined(AX_DLLIMPORT))
inline constexpr Vec4 Vec4::ZERO = Vec4(0.0f, 0.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::ONE = Vec4(1.0f, 1.0f, 1.0f, 1.0f);
inline constexpr Vec4 Vec4::UNIT_X = Vec4(1.0f, 0.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_Y = Vec4(0.0f, 1.0f, 0.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_Z = Vec4(0.0f, 0.0f, 1.0f, 0.0f);
inline constexpr Vec4 Vec4::UNIT_W = Vec4(0.0f, 0.0f, 0.0f, 1.0f);
#endif

}

0 comments on commit 353e279

Please sign in to comment.