82
82
const PHY_CollData *coll_data)
84
PHY_IPhysicsController* ctrl = static_cast<PHY_IPhysicsController*>(object1);
85
KX_ClientObjectInfo *info = (ctrl) ? static_cast<KX_ClientObjectInfo*>(ctrl->getNewClientInfo()) : NULL;
84
PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(object1);
85
PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(object2);
87
KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo()) : NULL;
88
KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->getNewClientInfo()) : NULL;
86
90
// This call back should only be called for controllers of Near and Radar sensor
94
// Get KX_GameObjects for callbacks
95
KX_GameObject* gobj1 = info1->m_gameobject;
96
KX_GameObject* gobj2 = (info2) ? info2->m_gameobject : NULL;
98
bool has_py_callbacks = false;
100
// Consider callbacks for broadphase inclusion if it's a sensor object type
102
has_py_callbacks = gobj1->m_collisionCallbacks || gobj2->m_collisionCallbacks;
104
switch (info1->m_type)
92
106
case KX_ClientObjectInfo::SENSOR:
93
if (info->m_sensors.size() == 1)
107
if (info1->m_sensors.size() == 1)
95
109
// only one sensor for this type of object
96
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
97
return touchsensor->BroadPhaseFilterCollision(object1,object2);
110
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info1->m_sensors.begin());
111
return touchsensor->BroadPhaseFilterCollision(object1, object2);
100
114
case KX_ClientObjectInfo::OBSENSOR:
101
115
case KX_ClientObjectInfo::OBACTORSENSOR:
102
116
// this object may have multiple collision sensors,
103
117
// check is any of them is interested in this object
104
for (std::list<SCA_ISensor*>::iterator it = info->m_sensors.begin();
105
it != info->m_sensors.end();
118
for (std::list<SCA_ISensor*>::iterator it = info1->m_sensors.begin();
119
it != info1->m_sensors.end();
108
122
if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH)
156
171
void KX_TouchEventManager::NextFrame()
158
if (!m_sensors.Empty())
160
173
SG_DList::iterator<KX_TouchSensor> it(m_sensors);
161
174
for (it.begin();!it.end();++it)
162
175
(*it)->SynchronizeTransform();
164
177
for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit)
166
180
PHY_IPhysicsController* ctrl1 = (*cit).first;
167
// PHY_IPhysicsController* ctrl2 = (*cit).second;
168
// KX_GameObject* gameOb1 = ctrl1->getClientInfo();
169
// KX_GameObject* gameOb1 = ctrl1->getClientInfo();
181
PHY_IPhysicsController* ctrl2 = (*cit).second;
171
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo *>(ctrl1->getNewClientInfo());
172
184
list<SCA_ISensor*>::iterator sit;
174
for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
175
static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL);
178
client_info = static_cast<KX_ClientObjectInfo *>((*cit).second->getNewClientInfo());
180
for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
181
static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL);
187
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo());
189
KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(client_info);
190
// Invoke sensor response for each object
192
for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
193
static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision(ctrl1, ctrl2, NULL);
197
// Second client info
198
client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->getNewClientInfo());
200
KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info);
202
for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
203
static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision(ctrl2, ctrl1, NULL);
206
// Run python callbacks
207
kxObj1->RunCollisionCallbacks(kxObj2);
208
kxObj2->RunCollisionCallbacks(kxObj1);
186
212
m_newCollisions.clear();