vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
contact_cache.h
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <glm/glm.hpp>
7
8#include "ecs/entity.h"
9#include "system/physics/physics_internal.h"
10#include "system/physics/collision/contact.h"
11
12namespace Vkm::Engine {
13
24class ContactCache {
25 public:
26 ContactCache() = default;
27 ~ContactCache() = default;
28
29 ContactCache(const ContactCache& other) = delete;
30 ContactCache& operator=(const ContactCache& other) = delete;
31
32 ContactCache(ContactCache && other) = delete;
33 ContactCache& operator=(ContactCache && other) = delete;
34
35 public:
43 void seed(
44 std::vector<ContactManifold>& manifolds,
45 const std::vector<EntityId>& entities,
46 const std::vector<BodyFrame>& frames
47 ) const;
48
59 void record(
60 const std::vector<ContactManifold>& manifolds,
61 const std::vector<EntityId>& entities,
62 const std::vector<BodyFrame>& frames
63 );
64
66 void clear();
67
68 private:
70 struct Held {
71 uint64_t pair = 0;
73 glm::vec3 offsetA = {0.0f, 0.0f, 0.0f};
75 glm::vec3 offsetB = {0.0f, 0.0f, 0.0f};
76 glm::vec3 friction = {0.0f, 0.0f, 0.0f};
77 float normalImpulse = 0.0f;
78 uint32_t sequence = 0;
79 };
80
81 private:
82 std::vector<Held> m_held;
83};
84
85} // namespace Vkm::Engine
void seed(std::vector< ContactManifold > &manifolds, const std::vector< EntityId > &entities, const std::vector< BodyFrame > &frames) const
Give every contact the impulse its pair carried last tick.
void clear()
Forget everything, for a world that is being replaced.
void record(const std::vector< ContactManifold > &manifolds, const std::vector< EntityId > &entities, const std::vector< BodyFrame > &frames)
Replace the store with what the solve just settled on.