Code refactor: store ShaderNode enums as enum rather than ustring.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 29 May 2016 14:13:14 +0000 (16:13 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sun, 29 May 2016 18:30:16 +0000 (20:30 +0200)
intern/cycles/app/cycles_xml.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/nodes.h

index 60fa2fc11b3c83e7321edc93b73bba24fea9e084..6f9cbe37a5828f76973bb5ec21778b404b5a770b 100644 (file)
@@ -215,24 +215,6 @@ static bool xml_equal_string(pugi::xml_node node, const char *name, const char *
        return false;
 }
 
-static bool xml_read_enum(ustring *str, NodeEnum& enm, pugi::xml_node node, const char *name)
-{
-       pugi::xml_attribute attr = node.attribute(name);
-
-       if(attr) {
-               ustring ustr(attr.value());
-
-               if(enm.exists(ustr)) {
-                       *str = ustr;
-                       return true;
-               }
-               else
-                       fprintf(stderr, "Unknown value \"%s\" for attribute \"%s\".\n", ustr.c_str(), name);
-       }
-
-       return false;
-}
-
 static bool xml_read_enum_value(int *value, NodeEnum& enm, pugi::xml_node node, const char *name)
 {
        pugi::xml_attribute attr = node.attribute(name);
@@ -305,8 +287,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                        xml_read_string(&img->filename, node, "src");
                        img->filename = path_join(state.base, img->filename);
                        
-                       xml_read_enum(&img->color_space, ImageTextureNode::color_space_enum, node, "color_space");
-                       xml_read_enum(&img->projection, ImageTextureNode::projection_enum, node, "projection");
+                       xml_read_enum_value((int*)&img->color_space, ImageTextureNode::color_space_enum, node, "color_space");
+                       xml_read_enum_value((int*)&img->projection, ImageTextureNode::projection_enum, node, "projection");
                        xml_read_float(&img->projection_blend, node, "projection_blend");
 
                        /* ToDo: Interpolation */
@@ -319,8 +301,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                        xml_read_string(&env->filename, node, "src");
                        env->filename = path_join(state.base, env->filename);
                        
-                       xml_read_enum(&env->color_space, EnvironmentTextureNode::color_space_enum, node, "color_space");
-                       xml_read_enum(&env->projection, EnvironmentTextureNode::projection_enum, node, "projection");
+                       xml_read_enum_value((int*)&env->color_space, EnvironmentTextureNode::color_space_enum, node, "color_space");
+                       xml_read_enum_value((int*)&env->projection, EnvironmentTextureNode::projection_enum, node, "projection");
 
                        snode = env;
                }
@@ -350,7 +332,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                else if(string_iequals(node.name(), "sky_texture")) {
                        SkyTextureNode *sky = new SkyTextureNode();
                        
-                       xml_read_enum(&sky->type, SkyTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&sky->type, SkyTextureNode::type_enum, node, "type");
                        xml_read_float3(&sky->sun_direction, node, "sun_direction");
                        xml_read_float(&sky->turbidity, node, "turbidity");
                        xml_read_float(&sky->ground_albedo, node, "ground_albedo");
@@ -375,17 +357,17 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "gradient_texture")) {
                        GradientTextureNode *blend = new GradientTextureNode();
-                       xml_read_enum(&blend->type, GradientTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&blend->type, GradientTextureNode::type_enum, node, "type");
                        snode = blend;
                }
                else if(string_iequals(node.name(), "voronoi_texture")) {
                        VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-                       xml_read_enum(&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
+                       xml_read_enum_value((int*)&voronoi->coloring, VoronoiTextureNode::coloring_enum, node, "coloring");
                        snode = voronoi;
                }
                else if(string_iequals(node.name(), "musgrave_texture")) {
                        MusgraveTextureNode *musgrave = new MusgraveTextureNode();
-                       xml_read_enum(&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&musgrave->type, MusgraveTextureNode::type_enum, node, "type");
                        snode = musgrave;
                }
                else if(string_iequals(node.name(), "magic_texture")) {
@@ -395,8 +377,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "wave_texture")) {
                        WaveTextureNode *wave = new WaveTextureNode();
-                       xml_read_enum(&wave->type, WaveTextureNode::type_enum, node, "type");
-                       xml_read_enum(&wave->profile, WaveTextureNode::profile_enum, node, "profile");
+                       xml_read_enum_value((int*)&wave->type, WaveTextureNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&wave->profile, WaveTextureNode::profile_enum, node, "profile");
                        snode = wave;
                }
                else if(string_iequals(node.name(), "normal")) {
@@ -431,7 +413,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "anisotropic_bsdf")) {
                        AnisotropicBsdfNode *aniso = new AnisotropicBsdfNode();
-                       xml_read_enum(&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&aniso->distribution, AnisotropicBsdfNode::distribution_enum, node, "distribution");
                        snode = aniso;
                }
                else if(string_iequals(node.name(), "diffuse_bsdf")) {
@@ -448,27 +430,27 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                }
                else if(string_iequals(node.name(), "toon_bsdf")) {
                        ToonBsdfNode *toon = new ToonBsdfNode();
-                       xml_read_enum(&toon->component, ToonBsdfNode::component_enum, node, "component");
+                       xml_read_enum_value((int*)&toon->component, ToonBsdfNode::component_enum, node, "component");
                        snode = toon;
                }
                else if(string_iequals(node.name(), "glossy_bsdf")) {
                        GlossyBsdfNode *glossy = new GlossyBsdfNode();
-                       xml_read_enum(&glossy->distribution, GlossyBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&glossy->distribution, GlossyBsdfNode::distribution_enum, node, "distribution");
                        snode = glossy;
                }
                else if(string_iequals(node.name(), "glass_bsdf")) {
                        GlassBsdfNode *diel = new GlassBsdfNode();
-                       xml_read_enum(&diel->distribution, GlassBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&diel->distribution, GlassBsdfNode::distribution_enum, node, "distribution");
                        snode = diel;
                }
                else if(string_iequals(node.name(), "refraction_bsdf")) {
                        RefractionBsdfNode *diel = new RefractionBsdfNode();
-                       xml_read_enum(&diel->distribution, RefractionBsdfNode::distribution_enum, node, "distribution");
+                       xml_read_enum_value((int*)&diel->distribution, RefractionBsdfNode::distribution_enum, node, "distribution");
                        snode = diel;
                }
                else if(string_iequals(node.name(), "hair_bsdf")) {
                        HairBsdfNode *hair = new HairBsdfNode();
-                       xml_read_enum(&hair->component, HairBsdfNode::component_enum, node, "component");
+                       xml_read_enum_value((int*)&hair->component, HairBsdfNode::component_enum, node, "component");
                        snode = hair;
                }
                else if(string_iequals(node.name(), "emission")) {
@@ -546,7 +528,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                else if(string_iequals(node.name(), "mix")) {
                        /* ToDo: Tag Mix case for optimization */
                        MixNode *mix = new MixNode();
-                       xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&mix->type, MixNode::type_enum, node, "type");
                        xml_read_bool(&mix->use_clamp, node, "use_clamp");
                        snode = mix;
                }
