Files
noahbackus 9d30169a8d
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
initial commit, 4.5 stable
2025-09-16 20:46:46 -04:00

37 lines
1.1 KiB
C++

// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
// SPDX-License-Identifier: MIT
#pragma once
#include <Jolt/Physics/Body/BodyID.h>
#include <Jolt/Core/HashCombine.h>
JPH_NAMESPACE_BEGIN
/// Structure that holds a body pair
struct alignas(uint64) BodyPair
{
JPH_OVERRIDE_NEW_DELETE
/// Constructor
BodyPair() = default;
BodyPair(BodyID inA, BodyID inB) : mBodyA(inA), mBodyB(inB) { }
/// Equals operator
bool operator == (const BodyPair &inRHS) const { return *reinterpret_cast<const uint64 *>(this) == *reinterpret_cast<const uint64 *>(&inRHS); }
/// Smaller than operator, used for consistently ordering body pairs
bool operator < (const BodyPair &inRHS) const { return *reinterpret_cast<const uint64 *>(this) < *reinterpret_cast<const uint64 *>(&inRHS); }
/// Get the hash value of this object
uint64 GetHash() const { return Hash64(*reinterpret_cast<const uint64 *>(this)); }
BodyID mBodyA;
BodyID mBodyB;
};
static_assert(sizeof(BodyPair) == sizeof(uint64), "Mismatch in class size");
JPH_NAMESPACE_END