diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-04-20 01:09:40 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-04-20 01:09:40 +0400 |
commit | b0049e608859bd129bb5c13fecdd161811741185 (patch) | |
tree | 683a14f4d5e4db2c3c2231df4a5f8fa59b93f886 | |
parent | eb7edc4cba5747f4db76d8b35f55b1c2b7553558 (diff) |
fix BGE bug #8094: Collision sensor on child object makes the object rotate or move very fast. Collision sensor can now be set on child object without side effect.
-rw-r--r-- | source/gameengine/Ketsji/KX_NearSensor.cpp | 15 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_NearSensor.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_TouchSensor.cpp | 14 |
3 files changed, 18 insertions, 12 deletions
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp index e646e8ef84f..4086ac53f2a 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.cpp +++ b/source/gameengine/Ketsji/KX_NearSensor.cpp @@ -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) diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h index 994090eea8c..c6724caccc3 100644 --- a/source/gameengine/Ketsji/KX_NearSensor.h +++ b/source/gameengine/Ketsji/KX_NearSensor.h @@ -68,6 +68,7 @@ public: PyTypeObject* T=&Type); */ virtual ~KX_NearSensor(); + virtual void SynchronizeTransform(); virtual CValue* GetReplica(); virtual bool Evaluate(CValue* event); diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index c4a01d5918c..3f185359de0 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -48,18 +48,8 @@ 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 } |