-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathContactListener.cpp
54 lines (46 loc) · 1.27 KB
/
ContactListener.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "ContactListener.h"
#include <iostream>
#include "DestroyableIntf.h"
#include "EventHandler.h"
ContactListener::ContactListener(EventHandler& eventHandler)
:m_eventHandler(eventHandler)
{
}
void ContactListener::BeginContact(b2Contact* contact)
{
/*
b2Body* bodyA = contact->GetFixtureA()->GetBody();
b2Body* bodyB = contact->GetFixtureB()->GetBody();
//Do nothing
if((bodyA->GetType() != b2_staticBody) &&
(bodyB->GetType() != b2_staticBody))
{
void* pTempA =
bodyA->GetUserData();
void* pTempB =
bodyB->GetUserData();
if(pTempA != pTempB)
{
m_eventHandler.CollisionHappened(bodyA,bodyB);
}
}
*/
}
void ContactListener::PreSolve(b2Contact* contact, const b2Manifold* /*oldManifold*/)
{
b2Body* bodyA = contact->GetFixtureA()->GetBody();
b2Body* bodyB = contact->GetFixtureB()->GetBody();
//Do nothing
if((bodyA->GetType() != b2_staticBody) &&
(bodyB->GetType() != b2_staticBody))
{
void* pTempA =
bodyA->GetUserData();
void* pTempB =
bodyB->GetUserData();
if(pTempA != pTempB)
{
m_eventHandler.CollisionHappened(bodyA,bodyB);
}
}
}