fix BGE bug #8094: Collision sensor on child object makes the object rotate or move...
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 19 Apr 2008 21:09:40 +0000 (21:09 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 19 Apr 2008 21:09:40 +0000 (21:09 +0000)
source/gameengine/Ketsji/KX_NearSensor.cpp
source/gameengine/Ketsji/KX_NearSensor.h
source/gameengine/Ketsji/KX_TouchSensor.cpp

index e646e8ef84f1d78db5101665702f17d89d8a3131..4086ac53f2a9c46c0f666a4ba951b92ff9c03266 100644 (file)
@@ -75,6 +75,21 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
        SynchronizeTransform();
 }
 
+void KX_NearSensor::SynchronizeTransform()
+{
+       // The near and radar sensors are using a different physical object which is 
+       // not linked to the parent object, must synchronize it.
+       if (m_physCtrl)
+       {
+               KX_GameObject* parent = ((KX_GameObject*)GetParent());
+               MT_Vector3 pos = parent->NodeGetWorldPosition();
+               MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
+               m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
+               m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
+               m_physCtrl->calcXform();
+       }
+}
+
 void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
 {
        if (m_physCtrl)
index 994090eea8cc00442e1315366612bc42250a1dae..c6724caccc332ef254c335ce26f76dd875238119 100644 (file)
@@ -68,6 +68,7 @@ public:
                        PyTypeObject* T=&Type);
 */
        virtual ~KX_NearSensor(); 
+       virtual void SynchronizeTransform();
        virtual CValue* GetReplica();
        virtual bool Evaluate(CValue* event);
 
index c4a01d5918c3e1a50888fc429881589b4522a52e..3f185359de00491c81804132d54431b4d6fc357e 100644 (file)
 
 void KX_TouchSensor::SynchronizeTransform()
 {
-
-       if (m_physCtrl)
-       {
-
-               KX_GameObject* parent = ((KX_GameObject*)GetParent());
-               MT_Vector3 pos = parent->NodeGetWorldPosition();
-               MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
-               m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
-               m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
-               m_physCtrl->calcXform();
-       }
-       
+       // the touch sensor does not require any synchronization: it uses
+       // the same physical object which is already synchronized by Blender
 }