Add ability to remove morph targets from mesh (#1378)

* Add ability to remove morph targets from mesh

* Add return values to removeMorphTarget functions

* Add null saftey

* Fix typo
This commit is contained in:
Trevor Flynn 2020-06-13 00:10:27 -08:00 committed by GitHub
parent dd0c169d62
commit e78f303a9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1530,6 +1530,41 @@ public class Mesh implements Savable, Cloneable, JmeCloneable {
morphTargets.add(target);
}
/**
* Remove the given MorphTarget from the Mesh
* @param target The MorphTarget to remove
* @return If the MorphTarget was removed
*/
public boolean removeMorphTarget(MorphTarget target) {
return morphTargets != null ? morphTargets.remove(target) : false;
}
/**
* Remove the MorphTarget from the Mesh at the given index
* @throws IndexOutOfBoundsException if the index outside the number of morph targets
* @param index Index of the MorphTarget to remove
* @return The MorphTarget that was removed
*/
public MorphTarget removeMorphTarget(int index) {
if (morphTargets == null) {
throw new IndexOutOfBoundsException("Index:" + index + ", Size:0");
}
return morphTargets.remove(index);
}
/**
* Get the MorphTarget at the given index
* @throws IndexOutOfBoundsException if the index outside the number of morph targets
* @param index The index of the morph target to get
* @return The MorphTarget at the index
*/
public MorphTarget getMorphTarget(int index) {
if (morphTargets == null) {
throw new IndexOutOfBoundsException("Index:" + index + ", Size:0");
}
return morphTargets.get(index);
}
public MorphTarget[] getMorphTargets() {
if (morphTargets == null) {
return new MorphTarget[0];