<commit_before>from . import texture_utils
from . import string_utils
from . import shadergraph_utils
from . import node_desc
from . import prefs_utils
from ..rman_constants import RFB_ARRAYS_MAX_LEN
from ..rfb_logger import rfb_log
from collections import OrderedDict
from bpy.props import *
from copy import deepcopy
import bpy
import sys


__GAINS_TO_ENABLE__ = {
    'diffuseGain': 'enableDiffuse',
    'specularFaceColor': 'enablePrimarySpecular',
    'specularEdgeColor': 'enablePrimarySpecular',
    'roughSpecularFaceColor': 'enableRoughSpecular',
    'roughSpecularEdgeColor': 'enableRoughSpecular',
    'clearcoatFaceColor': 'enableClearCoat',
    'clearcoatEdgeColor': 'enableClearCoat',
    'iridescenceFaceGain': 'enableIridescence',
    'iridescenceEdgeGain': 'enableIridescence',
    'fuzzGain': 'enableFuzz',
    'subsurfaceGain': 'enableSubsurface',
    'singlescatterGain': 'enableSingleScatter',
    'singlescatterDirectGain': 'enableSingleScatter',
    'refractionGain': 'enableGlass',
    'reflectionGain': 'enableGlass',
    'glowGain': 'enableGlow',
}

# special string to indicate an empty string
# necessary for EnumProperty because it cannot
# take an empty string as an item value
__RMAN_EMPTY_STRING__ = '__empty__'

def set_rix_param(params, param_type, param_name, val, is_reference=False, is_array=False, array_len=-1, dflt=None):
    if is_reference:
        if is_array:
            if param_type == 'float':
                params.SetFloatReferenceArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerReferenceArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorReferenceArray(param_name, val, array_len)         
        else:
            if param_type == "float":
                params.SetFloatReference(param_name, val)
            elif param_type == "int":
                params.SetIntegerReference(param_name, val)
            elif param_type == "color":
                params.SetColorReference(param_name, val)
            elif param_type == "point":
                params.SetPointReference(param_name, val)            
            elif param_type == "vector":
                params.SetVectorReference(param_name, val)
            elif param_type == "normal":
                params.SetNormalReference(param_name, val) 
            elif param_type == "struct":
                params.SetStructReference(param_name, val)        
            elif param_type == "bxdf":
                params.SetBxdfReference(param_name, val)       
    else:
        # check if we need to emit this parameter.
        if dflt != None and not prefs_utils.get_pref_val('rman_emit_default_params'):
            if isinstance(val, list):
                dflt = list(dflt)
            if param_type == 'string' and val == __RMAN_EMPTY_STRING__:
                val = ""
            if val == dflt:
                return                  

        if is_array:
            if param_type == 'float':
                params.SetFloatArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorArray(param_name, val, int(array_len/3))
            elif param_type == 'string':
                params.SetStringArray(param_name, val, array_len)
        else:
            if param_type == "float":
                params.SetFloat(param_name, float(val))
            elif param_type == "int":
                params.SetInteger(param_name, int(val))
            elif param_type == "color":
                params.SetColor(param_name, val)
            elif param_type == "string":
                if val == __RMAN_EMPTY_STRING__:
                    val = ""
                params.SetString(param_name, val)
            elif param_type == "point":
                params.SetPoint(param_name, val)                            
            elif param_type == "vector":
                params.SetVector(param_name, val)
            elif param_type == "normal":
                params.SetNormal(param_name, val)               

    '''
    if is_array:
        if is_reference:
            if param_type == 'float':
                params.SetFloatReferenceArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerReferenceArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorReferenceArray(param_name, val, array_len)
        else:
            # check if we need to emit this parameter.
            if dflt != None and not prefs.rman_emit_default_params:       
                if isinstance(val, list):
                    dflt = list(dflt)
                if val == dflt:
                    return

            if param_type == 'float':
                params.SetFloatArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorArray(param_name, val, int(array_len/3))
            elif param_type == 'string':
                params.SetStringArray(param_name, val, array_len)

    elif is_reference:
        if param_type == "float":
            params.SetFloatReference(param_name, val)
        elif param_type == "int":
            params.SetIntegerReference(param_name, val)
        elif param_type == "color":
            params.SetColorReference(param_name, val)
        elif param_type == "point":
            params.SetPointReference(param_name, val)            
        elif param_type == "vector":
            params.SetVectorReference(param_name, val)
        elif param_type == "normal":
            params.SetNormalReference(param_name, val) 
        elif param_type == "struct":
            params.SetStructReference(param_name, val)        
        elif param_type == "bxdf":
            params.SetBxdfReference(param_name, val)                              
    else:        
        # check if we need to emit this parameter.
        if dflt != None and not prefs.rman_emit_default_params:       
            if isinstance(val, list):
                dflt = list(dflt)
            if param_type == 'string' and val == __RMAN_EMPTY_STRING__:
                val = ""
            if val == dflt:
                return

        if param_type == "float":
            params.SetFloat(param_name, float(val))
        elif param_type == "int":
            params.SetInteger(param_name, int(val))
        elif param_type == "color":
            params.SetColor(param_name, val)
        elif param_type == "string":
            if val == __RMAN_EMPTY_STRING__:
                val = ""
            params.SetString(param_name, val)
        elif param_type == "point":
            params.SetPoint(param_name, val)                            
        elif param_type == "vector":
            params.SetVector(param_name, val)
        elif param_type == "normal":
            params.SetNormal(param_name, val)   
    '''

