Plasma Engine  2.0
Loading...
Searching...
No Matches
SimdConversion.h
1#pragma once
2
3#include <Foundation/Math/BoundingBox.h>
4#include <Foundation/Math/BoundingBoxSphere.h>
5#include <Foundation/Math/BoundingSphere.h>
6#include <Foundation/Math/Transform.h>
7#include <Foundation/SimdMath/SimdBBox.h>
8#include <Foundation/SimdMath/SimdBBoxSphere.h>
9#include <Foundation/SimdMath/SimdVec4i.h>
10
11namespace plSimdConversion
12{
13 PL_ALWAYS_INLINE plVec3 ToVec3(const plSimdVec4f& v)
14 {
15 plVec4 tmp;
16 v.Store<4>(&tmp.x);
17 return *reinterpret_cast<plVec3*>(&tmp.x);
18 }
19
20 PL_ALWAYS_INLINE plSimdVec4f ToVec3(const plVec3& v)
21 {
22 plSimdVec4f tmp;
23 tmp.Load<3>(&v.x);
24 return tmp;
25 }
26
27 PL_ALWAYS_INLINE plVec3I32 ToVec3i(const plSimdVec4i& v)
28 {
29 plVec4I32 tmp;
30 v.Store<4>(&tmp.x);
31 return *reinterpret_cast<plVec3I32*>(&tmp.x);
32 }
33
34 PL_ALWAYS_INLINE plSimdVec4i ToVec3i(const plVec3I32& v)
35 {
36 plSimdVec4i tmp;
37 tmp.Load<3>(&v.x);
38 return tmp;
39 }
40
41 PL_ALWAYS_INLINE plVec4 ToVec4(const plSimdVec4f& v)
42 {
43 plVec4 tmp;
44 v.Store<4>(&tmp.x);
45 return tmp;
46 }
47
48 PL_ALWAYS_INLINE plSimdVec4f ToVec4(const plVec4& v)
49 {
50 plSimdVec4f tmp;
51 tmp.Load<4>(&v.x);
52 return tmp;
53 }
54
55 PL_ALWAYS_INLINE plVec4I32 ToVec4i(const plSimdVec4i& v)
56 {
57 plVec4I32 tmp;
58 v.Store<4>(&tmp.x);
59 return tmp;
60 }
61
62 PL_ALWAYS_INLINE plSimdVec4i ToVec4i(const plVec4I32& v)
63 {
64 plSimdVec4i tmp;
65 tmp.Load<4>(&v.x);
66 return tmp;
67 }
68
69 PL_ALWAYS_INLINE plQuat ToQuat(const plSimdQuat& q)
70 {
71 plQuat tmp;
72 q.m_v.Store<4>(&tmp.x);
73 return tmp;
74 }
75
76 PL_ALWAYS_INLINE plSimdQuat ToQuat(const plQuat& q)
77 {
78 plSimdVec4f tmp;
79 tmp.Load<4>(&q.x);
80 return plSimdQuat(tmp);
81 }
82
83 PL_ALWAYS_INLINE plTransform ToTransform(const plSimdTransform& t)
84 {
85 return plTransform(ToVec3(t.m_Position), ToQuat(t.m_Rotation), ToVec3(t.m_Scale));
86 }
87
88 inline plSimdTransform ToTransform(const plTransform& t)
89 {
90 return plSimdTransform(ToVec3(t.m_vPosition), ToQuat(t.m_qRotation), ToVec3(t.m_vScale));
91 }
92
93 PL_ALWAYS_INLINE plMat4 ToMat4(const plSimdMat4f& m)
94 {
95 plMat4 tmp;
97 return tmp;
98 }
99
100 PL_ALWAYS_INLINE plSimdMat4f ToMat4(const plMat4& m)
101 {
103 }
104
105 PL_ALWAYS_INLINE plBoundingBoxSphere ToBBoxSphere(const plSimdBBoxSphere& b)
106 {
107 plVec4 centerAndRadius = ToVec4(b.m_CenterAndRadius);
108 return plBoundingBoxSphere::MakeFromCenterExtents(centerAndRadius.GetAsVec3(), ToVec3(b.m_BoxHalfExtents), centerAndRadius.w);
109 }
110
111 PL_ALWAYS_INLINE plSimdBBoxSphere ToBBoxSphere(const plBoundingBoxSphere& b)
112 {
113 return plSimdBBoxSphere::MakeFromCenterExtents(ToVec3(b.m_vCenter), ToVec3(b.m_vBoxHalfExtends), b.m_fSphereRadius);
114 }
115
116 PL_ALWAYS_INLINE plBoundingSphere ToBSphere(const plSimdBSphere& s)
117 {
118 plVec4 centerAndRadius = ToVec4(s.m_CenterAndRadius);
119 return plBoundingSphere::MakeFromCenterAndRadius(centerAndRadius.GetAsVec3(), centerAndRadius.w);
120 }
121
122 PL_ALWAYS_INLINE plSimdBSphere ToBSphere(const plBoundingSphere& s)
123 {
124 return plSimdBSphere(ToVec3(s.m_vCenter), s.m_fRadius);
125 }
126
127 PL_ALWAYS_INLINE plSimdBBox ToBBox(const plBoundingBox& b)
128 {
129 return plSimdBBox(ToVec3(b.m_vMin), ToVec3(b.m_vMax));
130 }
131
132 PL_ALWAYS_INLINE plBoundingBox ToBBox(const plSimdBBox& b)
133 {
134 return plBoundingBox::MakeFromMinMax(ToVec3(b.m_Min), ToVec3(b.m_Max));
135 }
136
137}; // namespace plSimdConversion
static plBoundingBoxSphereTemplate< float > MakeFromCenterExtents(const plVec3Template< float > &vCenter, const plVec3Template< float > &vBoxHalfExtents, float fSphereRadius)
Definition BoundingBoxSphere_inl.h:68
static plBoundingBoxTemplate< float > MakeFromMinMax(const plVec3Template< float > &vMin, const plVec3Template< float > &vMax)
Definition BoundingBox_inl.h:42
static plBoundingSphereTemplate< float > MakeFromCenterAndRadius(const plVec3Template< float > &vCenter, float fRadius)
Definition BoundingSphere_inl.h:35
Type m_fElementsCM[16]
The matrix as a 16-element Type array (column-major)
Definition Mat4.h:24
Definition SimdBBox.h:6
Definition SimdBBoxSphere.h:6
static plSimdBBoxSphere MakeFromCenterExtents(const plSimdVec4f &vCenter, const plSimdVec4f &vBoxHalfExtents, const plSimdFloat &fSphereRadius)
Creates an object from the given center point and extents.
Definition SimdBBoxSphere_inl.h:46
Definition SimdBSphere.h:6
A 4x4 matrix class.
Definition SimdMat4f.h:7
static plSimdMat4f MakeFromColumnMajorArray(const float *const pData)
Creates a matrix from 16 values that are in column-major layout.
Definition SimdMat4f_inl.h:37
Definition SimdQuat.h:6
Definition SimdTransform.h:6
A 4-component SIMD vector class.
Definition SimdVec4f.h:8
A SIMD 4-component vector class of signed 32b integers.
Definition SimdVec4i.h:9
const plVec3Template< Type > GetAsVec3() const
Returns an plVec3Template with x,y and z from this vector.
Definition Vec4_inl.h:112
@ ColumnMajor
The matrix is stored in column-major format.
Definition Declarations.h:67