Toast Engine
Toggle main menu visibility
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
16
namespace
event {
17
18
struct
ContactEventData {
19
physics::BroadPhasePair
pair;
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
35
struct
TOAST_API ContactBegin : Event<ContactBegin> {
36
explicit
ContactBegin(
const
physics::Manifold
& manifold) : contact(manifold) { }
37
38
ContactEventData
contact;
39
};
40
41
struct
TOAST_API ContactPersist : Event<ContactPersist> {
42
explicit
ContactPersist(
const
physics::Manifold
& manifold) : contact(manifold) { }
43
44
ContactEventData
contact;
45
};
46
47
struct
TOAST_API ContactEnd : Event<ContactEnd> {
48
explicit
ContactEnd(
physics::BroadPhasePair
pair) : pair(pair) { }
49
50
physics::BroadPhasePair
pair;
51
};
52
53
}
export.hpp
manifold.hpp
TODO: Brief description of the file's purpose.
event::ContactEventData
Definition
contact_events.hpp:18
physics::BroadPhasePair
Definition
collision.hpp:24
physics::Manifold
Definition
manifold.hpp:41
engine
src
toast
physics
contact_events.hpp
Generated by
1.17.0