|
|
@ -899,39 +899,51 @@ public class ShaderNodeLoaderDelegate { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* find the definition from this statement (loads it if necessary) |
|
|
|
* Find the definition from this statement (loads it if necessary) |
|
|
|
* |
|
|
|
* |
|
|
|
* @param statement the statement being read |
|
|
|
* @param statement the statement being read |
|
|
|
* @return the definition |
|
|
|
* @return the definition |
|
|
|
* @throws IOException |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public ShaderNodeDefinition findDefinition(Statement statement) throws IOException { |
|
|
|
public ShaderNodeDefinition findDefinition(Statement statement) throws IOException { |
|
|
|
String defLine[] = statement.getLine().split(":"); |
|
|
|
|
|
|
|
String defName = defLine[1].trim(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShaderNodeDefinition def = getNodeDefinitions().get(defName); |
|
|
|
final String defLine[] = statement.getLine().split(":"); |
|
|
|
if (def == null) { |
|
|
|
|
|
|
|
if (defLine.length == 3) { |
|
|
|
if (defLine.length != 3) { |
|
|
|
List<ShaderNodeDefinition> defs = null; |
|
|
|
throw new MatParseException("Can't find shader node definition for: ", statement); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final Map<String, ShaderNodeDefinition> nodeDefinitions = getNodeDefinitions(); |
|
|
|
|
|
|
|
final String definitionName = defLine[1].trim(); |
|
|
|
|
|
|
|
final String definitionPath = defLine[2].trim(); |
|
|
|
|
|
|
|
final String fullName = definitionName + ":" + definitionPath; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ShaderNodeDefinition def = nodeDefinitions.get(fullName); |
|
|
|
|
|
|
|
if (def != null) { |
|
|
|
|
|
|
|
return def; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ShaderNodeDefinition> defs; |
|
|
|
try { |
|
|
|
try { |
|
|
|
defs = assetManager.loadAsset(new ShaderNodeDefinitionKey(defLine[2].trim())); |
|
|
|
defs = assetManager.loadAsset(new ShaderNodeDefinitionKey(definitionPath)); |
|
|
|
} catch (AssetNotFoundException e) { |
|
|
|
} catch (final AssetNotFoundException e) { |
|
|
|
throw new MatParseException("Couldn't find " + defLine[2].trim(), statement, e); |
|
|
|
throw new MatParseException("Couldn't find " + definitionPath, statement, e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (ShaderNodeDefinition definition : defs) { |
|
|
|
for (final ShaderNodeDefinition definition : defs) { |
|
|
|
if (defName.equals(definition.getName())) { |
|
|
|
if (definitionName.equals(definition.getName())) { |
|
|
|
def = definition; |
|
|
|
def = definition; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!(getNodeDefinitions().containsKey(definition.getName()))) { |
|
|
|
final String key = definition.getName() + ":" + definitionPath; |
|
|
|
getNodeDefinitions().put(definition.getName(), definition); |
|
|
|
if (!(nodeDefinitions.containsKey(key))) { |
|
|
|
} |
|
|
|
nodeDefinitions.put(key, definition); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (def == null) { |
|
|
|
if (def == null) { |
|
|
|
throw new MatParseException(defName + " is not a declared as Shader Node Definition", statement); |
|
|
|
throw new MatParseException(definitionName + " is not a declared as Shader Node Definition", statement); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return def; |
|
|
|
return def; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|