From e78f303a9d75bd58a0763216af37f4ab82a804a0 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 13 Jun 2020 00:10:27 -0800 Subject: [PATCH] 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 --- .../src/main/java/com/jme3/scene/Mesh.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/jme3-core/src/main/java/com/jme3/scene/Mesh.java b/jme3-core/src/main/java/com/jme3/scene/Mesh.java index 6248f4430..04ef37984 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Mesh.java +++ b/jme3-core/src/main/java/com/jme3/scene/Mesh.java @@ -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];