Better error reporting when loading shaderNodeDefinition
This commit is contained in:
parent
e860fa6ce6
commit
5ac5731ebf
@ -232,40 +232,52 @@ public class ShaderNodeLoaderDelegate {
|
|||||||
protected void readShaderNodeDefinition(List<Statement> statements, ShaderNodeDefinitionKey key) throws IOException {
|
protected void readShaderNodeDefinition(List<Statement> statements, ShaderNodeDefinitionKey key) throws IOException {
|
||||||
boolean isLoadDoc = key instanceof ShaderNodeDefinitionKey && ((ShaderNodeDefinitionKey) key).isLoadDocumentation();
|
boolean isLoadDoc = key instanceof ShaderNodeDefinitionKey && ((ShaderNodeDefinitionKey) key).isLoadDocumentation();
|
||||||
for (Statement statement : statements) {
|
for (Statement statement : statements) {
|
||||||
String[] split = statement.getLine().split("[ \\{]");
|
try {
|
||||||
String line = statement.getLine();
|
String[] split = statement.getLine().split("[ \\{]");
|
||||||
|
String line = statement.getLine();
|
||||||
|
|
||||||
if (line.startsWith("Type")) {
|
if (line.startsWith("Type")) {
|
||||||
String type = line.substring(line.lastIndexOf(':') + 1).trim();
|
String type = line.substring(line.lastIndexOf(':') + 1).trim();
|
||||||
shaderNodeDefinition.setType(Shader.ShaderType.valueOf(type));
|
shaderNodeDefinition.setType(Shader.ShaderType.valueOf(type));
|
||||||
} else if (line.startsWith("Shader ")) {
|
} else if (line.startsWith("Shader ")) {
|
||||||
readShaderStatement(statement);
|
readShaderStatement(statement);
|
||||||
shaderNodeDefinition.getShadersLanguage().add(shaderLanguage);
|
shaderNodeDefinition.getShadersLanguage().add(shaderLanguage);
|
||||||
shaderNodeDefinition.getShadersPath().add(shaderName);
|
shaderNodeDefinition.getShadersPath().add(shaderName);
|
||||||
} else if (line.startsWith("Documentation")) {
|
} else if (line.startsWith("Documentation")) {
|
||||||
if (isLoadDoc) {
|
if (isLoadDoc) {
|
||||||
String doc = "";
|
String doc = "";
|
||||||
|
for (Statement statement1 : statement.getContents()) {
|
||||||
|
doc += "\n" + statement1.getLine();
|
||||||
|
}
|
||||||
|
shaderNodeDefinition.setDocumentation(doc);
|
||||||
|
}
|
||||||
|
} else if (line.startsWith("Input")) {
|
||||||
|
varNames = "";
|
||||||
for (Statement statement1 : statement.getContents()) {
|
for (Statement statement1 : statement.getContents()) {
|
||||||
doc += "\n" + statement1.getLine();
|
try {
|
||||||
|
shaderNodeDefinition.getInputs().add(readVariable(statement1));
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
throw new MatParseException(e.getMessage(), statement1, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
shaderNodeDefinition.setDocumentation(doc);
|
} else if (line.startsWith("Output")) {
|
||||||
}
|
varNames = "";
|
||||||
} else if (line.startsWith("Input")) {
|
for (Statement statement1 : statement.getContents()) {
|
||||||
varNames = "";
|
try {
|
||||||
for (Statement statement1 : statement.getContents()) {
|
if (statement1.getLine().trim().equals("None")) {
|
||||||
shaderNodeDefinition.getInputs().add(readVariable(statement1));
|
shaderNodeDefinition.setNoOutput(true);
|
||||||
}
|
} else {
|
||||||
} else if (line.startsWith("Output")) {
|
shaderNodeDefinition.getOutputs().add(readVariable(statement1));
|
||||||
varNames = "";
|
}
|
||||||
for (Statement statement1 : statement.getContents()) {
|
} catch (RuntimeException e) {
|
||||||
if(statement1.getLine().trim().equals("None")){
|
throw new MatParseException(e.getMessage(), statement1, e);
|
||||||
shaderNodeDefinition.setNoOutput(true);
|
}
|
||||||
}else{
|
|
||||||
shaderNodeDefinition.getOutputs().add(readVariable(statement1));
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
throw new MatParseException("one of Type, Shader, Documentation, Input, Output", split[0], statement);
|
||||||
}
|
}
|
||||||
} else {
|
} catch (RuntimeException e) {
|
||||||
throw new MatParseException("one of Type, Shader, Documentation, Input, Output", split[0], statement);
|
throw new MatParseException(e.getMessage(), statement, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,6 +292,9 @@ public class ShaderNodeLoaderDelegate {
|
|||||||
protected ShaderNodeVariable readVariable(Statement statement) throws IOException {
|
protected ShaderNodeVariable readVariable(Statement statement) throws IOException {
|
||||||
String line = statement.getLine().trim().replaceAll("\\s*\\[", "[");
|
String line = statement.getLine().trim().replaceAll("\\s*\\[", "[");
|
||||||
String[] splitVar = line.split("\\s");
|
String[] splitVar = line.split("\\s");
|
||||||
|
if (splitVar.length != 2) {
|
||||||
|
throw new MatParseException("2 arguments", splitVar.length + "", statement);
|
||||||
|
}
|
||||||
String varName = splitVar[1];
|
String varName = splitVar[1];
|
||||||
String varType = splitVar[0];
|
String varType = splitVar[0];
|
||||||
String multiplicity = null;
|
String multiplicity = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user