svn merge -r 15392:15551 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / gameengine / GameLogic / SCA_MouseSensor.cpp
index 42d35837489a501fea9bb180c2565d2768829b48..2298ddb07434cef2f84729bda053466ee187187c 100644 (file)
@@ -84,6 +84,7 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
 void SCA_MouseSensor::Init()
 {
        m_val = (m_invert)?1:0; /* stores the latest attribute */
+       m_reset = true;
 }
 
 SCA_MouseSensor::~SCA_MouseSensor() 
@@ -95,9 +96,10 @@ SCA_MouseSensor::~SCA_MouseSensor()
 
 CValue* SCA_MouseSensor::GetReplica()
 {
-       CValue* replica = new SCA_MouseSensor(*this);
+       SCA_MouseSensor* replica = new SCA_MouseSensor(*this);
        // this will copy properties and so on...
        CValue::AddDataToReplica(replica);
+       replica->Init();
 
        return replica;
 }
@@ -132,6 +134,7 @@ SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey()
 bool SCA_MouseSensor::Evaluate(CValue* event)
 {
        bool result = false;
+       bool reset = m_reset && m_level;
        SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
 
 
@@ -143,7 +146,7 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
        /* both MOUSEX and MOUSEY. Treat all of these as key-presses.            */
        /* So, treat KX_MOUSESENSORMODE_POSITION as                              */
        /* KX_MOUSESENSORMODE_POSITIONX || KX_MOUSESENSORMODE_POSITIONY          */
-
+       m_reset = false;
        switch (m_mousemode) {
        case KX_MOUSESENSORMODE_LEFTBUTTON:
        case KX_MOUSESENSORMODE_MIDDLEBUTTON:
@@ -168,9 +171,9 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
                                        {
                                                if (m_val == 0)
                                                {
+                                                       m_val = 1;
                                                        if (m_level)
                                                        {
-                                                               m_val = 1;
                                                                result = true;
                                                        }
                                                }
@@ -222,6 +225,9 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
                ; /* error */
        }
 
+       if (reset)
+               // force an event
+               result = true;
        return result;
 }