-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSIMDVector.hpp
More file actions
88 lines (70 loc) · 2.56 KB
/
SIMDVector.hpp
File metadata and controls
88 lines (70 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#ifndef SIMDVECTOR_H
#define SIMDVECTOR_H
#ifndef SIMD_H
#include "simd.h"
#endif
#ifdef _WINDLL
#define CGM_DLL __declspec(dllexport)
#else
#define CGM_DLL __declspec(dllimport)
#endif
namespace cliqCity
{
namespace graphicsMath
{
struct Vector4;
struct Vector3;
struct Vector2;
struct __declspec(align(16)) CGM_DLL SIMDVector
{
union
{
float128_t m;
struct
{
float x, y, z, w;
};
};
static SIMDVector SetVector(const float& x, const float& y, const float& z, const float& w);
static SIMDVector SetVector(const Vector4& vector);
static SIMDVector SetVector(const Vector3& vector);
static SIMDVector SetVector(const Vector2& vector);
inline SIMDVector(const SIMDVector& other) : m(other.m) {};
inline SIMDVector(const float128_t& m) : m(m) {};
inline SIMDVector(const float& x, const float& y, const float& z, const float& w) : SIMDVector(simd::Set(x, y, z, w)) {}
inline SIMDVector() : SIMDVector(simd::Set(0.0f)) {};
SIMDVector& operator+=(const SIMDVector& rhs);
SIMDVector& operator-=(const SIMDVector& rhs);
SIMDVector& operator*=(const SIMDVector& rhs);
SIMDVector& operator+=(const float& rhs);
SIMDVector& operator-=(const float& rhs);
SIMDVector& operator*=(const float& rhs);
SIMDVector& operator/=(const float& rhs);
// Unary
SIMDVector& operator=(const SIMDVector& rhs);
SIMDVector operator-();
float& operator[](const unsigned int& index);
inline operator float128_arg_t() const
{
return m;
}
};
CGM_DLL SIMDVector cross(const SIMDVector& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector normalize(const SIMDVector& vector);
CGM_DLL float magnitude(const SIMDVector& vector);
CGM_DLL float magnitudeSquared(const SIMDVector& vector);
CGM_DLL float dot(const SIMDVector& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator+(const SIMDVector& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator-(const SIMDVector& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator*(const SIMDVector& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator+(const SIMDVector& lhs, const float& rhs);
CGM_DLL SIMDVector operator-(const SIMDVector& lhs, const float& rhs);
CGM_DLL SIMDVector operator*(const SIMDVector& lhs, const float& rhs);
CGM_DLL SIMDVector operator/(const SIMDVector& lhs, const float& rhs);
CGM_DLL SIMDVector operator+(const float& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator-(const float& lhs, const SIMDVector& rhs);
CGM_DLL SIMDVector operator*(const float& lhs, const SIMDVector& rhs);
}
}
#endif