Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixes the bug in KeyframeController #44

Merged
merged 2 commits into from

3 participants

Julien Gouesse BuildHive Joshua Slack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 24, 2013
  1. Julien Gouesse

    Fixes the bug in KeyframeController, keeps the current time inside a …

    gouessej authored
    …reasonable frame to avoid weird morphing
  2. Julien Gouesse
This page is out of date. Refresh to see the latest.
24 ardor3d-extras/src/main/java/com/ardor3d/extension/model/util/KeyframeController.java
View
@@ -213,18 +213,18 @@ public void setKeyframe(final double time, final Mesh shape) {
/**
* 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 void update(final double time, final T caller) {
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;
4 ardor3d-jogl/src/main/java/com/ardor3d/input/jogl/JoglNewtKey.java
View
@@ -70,8 +70,8 @@
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), //
Something went wrong with that request. Please try again.