From 07f5f3a6e14c80ae2c6019603fd7eaa091a351c9 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Thu, 21 Mar 2019 11:03:44 -0700 Subject: [PATCH 01/10] Add support for gltf morph names. --- .../main/java/com/jme3/scene/Geometry.java | 95 +++++++++++++++++-- .../java/com/jme3/scene/mesh/MorphTarget.java | 13 +++ .../jme3/scene/plugins/gltf/GltfLoader.java | 5 + 3 files changed, 105 insertions(+), 8 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 005d0e8c75..aaee44364c 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -387,7 +387,6 @@ protected void setParent(Node parent) { } } - /** * Indicate that the transform of this spatial has changed and that * a refresh is required. @@ -514,7 +513,7 @@ public boolean isBatched() { */ @Override public Geometry clone(boolean cloneMaterial) { - return (Geometry)super.clone(cloneMaterial); + return (Geometry) super.clone(cloneMaterial); } /** @@ -545,16 +544,16 @@ public Spatial oldDeepClone() { } /** - * Called internally by com.jme3.util.clone.Cloner. Do not call directly. + * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override - public void cloneFields( Cloner cloner, Object original ) { + public void cloneFields(Cloner cloner, Object original) { super.cloneFields(cloner, original); // If this is a grouped node and if our group node is // also cloned then we'll grab its reference. - if( groupNode != null ) { - if( cloner.isCloned(groupNode) ) { + if (groupNode != null) { + if (cloner.isCloned(groupNode)) { // Then resolve the reference this.groupNode = cloner.clone(groupNode); } else { @@ -576,7 +575,7 @@ public void cloneFields( Cloner cloner, Object original ) { // See if we clone the mesh using the special animation // semi-deep cloning - if( shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null ) { + if (shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null) { // Then we need to clone the mesh a little deeper this.mesh = mesh.cloneForAnim(); } else { @@ -588,7 +587,7 @@ public void cloneFields( Cloner cloner, Object original ) { } public void setMorphState(float[] state) { - if (mesh == null || mesh.getMorphTargets().length == 0){ + if (mesh == null || mesh.getMorphTargets().length == 0) { return; } @@ -601,6 +600,39 @@ public void setMorphState(float[] state) { this.dirtyMorph = true; } + /** + * Set the state of the morph with the given name. + * + * If the name of the morph is not found, no state will be set. + * + * @param morphTarget The name of the morph to set the state of + * @param state The state to set the morph to + */ + public void setMorphState(String morphTarget, float state) { + if (mesh == null || mesh.getMorphTargets().length == 0) { + return; + } + MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); + + if (morphState == null) { + morphState = new float[nbMorphTargets.length]; + } + + int index; + boolean found = false; + for (index = 0; index < nbMorphTargets.length; index++) { + String name = nbMorphTargets[index].getName(); + if (name != null && name.equals(morphTarget)) { + found = true; + break; + } + } + if (found) { + morphState[index] = state; + this.dirtyMorph = true; + } + } + /** * returns true if the morph state has changed on the last frame. * @return true if changed, otherwise false @@ -629,6 +661,53 @@ public float[] getMorphState() { } return morphState; } + + /** + * Get the state of a morph + * @param morphTarget the name of the morph to get the state of + * @return the state of the morph, or -1 if the morph is not found + */ + public float getMorphState(String morphTarget) { + MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); + + if (morphState == null) { + morphState = new float[nbMorphTargets.length]; + } + + int index; + boolean found = false; + for (index = 0; index < nbMorphTargets.length; index++) { + if (nbMorphTargets[index].getName().equals(morphTarget)) { + found = true; + break; + } + } + if (found) { + return morphState[index]; + } + return -1; + } + + /** + * Get the name of all morphs in order. + * Morphs without names will be null + * @return an array + */ + public String[] getMorphTargets() { + if (mesh == null || mesh.getMorphTargets().length == 0) { + return new String[0]; + } + MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); + String[] targets = new String[nbMorphTargets.length]; + if (morphState == null) { + morphState = new float[nbMorphTargets.length]; + } + + for (int index = 0; index < nbMorphTargets.length; index++) { + targets[index] = nbMorphTargets[index].getName(); + } + return targets; + } /** * Return the number of morph targets that can be handled on the GPU simultaneously for this geometry. diff --git a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java index 083d04fb7f..3c9bcf3f91 100644 --- a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java +++ b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java @@ -11,6 +11,19 @@ public class MorphTarget implements Savable { private EnumMap buffers = new EnumMap<>(VertexBuffer.Type.class); + private String name; + + public MorphTarget() { + + } + + public MorphTarget(String name) { + this.name = name; + } + + public String getName() { + return name; + } public void setBuffer(VertexBuffer.Type type, FloatBuffer buffer) { buffers.put(type, buffer); diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java index 6c7372b6a4..b56cf389aa 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java @@ -399,6 +399,7 @@ public Geometry[] readMeshPrimitives(int meshIndex) throws IOException { mesh.generateBindPose(); } + //Read morph targets JsonArray targets = meshObject.getAsJsonArray("targets"); if(targets != null){ for (JsonElement target : targets) { @@ -415,6 +416,10 @@ public Geometry[] readMeshPrimitives(int meshIndex) throws IOException { } } + //Read morph target names + JsonArray targetNames = meshObject.getAsJsonArray("targetNames"); + + //Read mesh extras mesh = customContentManager.readExtensionAndExtras("primitive", meshObject, mesh); Geometry geom = new Geometry(null, mesh); From ab873449d0a92736b04971a0ce8cb80bd39fdb93 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 15 Jun 2019 13:51:23 -0800 Subject: [PATCH 02/10] Moving stuff around --- .../main/java/com/jme3/scene/Geometry.java | 28 +++++++------------ .../src/main/java/com/jme3/scene/Mesh.java | 19 +++++++++++++ 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index aaee44364c..071008d945 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -387,6 +387,7 @@ protected void setParent(Node parent) { } } + /** * Indicate that the transform of this spatial has changed and that * a refresh is required. @@ -513,7 +514,7 @@ public boolean isBatched() { */ @Override public Geometry clone(boolean cloneMaterial) { - return (Geometry) super.clone(cloneMaterial); + return (Geometry)super.clone(cloneMaterial); } /** @@ -544,16 +545,16 @@ public Spatial oldDeepClone() { } /** - * Called internally by com.jme3.util.clone.Cloner. Do not call directly. + * Called internally by com.jme3.util.clone.Cloner. Do not call directly. */ @Override - public void cloneFields(Cloner cloner, Object original) { + public void cloneFields( Cloner cloner, Object original ) { super.cloneFields(cloner, original); // If this is a grouped node and if our group node is // also cloned then we'll grab its reference. - if (groupNode != null) { - if (cloner.isCloned(groupNode)) { + if ( groupNode != null ) { + if ( cloner.isCloned(groupNode) ) { // Then resolve the reference this.groupNode = cloner.clone(groupNode); } else { @@ -575,7 +576,7 @@ public void cloneFields(Cloner cloner, Object original) { // See if we clone the mesh using the special animation // semi-deep cloning - if (shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null) { + if ( shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null ) { // Then we need to clone the mesh a little deeper this.mesh = mesh.cloneForAnim(); } else { @@ -586,7 +587,7 @@ public void cloneFields(Cloner cloner, Object original) { this.material = cloner.clone(material); } - public void setMorphState(float[] state) { + public void setMorphState(float[] state){ if (mesh == null || mesh.getMorphTargets().length == 0) { return; } @@ -693,20 +694,11 @@ public float getMorphState(String morphTarget) { * Morphs without names will be null * @return an array */ - public String[] getMorphTargets() { + public String[] getMorphNames() { if (mesh == null || mesh.getMorphTargets().length == 0) { return new String[0]; } - MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); - String[] targets = new String[nbMorphTargets.length]; - if (morphState == null) { - morphState = new float[nbMorphTargets.length]; - } - - for (int index = 0; index < nbMorphTargets.length; index++) { - targets[index] = nbMorphTargets[index].getName(); - } - return targets; + return mesh.getMorphTargetNames(); } /** 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 caffca063d..7252e67be7 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Mesh.java +++ b/jme3-core/src/main/java/com/jme3/scene/Mesh.java @@ -1529,6 +1529,25 @@ public void addMorphTarget(MorphTarget target) { public MorphTarget[] getMorphTargets() { return morphTargets.getArray(); } + + /** + * Get the name of all morphs in order. + * Morphs without names will be null + * @return an array + */ + public String[] getMorphTargetNames() { + + MorphTarget[] nbMorphTargets = getMorphTargets(); + if (nbMorphTargets.length == 0) { + return new String[0]; + } + String[] targets = new String[nbMorphTargets.length]; + + for (int index = 0; index < nbMorphTargets.length; index++) { + targets[index] = nbMorphTargets[index].getName(); + } + return targets; + } public boolean hasMorphTargets() { return morphTargets != null && !morphTargets.isEmpty(); From 9e32dc1bad636672fd95e72bd1a578cf25e4a2c9 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 15 Jun 2019 13:53:24 -0800 Subject: [PATCH 03/10] Fix formatting stuff --- jme3-core/src/main/java/com/jme3/scene/Geometry.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 071008d945..1a625f2334 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -387,7 +387,7 @@ protected void setParent(Node parent) { } } - + /** * Indicate that the transform of this spatial has changed and that * a refresh is required. @@ -553,8 +553,8 @@ public void cloneFields( Cloner cloner, Object original ) { // If this is a grouped node and if our group node is // also cloned then we'll grab its reference. - if ( groupNode != null ) { - if ( cloner.isCloned(groupNode) ) { + if( groupNode != null ) { + if( cloner.isCloned(groupNode) ) { // Then resolve the reference this.groupNode = cloner.clone(groupNode); } else { @@ -576,7 +576,7 @@ public void cloneFields( Cloner cloner, Object original ) { // See if we clone the mesh using the special animation // semi-deep cloning - if ( shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null ) { + if( shallowClone && mesh != null && mesh.getBuffer(Type.BindPosePosition) != null ) { // Then we need to clone the mesh a little deeper this.mesh = mesh.cloneForAnim(); } else { @@ -587,8 +587,8 @@ public void cloneFields( Cloner cloner, Object original ) { this.material = cloner.clone(material); } - public void setMorphState(float[] state){ - if (mesh == null || mesh.getMorphTargets().length == 0) { + public void setMorphState(float[] state) { + if (mesh == null || mesh.getMorphTargets().length == 0){ return; } From 7862a48e6765bc6111f4a96b1beb07bf29856812 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 15 Jun 2019 13:57:16 -0800 Subject: [PATCH 04/10] Add morph name to be saved --- jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java index 3c9bcf3f91..7c7500c77b 100644 --- a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java +++ b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java @@ -11,7 +11,7 @@ public class MorphTarget implements Savable { private EnumMap buffers = new EnumMap<>(VertexBuffer.Type.class); - private String name; + private String name = null; public MorphTarget() { @@ -48,6 +48,7 @@ public void write(JmeExporter ex) throws IOException { Buffer roData = entry.getValue().asReadOnlyBuffer(); oc.write((FloatBuffer) roData, entry.getKey().name(),null); } + oc.write(name, "morphName", null); } @Override @@ -59,6 +60,6 @@ public void read(JmeImporter im) throws IOException { setBuffer(type, b); } } - + name = ic.readString("morphName", null); } } From 0a84e8f6cf63ec8ce7a2e30a3024529acfd0c9c0 Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 15 Jun 2019 14:28:30 -0800 Subject: [PATCH 05/10] Testing changes to gltf plugin --- .../java/com/jme3/scene/mesh/MorphTarget.java | 4 ++++ .../com/jme3/scene/plugins/gltf/GltfLoader.java | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java index 7c7500c77b..fc80e21139 100644 --- a/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java +++ b/jme3-core/src/main/java/com/jme3/scene/mesh/MorphTarget.java @@ -21,6 +21,10 @@ public MorphTarget(String name) { this.name = name; } + public void setName(String name) { + this.name = name; + } + public String getName() { return name; } diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java index f4fabf3cf5..a32b548cf3 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java @@ -397,11 +397,23 @@ public Geometry[] readMeshPrimitives(int meshIndex) throws IOException { mesh.generateBindPose(); } + //Read morph target names + LinkedList targetNames = new LinkedList<>(); + if (meshObject.has("extras") && meshObject.getAsJsonObject("extras").has("targetNames")) { + JsonArray targetNamesJson = meshObject.getAsJsonObject("extras").getAsJsonArray("targetNames"); + for (JsonElement target : targetNamesJson) { + targetNames.add(target.getAsString()); + } + } + //Read morph targets JsonArray targets = meshObject.getAsJsonArray("targets"); if(targets != null){ for (JsonElement target : targets) { MorphTarget morphTarget = new MorphTarget(); + if (targetNames.size() > 0) { + morphTarget.setName(targetNames.pop()); + } for (Map.Entry entry : target.getAsJsonObject().entrySet()) { String bufferType = entry.getKey(); VertexBuffer.Type type = getVertexBufferType(bufferType); @@ -413,10 +425,7 @@ public Geometry[] readMeshPrimitives(int meshIndex) throws IOException { mesh.addMorphTarget(morphTarget); } } - - //Read morph target names - JsonArray targetNames = meshObject.getAsJsonArray("targetNames"); - + //Read mesh extras mesh = customContentManager.readExtensionAndExtras("primitive", meshObject, mesh); From 3fe6bd770eb7fbc608dce76b28cd97f8c614c84a Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 15 Jun 2019 14:49:25 -0800 Subject: [PATCH 06/10] It works --- .../src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java index a32b548cf3..cc9b54d454 100644 --- a/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java +++ b/jme3-plugins/src/gltf/java/com/jme3/scene/plugins/gltf/GltfLoader.java @@ -399,8 +399,8 @@ public Geometry[] readMeshPrimitives(int meshIndex) throws IOException { //Read morph target names LinkedList targetNames = new LinkedList<>(); - if (meshObject.has("extras") && meshObject.getAsJsonObject("extras").has("targetNames")) { - JsonArray targetNamesJson = meshObject.getAsJsonObject("extras").getAsJsonArray("targetNames"); + if (meshData.has("extras") && meshData.getAsJsonObject("extras").has("targetNames")) { + JsonArray targetNamesJson = meshData.getAsJsonObject("extras").getAsJsonArray("targetNames"); for (JsonElement target : targetNamesJson) { targetNames.add(target.getAsString()); } From 97971f2933aa892781976d576b20e1efd0baff5e Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Fri, 5 Jul 2019 18:33:47 -0800 Subject: [PATCH 07/10] Review changes --- .../main/java/com/jme3/scene/Geometry.java | 41 +++---------------- .../src/main/java/com/jme3/scene/Mesh.java | 18 +++++++- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 1a625f2334..ac73e1aeb9 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -610,25 +610,8 @@ public void setMorphState(float[] state) { * @param state The state to set the morph to */ public void setMorphState(String morphTarget, float state) { - if (mesh == null || mesh.getMorphTargets().length == 0) { - return; - } - MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); - - if (morphState == null) { - morphState = new float[nbMorphTargets.length]; - } - - int index; - boolean found = false; - for (index = 0; index < nbMorphTargets.length; index++) { - String name = nbMorphTargets[index].getName(); - if (name != null && name.equals(morphTarget)) { - found = true; - break; - } - } - if (found) { + int index = mesh.getMorphIndex(morphTarget); // need to add `getMorphIndex` into Mesh class + if(index > 0) { morphState[index] = state; this.dirtyMorph = true; } @@ -669,24 +652,12 @@ public float[] getMorphState() { * @return the state of the morph, or -1 if the morph is not found */ public float getMorphState(String morphTarget) { - MorphTarget[] nbMorphTargets = mesh.getMorphTargets(); - - if (morphState == null) { - morphState = new float[nbMorphTargets.length]; - } - - int index; - boolean found = false; - for (index = 0; index < nbMorphTargets.length; index++) { - if (nbMorphTargets[index].getName().equals(morphTarget)) { - found = true; - break; - } - } - if (found) { + int index = mesh.getMorphIndex(morphTarget); // need to add `getMorphIndex` into Mesh class + if(index < 0) { + return -1; + } else { return morphState[index]; } - return -1; } /** 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 7252e67be7..56751dd735 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Mesh.java +++ b/jme3-core/src/main/java/com/jme3/scene/Mesh.java @@ -1530,7 +1530,7 @@ public MorphTarget[] getMorphTargets() { return morphTargets.getArray(); } - /** + /** * Get the name of all morphs in order. * Morphs without names will be null * @return an array @@ -1552,6 +1552,22 @@ public String[] getMorphTargetNames() { public boolean hasMorphTargets() { return morphTargets != null && !morphTargets.isEmpty(); } + + /** + * Get the index of the morph that has the given name. + * @param morphName The name of the morph to search for + * @return The index of the morph, or -1 if not found. + */ + public int getMorphIndex(String morphName) { + int index = -1; + MorphTarget[] nbMorphTargets = getMorphTargets(); + for (int i = 0; i < nbMorphTargets.length; i++) { + if (nbMorphTargets[i].getName().equals(morphName)) { + index = i; + } + } + return index; + } @Override public void write(JmeExporter ex) throws IOException { From d0df346e71742a16c6299d257e529c37d197bd9c Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Fri, 5 Jul 2019 18:41:06 -0800 Subject: [PATCH 08/10] Fix comments --- jme3-core/src/main/java/com/jme3/scene/Geometry.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index ac73e1aeb9..5ded928374 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -610,7 +610,7 @@ public void setMorphState(float[] state) { * @param state The state to set the morph to */ public void setMorphState(String morphTarget, float state) { - int index = mesh.getMorphIndex(morphTarget); // need to add `getMorphIndex` into Mesh class + int index = mesh.getMorphIndex(morphTarget); if(index > 0) { morphState[index] = state; this.dirtyMorph = true; @@ -652,7 +652,7 @@ public float[] getMorphState() { * @return the state of the morph, or -1 if the morph is not found */ public float getMorphState(String morphTarget) { - int index = mesh.getMorphIndex(morphTarget); // need to add `getMorphIndex` into Mesh class + int index = mesh.getMorphIndex(morphTarget); if(index < 0) { return -1; } else { From 49caddcb471c9fabe1026259deb0b09e5f6ad80e Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sat, 6 Jul 2019 07:10:33 -0800 Subject: [PATCH 09/10] Fixes for review --- jme3-core/src/main/java/com/jme3/scene/Geometry.java | 4 ++-- jme3-core/src/main/java/com/jme3/scene/Mesh.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 5ded928374..7444506cfb 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -611,7 +611,7 @@ public void setMorphState(float[] state) { */ public void setMorphState(String morphTarget, float state) { int index = mesh.getMorphIndex(morphTarget); - if(index > 0) { + if (index >= 0) { morphState[index] = state; this.dirtyMorph = true; } @@ -653,7 +653,7 @@ public float[] getMorphState() { */ public float getMorphState(String morphTarget) { int index = mesh.getMorphIndex(morphTarget); - if(index < 0) { + if (index < 0) { return -1; } else { return morphState[index]; 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 56751dd735..1e3195e003 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Mesh.java +++ b/jme3-core/src/main/java/com/jme3/scene/Mesh.java @@ -1564,6 +1564,7 @@ public int getMorphIndex(String morphName) { for (int i = 0; i < nbMorphTargets.length; i++) { if (nbMorphTargets[i].getName().equals(morphName)) { index = i; + break; } } return index; From 82a773414d4e042683321b5b8dddbf18125d639c Mon Sep 17 00:00:00 2001 From: Trevor Flynn Date: Sun, 7 Jul 2019 09:23:17 -0800 Subject: [PATCH 10/10] Remove getMorphNames from Geometry class --- jme3-core/src/main/java/com/jme3/scene/Geometry.java | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/jme3-core/src/main/java/com/jme3/scene/Geometry.java b/jme3-core/src/main/java/com/jme3/scene/Geometry.java index 7444506cfb..adc1d51a55 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Geometry.java +++ b/jme3-core/src/main/java/com/jme3/scene/Geometry.java @@ -659,18 +659,6 @@ public float getMorphState(String morphTarget) { return morphState[index]; } } - - /** - * Get the name of all morphs in order. - * Morphs without names will be null - * @return an array - */ - public String[] getMorphNames() { - if (mesh == null || mesh.getMorphTargets().length == 0) { - return new String[0]; - } - return mesh.getMorphTargetNames(); - } /** * Return the number of morph targets that can be handled on the GPU simultaneously for this geometry.