@@ -610,32 +592,32 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml
                else if(string_iequals(node.name(), "normal_map")) {
                        NormalMapNode *nmap = new NormalMapNode;
                        xml_read_ustring(&nmap->attribute, node, "attribute");
-                       xml_read_enum(&nmap->space, NormalMapNode::space_enum, node, "space");
+                       xml_read_enum_value((int*)&nmap->space, NormalMapNode::space_enum, node, "space");
                        snode = nmap;
                }
                else if(string_iequals(node.name(), "tangent")) {
                        TangentNode *tangent = new TangentNode;
                        xml_read_ustring(&tangent->attribute, node, "attribute");
-                       xml_read_enum(&tangent->direction_type, TangentNode::direction_type_enum, node, "direction_type");
-                       xml_read_enum(&tangent->axis, TangentNode::axis_enum, node, "axis");
+                       xml_read_enum_value((int*)&tangent->direction_type, TangentNode::direction_type_enum, node, "direction_type");
+                       xml_read_enum_value((int*)&tangent->axis, TangentNode::axis_enum, node, "axis");
                        snode = tangent;
                }
                else if(string_iequals(node.name(), "math")) {
                        MathNode *math = new MathNode();
-                       xml_read_enum(&math->type, MathNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&math->type, MathNode::type_enum, node, "type");
                        xml_read_bool(&math->use_clamp, node, "use_clamp");
                        snode = math;
                }
                else if(string_iequals(node.name(), "vector_math")) {
                        VectorMathNode *vmath = new VectorMathNode();
-                       xml_read_enum(&vmath->type, VectorMathNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&vmath->type, VectorMathNode::type_enum, node, "type");
                        snode = vmath;
                }
                else if(string_iequals(node.name(), "vector_transform")) {
                        VectorTransformNode *vtransform = new VectorTransformNode();
-                       xml_read_enum(&vtransform->type, VectorTransformNode::type_enum, node, "type");
-                       xml_read_enum(&vtransform->convert_from, VectorTransformNode::convert_space_enum, node, "convert_from");
-                       xml_read_enum(&vtransform->convert_to, VectorTransformNode::convert_space_enum, node, "convert_to");
+                       xml_read_enum_value((int*)&vtransform->type, VectorTransformNode::type_enum, node, "type");
+                       xml_read_enum_value((int*)&vtransform->convert_from, VectorTransformNode::convert_space_enum, node, "convert_from");
+                       xml_read_enum_value((int*)&vtransform->convert_to, VectorTransformNode::convert_space_enum, node, "convert_to");
                        snode = vtransform;
                }
                else if(string_iequals(node.name(), "connect")) {
index eb96756201ab4b8842b96798af29ef3a15a99657..7a13641a312036be310a8fda13d64ecc720e81dc 100644 (file)
@@ -290,7 +290,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeMixRGB)) {
                BL::ShaderNodeMixRGB b_mix_node(b_node);
                MixNode *mix = new MixNode();
-               mix->type = MixNode::type_enum[b_mix_node.blend_type()];
+               mix->type = (NodeMix)b_mix_node.blend_type();
                mix->use_clamp = b_mix_node.use_clamp();
                node = mix;
        }
