Toast Engine
Loading...
Searching...
No Matches
contact_events.hpp
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "manifold.hpp"
9
10#include <algorithm>
11#include <array>
12#include <cstddef>
13#include <toast/events/event.hpp>
14#include <toast/export.hpp>
15
16namespace event {
17
18struct ContactEventData {
20 glm::vec3 normal = {};
21 std::array<physics::ContactPoint, 4> contacts = {};
22 uint8_t contact_count = 0;
23
24 explicit ContactEventData(const physics::Manifold& manifold)
25 : pair(manifold.pair),
26 normal(manifold.normal),
27 contact_count(static_cast<uint8_t>(std::min<size_t>(manifold.contact_count, contacts.size()))) {
28 const size_t count = contact_count;
29 for (size_t index = 0; index < count; ++index) {
30 contacts[index] = manifold.contacts[index];
31 }
32 }
33};
34
35struct TOAST_API ContactBegin : Event<ContactBegin> {
36 explicit ContactBegin(const physics::Manifold& manifold) : contact(manifold) { }
37
38 ContactEventData contact;
39};
40
41struct TOAST_API ContactPersist : Event<ContactPersist> {
42 explicit ContactPersist(const physics::Manifold& manifold) : contact(manifold) { }
43
44 ContactEventData contact;
45};
46
47struct TOAST_API ContactEnd : Event<ContactEnd> {
48 explicit ContactEnd(physics::BroadPhasePair pair) : pair(pair) { }
49
51};
52
53}
TODO: Brief description of the file's purpose.
Definition contact_events.hpp:18
Definition collision.hpp:24
Definition manifold.hpp:41