Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Float3.h
Go to the documentation of this file.
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
8
10
12class [[nodiscard]] Float3
13{
14public:
16
17 Float3() = default;
18 Float3(const Float3 &inRHS) = default;
19 Float3 & operator = (const Float3 &inRHS) = default;
20 constexpr Float3(float inX, float inY, float inZ) : x(inX), y(inY), z(inZ) { }
21
22 float operator [] (int inCoordinate) const
23 {
24 JPH_ASSERT(inCoordinate < 3);
25 return *(&x + inCoordinate);
26 }
27
28 bool operator == (const Float3 &inRHS) const
29 {
30 return x == inRHS.x && y == inRHS.y && z == inRHS.z;
31 }
32
33 bool operator != (const Float3 &inRHS) const
34 {
35 return x != inRHS.x || y != inRHS.y || z != inRHS.z;
36 }
37
38 float x;
39 float y;
40 float z;
41};
42
44
45static_assert(is_trivial<Float3>(), "Is supposed to be a trivial type!");
46
48
49// Create a std::hash for Float3
50JPH_MAKE_HASHABLE(JPH::Float3, t.x, t.y, t.z)
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_MAKE_HASHABLE(type,...)
Definition: HashCombine.h:87
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:31
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition: Float3.h:13
constexpr Float3(float inX, float inY, float inZ)
Definition: Float3.h:20
float y
Definition: Float3.h:39
float z
Definition: Float3.h:40
JPH_OVERRIDE_NEW_DELETE Float3()=default
Intentionally not initialized for performance reasons.
float x
Definition: Float3.h:38
Float3(const Float3 &inRHS)=default