Reverted incorrect merge (missing files)
[blender.git] / source / gameengine / Physics / Sumo / SumoPHYCallbackBridge.cpp
1 #include "SumoPHYCallbackBridge.h"
2 #include "PHY_IPhysicsController.h"
3 #include "SM_Object.h"
4
5
6 SumoPHYCallbackBridge::SumoPHYCallbackBridge(void* clientData,PHY_ResponseCallback phyCallback)
7 :m_orgClientData(clientData),
8 m_phyCallback(phyCallback)
9 {
10
11 }
12 DT_Bool SumoPHYCallbackBridge::StaticSolidToPHYCallback(void *client_data,
13                                                                                    void *client_object1,
14                                                                                    void *client_object2,
15                                                                                    const DT_CollData *coll_data)
16 {
17         SumoPHYCallbackBridge* bridge = static_cast<SumoPHYCallbackBridge*>(client_data);
18         bridge->SolidToPHY(client_object1,client_object2,coll_data);
19         return false;
20 }
21
22 DT_Bool SumoPHYCallbackBridge::SolidToPHY(void *client_object1,
23                                                                                 void *client_object2,
24                                                                                 const DT_CollData *coll_data)
25 {
26
27         SM_Object* smObject1 = static_cast<SM_Object*>(client_object1);
28         SM_Object* smObject2 = static_cast<SM_Object*>(client_object2);
29
30         PHY_IPhysicsController* ctrl1 = static_cast<PHY_IPhysicsController*>(smObject1->getPhysicsClientObject());
31         PHY_IPhysicsController* ctrl2 = static_cast<PHY_IPhysicsController*>(smObject2->getPhysicsClientObject());
32         
33         if (!ctrl1 || !ctrl2)
34         {
35                 //todo: check which objects are not linked up properly
36                 return false;
37         }
38         if (coll_data)
39         {
40                 PHY_CollData    phyCollData;
41                 
42                 phyCollData.m_point1[0] = coll_data->point1[0];
43                 phyCollData.m_point1[1] = coll_data->point1[1];
44                 phyCollData.m_point1[2] = coll_data->point1[2];
45                 phyCollData.m_point1[3] = 0.f;
46
47                 phyCollData.m_point2[0] = coll_data->point2[0];
48                 phyCollData.m_point2[1] = coll_data->point2[1];
49                 phyCollData.m_point2[2] = coll_data->point2[2];
50                 phyCollData.m_point2[3] = 0.f;
51
52                 phyCollData.m_normal[0] = coll_data->normal[0];
53                 phyCollData.m_normal[1] = coll_data->normal[1];
54                 phyCollData.m_normal[2] = coll_data->normal[2];
55                 phyCollData.m_normal[3] = 0.f;
56
57
58                 return m_phyCallback(m_orgClientData,
59                         ctrl1,ctrl2,&phyCollData);
60         }
61
62         return m_phyCallback(m_orgClientData,
63                 ctrl1,ctrl2,0);
64
65 }
66