diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java index 9eecd12b7..c8c674046 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java @@ -43,10 +43,7 @@ import com.jme3.shader.*; import com.jme3.util.blockparser.Statement; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * This class is here to be able to load shaderNodeDefinition from both the @@ -75,7 +72,7 @@ public class ShaderNodeLoaderDelegate { protected MaterialDef materialDef; protected String shaderLanguage; protected String shaderName; - protected String varNames = ""; + protected Set varNames = new HashSet<>(); protected AssetManager assetManager; protected ConditionParser conditionParser = new ConditionParser(); protected List nulledConditions = new ArrayList(); @@ -177,7 +174,7 @@ public class ShaderNodeLoaderDelegate { shaderNodeDefinition.setDocumentation(doc); } } else if (line.startsWith("Input")) { - varNames = ""; + varNames.clear(); for (Statement statement1 : statement.getContents()) { try { shaderNodeDefinition.getInputs().add(readVariable(statement1)); @@ -186,7 +183,7 @@ public class ShaderNodeLoaderDelegate { } } } else if (line.startsWith("Output")) { - varNames = ""; + varNames.clear(); for (Statement statement1 : statement.getContents()) { try { if (statement1.getLine().trim().equals("None")) { @@ -235,11 +232,11 @@ public class ShaderNodeLoaderDelegate { multiplicity = arr[1].replaceAll("\\]", "").trim(); } - if (varNames.contains(varName + ";")) { + if (varNames.contains(varName)) { throw new MatParseException("Duplicate variable name " + varName, statement); } - varNames += varName + ";"; + varNames.add(varName); final ShaderNodeVariable variable = new ShaderNodeVariable(varType, "", varName, multiplicity); variable.setDefaultValue(defaultValue); @@ -1139,7 +1136,7 @@ public class ShaderNodeLoaderDelegate { materialDef = null; shaderLanguage = ""; shaderName = ""; - varNames = ""; + varNames.clear(); assetManager = null; nulledConditions.clear(); }