Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Float2.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
9// With /fp:fast Float2 is using SIMD instructions where the last 2 floats are undefined, this causes exceptions
10#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
12#endif // JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
13
15class [[nodiscard]] Float2
16{
17public:
19
20 Float2() = default;
21 Float2(const Float2 &inRHS) = default;
22 Float2 & operator = (const Float2 &inRHS) = default;
23 Float2(float inX, float inY) : x(inX), y(inY) { }
24
25 bool operator == (const Float2 &inRHS) const { return x == inRHS.x && y == inRHS.y; }
26 bool operator != (const Float2 &inRHS) const { return x != inRHS.x || y != inRHS.y; }
27
29 friend ostream & operator << (ostream &inStream, const Float2 &inV)
30 {
31 inStream << inV.x << ", " << inV.y;
32 return inStream;
33 }
34
35 float x;
36 float y;
37};
38
39static_assert(std::is_trivially_default_constructible<Float2>() && std::is_trivially_copyable<Float2>(), "Is supposed to be a trivial type!");
40
41#ifdef JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
43#endif // JPH_FLOATING_POINT_EXCEPTIONS_ENABLED
44
#define JPH_PRECISE_MATH_OFF
Definition Core.h:686
#define JPH_NAMESPACE_END
Definition Core.h:487
#define JPH_PRECISE_MATH_ON
Definition Core.h:685
#define JPH_NAMESPACE_BEGIN
Definition Core.h:481
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:51
Float2(const Float2 &inRHS)=default
JPH_OVERRIDE_NEW_DELETE Float2()=default
Intentionally not initialized for performance reasons.
float y
Definition Float2.h:36
float x
Definition Float2.h:35
Float2(float inX, float inY)
Definition Float2.h:23