@@ -321,22 +321,22 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeMath)) {
                BL::ShaderNodeMath b_math_node(b_node);
                MathNode *math = new MathNode();
-               math->type = MathNode::type_enum[b_math_node.operation()];
+               math->type = (NodeMath)b_math_node.operation();
                math->use_clamp = b_math_node.use_clamp();
                node = math;
        }
        else if(b_node.is_a(&RNA_ShaderNodeVectorMath)) {
                BL::ShaderNodeVectorMath b_vector_math_node(b_node);
                VectorMathNode *vmath = new VectorMathNode();
-               vmath->type = VectorMathNode::type_enum[b_vector_math_node.operation()];
+               vmath->type = (NodeVectorMath)b_vector_math_node.operation();
                node = vmath;
        }
        else if(b_node.is_a(&RNA_ShaderNodeVectorTransform)) {
                BL::ShaderNodeVectorTransform b_vector_transform_node(b_node);
                VectorTransformNode *vtransform = new VectorTransformNode();
-               vtransform->type = VectorTransformNode::type_enum[b_vector_transform_node.vector_type()];
-               vtransform->convert_from = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_from()];
-               vtransform->convert_to = VectorTransformNode::convert_space_enum[b_vector_transform_node.convert_to()];
+               vtransform->type = (NodeVectorTransformType)b_vector_transform_node.vector_type();
+               vtransform->convert_from = (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_from();
+               vtransform->convert_to = (NodeVectorTransformConvertSpace)b_vector_transform_node.convert_to();
                node = vtransform;
        }
        else if(b_node.is_a(&RNA_ShaderNodeNormal)) {
@@ -385,13 +385,13 @@ static ShaderNode *add_node(Scene *scene,
 
                switch(b_aniso_node.distribution()) {
                        case BL::ShaderNodeBsdfAnisotropic::distribution_BECKMANN:
-                               aniso->distribution = ustring("Beckmann");
+                               aniso->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID;
                                break;
                        case BL::ShaderNodeBsdfAnisotropic::distribution_GGX:
-                               aniso->distribution = ustring("GGX");
+                               aniso->distribution = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
                                break;
                        case BL::ShaderNodeBsdfAnisotropic::distribution_ASHIKHMIN_SHIRLEY:
-                               aniso->distribution = ustring("Ashikhmin-Shirley");
+                               aniso->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
                                break;
                }
 
@@ -407,13 +407,13 @@ static ShaderNode *add_node(Scene *scene,
 
                switch(b_subsurface_node.falloff()) {
                        case BL::ShaderNodeSubsurfaceScattering::falloff_CUBIC:
-                               subsurface->closure = CLOSURE_BSSRDF_CUBIC_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_CUBIC_ID;
                                break;
                        case BL::ShaderNodeSubsurfaceScattering::falloff_GAUSSIAN:
-                               subsurface->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_GAUSSIAN_ID;
                                break;
                        case BL::ShaderNodeSubsurfaceScattering::falloff_BURLEY:
-                               subsurface->closure = CLOSURE_BSSRDF_BURLEY_ID;
+                               subsurface->falloff = CLOSURE_BSSRDF_BURLEY_ID;
                                break;
                }
 
@@ -425,16 +425,16 @@ static ShaderNode *add_node(Scene *scene,
                
                switch(b_glossy_node.distribution()) {
                        case BL::ShaderNodeBsdfGlossy::distribution_SHARP:
-                               glossy->distribution = ustring("Sharp");
+                               glossy->distribution = CLOSURE_BSDF_REFLECTION_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_BECKMANN:
-                               glossy->distribution = ustring("Beckmann");
+                               glossy->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_GGX:
-                               glossy->distribution = ustring("GGX");
+                               glossy->distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
                                break;
                        case BL::ShaderNodeBsdfGlossy::distribution_ASHIKHMIN_SHIRLEY:
-                               glossy->distribution = ustring("Ashikhmin-Shirley");
+                               glossy->distribution = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID;
                                break;
                }
                node = glossy;
@@ -444,13 +444,13 @@ static ShaderNode *add_node(Scene *scene,
                GlassBsdfNode *glass = new GlassBsdfNode();
                switch(b_glass_node.distribution()) {
                        case BL::ShaderNodeBsdfGlass::distribution_SHARP:
-                               glass->distribution = ustring("Sharp");
+                               glass->distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
                                break;
                        case BL::ShaderNodeBsdfGlass::distribution_BECKMANN:
-                               glass->distribution = ustring("Beckmann");
+                               glass->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID;
                                break;
                        case BL::ShaderNodeBsdfGlass::distribution_GGX:
-                               glass->distribution = ustring("GGX");
+                               glass->distribution = CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID;
                                break;
                }
                node = glass;
@@ -460,13 +460,13 @@ static ShaderNode *add_node(Scene *scene,
                RefractionBsdfNode *refraction = new RefractionBsdfNode();
                switch(b_refraction_node.distribution()) {
                        case BL::ShaderNodeBsdfRefraction::distribution_SHARP:
-                               refraction->distribution = ustring("Sharp");
+                               refraction->distribution = CLOSURE_BSDF_REFRACTION_ID;
                                break;
                        case BL::ShaderNodeBsdfRefraction::distribution_BECKMANN:
-                               refraction->distribution = ustring("Beckmann");
+                               refraction->distribution = CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID;
                                break;
                        case BL::ShaderNodeBsdfRefraction::distribution_GGX:
-                               refraction->distribution = ustring("GGX");
+                               refraction->distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
                                break;
                }
                node = refraction;
@@ -476,10 +476,10 @@ static ShaderNode *add_node(Scene *scene,
                ToonBsdfNode *toon = new ToonBsdfNode();
                switch(b_toon_node.component()) {
                        case BL::ShaderNodeBsdfToon::component_DIFFUSE:
-                               toon->component = ustring("Diffuse");
+                               toon->component = CLOSURE_BSDF_DIFFUSE_TOON_ID;
                                break;
                        case BL::ShaderNodeBsdfToon::component_GLOSSY:
-                               toon->component = ustring("Glossy");
+                               toon->component = CLOSURE_BSDF_GLOSSY_TOON_ID;
                                break;
                }
                node = toon;
@@ -489,10 +489,10 @@ static ShaderNode *add_node(Scene *scene,
                HairBsdfNode *hair = new HairBsdfNode();
                switch(b_hair_node.component()) {
                        case BL::ShaderNodeBsdfHair::component_Reflection:
-                               hair->component = ustring("Reflection");
+                               hair->component = CLOSURE_BSDF_HAIR_REFLECTION_ID;
                                break;
                        case BL::ShaderNodeBsdfHair::component_Transmission:
-                               hair->component = ustring("Transmission");
+                               hair->component = CLOSURE_BSDF_HAIR_TRANSMISSION_ID;
                                break;
                }
                node = hair;
@@ -622,8 +622,8 @@ static ShaderNode *add_node(Scene *scene,
                                        get_image_extension(b_image_node));
                        }
                }
-               image->color_space = ImageTextureNode::color_space_enum[(int)b_image_node.color_space()];
-               image->projection = ImageTextureNode::projection_enum[(int)b_image_node.projection()];
+               image->color_space = (NodeImageColorSpace)b_image_node.color_space();
+               image->projection = (NodeImageProjection)b_image_node.projection();
                image->interpolation = get_image_interpolation(b_image_node);
                image->extension = get_image_extension(b_image_node);
                image->projection_blend = b_image_node.projection_blend();
@@ -668,9 +668,9 @@ static ShaderNode *add_node(Scene *scene,
                                        EXTENSION_REPEAT);
                        }
                }
-               env->color_space = EnvironmentTextureNode::color_space_enum[(int)b_env_node.color_space()];
+               env->color_space = (NodeImageColorSpace)b_env_node.color_space();
                env->interpolation = get_image_interpolation(b_env_node);
-               env->projection = EnvironmentTextureNode::projection_enum[(int)b_env_node.projection()];
+               env->projection = (NodeEnvironmentProjection)b_env_node.projection();
                BL::TexMapping b_texture_mapping(b_env_node.texture_mapping());
                get_tex_mapping(&env->tex_mapping, b_texture_mapping);
                node = env;
@@ -678,7 +678,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexGradient)) {
                BL::ShaderNodeTexGradient b_gradient_node(b_node);
                GradientTextureNode *gradient = new GradientTextureNode();
-               gradient->type = GradientTextureNode::type_enum[(int)b_gradient_node.gradient_type()];
+               gradient->type = (NodeGradientType)b_gradient_node.gradient_type();
                BL::TexMapping b_texture_mapping(b_gradient_node.texture_mapping());
                get_tex_mapping(&gradient->tex_mapping, b_texture_mapping);
                node = gradient;
@@ -686,7 +686,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexVoronoi)) {
                BL::ShaderNodeTexVoronoi b_voronoi_node(b_node);
                VoronoiTextureNode *voronoi = new VoronoiTextureNode();
-               voronoi->coloring = VoronoiTextureNode::coloring_enum[(int)b_voronoi_node.coloring()];
+               voronoi->coloring = (NodeVoronoiColoring)b_voronoi_node.coloring();
                BL::TexMapping b_texture_mapping(b_voronoi_node.texture_mapping());
                get_tex_mapping(&voronoi->tex_mapping, b_texture_mapping);
                node = voronoi;
@@ -702,8 +702,8 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexWave)) {
                BL::ShaderNodeTexWave b_wave_node(b_node);
                WaveTextureNode *wave = new WaveTextureNode();
-               wave->type = WaveTextureNode::type_enum[(int)b_wave_node.wave_type()];
-               wave->profile = WaveTextureNode::profile_enum[(int)b_wave_node.wave_profile()];
+               wave->type = (NodeWaveType)b_wave_node.wave_type();
+               wave->profile = (NodeWaveProfile)b_wave_node.wave_profile();
                BL::TexMapping b_texture_mapping(b_wave_node.texture_mapping());
                get_tex_mapping(&wave->tex_mapping, b_texture_mapping);
                node = wave;
@@ -736,7 +736,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexMusgrave)) {
                BL::ShaderNodeTexMusgrave b_musgrave_node(b_node);
                MusgraveTextureNode *musgrave = new MusgraveTextureNode();
-               musgrave->type = MusgraveTextureNode::type_enum[(int)b_musgrave_node.musgrave_type()];
+               musgrave->type = (NodeMusgraveType)b_musgrave_node.musgrave_type();
                BL::TexMapping b_texture_mapping(b_musgrave_node.texture_mapping());
                get_tex_mapping(&musgrave->tex_mapping, b_texture_mapping);
                node = musgrave;
@@ -754,7 +754,7 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeTexSky)) {
                BL::ShaderNodeTexSky b_sky_node(b_node);
                SkyTextureNode *sky = new SkyTextureNode();
-               sky->type = SkyTextureNode::type_enum[(int)b_sky_node.sky_type()];
+               sky->type = (NodeSkyType)b_sky_node.sky_type();
                sky->sun_direction = normalize(get_float3(b_sky_node.sun_direction()));
                sky->turbidity = b_sky_node.turbidity();
                sky->ground_albedo = b_sky_node.ground_albedo();
@@ -765,15 +765,15 @@ static ShaderNode *add_node(Scene *scene,
        else if(b_node.is_a(&RNA_ShaderNodeNormalMap)) {
                BL::ShaderNodeNormalMap b_normal_map_node(b_node);
                NormalMapNode *nmap = new NormalMapNode();
-               nmap->space = NormalMapNode::space_enum[(int)b_normal_map_node.space()];
+               nmap->space = (NodeNormalMapSpace)b_normal_map_node.space();
                nmap->attribute = b_normal_map_node.uv_map();
                node = nmap;
        }
        else if(b_node.is_a(&RNA_ShaderNodeTangent)) {
                BL::ShaderNodeTangent b_tangent_node(b_node);
                TangentNode *tangent = new TangentNode();
-               tangent->direction_type = TangentNode::direction_type_enum[(int)b_tangent_node.direction_type()];
-               tangent->axis = TangentNode::axis_enum[(int)b_tangent_node.axis()];
+               tangent->direction_type = (NodeTangentDirectionType)b_tangent_node.direction_type();
+               tangent->axis = (NodeTangentAxis)b_tangent_node.axis();
                tangent->attribute = b_tangent_node.uv_map();
                node = tangent;
        }
@@ -788,8 +788,7 @@ static ShaderNode *add_node(Scene *scene,
                BL::ShaderNodeTexPointDensity b_point_density_node(b_node);
                PointDensityTextureNode *point_density = new PointDensityTextureNode();
                point_density->filename = b_point_density_node.name();
-               point_density->space =
-                       PointDensityTextureNode::space_enum[(int)b_point_density_node.space()];
+               point_density->space = (NodeTexVoxelSpace)b_point_density_node.space();
                point_density->interpolation = get_image_interpolation(b_point_density_node);
                point_density->builtin_data = b_point_density_node.ptr.data;
 
index a73204bc190b669ab65769490fe728571c11906a..4656b3de9f30ab3f538f3b95f541086b6a841c59 100644 (file)
@@ -272,8 +272,8 @@ ImageTextureNode::ImageTextureNode()
        use_alpha = true;
        filename = "";
        builtin_data = NULL;
-       color_space = ustring("Color");
-       projection = ustring("Flat");
+       color_space = NODE_COLOR_SPACE_COLOR;
+       projection = NODE_IMAGE_PROJ_FLAT;
        interpolation = INTERPOLATION_LINEAR;
        extension = EXTENSION_REPEAT;
        projection_blend = 0.0f;
@@ -341,10 +341,10 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
        }
 
        if(slot != -1) {
-               int srgb = (is_linear || color_space != "Color")? 0: 1;
+               int srgb = (is_linear || color_space != NODE_COLOR_SPACE_COLOR)? 0: 1;
                int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
 
-               if(projection != "Box") {
+               if(projection != NODE_IMAGE_PROJ_BOX) {
                        compiler.add_node(NODE_TEX_IMAGE,
                                slot,
                                compiler.encode_uchar4(
@@ -352,7 +352,7 @@ void ImageTextureNode::compile(SVMCompiler& compiler)
                                        compiler.stack_assign_if_linked(color_out),
                                        compiler.stack_assign_if_linked(alpha_out),
                                        srgb),
-                               projection_enum[projection]);
+                               projection);
                }
                else {
                        compiler.add_node(NODE_TEX_IMAGE_BOX,
@@ -421,7 +421,7 @@ void ImageTextureNode::compile(OSLCompiler& compiler)
                 */
                compiler.parameter("filename", string_printf("@%d", slot).c_str());
        }
-       if(is_linear || color_space != "Color")
+       if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
                compiler.parameter("color_space", "Linear");
        else
                compiler.parameter("color_space", "sRGB");
@@ -472,9 +472,9 @@ EnvironmentTextureNode::EnvironmentTextureNode()
        use_alpha = true;
        filename = "";
        builtin_data = NULL;
-       color_space = ustring("Color");
+       color_space = NODE_COLOR_SPACE_COLOR;
        interpolation = INTERPOLATION_LINEAR;
-       projection = ustring("Equirectangular");
+       projection = NODE_ENVIRONMENT_EQUIRECTANGULAR;
        animated = false;
 
        add_input("Vector", SocketType::VECTOR, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_POSITION);
@@ -537,7 +537,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
        }
 
        if(slot != -1) {
-               int srgb = (is_linear || color_space != "Color")? 0: 1;
+               int srgb = (is_linear || color_space != NODE_COLOR_SPACE_COLOR)? 0: 1;
                int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
 
                compiler.add_node(NODE_TEX_ENVIRONMENT,
@@ -547,7 +547,7 @@ void EnvironmentTextureNode::compile(SVMCompiler& compiler)
                                compiler.stack_assign_if_linked(color_out),
                                compiler.stack_assign_if_linked(alpha_out),
                                srgb),
-                       projection_enum[projection]);
+                       projection);
        
                tex_mapping.compile_end(compiler, vector_in, vector_offset);
        }
@@ -602,8 +602,8 @@ void EnvironmentTextureNode::compile(OSLCompiler& compiler)
        else {
                compiler.parameter("filename", string_printf("@%d", slot).c_str());
        }
-       compiler.parameter("projection", projection);
-       if(is_linear || color_space != "Color")
+       compiler.parameter("projection", projection_enum[projection]);
+       if(is_linear || color_space != NODE_COLOR_SPACE_COLOR)
                compiler.parameter("color_space", "Linear");
        else
                compiler.parameter("color_space", "sRGB");
@@ -753,7 +753,7 @@ NodeEnum SkyTextureNode::type_enum = sky_type_init();
 SkyTextureNode::SkyTextureNode()
 : TextureNode("sky_texture")
 {
-       type = ustring("Hosek / Wilkie");
+       type = NODE_SKY_NEW;
        
        sun_direction = make_float3(0.0f, 0.0f, 1.0f);
        turbidity = 2.2f;
@@ -769,15 +769,15 @@ void SkyTextureNode::compile(SVMCompiler& compiler)
        ShaderOutput *color_out = output("Color");
 
        SunSky sunsky;
-       if(type_enum[type] == NODE_SKY_OLD)
+       if(type == NODE_SKY_OLD)
                sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
-       else if(type_enum[type] == NODE_SKY_NEW)
+       else if(type == NODE_SKY_NEW)
                sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
        else
                assert(false);
 
        int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
-       int sky_model = type_enum[type];
+       int sky_model = type;
 
        compiler.stack_assign(color_out);
        compiler.add_node(NODE_TEX_SKY, vector_offset, compiler.stack_assign(color_out), sky_model);
@@ -799,14 +799,14 @@ void SkyTextureNode::compile(OSLCompiler& compiler)
 
        SunSky sunsky;
 
-       if(type_enum[type] == NODE_SKY_OLD)
+       if(type == NODE_SKY_OLD)
                sky_texture_precompute_old(&sunsky, sun_direction, turbidity);
-       else if(type_enum[type] == NODE_SKY_NEW)
+       else if(type == NODE_SKY_NEW)
                sky_texture_precompute_new(&sunsky, sun_direction, turbidity, ground_albedo);
        else
                assert(false);
                
-       compiler.parameter("sky_model", type);
+       compiler.parameter("sky_model", type_enum[type]);
        compiler.parameter("theta", sunsky.theta);
        compiler.parameter("phi", sunsky.phi);
        compiler.parameter_color("radiance", make_float3(sunsky.radiance_x, sunsky.radiance_y, sunsky.radiance_z));
@@ -838,7 +838,7 @@ NodeEnum GradientTextureNode::type_enum = gradient_type_init();
 GradientTextureNode::GradientTextureNode()
 : TextureNode("gradient_texture")
 {
-       type = ustring("Linear");
+       type = NODE_BLEND_LINEAR;
 
        add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
        add_output("Color", SocketType::COLOR);
@@ -855,7 +855,7 @@ void GradientTextureNode::compile(SVMCompiler& compiler)
 
        compiler.add_node(NODE_TEX_GRADIENT,
                compiler.encode_uchar4(
-                       type_enum[type],
+                       type,
                        vector_offset,
                        compiler.stack_assign_if_linked(fac_out),
                        compiler.stack_assign_if_linked(color_out)));
@@ -867,7 +867,7 @@ void GradientTextureNode::compile(OSLCompiler& compiler)
 {
        tex_mapping.compile(compiler);
 
-       compiler.parameter("type", type);
+       compiler.parameter("type", type_enum[type]);
        compiler.add(this, "node_gradient_texture");
 }
 
@@ -937,7 +937,7 @@ NodeEnum VoronoiTextureNode::coloring_enum  = voronoi_coloring_init();
 VoronoiTextureNode::VoronoiTextureNode()
 : TextureNode("voronoi_texture")
 {
-       coloring = ustring("Intensity");
+       coloring = NODE_VORONOI_INTENSITY;
 
        add_input("Scale", SocketType::FLOAT, 1.0f);
        add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED);
@@ -956,7 +956,7 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
        int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
 
        compiler.add_node(NODE_TEX_VORONOI,
-               coloring_enum[coloring],
+               coloring,
                compiler.encode_uchar4(
                        compiler.stack_assign_if_linked(scale_in),
                        vector_offset,
@@ -971,7 +971,7 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler)
 {
        tex_mapping.compile(compiler);
 
-       compiler.parameter("coloring", coloring);
+       compiler.parameter("coloring", coloring_enum[coloring]);
        compiler.add(this, "node_voronoi_texture");
 }
 
@@ -995,7 +995,7 @@ NodeEnum MusgraveTextureNode::type_enum = musgrave_type_init();
 MusgraveTextureNode::MusgraveTextureNode()
 : TextureNode("musgrave_texture")
 {
-       type = ustring("fBM");
+       type = NODE_MUSGRAVE_FBM;
 
        add_input("Scale", SocketType::FLOAT, 1.0f);
        add_input("Detail", SocketType::FLOAT, 2.0f);
@@ -1025,7 +1025,7 @@ void MusgraveTextureNode::compile(SVMCompiler& compiler)
 
        compiler.add_node(NODE_TEX_MUSGRAVE,
                compiler.encode_uchar4(
-                       type_enum[type],
+                       type,
                        vector_offset,
                        compiler.stack_assign_if_linked(color_out),
                        compiler.stack_assign_if_linked(fac_out)),
@@ -1051,7 +1051,7 @@ void MusgraveTextureNode::compile(OSLCompiler& compiler)
 {
        tex_mapping.compile(compiler);
 
-       compiler.parameter("type", type);
+       compiler.parameter("type", type_enum[type]);
 
        compiler.add(this, "node_musgrave_texture");
 }
@@ -1084,8 +1084,8 @@ NodeEnum WaveTextureNode::profile_enum = wave_profile_init();
 WaveTextureNode::WaveTextureNode()
 : TextureNode("wave_texture")
 {
-       type = ustring("Bands");
-       profile = ustring("Sine");
+       type = NODE_WAVE_BANDS;
+       profile = NODE_WAVE_PROFILE_SIN;
 
        add_input("Scale", SocketType::FLOAT, 1.0f);
        add_input("Distortion", SocketType::FLOAT, 0.0f);
@@ -1111,7 +1111,7 @@ void WaveTextureNode::compile(SVMCompiler& compiler)
 
        compiler.add_node(NODE_TEX_WAVE,
                compiler.encode_uchar4(
-                       type_enum[type],
+                       type,
                        compiler.stack_assign_if_linked(color_out),
                        compiler.stack_assign_if_linked(fac_out),
                        compiler.stack_assign_if_linked(dscale_in)),
@@ -1120,7 +1120,7 @@ void WaveTextureNode::compile(SVMCompiler& compiler)
                        compiler.stack_assign_if_linked(scale_in),
                        compiler.stack_assign_if_linked(detail_in),
                        compiler.stack_assign_if_linked(distortion_in)),
-               profile_enum[profile]);
+               profile);
 
        compiler.add_node(
                __float_as_int(scale_in->value_float()),
@@ -1135,8 +1135,8 @@ void WaveTextureNode::compile(OSLCompiler& compiler)
 {
        tex_mapping.compile(compiler);
 
-       compiler.parameter("type", type);
-       compiler.parameter("profile", profile);
+       compiler.parameter("type", type_enum[type]);
+       compiler.parameter("profile", profile_enum[profile]);
 
        compiler.add(this, "node_wave_texture");
 }
@@ -1338,7 +1338,7 @@ PointDensityTextureNode::PointDensityTextureNode()
        image_manager = NULL;
        slot = -1;
        filename = "";
-       space = ustring("Object");
+       space = NODE_TEX_VOXEL_SPACE_OBJECT;
        builtin_data = NULL;
        interpolation = INTERPOLATION_LINEAR;
 
@@ -1405,8 +1405,8 @@ void PointDensityTextureNode::compile(SVMCompiler& compiler)
                                          compiler.encode_uchar4(compiler.stack_assign(vector_in),
                                                                 compiler.stack_assign_if_linked(density_out),
                                                                 compiler.stack_assign_if_linked(color_out),
-                                                                space_enum[space]));
-                       if(space == "World") {
+                                                                space));
+                       if(space == NODE_TEX_VOXEL_SPACE_WORLD) {
                                compiler.add_node(tfm.x);
                                compiler.add_node(tfm.y);
                                compiler.add_node(tfm.z);
@@ -1453,7 +1453,7 @@ void PointDensityTextureNode::compile(OSLCompiler& compiler)
                if(slot != -1) {
                        compiler.parameter("filename", string_printf("@%d", slot).c_str());
                }
-               if(space == "World") {
+               if(space == NODE_TEX_VOXEL_SPACE_WORLD) {
                        compiler.parameter("mapping", transform_transpose(tfm));
                        compiler.parameter("use_mapping", 1);
                }
@@ -1805,7 +1805,7 @@ NodeEnum AnisotropicBsdfNode::distribution_enum = aniso_distribution_init();
 AnisotropicBsdfNode::AnisotropicBsdfNode()
 {
        closure = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
-       distribution = ustring("GGX");
+       distribution = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID;
 
        add_input("Tangent", SocketType::VECTOR, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TANGENT);
 
@@ -1828,14 +1828,14 @@ void AnisotropicBsdfNode::attributes(Shader *shader, AttributeRequestSet *attrib
 
 void AnisotropicBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 
        BsdfNode::compile(compiler, input("Roughness"), input("Anisotropy"), input("Rotation"));
 }
 
 void AnisotropicBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("distribution", distribution);
+       compiler.parameter("distribution", distribution_enum[distribution]);
        compiler.add(this, "node_anisotropic_bsdf");
 }
 
@@ -1858,15 +1858,15 @@ NodeEnum GlossyBsdfNode::distribution_enum = glossy_distribution_init();
 GlossyBsdfNode::GlossyBsdfNode()
 {
        closure = CLOSURE_BSDF_MICROFACET_GGX_ID;
-       distribution = ustring("GGX");
-       distribution_orig = ustring("");
+       distribution = CLOSURE_BSDF_MICROFACET_GGX_ID;
+       distribution_orig = NBUILTIN_CLOSURES;
 
        add_input("Roughness", SocketType::FLOAT, 0.2f);
 }
 
 void GlossyBsdfNode::simplify_settings(Scene *scene)
 {
-       if(distribution_orig == "") {
+       if(distribution_orig == NBUILTIN_CLOSURES) {
                distribution_orig = distribution;
        }
        Integrator *integrator = scene->integrator;
@@ -1876,14 +1876,14 @@ void GlossyBsdfNode::simplify_settings(Scene *scene)
                 */
                ShaderInput *roughness_input = input("Roughness");
                if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) {
-                       distribution = ustring("Sharp");
+                       distribution = CLOSURE_BSDF_REFLECTION_ID;
                }
        }
        else {
                /* Rollback to original distribution when filter glossy is used. */
                distribution = distribution_orig;
        }
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 }
 
 bool GlossyBsdfNode::has_integrator_dependency()
@@ -1894,7 +1894,7 @@ bool GlossyBsdfNode::has_integrator_dependency()
 
 void GlossyBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 
        if(closure == CLOSURE_BSDF_REFLECTION_ID)
                BsdfNode::compile(compiler, NULL, NULL);
@@ -1904,7 +1904,7 @@ void GlossyBsdfNode::compile(SVMCompiler& compiler)
 
 void GlossyBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("distribution", distribution);
+       compiler.parameter("distribution", distribution_enum[distribution]);
        compiler.add(this, "node_glossy_bsdf");
 }
 
@@ -1926,8 +1926,8 @@ NodeEnum GlassBsdfNode::distribution_enum = glass_distribution_init();
 GlassBsdfNode::GlassBsdfNode()
 {
        closure = CLOSURE_BSDF_SHARP_GLASS_ID;
-       distribution = ustring("Sharp");
-       distribution_orig = ustring("");
+       distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
+       distribution_orig = NBUILTIN_CLOSURES;
 
        add_input("Roughness", SocketType::FLOAT, 0.0f);
        add_input("IOR", SocketType::FLOAT, 0.3f);
@@ -1935,7 +1935,7 @@ GlassBsdfNode::GlassBsdfNode()
 
 void GlassBsdfNode::simplify_settings(Scene *scene)
 {
-       if(distribution_orig == "") {
+       if(distribution_orig == NBUILTIN_CLOSURES) {
                distribution_orig = distribution;
        }
        Integrator *integrator = scene->integrator;
@@ -1945,14 +1945,14 @@ void GlassBsdfNode::simplify_settings(Scene *scene)
                 */
                ShaderInput *roughness_input = input("Roughness");
                if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) {
-                       distribution = ustring("Sharp");
+                       distribution = CLOSURE_BSDF_SHARP_GLASS_ID;
                }
        }
        else {
                /* Rollback to original distribution when filter glossy is used. */
                distribution = distribution_orig;
        }
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 }
 
 bool GlassBsdfNode::has_integrator_dependency()
@@ -1963,7 +1963,7 @@ bool GlassBsdfNode::has_integrator_dependency()
 
 void GlassBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 
        if(closure == CLOSURE_BSDF_SHARP_GLASS_ID)
                BsdfNode::compile(compiler, NULL, input("IOR"));
@@ -1973,7 +1973,7 @@ void GlassBsdfNode::compile(SVMCompiler& compiler)
 
 void GlassBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("distribution", distribution);
+       compiler.parameter("distribution", distribution_enum[distribution]);
        compiler.add(this, "node_glass_bsdf");
 }
 
@@ -1995,8 +1995,8 @@ NodeEnum RefractionBsdfNode::distribution_enum = refraction_distribution_init();
 RefractionBsdfNode::RefractionBsdfNode()
 {
        closure = CLOSURE_BSDF_REFRACTION_ID;
-       distribution = ustring("Sharp");
-       distribution_orig = ustring("");
+       distribution = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
+       distribution_orig = NBUILTIN_CLOSURES;
 
        add_input("Roughness", SocketType::FLOAT, 0.0f);
        add_input("IOR", SocketType::FLOAT, 0.3f);
@@ -2004,7 +2004,7 @@ RefractionBsdfNode::RefractionBsdfNode()
 
 void RefractionBsdfNode::simplify_settings(Scene *scene)
 {
-       if(distribution_orig == "") {
+       if(distribution_orig == NBUILTIN_CLOSURES) {
                distribution_orig = distribution;
        }
        Integrator *integrator = scene->integrator;
@@ -2014,14 +2014,14 @@ void RefractionBsdfNode::simplify_settings(Scene *scene)
                 */
                ShaderInput *roughness_input = input("Roughness");
                if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) {
-                       distribution = ustring("Sharp");
+                       distribution = CLOSURE_BSDF_REFRACTION_ID;
                }
        }
        else {
                /* Rollback to original distribution when filter glossy is used. */
                distribution = distribution_orig;
        }
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 }
 
 bool RefractionBsdfNode::has_integrator_dependency()
@@ -2032,7 +2032,7 @@ bool RefractionBsdfNode::has_integrator_dependency()
 
 void RefractionBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)distribution_enum[distribution];
+       closure = distribution;
 
        if(closure == CLOSURE_BSDF_REFRACTION_ID)
                BsdfNode::compile(compiler, NULL, input("IOR"));
@@ -2042,7 +2042,7 @@ void RefractionBsdfNode::compile(SVMCompiler& compiler)
 
 void RefractionBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("distribution", distribution);
+       compiler.parameter("distribution", distribution_enum[distribution]);
        compiler.add(this, "node_refraction_bsdf");
 }
 
@@ -2063,7 +2063,7 @@ NodeEnum ToonBsdfNode::component_enum = toon_component_init();
 ToonBsdfNode::ToonBsdfNode()
 {
        closure = CLOSURE_BSDF_DIFFUSE_TOON_ID;
-       component = ustring("Diffuse");
+       component = CLOSURE_BSDF_DIFFUSE_TOON_ID;
 
        add_input("Size", SocketType::FLOAT, 0.5f);
        add_input("Smooth", SocketType::FLOAT, 0.0f);
@@ -2071,14 +2071,14 @@ ToonBsdfNode::ToonBsdfNode()
 
 void ToonBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)component_enum[component];
+       closure = component;
        
        BsdfNode::compile(compiler, input("Size"), input("Smooth"));
 }
 
 void ToonBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("component", component);
