From b14f33936f3d05ddde0f6661b2146063c51af696 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Thu, 31 Oct 2013 18:04:06 +0000 Subject: [PATCH] the ShaderNodesLoader is now properly reset when loading several technique def using nodes git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10859 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../com/jme3/material/plugins/J3MLoader.java | 14 +++++++++----- .../plugins/ShaderNodeLoaderDelegate.java | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) 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(); + } }