From 47406058a66364ba1330ee50f23c6763cb77dd0a Mon Sep 17 00:00:00 2001 From: Nehon Date: Mon, 12 Mar 2018 08:09:42 +0100 Subject: [PATCH] Fixes condition parsing for shader nodes --- .../com/jme3/material/plugins/ConditionParser.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/jme3-core/src/plugins/java/com/jme3/material/plugins/ConditionParser.java b/jme3-core/src/plugins/java/com/jme3/material/plugins/ConditionParser.java index 2041fba09..07569ce90 100644 --- a/jme3-core/src/plugins/java/com/jme3/material/plugins/ConditionParser.java +++ b/jme3-core/src/plugins/java/com/jme3/material/plugins/ConditionParser.java @@ -51,8 +51,8 @@ public class ConditionParser { public static void main(String argv[]) { ConditionParser parser = new ConditionParser(); - List defines = parser.extractDefines("(LightMap && SeparateTexCoord) || !ColorMap"); - + //List defines = parser.extractDefines("(LightMap && SeparateTexCoord) || !ColorMap"); + List defines = parser.extractDefines("RoughnessMap && MetallicRoughnessMap"); for (String string : defines) { System.err.println(string); } @@ -78,15 +78,15 @@ public class ConditionParser { * parse a condition and returns the list of defines of this condition. * additionally this methods updates the formattedExpression with uppercased * defines names - * - * supported expression syntax example: + * + * supported expression syntax example: * * "(LightMap && SeparateTexCoord) || !ColorMap" * "#if (defined(LightMap) && defined(SeparateTexCoord)) || !defined(ColorMap)" * "#ifdef LightMap" * "#ifdef (LightMap && SeparateTexCoord) || !ColorMap" * - * + * * @param expression the expression to parse * @return the list of defines */ @@ -99,13 +99,13 @@ public class ConditionParser { while (m.find()) { String match = m.group(); defines.add(match); - formattedExpression = formattedExpression.replaceAll(match, "defined(" + match.toUpperCase() + ")"); + formattedExpression = formattedExpression.replaceAll("\\b" + match + "\\b", "defined(" + match.toUpperCase() + ")"); } return defines; } /** - * + * * @return the formatted expression previously updated by extractDefines */ public String getFormattedExpression() {