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
experimental
rem..om 11 years ago
parent 0759c74764
commit b14f33936f
  1. 14
      engine/src/core-plugins/com/jme3/material/plugins/J3MLoader.java
  2. 18
      engine/src/core-plugins/com/jme3/material/plugins/ShaderNodeLoaderDelegate.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<Statement> roots) throws IOException{
isUseNodes = false;
private void loadFromRoot(List<Statement> 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);
}
}
}
}
}

@ -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();
}
}

Loading…
Cancel
Save