Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
BVec16.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10class [[nodiscard]] alignas(JPH_VECTOR_ALIGNMENT) BVec16
11{
12public:
14
15 // Underlying vector type
16#if defined(JPH_USE_SSE)
17 using Type = __m128i;
18#elif defined(JPH_USE_NEON)
19 using Type = uint8x16_t;
20#else
21 using Type = struct { uint64 mData[2]; };
22#endif
23
25 BVec16() = default;
26 BVec16(const BVec16 &inRHS) = default;
27 BVec16 & operator = (const BVec16 &inRHS) = default;
28 JPH_INLINE BVec16(Type inRHS) : mValue(inRHS) { }
29
31 JPH_INLINE BVec16(uint8 inB0, uint8 inB1, uint8 inB2, uint8 inB3, uint8 inB4, uint8 inB5, uint8 inB6, uint8 inB7, uint8 inB8, uint8 inB9, uint8 inB10, uint8 inB11, uint8 inB12, uint8 inB13, uint8 inB14, uint8 inB15);
32
34 JPH_INLINE BVec16(uint64 inV0, uint64 inV1);
35
37 JPH_INLINE bool operator == (BVec16Arg inV2) const;
38 JPH_INLINE bool operator != (BVec16Arg inV2) const { return !(*this == inV2); }
39
41 static JPH_INLINE BVec16 sZero();
42
44 static JPH_INLINE BVec16 sReplicate(uint8 inV);
45
47 static JPH_INLINE BVec16 sLoadByte16(const uint8 *inV);
48
50 static JPH_INLINE BVec16 sEquals(BVec16Arg inV1, BVec16Arg inV2);
51
53 static JPH_INLINE BVec16 sOr(BVec16Arg inV1, BVec16Arg inV2);
54
56 static JPH_INLINE BVec16 sXor(BVec16Arg inV1, BVec16Arg inV2);
57
59 static JPH_INLINE BVec16 sAnd(BVec16Arg inV1, BVec16Arg inV2);
60
62 static JPH_INLINE BVec16 sNot(BVec16Arg inV1);
63
65 JPH_INLINE uint8 operator [] (uint inCoordinate) const { JPH_ASSERT(inCoordinate < 16); return mU8[inCoordinate]; }
66 JPH_INLINE uint8 & operator [] (uint inCoordinate) { JPH_ASSERT(inCoordinate < 16); return mU8[inCoordinate]; }
67
69 JPH_INLINE bool TestAnyTrue() const;
70
72 JPH_INLINE bool TestAllTrue() const;
73
75 JPH_INLINE int GetTrues() const;
76
78 friend ostream & operator << (ostream &inStream, BVec16Arg inV)
79 {
80 inStream << uint(inV.mU8[0]) << ", " << uint(inV.mU8[1]) << ", " << uint(inV.mU8[2]) << ", " << uint(inV.mU8[3]) << ", "
81 << uint(inV.mU8[4]) << ", " << uint(inV.mU8[5]) << ", " << uint(inV.mU8[6]) << ", " << uint(inV.mU8[7]) << ", "
82 << uint(inV.mU8[8]) << ", " << uint(inV.mU8[9]) << ", " << uint(inV.mU8[10]) << ", " << uint(inV.mU8[11]) << ", "
83 << uint(inV.mU8[12]) << ", " << uint(inV.mU8[13]) << ", " << uint(inV.mU8[14]) << ", " << uint(inV.mU8[15]);
84 return inStream;
85 }
86
87 union
88 {
90 uint8 mU8[16];
91 uint64 mU64[2];
92 };
93};
94
95static_assert(std::is_trivial<BVec16>(), "Is supposed to be a trivial type!");
96
98
99#include "BVec16.inl"
std::uint8_t uint8
Definition Core.h:482
std::uint64_t uint64
Definition Core.h:485
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
A vector consisting of 16 bytes.
Definition BVec16.h:11
uint8 mU8[16]
Definition BVec16.h:90
BVec16()=default
Constructor.
JPH_INLINE BVec16(Type inRHS)
Definition BVec16.h:28
{ uint64 mData[2] Type
Definition BVec16.h:21
Type mValue
Definition BVec16.h:89
BVec16(const BVec16 &inRHS)=default