Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/jolt_physics/Jolt/Math/Float2.h
9913 views
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 2 floats, used as a storage class mainly.
10
class [[nodiscard]] Float2
11
{
12
public:
13
JPH_OVERRIDE_NEW_DELETE
14
15
Float2() = default; ///< Intentionally not initialized for performance reasons
16
Float2(const Float2 &inRHS) = default;
17
Float2 & operator = (const Float2 &inRHS) = default;
18
Float2(float inX, float inY) : x(inX), y(inY) { }
19
20
bool operator == (const Float2 &inRHS) const { return x == inRHS.x && y == inRHS.y; }
21
bool operator != (const Float2 &inRHS) const { return x != inRHS.x || y != inRHS.y; }
22
23
/// To String
24
friend ostream & operator << (ostream &inStream, const Float2 &inV)
25
{
26
inStream << inV.x << ", " << inV.y;
27
return inStream;
28
}
29
30
float x;
31
float y;
32
};
33
34
static_assert(std::is_trivial<Float2>(), "Is supposed to be a trivial type!");
35
36
JPH_NAMESPACE_END
37
38