if (!mapping.getLeftSwizzling().equals("")) { out.write("."); out.write(mapping.getLeftSwizzling());
if (mapping.getLeftSwizzling().length() > 0) { source.append(leftVariable.getName()); source.append("."); source.append(mapping.getLeftSwizzling());
/** * Check if a mapping is valid by checking the types and swizzle of both of * the variables * * @param mapping the mapping * @return true if this mapping is valid */ public static boolean typesMatch(VariableMapping mapping) { String leftType = mapping.getLeftVariable().getType(); String rightType = mapping.getRightVariable().getType(); String leftSwizzling = mapping.getLeftSwizzling(); String rightSwizzling = mapping.getRightSwizzling(); //types match : no error if (leftType.equals(rightType) && leftSwizzling.length() == rightSwizzling.length()) { return true; } if (isSwizzlable(leftType) && isSwizzlable(rightType)) { if (getCardinality(leftType, leftSwizzling) == getCardinality(rightType, rightSwizzling)) { return true; } } return false; }
/** * check the types of a mapping, left type must match right type take the * swizzle into account * * @param mapping the mapping * @param statement1 the statement being read * @throws MatParseException */ protected void checkTypes(VariableMapping mapping, Statement statement1) throws MatParseException { if (!ShaderUtils.typesMatch(mapping)) { String ls = mapping.getLeftSwizzling().length() == 0 ? "" : "." + mapping.getLeftSwizzling(); String rs = mapping.getRightSwizzling().length() == 0 ? "" : "." + mapping.getRightSwizzling(); throw new MatParseException("Type mismatch, cannot convert " + mapping.getRightVariable().getType() + rs + " to " + mapping.getLeftVariable().getType() + ls, statement1); } if (!ShaderUtils.multiplicityMatch(mapping)) { String type1 = mapping.getLeftVariable().getType() + "[" + mapping.getLeftVariable().getMultiplicity() + "]"; String type2 = mapping.getRightVariable().getType() + "[" + mapping.getRightVariable().getMultiplicity() + "]"; throw new MatParseException("Type mismatch, cannot convert " + type1 + " to " + type2, statement1); } }
private void assertEqualsVariableMapping(VariableMapping im1, VariableMapping im2) { assertEquals(im1.getCondition(), im2.getCondition()); assertEquals(im1.getLeftSwizzling(), im2.getLeftSwizzling()); assertEquals(im1.getRightSwizzling(), im2.getRightSwizzling()); assertEqualsVariables(im1.getRightVariable(), im2.getRightVariable()); assertEqualsVariables(im1.getLeftVariable(), im2.getLeftVariable()); }
private void writeVariableMapping(OutputStreamWriter out, ShaderNode shaderNode, VariableMapping mapping, Collection<MatParam> matParams) throws IOException { out.write(" "); if(!mapping.getLeftVariable().getNameSpace().equals(shaderNode.getName())) { out.write(mapping.getLeftVariable().getNameSpace()); out.write("."); } out.write(mapping.getLeftVariable().getName()); if(!mapping.getLeftSwizzling().equals("")){ out.write("."); out.write(mapping.getLeftSwizzling()); } out.write(" = "); if(!mapping.getRightVariable().getNameSpace().equals(shaderNode.getName())) { out.write(mapping.getRightVariable().getNameSpace()); out.write("."); } out.write(mapping.getRightVariable().getName().replaceFirst("g_","").replaceFirst("m_","")); if(!mapping.getRightSwizzling().equals("")){ out.write("."); out.write(mapping.getRightSwizzling()); } if (mapping.getCondition() != null){ out.write(" : "); out.write(formatCondition(mapping.getCondition(),matParams)); } out.write("\n"); }
if (mapping.getLeftSwizzling().length() > 0) { source.append(mapping.getLeftVariable().getName()); source.append("."); source.append(mapping.getLeftSwizzling());
/** * Check if a mapping is valid by checking the types and swizzle of both of * the variables * * @param mapping the mapping * @return true if this mapping is valid */ public static boolean typesMatch(VariableMapping mapping) { String leftType = mapping.getLeftVariable().getType(); String rightType = mapping.getRightVariable().getType(); String leftSwizzling = mapping.getLeftSwizzling(); String rightSwizzling = mapping.getRightSwizzling(); //types match : no error if (leftType.equals(rightType) && leftSwizzling.length() == rightSwizzling.length()) { return true; } if (isSwizzlable(leftType) && isSwizzlable(rightType)) { if (getCardinality(leftType, leftSwizzling) == getCardinality(rightType, rightSwizzling)) { return true; } } return false; }
/** * check the types of a mapping, left type must match right type take the * swizzle into account * * @param mapping the mapping * @param statement1 the statement being read * @throws MatParseException */ protected void checkTypes(VariableMapping mapping, Statement statement1) throws MatParseException { if (!ShaderUtils.typesMatch(mapping)) { String ls = mapping.getLeftSwizzling().length() == 0 ? "" : "." + mapping.getLeftSwizzling(); String rs = mapping.getRightSwizzling().length() == 0 ? "" : "." + mapping.getRightSwizzling(); throw new MatParseException("Type mismatch, cannot convert " + mapping.getRightVariable().getType() + rs + " to " + mapping.getLeftVariable().getType() + ls, statement1); } if (!ShaderUtils.multiplicityMatch(mapping)) { String type1 = mapping.getLeftVariable().getType() + "[" + mapping.getLeftVariable().getMultiplicity() + "]"; String type2 = mapping.getRightVariable().getType() + "[" + mapping.getRightVariable().getMultiplicity() + "]"; throw new MatParseException("Type mismatch, cannot convert " + type1 + " to " + type2, statement1); } }