aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Slack <[email protected]>2013-04-24 13:36:36 -0700
committerJoshua Slack <[email protected]>2013-04-24 13:36:36 -0700
commit980b453284e1dcc0796bf2360bddccb5a1a2e859 (patch)
tree0ca711ff06f41edc92d0cec05ed503f788b31cd7
parent8d762054495151f1b7224417eb6dd8506bb1e87c (diff)
parente48f8e09478ea0e1378f415b9c0d19c97cb9a3f9 (diff)
Merge pull request #44 from gouessej/master
Fixes the bug in KeyframeController
-rw-r--r--ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java24
-rw-r--r--ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java4
2 files changed, 17 insertions, 11 deletions
diff --git a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
index 1df05a6..e413aa8 100644
--- a/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
+++ b/ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
@@ -213,18 +213,18 @@ public class KeyframeController<T extends Spatial> extends ComplexSpatialControl
/**
* This function will do a smooth translation between a keframe's current look, to the look directly at
- * newTimeToReach. It takes translationLen time (in sec) to do that translation, and once translated will animate
- * like normal between newBeginTime and newEndTime <br>
+ * newTimeToReach. It takes translationLen time (in seconds) to do that translation, and once translated will
+ * animate like normal between newBeginTime and newEndTime <br>
* <br>
- * This would be usefull for example when a figure stops running and tries to raise an arm. Instead of "teleporting"
- * to the raise-arm animation begining, a smooth translation can occur.
+ * This would be useful for example when a figure stops running and tries to raise an arm. Instead of "teleporting"
+ * to the raise-arm animation beginning, a smooth translation can occur.
*
* @param newTimeToReach
* The time to reach.
* @param translationLen
* How long it takes
* @param newBeginTime
- * The new cycle begining time
+ * The new cycle beginning time
* @param newEndTime
* The new cycle ending time.
*/
@@ -434,17 +434,23 @@ public class KeyframeController<T extends Spatial> extends ComplexSpatialControl
findFrame();
_before = _keyframes.get(_curFrame);
// Change this bit so the next frame we're heading towards isn't always going
- // to be one frame ahead since now we coule be animating from the last to first
+ // to be one frame ahead since now we could be animating from the last to first
// frames.
// after = keyframes.get(curFrame + 1));
_after = _keyframes.get(_nextFrame);
- double delta = (_curTime - _before._time) / (_after._time - _before._time);
+ final double localMinTime = Math.min(_before._time, _after._time);
+ final double localMaxTime = Math.max(_before._time, _after._time);
+ final double clampedCurTime = Math.max(localMinTime, Math.min(_curTime, localMaxTime));
+ final double delta;
- // If we doing that wrapping bit then delta should be caculated based
+ // If we doing that wrapping bit then delta should be calculated based
// on the time before the start of the animation we are.
if (_nextFrame < _curFrame) {
- delta = blendTime - (getMinTime() - _curTime);
+ delta = blendTime - (getMinTime() - clampedCurTime);
+ } else {
+ // general case
+ delta = (clampedCurTime - _before._time) / (_after._time - _before._time);
}
final Mesh oldShape = _before._newShape;
diff --git a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java
index 837e338..73c5684 100644
--- a/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java
+++ b/ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java
@@ -70,8 +70,8 @@ public enum JoglNewtKey {
INSERT(KeyEvent.VK_INSERT, Key.INSERT), //
J(KeyEvent.VK_J, Key.J), //
K(KeyEvent.VK_K, Key.K), //
- KANA(KeyEvent.VK_KANA, Key.KANA), //
- KANJI(KeyEvent.VK_KANJI, Key.KANJI), //
+ // KANA(KeyEvent.VK_KANA, Key.KANA), //
+ // KANJI(KeyEvent.VK_KANJI, Key.KANJI), //
L(KeyEvent.VK_L, Key.L), //
OPEN_BRACKET(KeyEvent.VK_OPEN_BRACKET, Key.LBRACKET), //
CONTROL(KeyEvent.VK_CONTROL, Key.LCONTROL), //