Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
BodyPair.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
9
11
13struct alignas(uint64) BodyPair
14{
16
18 BodyPair() = default;
19 BodyPair(BodyID inA, BodyID inB) : mBodyA(inA), mBodyB(inB) { }
20
22 bool operator == (const BodyPair &inRHS) const { return *reinterpret_cast<const uint64 *>(this) == *reinterpret_cast<const uint64 *>(&inRHS); }
23
25 bool operator < (const BodyPair &inRHS) const { return *reinterpret_cast<const uint64 *>(this) < *reinterpret_cast<const uint64 *>(&inRHS); }
26
28 uint64 GetHash() const { return Hash64(*reinterpret_cast<const uint64 *>(this)); }
29
32};
33
34static_assert(sizeof(BodyPair) == sizeof(uint64), "Mismatch in class size");
35
std::uint64_t uint64
Definition: Core.h:456
#define JPH_NAMESPACE_END
Definition: Core.h:378
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
uint64 Hash64(uint64 inValue)
Definition: HashCombine.h:30
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:31
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Structure that holds a body pair.
Definition: BodyPair.h:14
uint64 GetHash() const
Get the hash value of this object.
Definition: BodyPair.h:28
BodyPair(BodyID inA, BodyID inB)
Definition: BodyPair.h:19
BodyID mBodyA
Definition: BodyPair.h:30
BodyID mBodyB
Definition: BodyPair.h:31
JPH_OVERRIDE_NEW_DELETE BodyPair()=default
Constructor.