aboutsummaryrefslogtreecommitdiffstats
path: root/trunk/ardor3d-animation
diff options
context:
space:
mode:
authorricardolpd <[email protected]>2012-11-28 22:12:31 +0000
committerricardolpd <[email protected]>2012-11-28 22:12:31 +0000
commitc896e51a67873939bec3e2c9d9a424b32241c56e (patch)
treea537b82b91589965584f9539f64e74a001043ac5 /trunk/ardor3d-animation
parent362f97fc3e2b37393f678a5530624f439ea10c78 (diff)
Changed AnimationManager to support automatic reset once the current state is stop.
Diffstat (limited to 'trunk/ardor3d-animation')
-rw-r--r--trunk/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AnimationManager.java51
1 files changed, 42 insertions, 9 deletions
diff --git a/trunk/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AnimationManager.java b/trunk/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AnimationManager.java
index 01afa82..30e2e9b 100644
--- a/trunk/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AnimationManager.java
+++ b/trunk/ardor3d-animation/src/main/java/com/ardor3d/extension/animation/skeletal/AnimationManager.java
@@ -85,9 +85,14 @@ public class AnimationManager {
protected AnimationUpdateState _currentAnimationState = AnimationUpdateState.Play;
/**
- * boolean threshold to allow stop state to be updated one last time...
+ * boolean flag to allow stop state to be updated one last time.
*/
- private boolean _canSetStopState = false;
+ protected boolean _canSetStopState = false;
+
+ /**
+ * boolean flag to reset Clips automatically once they are stopped.
+ */
+ protected boolean _resetClipsOnStop = false;
/**
* Listeners for changes to this manager's AnimationUpdateState.
@@ -157,6 +162,24 @@ public class AnimationManager {
_globalTimer = timer;
}
+ /**
+ *
+ * @return True if clips will reset if the currentUpdateState is Stop.
+ */
+ public boolean isResetClipsOnStop() {
+ return _resetClipsOnStop;
+ }
+
+ /**
+ * @param resetClipsOnStop
+ * True if clips are to be reset when currentUpdateState is Stop, false otherwise.
+ *
+ *
+ */
+ public void setResetClipsOnStop(final boolean resetClipsOnStop) {
+ _resetClipsOnStop = resetClipsOnStop;
+ }
+
public void play() {
setAnimationUpdateState(AnimationUpdateState.Play);
}
@@ -165,7 +188,8 @@ public class AnimationManager {
setAnimationUpdateState(AnimationUpdateState.Pause);
}
- public void stop() {
+ public void stop(final boolean resetOnStop) {
+ setResetClipsOnStop(resetOnStop);
setAnimationUpdateState(AnimationUpdateState.Stop);
}
@@ -205,12 +229,15 @@ public class AnimationManager {
}
}
} else {
- // must be resuming from stop, so restart clips
- for (final AnimationClipInstance instance : _clipInstances.values()) {
- if (instance.isActive()) {
- instance.setStartTime(currentTime);
+ // if newState is check if we will restart clips.
+ if (_resetClipsOnStop) {
+ for (final AnimationClipInstance instance : _clipInstances.values()) {
+ if (instance.isActive()) {
+ instance.setStartTime(currentTime);
+ }
}
}
+
}
} else {
for (final AnimationClipInstance instance : _clipInstances.values()) {
@@ -338,9 +365,15 @@ public class AnimationManager {
public void update() {
if (_currentAnimationState != AnimationUpdateState.Play) {
- if (_currentAnimationState == AnimationUpdateState.Stop && !_canSetStopState) {
- _canSetStopState = true;
+ if (_resetClipsOnStop) {
+ if (_currentAnimationState == AnimationUpdateState.Stop && !_canSetStopState) {
+ _canSetStopState = true;
+ } else {
+ // pause state or reset update has occurred
+ return;
+ }
} else {
+ // stop update without reseting
return;
}
} else {