+       compiler.parameter("component", component_enum[component]);
        compiler.add(this, "node_toon_bsdf");
 }
 
@@ -2173,7 +2173,7 @@ SubsurfaceScatteringNode::SubsurfaceScatteringNode()
 : BsdfNode(true)
 {
        name = "subsurface_scattering";
-       closure = CLOSURE_BSSRDF_CUBIC_ID;
+       falloff = CLOSURE_BSSRDF_CUBIC_ID;
 
        add_input("Scale", SocketType::FLOAT, 0.01f);
        add_input("Radius", SocketType::VECTOR, make_float3(0.1f, 0.1f, 0.1f));
@@ -2183,6 +2183,7 @@ SubsurfaceScatteringNode::SubsurfaceScatteringNode()
 
 void SubsurfaceScatteringNode::compile(SVMCompiler& compiler)
 {
+       closure = falloff;
        BsdfNode::compile(compiler, input("Scale"), input("Texture Blur"), input("Radius"), input("Sharpness"));
 }
 
@@ -2431,7 +2432,7 @@ NodeEnum HairBsdfNode::component_enum = hair_component_init();
 HairBsdfNode::HairBsdfNode()
 {
        closure = CLOSURE_BSDF_HAIR_REFLECTION_ID;
-       component = ustring("Reflection");
+       component = CLOSURE_BSDF_HAIR_REFLECTION_ID;
 
        add_input("Offset", SocketType::FLOAT);
        add_input("RoughnessU", SocketType::FLOAT);
@@ -2441,14 +2442,14 @@ HairBsdfNode::HairBsdfNode()
 
 void HairBsdfNode::compile(SVMCompiler& compiler)
 {
-       closure = (ClosureType)component_enum[component];
+       closure = component;
 
        BsdfNode::compile(compiler, input("RoughnessU"), input("RoughnessV"), input("Offset"));
 }
 
 void HairBsdfNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("component", component);
+       compiler.parameter("component", component_enum[component]);
 
        compiler.add(this, "node_hair_bsdf");
 }
@@ -3316,7 +3317,7 @@ void InvertNode::compile(OSLCompiler& compiler)
 MixNode::MixNode()
 : ShaderNode("mix")
 {
-       type = ustring("Mix");
+       type = NODE_MIX_BLEND;
 
        use_clamp = false;
 
@@ -3365,7 +3366,7 @@ void MixNode::compile(SVMCompiler& compiler)
                compiler.stack_assign(fac_in),
                compiler.stack_assign(color1_in),
                compiler.stack_assign(color2_in));
-       compiler.add_node(NODE_MIX, type_enum[type], compiler.stack_assign(color_out));
+       compiler.add_node(NODE_MIX, type, compiler.stack_assign(color_out));
 
        if(use_clamp) {
                compiler.add_node(NODE_MIX, 0, compiler.stack_assign(color_out));
@@ -3375,7 +3376,7 @@ void MixNode::compile(SVMCompiler& compiler)
 
 void MixNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("type", type);
+       compiler.parameter("type", type_enum[type]);
        compiler.parameter("use_clamp", use_clamp);
        compiler.add(this, "node_mix");
 }
@@ -4057,7 +4058,7 @@ void OutputNode::compile(OSLCompiler& compiler)
 MathNode::MathNode()
 : ShaderNode("math")
 {
-       type = ustring("Add");
+       type = NODE_MATH_ADD;
 
        use_clamp = false;
 
@@ -4102,7 +4103,7 @@ bool MathNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderInput *o
 
        if(socket == output("Value")) {
                if(value1_in->link == NULL && value2_in->link == NULL) {
-                       float value = svm_math((NodeMath)type_enum[type],
+                       float value = svm_math(type,
                                               value1_in->value_float(),
                                               value2_in->value_float());
 
@@ -4125,10 +4126,7 @@ void MathNode::compile(SVMCompiler& compiler)
        ShaderInput *value2_in = input("Value2");
        ShaderOutput *value_out = output("Value");
 
-       compiler.add_node(NODE_MATH,
-               type_enum[type],
-               compiler.stack_assign(value1_in),
-               compiler.stack_assign(value2_in));
+       compiler.add_node(NODE_MATH, type, compiler.stack_assign(value1_in), compiler.stack_assign(value2_in));
        compiler.add_node(NODE_MATH, compiler.stack_assign(value_out));
 
        if(use_clamp) {
@@ -4139,7 +4137,7 @@ void MathNode::compile(SVMCompiler& compiler)
 
 void MathNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("type", type);
+       compiler.parameter("type", type_enum[type]);
        compiler.parameter("use_clamp", use_clamp);
        compiler.add(this, "node_math");
 }
@@ -4149,7 +4147,7 @@ void MathNode::compile(OSLCompiler& compiler)
 VectorMathNode::VectorMathNode()
 : ShaderNode("vector_math")
 {
-       type = ustring("Add");
+       type = NODE_VECTOR_MATH_ADD;
 
        add_input("Vector1", SocketType::VECTOR);
        add_input("Vector2", SocketType::VECTOR);
@@ -4184,7 +4182,7 @@ bool VectorMathNode::constant_fold(ShaderGraph *, ShaderOutput *socket, ShaderIn
        if(vector1_in->link == NULL && vector2_in->link == NULL) {
                svm_vector_math(&value,
                                &vector,
-                               (NodeVectorMath)type_enum[type],
+                               type,
                                vector1_in->value(),
                                vector2_in->value());
 
@@ -4209,7 +4207,7 @@ void VectorMathNode::compile(SVMCompiler& compiler)
        ShaderOutput *vector_out = output("Vector");
 
        compiler.add_node(NODE_VECTOR_MATH,
-               type_enum[type],
+               type,
                compiler.stack_assign(vector1_in),
                compiler.stack_assign(vector2_in));
        compiler.add_node(NODE_VECTOR_MATH,
@@ -4219,7 +4217,7 @@ void VectorMathNode::compile(SVMCompiler& compiler)
 
 void VectorMathNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("type", type);
+       compiler.parameter("type", type_enum[type]);
        compiler.add(this, "node_vector_math");
 }
 
@@ -4228,9 +4226,9 @@ void VectorMathNode::compile(OSLCompiler& compiler)
 VectorTransformNode::VectorTransformNode()
 : ShaderNode("vector_transform")
 {
-       type = ustring("Vector");
-       convert_from = ustring("world");
-       convert_to = ustring("object");
+       type = NODE_VECTOR_TRANSFORM_TYPE_VECTOR;
+       convert_from = NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD;
+       convert_to = NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT;
 
        add_input("Vector", SocketType::VECTOR);
        add_output("Vector",  SocketType::VECTOR);
@@ -4267,18 +4265,16 @@ void VectorTransformNode::compile(SVMCompiler& compiler)
        ShaderOutput *vector_out = output("Vector");
 
        compiler.add_node(NODE_VECTOR_TRANSFORM,
-               compiler.encode_uchar4(type_enum[type],
-                                      convert_space_enum[convert_from],
-                                      convert_space_enum[convert_to]),
+               compiler.encode_uchar4(type, convert_from, convert_to),
                compiler.encode_uchar4(compiler.stack_assign(vector_in),
                                       compiler.stack_assign(vector_out)));
 }
 
 void VectorTransformNode::compile(OSLCompiler& compiler)
 {
-       compiler.parameter("type", type);
-       compiler.parameter("convert_from", convert_from);
-       compiler.parameter("convert_to", convert_to);
+       compiler.parameter("type", type_enum[type]);
+       compiler.parameter("convert_from", convert_space_enum[convert_from]);
+       compiler.parameter("convert_to", convert_space_enum[convert_to]);
        compiler.add(this, "node_vector_transform");
 }
 
@@ -4566,7 +4562,7 @@ NodeEnum NormalMapNode::space_enum = normal_map_space_init();
 NormalMapNode::NormalMapNode()
 : ShaderNode("normal_map")
 {
-       space = ustring("Tangent");
+       space = NODE_NORMAL_MAP_TANGENT;
        attribute = ustring("");
 
        add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL);
@@ -4578,7 +4574,7 @@ NormalMapNode::NormalMapNode()
 
 void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 {
-       if(shader->has_surface && space == ustring("Tangent")) {
+       if(shader->has_surface && space == NODE_NORMAL_MAP_TANGENT) {
                if(attribute == ustring("")) {
                        attributes->add(ATTR_STD_UV_TANGENT);
                        attributes->add(ATTR_STD_UV_TANGENT_SIGN);
@@ -4601,7 +4597,7 @@ void NormalMapNode::compile(SVMCompiler& compiler)
        ShaderOutput *normal_out = output("Normal");
        int attr = 0, attr_sign = 0;
 
-       if(space == ustring("Tangent")) {
+       if(space == NODE_NORMAL_MAP_TANGENT) {
                if(attribute == ustring("")) {
                        attr = compiler.attribute(ATTR_STD_UV_TANGENT);
                        attr_sign = compiler.attribute(ATTR_STD_UV_TANGENT_SIGN);
@@ -4617,13 +4613,13 @@ void NormalMapNode::compile(SVMCompiler& compiler)
                        compiler.stack_assign(color_in),
                        compiler.stack_assign(strength_in),
                        compiler.stack_assign(normal_out),
-                       space_enum[space]),
+                       space),
                attr, attr_sign);
 }
 
 void NormalMapNode::compile(OSLCompiler& compiler)
 {
-       if(space == ustring("Tangent")) {
+       if(space == NODE_NORMAL_MAP_TANGENT) {
                if(attribute == ustring("")) {
                        compiler.parameter("attr_name", ustring("geom:tangent"));
                        compiler.parameter("attr_sign_name", ustring("geom:tangent_sign"));
@@ -4634,7 +4630,7 @@ void NormalMapNode::compile(OSLCompiler& compiler)
                }
        }
 
-       compiler.parameter("space", space);
+       compiler.parameter("space", space_enum[space]);
 
        compiler.add(this, "node_normal_map"); 
 }
@@ -4668,8 +4664,8 @@ NodeEnum TangentNode::axis_enum = tangent_axis_init();
 TangentNode::TangentNode()
 : ShaderNode("tangent")
 {
-       direction_type = ustring("Radial");
-       axis = ustring("X");
+       direction_type = NODE_TANGENT_RADIAL;
+       axis = NODE_TANGENT_AXIS_X;
        attribute = ustring("");
 
        add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL);
@@ -4679,7 +4675,7 @@ TangentNode::TangentNode()
 void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 {
        if(shader->has_surface) {
-               if(direction_type == ustring("UV Map")) {
+               if(direction_type == NODE_TANGENT_UVMAP) {
                        if(attribute == ustring(""))
                                attributes->add(ATTR_STD_UV_TANGENT);
                        else
@@ -4697,7 +4693,7 @@ void TangentNode::compile(SVMCompiler& compiler)
        ShaderOutput *tangent_out = output("Tangent");
        int attr;
 
-       if(direction_type == ustring("UV Map")) {
+       if(direction_type == NODE_TANGENT_UVMAP) {
                if(attribute == ustring(""))
                        attr = compiler.attribute(ATTR_STD_UV_TANGENT);
                else
@@ -4709,21 +4705,21 @@ void TangentNode::compile(SVMCompiler& compiler)
        compiler.add_node(NODE_TANGENT,
                compiler.encode_uchar4(
                        compiler.stack_assign(tangent_out),
-                       direction_type_enum[direction_type],
-                       axis_enum[axis]), attr);
+                       direction_type,
+                       axis), attr);
 }
 
 void TangentNode::compile(OSLCompiler& compiler)
 {
-       if(direction_type == ustring("UV Map")) {
+       if(direction_type == NODE_TANGENT_UVMAP) {
                if(attribute == ustring(""))
                        compiler.parameter("attr_name", ustring("geom:tangent"));
                else
                        compiler.parameter("attr_name", ustring((string(attribute.c_str()) + ".tangent").c_str()));
        }
 
-       compiler.parameter("direction_type", direction_type);
-       compiler.parameter("axis", axis);
+       compiler.parameter("direction_type", direction_type_enum[direction_type]);
+       compiler.parameter("axis", axis_enum[axis]);
        compiler.add(this, "node_tangent"); 
 }
 
index 9ece9b86eaca937e041f031a1337da826141f578..8b17e455f7a5af43a47ce06b15cd13ac77eca040 100644 (file)
@@ -109,8 +109,8 @@ public:
        bool use_alpha;
        string filename;
        void *builtin_data;
-       ustring color_space;
-       ustring projection;
+       NodeImageColorSpace color_space;
+       NodeImageProjection projection;
        InterpolationType interpolation;
        ExtensionType extension;
        float projection_blend;
@@ -148,8 +148,8 @@ public:
        bool use_alpha;
        string filename;
        void *builtin_data;
-       ustring color_space;
-       ustring projection;
+       NodeImageColorSpace color_space;
+       NodeEnvironmentProjection projection;
        InterpolationType interpolation;
        bool animated;
 
@@ -175,11 +175,11 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_2; }
 
+       NodeSkyType type;
        float3 sun_direction;
        float turbidity;
        float ground_albedo;
 
-       ustring type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other) {
@@ -206,7 +206,7 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_2; }
 
-       ustring type;
+       NodeGradientType type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other) {
@@ -227,8 +227,7 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_2; }
 
-       ustring coloring;
-
+       NodeVoronoiColoring coloring;
        static NodeEnum coloring_enum;
 
        virtual bool equals(const ShaderNode *other) {
@@ -244,8 +243,7 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_2; }
 
-       ustring type;
-
+       NodeMusgraveType type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other) {
@@ -261,8 +259,8 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_2; }
 
-       ustring type;
-       ustring profile;
+       NodeWaveType type;
+       NodeWaveProfile profile;
        static NodeEnum type_enum;
        static NodeEnum profile_enum;
 
@@ -329,7 +327,7 @@ public:
        ImageManager *image_manager;
        int slot;
        string filename;
-       ustring space;
+       NodeTexVoxelSpace space;
        void *builtin_data;
        InterpolationType interpolation;
 
@@ -410,7 +408,7 @@ class AnisotropicBsdfNode : public BsdfNode {
 public:
        SHADER_NODE_CLASS(AnisotropicBsdfNode)
 
-       ustring distribution;
+       ClosureType distribution;
        static NodeEnum distribution_enum;
 
        void attributes(Shader *shader, AttributeRequestSet *attributes);
@@ -445,7 +443,7 @@ public:
        void simplify_settings(Scene *scene);
        bool has_integrator_dependency();
 
-       ustring distribution, distribution_orig;
+       ClosureType distribution, distribution_orig;
        static NodeEnum distribution_enum;
 };
 
@@ -456,7 +454,7 @@ public:
        void simplify_settings(Scene *scene);
        bool has_integrator_dependency();
 
-       ustring distribution, distribution_orig;
+       ClosureType distribution, distribution_orig;
        static NodeEnum distribution_enum;
 };
 
@@ -467,7 +465,7 @@ public:
        void simplify_settings(Scene *scene);
        bool has_integrator_dependency();
 
-       ustring distribution, distribution_orig;
+       ClosureType distribution, distribution_orig;
        static NodeEnum distribution_enum;
 };
 
@@ -475,7 +473,7 @@ class ToonBsdfNode : public BsdfNode {
 public:
        SHADER_NODE_CLASS(ToonBsdfNode)
 
-       ustring component;
+       ClosureType component;
        static NodeEnum component_enum;
 };
 
@@ -485,6 +483,7 @@ public:
        bool has_surface_bssrdf() { return true; }
        bool has_bssrdf_bump();
 
+       ClosureType falloff;
        static NodeEnum falloff_enum;
 };
 
@@ -554,7 +553,7 @@ class HairBsdfNode : public BsdfNode {
 public:
        SHADER_NODE_CLASS(HairBsdfNode)
 
-       ustring component;
+       ClosureType component;
        static NodeEnum component_enum;
 
 };
@@ -704,7 +703,7 @@ public:
 
        bool use_clamp;
 
-       ustring type;
+       NodeMix type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other)
@@ -845,7 +844,7 @@ public:
 
        bool use_clamp;
 
-       ustring type;
+       NodeMath type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other)
@@ -878,12 +877,12 @@ public:
        virtual int get_group() { return NODE_GROUP_LEVEL_1; }
        bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, ShaderInput *optimized);
 
-       ustring type;
+       NodeVectorMath type;
        static NodeEnum type_enum;
 
        virtual bool equals(const ShaderNode *other)
        {
-               const MathNode *math_node = (const MathNode*)other;
+               const VectorMathNode *math_node = (const VectorMathNode*)other;
                return ShaderNode::equals(other) &&
                       type == math_node->type;
        }
@@ -895,9 +894,9 @@ public:
 
        virtual int get_group() { return NODE_GROUP_LEVEL_3; }
 
-       ustring type;
-       ustring convert_from;
-       ustring convert_to;
+       NodeVectorTransformType type;
+       NodeVectorTransformConvertSpace convert_from;
+       NodeVectorTransformConvertSpace convert_to;
 
        static NodeEnum type_enum;
        static NodeEnum convert_space_enum;
@@ -991,7 +990,7 @@ public:
        bool has_spatial_varying() { return true; }
        virtual int get_group() { return NODE_GROUP_LEVEL_3; }
 
-       ustring space;
+       NodeNormalMapSpace space;
        static NodeEnum space_enum;
 
        ustring attribute;
@@ -1012,10 +1011,9 @@ public:
        bool has_spatial_varying() { return true; }
        virtual int get_group() { return NODE_GROUP_LEVEL_3; }
 
-       ustring direction_type;
+       NodeTangentDirectionType direction_type;
+       NodeTangentAxis axis;
        static NodeEnum direction_type_enum;
-
-       ustring axis;
        static NodeEnum axis_enum;
 
        ustring attribute;