Animation tracks is now a SafeArrayList instead of an array. One can now add a track to an Animation
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9565 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
96ae823504
commit
94ae185d6d
@ -32,6 +32,7 @@
|
|||||||
package com.jme3.animation;
|
package com.jme3.animation;
|
||||||
|
|
||||||
import com.jme3.export.*;
|
import com.jme3.export.*;
|
||||||
|
import com.jme3.util.SafeArrayList;
|
||||||
import com.jme3.util.TempVars;
|
import com.jme3.util.TempVars;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ public class Animation implements Savable, Cloneable {
|
|||||||
/**
|
/**
|
||||||
* The tracks of the animation.
|
* The tracks of the animation.
|
||||||
*/
|
*/
|
||||||
private Track[] tracks;
|
private SafeArrayList<Track> tracks = new SafeArrayList<Track>(Track.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialization-only. Do not use.
|
* Serialization-only. Do not use.
|
||||||
@ -104,21 +105,38 @@ public class Animation implements Savable, Cloneable {
|
|||||||
if (tracks == null)
|
if (tracks == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < tracks.length; i++){
|
for (Track track : tracks) {
|
||||||
tracks[i].setTime(time, blendAmount, control, channel, vars);
|
track.setTime(time, blendAmount, control, channel, vars);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link Track}s to be used by this animation.
|
* Set the {@link Track}s to be used by this animation.
|
||||||
* <p>
|
* <p>
|
||||||
* The array should be organized so that the appropriate Track can
|
|
||||||
* be retrieved based on a bone index.
|
|
||||||
*
|
*
|
||||||
* @param tracks The tracks to set.
|
* @param tracks The tracks to set.
|
||||||
*/
|
*/
|
||||||
public void setTracks(Track[] tracks){
|
public void setTracks(Track[] tracksArray){
|
||||||
this.tracks = tracks;
|
for (Track track : tracksArray) {
|
||||||
|
tracks.add(track);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a track to this animation
|
||||||
|
* @param track the track to add
|
||||||
|
*/
|
||||||
|
public void addTrack(Track track){
|
||||||
|
tracks.add(track);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* removes a track from this animation
|
||||||
|
* @param track the track to remove
|
||||||
|
*/
|
||||||
|
public void removeTrack(Track track){
|
||||||
|
tracks.remove(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +145,7 @@ public class Animation implements Savable, Cloneable {
|
|||||||
* @return the tracks set previously
|
* @return the tracks set previously
|
||||||
*/
|
*/
|
||||||
public Track[] getTracks() {
|
public Track[] getTracks() {
|
||||||
return tracks;
|
return tracks.getArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -138,9 +156,9 @@ public class Animation implements Savable, Cloneable {
|
|||||||
public Animation clone() {
|
public Animation clone() {
|
||||||
try {
|
try {
|
||||||
Animation result = (Animation) super.clone();
|
Animation result = (Animation) super.clone();
|
||||||
result.tracks = tracks.clone();
|
result.tracks = new SafeArrayList<Track>(Track.class);
|
||||||
for (int i = 0; i < tracks.length; ++i) {
|
for (Track track : tracks) {
|
||||||
result.tracks[i] = this.tracks[i].clone();
|
result.tracks.add(track.clone());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
@ -158,7 +176,7 @@ public class Animation implements Savable, Cloneable {
|
|||||||
OutputCapsule out = ex.getCapsule(this);
|
OutputCapsule out = ex.getCapsule(this);
|
||||||
out.write(name, "name", null);
|
out.write(name, "name", null);
|
||||||
out.write(length, "length", 0f);
|
out.write(length, "length", 0f);
|
||||||
out.write(tracks, "tracks", null);
|
out.write(tracks.getArray(), "tracks", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -173,8 +191,10 @@ public class Animation implements Savable, Cloneable {
|
|||||||
// tracks set at all even though it makes no sense.
|
// tracks set at all even though it makes no sense.
|
||||||
// Since there's a null check in setTime(),
|
// Since there's a null check in setTime(),
|
||||||
// its only appropriate that the check is made here as well.
|
// its only appropriate that the check is made here as well.
|
||||||
tracks = new Track[arr.length];
|
tracks = new SafeArrayList<Track>(Track.class);
|
||||||
System.arraycopy(arr, 0, tracks, 0, arr.length);
|
for (Savable savable : arr) {
|
||||||
|
tracks.add((Track)savable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user