aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-extras/src/main/java/com
diff options
context:
space:
mode:
authorJulien Gouesse <[email protected]>2018-01-27 12:59:38 +0100
committerJulien Gouesse <[email protected]>2018-01-27 12:59:38 +0100
commitbb42b2dbc95043a5141d033427339e6a80fc46c8 (patch)
tree6127178f2aa9e50d7b21ea82934b99b005103aba /ardor3d-extras/src/main/java/com
parentf0119b61750022a45d7e93db8a0aa926b7704481 (diff)
parent1aae3c9d22835dded3f6cc6ba0d2e9cc040a92aa (diff)
Merge commit '1aae3c9d22835dded3f6cc6ba0d2e9cc040a92aa'
Diffstat (limited to 'ardor3d-extras/src/main/java/com')
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java70
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java5
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java7
3 files changed, 79 insertions, 3 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
index e924ede..d323736 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/InteractManager.java
@@ -68,6 +68,9 @@ public class InteractManager {
*/
protected List<UpdateFilter> _filters = new ArrayList<>();
+ /** ArrayList of update logic for this manager. */
+ protected List<UpdateLogic> _updateLogic;
+
public InteractManager() {
_state = new SpatialState();
setupLogicalLayer();
@@ -79,6 +82,7 @@ public class InteractManager {
}
public void update(final ReadOnlyTimer timer) {
+ runUpdateLogic(timer.getTimePerFrame());
for (final AbstractInteractWidget widget : _widgets) {
if (!widget.isActiveUpdateOnly() || widget == _activeWidget) {
widget.update(timer, this);
@@ -253,4 +257,70 @@ public class InteractManager {
return _state;
}
+ public interface UpdateLogic {
+ public void update(double time, InteractManager manager);
+ }
+
+ public void addUpdateLogic(final UpdateLogic logic) {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ _updateLogic.add(logic);
+ }
+
+ public boolean removeUpdateLogic(final UpdateLogic logic) {
+ if (_updateLogic == null) {
+ return false;
+ }
+ return _updateLogic.remove(logic);
+ }
+
+ public UpdateLogic removeUpdateLogic(final int index) {
+ if (_updateLogic == null) {
+ return null;
+ }
+ return _updateLogic.remove(index);
+ }
+
+ public void clearUpdateLogic() {
+ if (_updateLogic != null) {
+ _updateLogic.clear();
+ }
+ }
+
+ public UpdateLogic getUpdateLogic(final int i) {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ return _updateLogic.get(i);
+ }
+
+ public List<UpdateLogic> getUpdateLogic() {
+ if (_updateLogic == null) {
+ _updateLogic = new ArrayList<UpdateLogic>(1);
+ }
+ return _updateLogic;
+ }
+
+ public int getUpdateLogicCount() {
+ if (_updateLogic == null) {
+ return 0;
+ }
+ return _updateLogic.size();
+ }
+
+ public void runUpdateLogic(final double time) {
+ if (_updateLogic != null) {
+ for (int i = 0, gSize = _updateLogic.size(); i < gSize; i++) {
+ try {
+ final UpdateLogic logic = _updateLogic.get(i);
+ if (logic != null) {
+ logic.update(time, this);
+ }
+ } catch (final IndexOutOfBoundsException e) {
+ break;
+ }
+ }
+ }
+ }
}
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java
index 16b650f..6706f5d 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MovePlanarWidget.java
@@ -3,7 +3,7 @@
*
* This file is part of Ardor3D.
*
- * Ardor3D is free software: you can redistribute it and/or modify it
+ * Ardor3D is free software: you can redistribute it and/or modify it
* under the terms of its license which may be found in the accompanying
* LICENSE file or at <http://www.ardor3d.com/LICENSE>.
*/
@@ -108,6 +108,9 @@ public class MovePlanarWidget extends AbstractInteractWidget {
_handle.setScale(1.0);
_handle.setRotation(Matrix3.IDENTITY);
} else {
+ _handle.setScale(Math.max(MoveWidget.MIN_SCALE, target.getWorldBound().getRadius()
+ + target.getWorldTranslation().subtract(target.getWorldBound().getCenter(), _calcVec3A).length()));
+
// update scale of widget using bounding radius
target.updateGeometricState(0);
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
index c06569d..dff1987 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/interact/widget/MoveWidget.java
@@ -151,6 +151,9 @@ public class MoveWidget extends AbstractInteractWidget {
_handle.setScale(1.0);
_handle.setRotation(Matrix3.IDENTITY);
} else {
+ _handle.setScale(Math.max(MoveWidget.MIN_SCALE, target.getWorldBound().getRadius()
+ + target.getWorldTranslation().subtract(target.getWorldBound().getCenter(), _calcVec3A).length()));
+
// update scale of widget using bounding radius
target.updateGeometricState(0);
@@ -242,8 +245,8 @@ public class MoveWidget extends AbstractInteractWidget {
_calcVec3B.set(_calcVec3A).addLocal(camera.getLeft());
_calcVec3C.set( //
arrow == _xArrow ? Vector3.UNIT_X : //
- arrow == _yArrow ? Vector3.UNIT_Y : //
- Vector3.UNIT_Z);
+ arrow == _yArrow ? Vector3.UNIT_Y : //
+ Vector3.UNIT_Z);
// rotate to arrow plane
_handle.getRotation().applyPost(_calcVec3C, _calcVec3C);