diff --git a/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java b/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java index fd3ce155f..ab06cdf0b 100644 --- a/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java +++ b/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java @@ -189,30 +189,30 @@ public class ShaderGenerationInfo implements Savable, Cloneable { } @Override - protected Object clone() throws CloneNotSupportedException { + protected ShaderGenerationInfo clone() throws CloneNotSupportedException { ShaderGenerationInfo clone = (ShaderGenerationInfo) super.clone(); for (ShaderNodeVariable attribute : attributes) { - clone.attributes.add((ShaderNodeVariable) attribute.clone()); + clone.attributes.add(attribute.clone()); } for (ShaderNodeVariable uniform : vertexUniforms) { - clone.vertexUniforms.add((ShaderNodeVariable) uniform.clone()); + clone.vertexUniforms.add(uniform.clone()); } - clone.vertexGlobal = (ShaderNodeVariable) vertexGlobal.clone(); + clone.vertexGlobal = vertexGlobal.clone(); for (ShaderNodeVariable varying : varyings) { - clone.varyings.add((ShaderNodeVariable) varying.clone()); + clone.varyings.add(varying.clone()); } for (ShaderNodeVariable uniform : fragmentUniforms) { - clone.fragmentUniforms.add((ShaderNodeVariable) uniform.clone()); + clone.fragmentUniforms.add(uniform.clone()); } for (ShaderNodeVariable globals : fragmentGlobals) { - clone.fragmentGlobals.add((ShaderNodeVariable) globals.clone()); + clone.fragmentGlobals.add(globals.clone()); } clone.unusedNodes.addAll(unusedNodes); diff --git a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java index 83135cf0c..429522c59 100644 --- a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java +++ b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java @@ -778,7 +778,7 @@ public class TechniqueDef implements Savable, Cloneable { } @Override - public Object clone() throws CloneNotSupportedException { + public TechniqueDef clone() throws CloneNotSupportedException { //cannot use super.clone because of the final fields instance that would be shared by the clones. TechniqueDef clone = new TechniqueDef(name, sortId); @@ -802,9 +802,9 @@ public class TechniqueDef implements Savable, Cloneable { if (shaderNodes != null) { for (ShaderNode shaderNode : shaderNodes) { - clone.shaderNodes.add((ShaderNode) shaderNode.clone()); + clone.shaderNodes.add(shaderNode.clone()); } - clone.shaderGenerationInfo = (ShaderGenerationInfo) shaderGenerationInfo.clone(); + clone.shaderGenerationInfo = shaderGenerationInfo.clone(); } if (renderState != null) { diff --git a/jme3-core/src/main/java/com/jme3/shader/ShaderNode.java b/jme3-core/src/main/java/com/jme3/shader/ShaderNode.java index 9f8156933..4f5779363 100644 --- a/jme3-core/src/main/java/com/jme3/shader/ShaderNode.java +++ b/jme3-core/src/main/java/com/jme3/shader/ShaderNode.java @@ -214,7 +214,7 @@ public class ShaderNode implements Savable, Cloneable { } @Override - public Object clone() throws CloneNotSupportedException { + public ShaderNode clone() throws CloneNotSupportedException { ShaderNode clone = (ShaderNode) super.clone(); //No need to clone the definition. diff --git a/jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java b/jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java index 7d0d959e3..22811de6f 100644 --- a/jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java +++ b/jme3-core/src/main/java/com/jme3/shader/ShaderNodeVariable.java @@ -278,7 +278,7 @@ public class ShaderNodeVariable implements Savable, Cloneable { } @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); + public ShaderNodeVariable clone() throws CloneNotSupportedException { + return (ShaderNodeVariable) super.clone(); } } diff --git a/jme3-core/src/main/java/com/jme3/shader/VariableMapping.java b/jme3-core/src/main/java/com/jme3/shader/VariableMapping.java index 61ae612fd..4a88c5d9f 100644 --- a/jme3-core/src/main/java/com/jme3/shader/VariableMapping.java +++ b/jme3-core/src/main/java/com/jme3/shader/VariableMapping.java @@ -197,11 +197,11 @@ public class VariableMapping implements Savable, Cloneable { } @Override - protected Object clone() throws CloneNotSupportedException { + protected VariableMapping clone() throws CloneNotSupportedException { VariableMapping clone = (VariableMapping) super.clone(); - clone.leftVariable = (ShaderNodeVariable) leftVariable.clone(); - clone.rightVariable = (ShaderNodeVariable) rightVariable.clone(); + clone.leftVariable = leftVariable.clone(); + clone.rightVariable = rightVariable.clone(); return clone; } diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java index 0dfaafd3c..e725301bb 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/J3MLoader.java @@ -615,6 +615,7 @@ public class J3MLoader implements AssetLoader { private void readTechnique(Statement techStat) throws IOException{ isUseNodes = false; String[] split = techStat.getLine().split(whitespacePattern); + Cloner cloner = new Cloner(); String name; if (split.length == 1) { @@ -669,12 +670,8 @@ public class J3MLoader implements AssetLoader { }else if (shaderNames.containsKey(Shader.ShaderType.Vertex) && shaderNames.containsKey(Shader.ShaderType.Fragment)) { if (shaderLanguages.size() > 1) { for (int i = 1; i < shaderLanguages.size(); i++) { - TechniqueDef td = null; - try { - td = (TechniqueDef) technique.clone(); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } + cloner.clearIndex(); + TechniqueDef td = cloner.clone(technique); td.setShaderFile(shaderNames, shaderLanguages.get(i)); techniqueDefs.add(td); }