group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
ContactCache.hpp
Go to the documentation of this file.
1
14
15#pragma once
16
18
19#include <cstdint>
20#include <unordered_map>
21
22namespace physics
23{
24
26{
27public:
30 [[nodiscard]] static uint64_t pairKey(entt::entity a, entt::entity b) noexcept;
31
36 ContactManifold& merge(const ContactManifold& incoming);
37
41 void endFrame() noexcept;
42
44 [[nodiscard]] auto begin() { return cache_.begin(); }
45 [[nodiscard]] auto end() { return cache_.end(); }
46 [[nodiscard]] auto begin() const { return cache_.begin(); }
47 [[nodiscard]] auto end() const { return cache_.end(); }
48 [[nodiscard]] size_t size() const noexcept { return cache_.size(); }
49 void clear() noexcept;
50
51private:
52 struct Entry
53 {
55 uint32_t lastTouchedFrame = 0;
56 };
57
58 std::unordered_map<uint64_t, Entry> cache_;
59 uint32_t currentFrame_ = 0;
60};
61
62} // namespace physics
Multi-point contact manifold + persistent contact cache.
Definition ContactCache.hpp:26
void clear() noexcept
Definition ContactCache.cpp:65
std::unordered_map< uint64_t, Entry > cache_
Definition ContactCache.hpp:58
ContactManifold & merge(const ContactManifold &incoming)
Look up the cached manifold for (a, b), copy accumulated impulses from any matching feature ids,...
Definition ContactCache.cpp:20
auto begin() const
Definition ContactCache.hpp:46
uint32_t currentFrame_
Definition ContactCache.hpp:59
void endFrame() noexcept
Drop any cached manifolds that weren't merged this frame.
Definition ContactCache.cpp:55
static uint64_t pairKey(entt::entity a, entt::entity b) noexcept
Canonical 64-bit key for an ordered pair (a, b) — undirected, so swapping a and b yields the same key...
Definition ContactCache.cpp:11
size_t size() const noexcept
Definition ContactCache.hpp:48
auto begin()
Iterate every live cached manifold (e.g. for the solver).
Definition ContactCache.hpp:44
auto end() const
Definition ContactCache.hpp:47
auto end()
Definition ContactCache.hpp:45
Pure physics math — no ECS types, no registry.
Definition BroadphaseTree.cpp:11
Definition ContactCache.hpp:53
uint32_t lastTouchedFrame
Definition ContactCache.hpp:55
ContactManifold manifold
Definition ContactCache.hpp:54
A contact manifold between exactly two entities.
Definition ContactManifold.hpp:58