45 JPL_INLINE
Vec3Pack(
float x,
float y,
float z) noexcept :
X(x),
Y(y),
Z(z) {}
46 JPL_INLINE
Vec3Pack(
const float* x,
const float* y,
const float* z) noexcept :
X(x),
Y(y),
Z(z) {}
49 template<CVec3 Vec3Type>
52 explicit JPL_INLINE
Vec3Pack(
const simd& axis) noexcept :
X(axis),
Y(axis),
Z(axis) {}
54 template<CVec3 Vec3Type>
65 template<CVec3 Vec3Type>
66 JPL_INLINE
void load(std::span<const Vec3Type> inVecs)
70 *
this =
Vec3Pack(inVecs[0], inVecs[1], inVecs[2], inVecs[3]);
74 JPL_INLINE
void store(
float* outX,
float* outY,
float* outZ)
const
79 template<CVec3 Vec3Type>
80 JPL_INLINE
void store(std::span<Vec3Type> outVecs)
const
90 Vec3Type& outVec = outVecs[i];
91 SetX(outVec, xs[i]);
SetY(outVec, ys[i]);
SetZ(outVec, zs[i]);
138 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
139 [[nodiscard]] JPL_INLINE
Vec3Pack operator*(Arg Scale)
const noexcept {
return Vec3Pack(
X * (
float)Scale,
Y * (
float)Scale,
Z * (
float)Scale); }
140 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
141 [[nodiscard]] JPL_INLINE
Vec3Pack operator/(Arg Scale)
const noexcept {
return Vec3Pack(
X / (
float)Scale,
Y / (
float)Scale,
Z / (
float)Scale); }
150 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
151 JPL_INLINE
Vec3Pack&
operator/=(Arg Scale)
noexcept {
X /= (float)Scale;
Y /= (float)Scale;
Z /= (float)Scale;
return *
this; }
153 template<
typename Arg>
requires(std::is_arithmetic_v<Arg>)
154 JPL_INLINE
Vec3Pack&
operator*=(Arg Scale)
noexcept {
X *= (float)Scale;
Y *= (float)Scale;
Z *= (float)Scale;
return *
this; }
164 template<
typename T>
requires(std::is_arithmetic_v<T>)
165 [[nodiscard]] JPL_INLINE
Vec3Pack operator*(T Scale,
const JPL::Vec3Pack& V)
noexcept {
return V.operator*(Scale); }
166 template<
typename T>
requires(std::is_arithmetic_v<T>)
167 [[nodiscard]] JPL_INLINE
Vec3Pack operator/(T Scale,
const JPL::Vec3Pack& V)
noexcept {
return V.operator/(Scale); }
176 [[nodiscard]]
static JPL_INLINE simd LengthSquared(
const Vec3Pack& V)
noexcept {
return V.
LengthSquared(); }
177 [[nodiscard]]
static JPL_INLINE simd Length(
const Vec3Pack& V)
noexcept {
return V.
Length(); }
178 static JPL_INLINE Vec3Pack& Normalize(Vec3Pack& V)
noexcept {
return V.
Normalize(); }
179 [[nodiscard]]
static JPL_INLINE Vec3Pack Normalized(
const Vec3Pack& V)
noexcept {
return Vec3Pack(V).Normalize(); }
180 [[nodiscard]]
static JPL_INLINE simd DotProduct(
const Vec3Pack& A,
const Vec3Pack& B)
noexcept {
return A.X * B.X + A.Y * B.Y + A.Z * B.Z; }
181 [[nodiscard]]
static JPL_INLINE Vec3Pack CrossProduct(
const Vec3Pack& A,
const Vec3Pack& B)
noexcept
184 A.Y * B.Z - A.Z * B.Y,
185 A.Z * B.X - A.X * B.Z,
186 A.X * B.Y - A.Y * B.X
190 [[nodiscard]]
static JPL_INLINE Vec3Pack
Abs(
const Vec3Pack& V)
noexcept {
return {
abs(V.
X),
abs(V.
Y),
abs(V.
Z) }; }
194 os <<
"{ " << v.
X <<
", " << v.
Y <<
", " << v.
Z <<
" }";
return os;
199 [[nodiscard]]
static JPL_INLINE Vec3Pack
FMA(
const Vec3Pack& mulA,
const Vec3Pack& mulB,
const Vec3Pack& addC)
noexcept
202 fma(mulA.X, mulB.X, addC.X),
203 fma(mulA.Y, mulB.Y, addC.Y),
204 fma(mulA.Z, mulB.Z, addC.Z),
208 [[nodiscard]]
static JPL_INLINE Vec3Pack
FMA(
const Vec3Pack& mulA,
const simd& mulB,
const Vec3Pack& addC)
noexcept
211 fma(mulA.X, mulB, addC.X),
212 fma(mulA.Y, mulB, addC.Y),
213 fma(mulA.Z, mulB, addC.Z),
217 [[nodiscard]]
static JPL_INLINE Vec3Pack
FMA(
const simd& mulA,
const Vec3Pack& mulB,
const Vec3Pack& addC)
noexcept
220 fma(mulA, mulB.X, addC.X),
221 fma(mulA, mulB.Y, addC.Y),
222 fma(mulA, mulB.Z, addC.Z),
#define JPL_ASSERT(inExpression,...)
Main assert macro, usage: JPL_ASSERT(condition, message) or JPL_ASSERT(condition)
Definition ErrorReporting.h:80
JPL_INLINE constexpr T FMA(T a, T b, T c) noexcept
Inlined fuse multiply-add. Compiler in some circumstances is more eager to optimize this than std::fm...
Definition Math.h:186
JPL_INLINE constexpr T Sqrt(T x) noexcept
Definition Math.h:269
JPL_INLINE constexpr auto Abs(const T &value) noexcept
Standard abs is not constexpr in C++20.
Definition Math.h:87
JPL_INLINE simd InvSqrtFast(const simd &vec) noexcept
Definition SIMD.h:1783
Definition AcousticMaterial.h:36
JPL_INLINE void SetZ(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:41
std::uint32_t uint32
Definition Core.h:311
JPL_INLINE auto GetX(const Vec3Type &v) noexcept
Definition Vec3Traits.h:35
JPL_INLINE void SetY(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:40
JPL_INLINE auto GetZ(const Vec3Type &v) noexcept
Definition Vec3Traits.h:37
JPL_INLINE constexpr Vec2 operator/(T Scale, const JPL::Vec2 &V) noexcept
Definition MinimalVec2.h:64
JPL_INLINE constexpr bool operator==(const Vec2 &A, const Vec2 &B) noexcept
Definition MinimalVec2.h:59
JPL_INLINE auto GetY(const Vec3Type &v) noexcept
Definition Vec3Traits.h:36
JPL_INLINE simd fma(const simd &mul1, const simd &mul2, const simd &addV) noexcept
Element-wise fused multiply-add.
Definition SIMD.h:1843
JPL_INLINE constexpr Vec2 operator*(T Scale, const JPL::Vec2 &V) noexcept
Definition MinimalVec2.h:62
JPL_INLINE void SetX(Vec3Type &v, Vec3FloatType< Vec3Type > value) noexcept
Definition Vec3Traits.h:39
JPL_INLINE simd abs(const simd &vec) noexcept
Definition SIMD.h:1827
std::ostream & operator<<(std::ostream &os, const AcousticMaterial &v)
Definition AcousticMaterial.h:104
Structure to pass around per axis mask parameters.
Definition Vec3Pack.h:34
simd_mask X
Definition Vec3Pack.h:35
simd_mask Y
Definition Vec3Pack.h:35
simd_mask Z
Definition Vec3Pack.h:35
Minimal Vec3 class for SIMD operations on 4 Vec3 at a time.
Definition Vec3Pack.h:41
JPL_INLINE bool IsEqual(const Vec3Pack &other) const
Check if all components of all lanes match.
Definition Vec3Pack.h:162
JPL_INLINE void store(std::span< Vec3Type > outVecs) const
Definition Vec3Pack.h:80
JPL_INLINE Vec3Pack & operator/=(simd Scale) noexcept
Definition Vec3Pack.h:156
JPL_INLINE Vec3Pack operator*(simd Scale) const noexcept
Definition Vec3Pack.h:143
static JPL_INLINE Vec3Pack select(const Vec3MaskPack &conditionMasks, const Vec3Pack &ifTrue, const Vec3Pack &ifFalse)
Definition Vec3Pack.h:108
JPL_INLINE Vec3Pack(const Vec3Type &vec) noexcept
Definition Vec3Pack.h:50
JPL_INLINE Vec3Pack operator-(const Vec3Pack &V) const
Definition Vec3Pack.h:135
JPL_INLINE Vec3Pack & operator*=(simd Scale) noexcept
Definition Vec3Pack.h:157
JPL_INLINE Vec3Pack operator-() const
Definition Vec3Pack.h:134
static JPL_INLINE Vec3Pack select(const simd_mask &conditionMask, const Vec3Pack &ifTrue, const Vec3Pack &ifFalse)
Definition Vec3Pack.h:97
JPL_INLINE void load(std::span< const Vec3Type > inVecs)
Definition Vec3Pack.h:66
JPL_INLINE Vec3Pack(const Vec3Type &vec1, const Vec3Type &vec2, const Vec3Type &vec3, const Vec3Type &vec4)
Definition Vec3Pack.h:55
JPL_INLINE Vec3Pack(float x, float y, float z) noexcept
Definition Vec3Pack.h:45
JPL_INLINE Vec3Pack & Normalize() noexcept
Definition Vec3Pack.h:122
JPL_INLINE Vec3Pack(simd x, simd y, simd z) noexcept
Definition Vec3Pack.h:47
JPL_INLINE Vec3Pack operator+(const Vec3Pack &V) const
Definition Vec3Pack.h:136
JPL_INLINE void store(float *outX, float *outY, float *outZ) const
Pointers must point to storate allocated for at least simd::size() num of floats each.
Definition Vec3Pack.h:74
simd Z
Definition Vec3Pack.h:42
JPL_INLINE void operator+=(const Vec3Pack &V) noexcept
Definition Vec3Pack.h:147
simd X
Definition Vec3Pack.h:42
JPL_INLINE Vec3Pack(const float *x, const float *y, const float *z) noexcept
Definition Vec3Pack.h:46
JPL_INLINE Vec3Pack & operator*=(const Vec3Pack Other)
Definition Vec3Pack.h:148
static JPL_INLINE Vec3Pack Zero() noexcept
Definition Vec3Pack.h:117
JPL_INLINE simd LengthSquared() const noexcept
Definition Vec3Pack.h:119
JPL_INLINE Vec3Pack(const simd &axis) noexcept
Definition Vec3Pack.h:52
simd Y
Definition Vec3Pack.h:42
JPL_INLINE Vec3Pack operator/(simd Scale) const noexcept
Definition Vec3Pack.h:144
JPL_INLINE simd Length() const noexcept
Definition Vec3Pack.h:120
JPL_INLINE bool all_of() const noexcept
Test if all of the components are true.
Definition SIMD.h:1169
Minimal 4-wide 32-bit float vector implementation for SIMD.
Definition SIMD.h:60
static JPL_INLINE simd select(const simd_mask &mask, const simd &a, const simd &b) noexcept
Component-wise select, returns 'a' if mask is true, 'b' otherwise.
Definition SIMD.h:1034
JPL_INLINE void store(float *mem) const
Store values from simd to provided memory location.
Definition SIMD.h:573
static constexpr std::size_t size() noexcept
Get number of element of the vector.
Definition SIMD.h:97