Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
CollisionObject.cpp
Go to the documentation of this file.
1#include "physics/CollisionObject.h"
2
3#include <algorithm>
4
5namespace mnd
6{
7
12
14{
15 if (listener == nullptr)
16 {
17 return;
18 }
19 if (std::find(m_contactListeners.begin(), m_contactListeners.end(), listener) != m_contactListeners.end())
20 {
21 return;
22 }
23 m_contactListeners.push_back(listener);
24}
25
27{
28 auto iter = std::find(m_contactListeners.begin(), m_contactListeners.end(), listener);
29 if (iter != m_contactListeners.end())
30 {
31 m_contactListeners.erase(iter);
32 }
33}
34
36{
37 auto listeners = m_contactListeners;
38 for (auto listener : listeners)
39 {
40 if (listener
41 && std::find(m_contactListeners.begin(), m_contactListeners.end(), listener) != m_contactListeners.end())
42 {
43 listener->OnContact(obj, pos, norm);
44 }
45 }
46}
47
48} // namespace mnd
CollisionObjectType m_collisionObjType
void RemoveContactListener(IContactListener *listener)
CollisionObjectType GetCollisionObjectType()
std::vector< IContactListener * > m_contactListeners
void AddContactListener(IContactListener *listener)
void DispatchContactEvent(CollisionObject *obj, const vec3 &pos, const vec3 &norm)
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
Definition Types.h:51
CollisionObjectType