diff --git a/engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java b/engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java index 9a1d6be6a..e12a0759f 100644 --- a/engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java +++ b/engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java @@ -431,6 +431,7 @@ public class J3MLoader implements AssetLoader { } private void readTechnique(Statement techStat) throws IOException{ + isUseNodes = false; String[] split = techStat.getLine().split(whitespacePattern); if (split.length == 1) { technique = new TechniqueDef(null); @@ -468,8 +469,7 @@ public class J3MLoader implements AssetLoader { fragLanguage = null; } - private void loadFromRoot(List roots) throws IOException{ - isUseNodes = false; + private void loadFromRoot(List roots) throws IOException{ if (roots.size() == 2){ Statement exception = roots.get(0); String line = exception.getLine(); @@ -585,13 +585,17 @@ public class J3MLoader implements AssetLoader { protected void initNodesLoader() { if (!isUseNodes) { isUseNodes = fragName == null && vertName == null; - if (isUseNodes) { - nodesLoaderDelegate = new ShaderNodeLoaderDelegate(); + if (isUseNodes) { + if(nodesLoaderDelegate == null){ + nodesLoaderDelegate = new ShaderNodeLoaderDelegate(); + }else{ + nodesLoaderDelegate.clear(); + } nodesLoaderDelegate.setTechniqueDef(technique); nodesLoaderDelegate.setMaterialDef(materialDef); nodesLoaderDelegate.setAssetManager(assetManager); } } - } + } } diff --git a/engine/src/core-plugins/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java b/engine/src/core-plugins/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java index d738b39db..dd1bc6dcd 100644 --- a/engine/src/core-plugins/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java +++ b/engine/src/core-plugins/com/jme3/material/plugins/ShaderNodeLoaderDelegate.java @@ -1077,4 +1077,22 @@ public class ShaderNodeLoaderDelegate { declaredVariable.makeCondition(); } } + + public void clear() { + nodeDefinitions.clear(); + nodes.clear(); + shaderNodeDefinition = null; + shaderNode = null; + techniqueDef = null; + attributes.clear(); + vertexDeclaredUniforms.clear(); + fragmentDeclaredUniforms.clear(); + varyings.clear(); + materialDef = null; + shaderLanguage = ""; + shaderName = ""; + varNames = ""; + assetManager = null; + nulledConditions.clear(); + } }