added the "mouse over any", makes the sensor more useful
This commit is contained in:
@@ -233,6 +233,7 @@ typedef struct bJoystickSensor {
|
|||||||
#define BL_SENS_MOUSE_WHEEL_DOWN 6
|
#define BL_SENS_MOUSE_WHEEL_DOWN 6
|
||||||
#define BL_SENS_MOUSE_MOVEMENT 8
|
#define BL_SENS_MOUSE_MOVEMENT 8
|
||||||
#define BL_SENS_MOUSE_MOUSEOVER 16
|
#define BL_SENS_MOUSE_MOUSEOVER 16
|
||||||
|
#define BL_SENS_MOUSE_MOUSEOVER_ANY 32
|
||||||
|
|
||||||
#define SENS_JOY_BUTTON 0
|
#define SENS_JOY_BUTTON 0
|
||||||
#define SENS_JOY_BUTTON_PRESSED 0
|
#define SENS_JOY_BUTTON_PRESSED 0
|
||||||
|
|||||||
@@ -1219,7 +1219,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
|
|||||||
/* Line 2: type selection. The number are a bit mangled to get
|
/* Line 2: type selection. The number are a bit mangled to get
|
||||||
* proper compatibility with older .blend files. */
|
* proper compatibility with older .blend files. */
|
||||||
str= "Type %t|Left button %x1|Middle button %x2|"
|
str= "Type %t|Left button %x1|Middle button %x2|"
|
||||||
"Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16";
|
"Right button %x4|Wheel Up %x5|Wheel Down %x6|Movement %x8|Mouse over %x16|Mouse over any%x32";
|
||||||
uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19,
|
uiDefButS(block, MENU, B_REDR, str, xco+10, yco-44, width-20, 19,
|
||||||
&ms->type, 0, 31, 0, 0,
|
&ms->type, 0, 31, 0, 0,
|
||||||
"Specify the type of event this mouse sensor should trigger on.");
|
"Specify the type of event this mouse sensor should trigger on.");
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
|
|||||||
case SENS_MOUSE:
|
case SENS_MOUSE:
|
||||||
{
|
{
|
||||||
int keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_NODEF;
|
int keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_NODEF;
|
||||||
bool trackfocus = false;
|
int trackfocus = 0;
|
||||||
bMouseSensor *bmouse = (bMouseSensor *)sens->data;
|
bMouseSensor *bmouse = (bMouseSensor *)sens->data;
|
||||||
|
|
||||||
/* There are two main types of mouse sensors. If there is
|
/* There are two main types of mouse sensors. If there is
|
||||||
@@ -455,8 +455,12 @@ void BL_ConvertSensors(struct Object* blenderobject,
|
|||||||
keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_MOVEMENT;
|
keytype = SCA_MouseSensor::KX_MOUSESENSORMODE_MOVEMENT;
|
||||||
break;
|
break;
|
||||||
case BL_SENS_MOUSE_MOUSEOVER:
|
case BL_SENS_MOUSE_MOUSEOVER:
|
||||||
trackfocus = true;
|
trackfocus = 1;
|
||||||
break;
|
break;
|
||||||
|
case BL_SENS_MOUSE_MOUSEOVER_ANY:
|
||||||
|
trackfocus = 2;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
; /* error */
|
; /* error */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr,
|
|||||||
int startx,
|
int startx,
|
||||||
int starty,
|
int starty,
|
||||||
short int mousemode,
|
short int mousemode,
|
||||||
bool focusmode,
|
int focusmode,
|
||||||
RAS_ICanvas* canvas,
|
RAS_ICanvas* canvas,
|
||||||
KX_Scene* kxscene,
|
KX_Scene* kxscene,
|
||||||
SCA_IObject* gameobj,
|
SCA_IObject* gameobj,
|
||||||
@@ -72,8 +72,7 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr,
|
|||||||
m_gp_canvas(canvas),
|
m_gp_canvas(canvas),
|
||||||
m_kxscene(kxscene)
|
m_kxscene(kxscene)
|
||||||
{
|
{
|
||||||
/* Or postpone? I think a sumo scene and kx scene go pretty much
|
|
||||||
* together, so it should be safe to do it here. */
|
|
||||||
m_mouse_over_in_previous_frame = false;
|
m_mouse_over_in_previous_frame = false;
|
||||||
m_positive_event = false;
|
m_positive_event = false;
|
||||||
m_hitObject = 0;
|
m_hitObject = 0;
|
||||||
@@ -134,7 +133,7 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hi
|
|||||||
* self-hits are excluded by setting the correct ignore-object.)
|
* self-hits are excluded by setting the correct ignore-object.)
|
||||||
* Hitspots now become valid. */
|
* Hitspots now become valid. */
|
||||||
KX_GameObject* thisObj = (KX_GameObject*) GetParent();
|
KX_GameObject* thisObj = (KX_GameObject*) GetParent();
|
||||||
if (hitKXObj != thisObj)
|
if ((m_focusmode == 2) || hitKXObj == thisObj)
|
||||||
{
|
{
|
||||||
m_hitObject = hitKXObj;
|
m_hitObject = hitKXObj;
|
||||||
m_hitPosition = hit_point;
|
m_hitPosition = hit_point;
|
||||||
@@ -150,7 +149,7 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hi
|
|||||||
|
|
||||||
bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
|
bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
|
||||||
{
|
{
|
||||||
|
m_hitObject = 0;
|
||||||
m_hitPosition = MT_Vector3(0,0,0);
|
m_hitPosition = MT_Vector3(0,0,0);
|
||||||
m_hitNormal = MT_Vector3(1,0,0);
|
m_hitNormal = MT_Vector3(1,0,0);
|
||||||
MT_Point3 resultpoint;
|
MT_Point3 resultpoint;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
|||||||
int startx,
|
int startx,
|
||||||
int starty,
|
int starty,
|
||||||
short int mousemode,
|
short int mousemode,
|
||||||
bool focusmode,
|
int focusmode,
|
||||||
RAS_ICanvas* canvas,
|
RAS_ICanvas* canvas,
|
||||||
KX_Scene* kxscene,
|
KX_Scene* kxscene,
|
||||||
SCA_IObject* gameobj,
|
SCA_IObject* gameobj,
|
||||||
@@ -98,9 +98,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* The focus mode. True for handling focus, false for not handling
|
* The focus mode. 1 for handling focus, 0 for not handling, 2 for focus on any object
|
||||||
* it. */
|
*/
|
||||||
bool m_focusmode;
|
int m_focusmode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags whether the previous test showed a mouse-over.
|
* Flags whether the previous test showed a mouse-over.
|
||||||
@@ -146,6 +146,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
|
|||||||
* scene. */
|
* scene. */
|
||||||
class KX_KetsjiEngine* m_engine;
|
class KX_KetsjiEngine* m_engine;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The active canvas. The size of this canvas determines a part of
|
* The active canvas. The size of this canvas determines a part of
|
||||||
* the start position of the picking ray. */
|
* the start position of the picking ray. */
|
||||||
|
|||||||
Reference in New Issue
Block a user