diff options
author | Steve Bennetts <steve@lindenlab.com> | 2009-11-16 09:03:05 -0800 |
---|---|---|
committer | Steve Bennetts <steve@lindenlab.com> | 2009-11-16 09:03:05 -0800 |
commit | be666bc14f7252b5cfa0b9c2e34f170f5e24c4d3 (patch) | |
tree | 282683cfddf5c624a72cd3f21cd66f18818cba77 /indra/newview/lljoystickbutton.cpp | |
parent | 211529eee9a4cbb36961af75e94af73da920d08d (diff) | |
parent | aba8b04cfc6763ee565a5ae9929e8be044272b08 (diff) |
merge from product-engine
Diffstat (limited to 'indra/newview/lljoystickbutton.cpp')
-rw-r--r-- | indra/newview/lljoystickbutton.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/indra/newview/lljoystickbutton.cpp b/indra/newview/lljoystickbutton.cpp index d7eaad94f0..0acc67ff5a 100644 --- a/indra/newview/lljoystickbutton.cpp +++ b/indra/newview/lljoystickbutton.cpp @@ -134,15 +134,17 @@ void LLJoystick::updateSlop() return; } -BOOL LLJoystick::pointInCircle(S32 x, S32 y) const +bool LLJoystick::pointInCircle(S32 x, S32 y) const { - //cnt is x and y coordinates of center of joystick circle, and also its radius, - //because area is not just rectangular, it's a square! - //Make sure to change method if this changes. - int cnt = this->getLocalRect().mTop/2; - if((x-cnt)*(x-cnt)+(y-cnt)*(y-cnt)<=cnt*cnt) + if(this->getLocalRect().mTop!=this->getLocalRect().mRight) + { + llwarns << "Joystick shape is not square"<<llendl; return TRUE; - return FALSE; + } + //center is x and y coordinates of center of joystick circle, and also its radius + int center = this->getLocalRect().mTop/2; + bool in_circle = (x - center) * (x - center) + (y - center) * (y - center) <= center * center; + return in_circle; } BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask) @@ -150,7 +152,7 @@ BOOL LLJoystick::handleMouseDown(S32 x, S32 y, MASK mask) //llinfos << "joystick mouse down " << x << ", " << y << llendl; bool handles = false; - if(handles = pointInCircle(x, y)) + if(pointInCircle(x, y)) { mLastMouse.set(x, y); mFirstMouse.set(x, y); |