~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/gameengine/Ketsji/KX_TouchEventManager.cpp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
                                                        void *object2,
82
82
                                                        const PHY_CollData *coll_data)
83
83
{
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);
 
86
 
 
87
        KX_ClientObjectInfo *info1 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo()) : NULL;
 
88
        KX_ClientObjectInfo *info2 = (ctrl1) ? static_cast<KX_ClientObjectInfo*>(ctrl2->getNewClientInfo()) : NULL;
 
89
 
86
90
        // This call back should only be called for controllers of Near and Radar sensor
87
 
        if (!info)
 
91
        if (!info1)
88
92
                return true;
89
93
 
90
 
        switch (info->m_type)
 
94
        // Get KX_GameObjects for callbacks
 
95
        KX_GameObject* gobj1 = info1->m_gameobject;
 
96
        KX_GameObject* gobj2 = (info2) ? info2->m_gameobject : NULL;
 
97
 
 
98
        bool has_py_callbacks = false;
 
99
 
 
100
        // Consider callbacks for broadphase inclusion if it's a sensor object type
 
101
        if (gobj1 && gobj2)
 
102
                has_py_callbacks = gobj1->m_collisionCallbacks || gobj2->m_collisionCallbacks;
 
103
 
 
104
        switch (info1->m_type)
91
105
        {
92
106
        case KX_ClientObjectInfo::SENSOR:
93
 
                if (info->m_sensors.size() == 1)
 
107
                if (info1->m_sensors.size() == 1)
94
108
                {
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);
98
112
                }
99
113
                break;
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();
106
120
                        ++it)
107
121
                {
108
122
                        if ((*it)->GetSensorType() == SCA_ISensor::ST_TOUCH) 
112
126
                                        return true;
113
127
                        }
114
128
                }
115
 
                return false;
 
129
 
 
130
                return has_py_callbacks;
116
131
 
117
132
        // quiet the compiler
118
133
        case KX_ClientObjectInfo::STATIC:
155
170
 
156
171
void KX_TouchEventManager::NextFrame()
157
172
{
158
 
        if (!m_sensors.Empty())
159
 
        {
160
173
                SG_DList::iterator<KX_TouchSensor> it(m_sensors);
161
174
                for (it.begin();!it.end();++it)
162
175
                        (*it)->SynchronizeTransform();
163
176
                
164
177
                for (std::set<NewCollision>::iterator cit = m_newCollisions.begin(); cit != m_newCollisions.end(); ++cit)
165
178
                {
 
179
                        // Controllers
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;
170
182
 
171
 
                        KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo *>(ctrl1->getNewClientInfo());
 
183
                        // Sensor iterator
172
184
                        list<SCA_ISensor*>::iterator sit;
173
 
                        if (client_info) {
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);
176
 
                                }
177
 
                        }
178
 
                        client_info = static_cast<KX_ClientObjectInfo *>((*cit).second->getNewClientInfo());
179
 
                        if (client_info) {
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);
182
 
                                }
183
 
                        }
 
185
 
 
186
                        // First client info
 
187
                        KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo*>(ctrl1->getNewClientInfo());
 
188
                        // First gameobject
 
189
                        KX_GameObject *kxObj1 = KX_GameObject::GetClientObject(client_info);
 
190
                        // Invoke sensor response for each object
 
191
                        if (client_info) {
 
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);
 
194
                                }
 
195
                        }
 
196
 
 
197
                        // Second client info
 
198
                        client_info = static_cast<KX_ClientObjectInfo *>(ctrl2->getNewClientInfo());
 
199
                        // Second gameobject
 
200
                        KX_GameObject *kxObj2 = KX_GameObject::GetClientObject(client_info);
 
201
                        if (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);
 
204
                                }
 
205
                        }
 
206
                        // Run python callbacks
 
207
                        kxObj1->RunCollisionCallbacks(kxObj2);
 
208
                        kxObj2->RunCollisionCallbacks(kxObj1);
 
209
 
184
210
                }
185
211
                        
186
212
                m_newCollisions.clear();
188
214
                for (it.begin();!it.end();++it)
189
215
                        (*it)->Activate(m_logicmgr);
190
216
        }
191
 
}