def build_output_param_str(mat_name, from_node, from_socket, convert_socket=False, param_type=''):
    from_node_name = shadergraph_utils.get_node_name(from_node, mat_name)
    from_sock_name = shadergraph_utils.get_socket_name(from_node, from_socket)

    # replace with the convert node's output
    if convert_socket:
        if shadergraph_utils.is_float_type(from_socket):
            return "convert_%s_%s:resultRGB" % (from_node_name, from_sock_name)
        else:
            return "convert_%s_%s:resultF" % (from_node_name, from_sock_name)
    elif param_type == 'bxdf':<commit_msg>Forgot to remove commented out code.<commit_after>from . import texture_utils
from . import string_utils
from . import shadergraph_utils
from . import node_desc
from . import prefs_utils
from ..rman_constants import RFB_ARRAYS_MAX_LEN
from ..rfb_logger import rfb_log
from collections import OrderedDict
from bpy.props import *
from copy import deepcopy
import bpy
import sys


__GAINS_TO_ENABLE__ = {
    'diffuseGain': 'enableDiffuse',
    'specularFaceColor': 'enablePrimarySpecular',
    'specularEdgeColor': 'enablePrimarySpecular',
    'roughSpecularFaceColor': 'enableRoughSpecular',
    'roughSpecularEdgeColor': 'enableRoughSpecular',
    'clearcoatFaceColor': 'enableClearCoat',
    'clearcoatEdgeColor': 'enableClearCoat',
    'iridescenceFaceGain': 'enableIridescence',
    'iridescenceEdgeGain': 'enableIridescence',
    'fuzzGain': 'enableFuzz',
    'subsurfaceGain': 'enableSubsurface',
    'singlescatterGain': 'enableSingleScatter',
    'singlescatterDirectGain': 'enableSingleScatter',
    'refractionGain': 'enableGlass',
    'reflectionGain': 'enableGlass',
    'glowGain': 'enableGlow',
}

# special string to indicate an empty string
# necessary for EnumProperty because it cannot
# take an empty string as an item value
__RMAN_EMPTY_STRING__ = '__empty__'

def set_rix_param(params, param_type, param_name, val, is_reference=False, is_array=False, array_len=-1, dflt=None):
    if is_reference:
        if is_array:
            if param_type == 'float':
                params.SetFloatReferenceArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerReferenceArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorReferenceArray(param_name, val, array_len)         
        else:
            if param_type == "float":
                params.SetFloatReference(param_name, val)
            elif param_type == "int":
                params.SetIntegerReference(param_name, val)
            elif param_type == "color":
                params.SetColorReference(param_name, val)
            elif param_type == "point":
                params.SetPointReference(param_name, val)            
            elif param_type == "vector":
                params.SetVectorReference(param_name, val)
            elif param_type == "normal":
                params.SetNormalReference(param_name, val) 
            elif param_type == "struct":
                params.SetStructReference(param_name, val)        
            elif param_type == "bxdf":
                params.SetBxdfReference(param_name, val)       
    else:
        # check if we need to emit this parameter.
        if dflt != None and not prefs_utils.get_pref_val('rman_emit_default_params'):
            if isinstance(val, list):
                dflt = list(dflt)
            if param_type == 'string' and val == __RMAN_EMPTY_STRING__:
                val = ""
            if val == dflt:
                return                  

        if is_array:
            if param_type == 'float':
                params.SetFloatArray(param_name, val, array_len)
            elif param_type == 'int':
                params.SetIntegerArray(param_name, val, array_len)
            elif param_type == 'color':
                params.SetColorArray(param_name, val, int(array_len/3))
            elif param_type == 'string':
                params.SetStringArray(param_name, val, array_len)
        else:
            if param_type == "float":
                params.SetFloat(param_name, float(val))
            elif param_type == "int":
                params.SetInteger(param_name, int(val))
            elif param_type == "color":
                params.SetColor(param_name, val)
            elif param_type == "string":
                if val == __RMAN_EMPTY_STRING__:
                    val = ""
                params.SetString(param_name, val)
            elif param_type == "point":
                params.SetPoint(param_name, val)                            
            elif param_type == "vector":
                params.SetVector(param_name, val)
            elif param_type == "normal":
                params.SetNormal(param_name, val)               

def build_output_param_str(mat_name, from_node, from_socket, convert_socket=False, param_type=''):
    from_node_name = shadergraph_utils.get_node_name(from_node, mat_name)
    from_sock_name = shadergraph_utils.get_socket_name(from_node, from_socket)

    # replace with the convert node's output
    if convert_socket:
        if shadergraph_utils.is_float_type(from_socket):
            return "convert_%s_%s:resultRGB" % (from_node_name, from_sock_name)
        else:
            return "convert_%s_%s:resultF" % (from_node_name, from_sock_name)
    elif param_type == 'bxdf':
{'fraction_non_alphanumeric': 0.0918733551319882, 'fraction_numerical': 0.00039875588164925435, 'mean_word_length': 2.1867852604828464, 'pattern_counts': {'":': 45, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1334845', 'n_tokens_mistral': 3621, 'n_tokens_neox': 3532, 'n_words': 782}