Debian Codegraph @

thirdparty/jolt_physics/Jolt/Math/Float4.h

raw symbols SCIP
1 // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2 // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3 // SPDX-License-Identifier: MIT
4
5 #pragma once
6
7 JPH_NAMESPACE_BEGIN
8
9 /// Class that holds 4 float values. Convert to Vec4 to perform calculations.
10 class [[nodiscard]] Float4
11 {
12 public:
13 JPH_OVERRIDE_NEW_DELETE
14
15 Float4() = default; ///< Intentionally not initialized for performance reasons
16 Float4(const Float4 &inRHS) = default;
17 Float4(float inX, float inY, float inZ, float inW) : x(inX), y(inY), z(inZ), w(inW) { }
18 Float4 & operator = (const Float4 &inRHS) = default;
19
20 float operator [] (int inCoordinate) const
21 {
22 JPH_ASSERT(inCoordinate < 4);
23 return *(&x + inCoordinate);
24 }
25
26 bool operator == (const Float4 &inRHS) const
27 {
28 return x == inRHS.x && y == inRHS.y && z == inRHS.z && w == inRHS.w;
29 }
30
31 bool operator != (const Float4 &inRHS) const
32 {
33 return x != inRHS.x || y != inRHS.y || z != inRHS.z || w != inRHS.w;
34 }
35
36 float x;
37 float y;
38 float z;
39 float w;
40 };
41
42 static_assert(std::is_trivial<Float4>(), "Is supposed to be a trivial type!");
43
44 JPH_NAMESPACE_END