aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Slack <[email protected]>2017-10-26 09:22:43 -0500
committerJoshua Slack <[email protected]>2017-10-26 09:22:43 -0500
commitd1fcf4cdaca9d5fb922eee1e6dedc4b0c53014f8 (patch)
tree301256a02d915c978450de39c231c2f5b34ae990
parentdd95ebfb47e3d1d9573240c588f91c1add1220b4 (diff)
Fix mouseover/click issue with pie menu when start angle is negative.
Fix issue with forwarding "consumed" mouse/key events through to next logical layer.
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java14
-rw-r--r--ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPieMenu.java5
2 files changed, 10 insertions, 9 deletions
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
index 0469172..3311c3c 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIHud.java
@@ -503,6 +503,8 @@ public class UIHud extends Node {
final TwoInputStates states, final double tpf) {
super.checkAndPerformTriggers(triggers, source, states, tpf);
+ final InputState prev = states.getPrevious();
+ final InputState curr = states.getCurrent();
if (!_mouseInputConsumed) {
if (!_keyInputConsumed) {
// nothing consumed
@@ -510,18 +512,18 @@ public class UIHud extends Node {
.checkAndPerformTriggers(forwardTo.getTriggers(), source, states, tpf);
} else {
// only key state consumed
- final TwoInputStates forwardingState = new TwoInputStates(states.getPrevious(),
- new InputState(KeyboardState.NOTHING, states.getCurrent().getMouseState(), states
- .getCurrent().getControllerState()));
+ final TwoInputStates forwardingState = new TwoInputStates(
+ new InputState(KeyboardState.NOTHING, prev.getMouseState(), prev.getControllerState()),
+ new InputState(KeyboardState.NOTHING, curr.getMouseState(), curr.getControllerState()));
forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source,
forwardingState, tpf);
}
} else {
if (!_keyInputConsumed) {
// only mouse consumed
- final TwoInputStates forwardingState = new TwoInputStates(states.getPrevious(),
- new InputState(states.getCurrent().getKeyboardState(), MouseState.NOTHING, states
- .getCurrent().getControllerState()));
+ final TwoInputStates forwardingState = new TwoInputStates(
+ new InputState(prev.getKeyboardState(), MouseState.NOTHING, prev.getControllerState()),
+ new InputState(curr.getKeyboardState(), MouseState.NOTHING, curr.getControllerState()));
forwardTo.getApplier().checkAndPerformTriggers(forwardTo.getTriggers(), source,
forwardingState, tpf);
} else {
diff --git a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPieMenu.java b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPieMenu.java
index 5d87e92..0913c76 100644
--- a/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPieMenu.java
+++ b/ardor3d-ui/src/main/java/com/ardor3d/extension/ui/UIPieMenu.java
@@ -157,9 +157,8 @@ public class UIPieMenu extends UIPopupMenu implements IPopOver {
double r = MathUtils.HALF_PI - Math.atan2(vec.getY(), vec.getX()) - _startAngle;
- if (r < 0) {
- r += MathUtils.TWO_PI;
- }
+ // move into range [0, 2pi]
+ r = (r % MathUtils.TWO_PI + MathUtils.TWO_PI) % MathUtils.TWO_PI;
int index = (int) (r / _sliceRadians);
for (int i = 0; i < getNumberOfChildren(); i++) {