diff options
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_MouseFocusSensor.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_MouseFocusSensor.h | 9 |
2 files changed, 18 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index fde10a493db..1880fcfb6f0 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -61,12 +61,14 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr, int starty, short int mousemode, int focusmode, + bool bTouchPulse, KX_Scene* kxscene, KX_KetsjiEngine *kxengine, SCA_IObject* gameobj, PyTypeObject* T) : SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj, T), m_focusmode(focusmode), + m_bTouchPulse(bTouchPulse), m_kxscene(kxscene), m_kxengine(kxengine) { @@ -78,6 +80,7 @@ void KX_MouseFocusSensor::Init() m_mouse_over_in_previous_frame = (m_invert)?true:false; m_positive_event = false; m_hitObject = 0; + m_hitObject_Last = NULL; m_reset = true; m_hitPosition.setValue(0,0,0); @@ -108,7 +111,10 @@ bool KX_MouseFocusSensor::Evaluate() m_positive_event = true; if (!m_mouse_over_in_previous_frame) { result = true; - } + } + else if(m_bTouchPulse && (m_hitObject != m_hitObject_Last)) { + result = true; + } } if (reset) { // force an event @@ -124,7 +130,8 @@ bool KX_MouseFocusSensor::Evaluate() } m_mouse_over_in_previous_frame = obHasFocus; - + m_hitObject_Last = (void *)m_hitObject; + return result; } @@ -390,6 +397,7 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = { KX_PYATTRIBUTE_RO_FUNCTION("hitObject", KX_MouseFocusSensor, pyattr_get_hit_object), KX_PYATTRIBUTE_RO_FUNCTION("hitPosition", KX_MouseFocusSensor, pyattr_get_hit_position), KX_PYATTRIBUTE_RO_FUNCTION("hitNormal", KX_MouseFocusSensor, pyattr_get_hit_normal), + KX_PYATTRIBUTE_BOOL_RW("usePulseFocus", KX_MouseFocusSensor,m_bTouchPulse), { NULL } //Sentinel }; diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h index 29d674eb305..e1f8d9246e3 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h @@ -49,11 +49,12 @@ class KX_MouseFocusSensor : public SCA_MouseSensor public: - KX_MouseFocusSensor(class SCA_MouseManager* keybdmgr, + KX_MouseFocusSensor(class SCA_MouseManager* eventmgr, int startx, int starty, short int mousemode, int focusmode, + bool bTouchPulse, KX_Scene* kxscene, KX_KetsjiEngine* kxengine, SCA_IObject* gameobj, @@ -110,6 +111,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor /* --------------------------------------------------------------------- */ SCA_IObject* m_hitObject; + void* m_hitObject_Last; /* only use for comparison, never access */ private: /** @@ -123,6 +125,11 @@ class KX_MouseFocusSensor : public SCA_MouseSensor bool m_mouse_over_in_previous_frame; /** + * Flags whether changes in hit object should trigger a pulse + */ + bool m_bTouchPulse; + + /** * Flags whether the previous test evaluated positive. */ bool m_positive_event; |