Cycles: Cleanup, style
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Aug 2018 12:36:18 +0000 (14:36 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 24 Aug 2018 12:36:18 +0000 (14:36 +0200)
I wouldn't mind changing style to have space after keyword, but there was
no official code style change proposed.

20 files changed:
intern/cycles/app/cycles_cubin_cc.cpp
intern/cycles/blender/blender_shader.cpp
intern/cycles/device/device_cpu.cpp
intern/cycles/device/opencl/opencl_util.cpp
intern/cycles/graph/node.cpp
intern/cycles/kernel/closure/bsdf_hair_principled.h
intern/cycles/kernel/kernel_path_state.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/osl/osl_bssrdf.cpp
intern/cycles/kernel/osl/osl_closures.cpp
intern/cycles/kernel/svm/svm_ao.h
intern/cycles/kernel/svm/svm_bevel.h
intern/cycles/kernel/svm/svm_closure.h
intern/cycles/kernel/svm/svm_math_util.h
intern/cycles/kernel/svm/svm_voronoi.h
intern/cycles/render/graph.cpp
intern/cycles/render/light.cpp
intern/cycles/render/nodes.cpp
intern/cycles/util/util_math_intersect.h
intern/cycles/util/util_system.cpp

index 01a1234531b24b67caba56bf26edf0815f5bf475..da8ca53c8dfc8aebac9d09017ec14497de1716d3 100644 (file)
@@ -159,8 +159,7 @@ bool link_ptxas(CompilationSettings &settings)
                                        " --gpu-name sm_" + std::to_string(settings.target_arch) +
                                        " -m" + std::to_string(settings.bits);
 
-       if (settings.verbose)
-       {
+       if(settings.verbose) {
                ptx += " --verbose";
                printf("%s\n", ptx.c_str());
        }
index 25e6db18588be9d8fab47872ffee0b0bf5134c27..3eefb92f6aff66e4144a92bc13acc06628ddc55d 100644 (file)
@@ -1057,7 +1057,7 @@ static void add_nodes(Scene *scene,
                        for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) {
                                BL::NodeSocket to_socket(b_link->to_socket());
                                SocketType::Type to_socket_type = convert_socket_type(to_socket);
-                               if (to_socket_type == SocketType::UNDEFINED) {
+                               if(to_socket_type == SocketType::UNDEFINED) {
                                        continue;
                                }
 
@@ -1084,7 +1084,7 @@ static void add_nodes(Scene *scene,
                         */
                        for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) {
                                SocketType::Type input_type = convert_socket_type(*b_input);
-                               if (input_type == SocketType::UNDEFINED) {
+                               if(input_type == SocketType::UNDEFINED) {
                                        continue;
                                }
 
@@ -1100,7 +1100,7 @@ static void add_nodes(Scene *scene,
                        }
                        for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) {
                                SocketType::Type output_type = convert_socket_type(*b_output);
-                               if (output_type == SocketType::UNDEFINED) {
+                               if(output_type == SocketType::UNDEFINED) {
                                        continue;
                                }
 
index be0dcc207557ea08dbd22c1df968802004006150..6867dffc727143e230607f129207bcf07835fe4c 100644 (file)
@@ -1025,7 +1025,7 @@ void device_cpu_info(vector<DeviceInfo>& devices)
        info.num = 0;
        info.advanced_shading = true;
        info.bvh_layout_mask = BVH_LAYOUT_BVH2;
-       if (system_cpu_support_sse2()) {
+       if(system_cpu_support_sse2()) {
                info.bvh_layout_mask |= BVH_LAYOUT_BVH4;
        }
        info.has_volume_decoupled = true;
index d6304ba688a5d3496c43cbe7939773a42133e0d1..895e4149a3ac293c9cd3c270b8883505a513edab 100644 (file)
@@ -1139,13 +1139,13 @@ string OpenCLInfo::get_readable_device_name(cl_device_id device_id)
        /* Special exception for AMD Vega, need to be able to tell
         * Vega 56 from 64 apart.
         */
-       if (name == "Radeon RX Vega") {
+       if(name == "Radeon RX Vega") {
                cl_int max_compute_units = 0;
-               if (clGetDeviceInfo(device_id,
-                                   CL_DEVICE_MAX_COMPUTE_UNITS,
-                                   sizeof(max_compute_units),
-                                   &max_compute_units,
-                                   NULL) == CL_SUCCESS)
+               if(clGetDeviceInfo(device_id,
+                                  CL_DEVICE_MAX_COMPUTE_UNITS,
+                                  sizeof(max_compute_units),
+                                  &max_compute_units,
+                                  NULL) == CL_SUCCESS)
                {
                        name += " " + to_string(max_compute_units);
                }
index 5960d9aa7d53b964d823fa32465dc535baad397f..19fe0a168eaa1937fe921bfd2647e9098fadb002 100644 (file)
@@ -443,7 +443,7 @@ template<typename T>
 void array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
 {
        const array<T>& a = *(const array<T>*)(((char*)node) + socket.struct_offset);
-       for (size_t i = 0; i < a.size(); i++) {
+       for(size_t i = 0; i < a.size(); i++) {
                md5.append((uint8_t*)&a[i], sizeof(T));
        }
 }
@@ -452,7 +452,7 @@ void float3_array_hash(const Node *node, const SocketType& socket, MD5Hash& md5)
 {
        /* Don't compare 4th element used for padding. */
        const array<float3>& a = *(const array<float3>*)(((char*)node) + socket.struct_offset);
-       for (size_t i = 0; i < a.size(); i++) {
+       for(size_t i = 0; i < a.size(); i++) {
                md5.append((uint8_t*)&a[i], sizeof(float) * 3);
        }
 }
index 4ee580893849bee805f8a8b04ec691e38516c311..b3b56be39ff354b1e2699778cebbed91e863b47c 100644 (file)
@@ -120,7 +120,7 @@ ccl_device_inline float bessel_I0(float x)
 /* Logarithm of the Bessel function of the first kind. */
 ccl_device_inline float log_bessel_I0(float x)
 {
-       if (x > 12.0f) {
+       if(x > 12.0f) {
                /* log(1/x) == -log(x) iff x > 0.
                 * This is only used with positive cosines */
                return x + 0.5f * (1.f / (8.0f * x) - M_LN_2PI_F - logf(x));
index b13fabde268559b9ad92d8a888f0043ab3873b53..e85050df4bbe57274db97cf1dfde0923aa6c4f69 100644 (file)
@@ -170,7 +170,7 @@ ccl_device_inline bool path_state_volume_next(KernelGlobals *kg, ccl_addr_space
        /* For volume bounding meshes we pass through without counting transparent
         * bounces, only sanity check in case self intersection gets us stuck. */
        state->volume_bounds_bounce++;
-       if (state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
+       if(state->volume_bounds_bounce > VOLUME_BOUNDS_MAX) {
                return false;
        }
 
index b83460b3ffb932ee29f0b9b04375fec2fc82feda..e834b701f963ff3d7fe6b5a36b2017ecff04b7cb 100644 (file)
@@ -1010,7 +1010,7 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
                DiffuseBsdf *bsdf = (DiffuseBsdf*)bsdf_alloc(sd,
                                                             sizeof(DiffuseBsdf),
                                                             make_float3(0.8f, 0.8f, 0.8f));
-               if (bsdf != NULL) {
+               if(bsdf != NULL) {
                        bsdf->N = sd->N;
                        sd->flag |= bsdf_diffuse_setup(bsdf);
                }
index 2ebfd5f0c2f39b714cad8ba1510c05480b549ba5..66ec8a996caedbb04315b90864aeb05a7eaebe91 100644 (file)
@@ -69,22 +69,22 @@ public:
 
        void setup(ShaderData *sd, int path_flag, float3 weight)
        {
-               if (method == u_cubic) {
+               if(method == u_cubic) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_CUBIC_ID);
                }
-               else if (method == u_gaussian) {
+               else if(method == u_gaussian) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_GAUSSIAN_ID);
                }
-               else if (method == u_burley) {
+               else if(method == u_burley) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID);
                }
-               else if (method == u_principled) {
+               else if(method == u_principled) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_ID);
                }
-               else if (method == u_random_walk) {
+               else if(method == u_random_walk) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_RANDOM_WALK_ID);
                }
-               else if (method == u_principled_random_walk) {
+               else if(method == u_principled_random_walk) {
                        alloc(sd, path_flag, weight, CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID);
                }
        }
index 8c7ae30725cd7580d15bd58da03c9569cb1b6744..169351d5ad958813d8d9156fb6617d8a586fde7f 100644 (file)
@@ -200,11 +200,9 @@ public:
 
        void setup(ShaderData *sd, int path_flag, float3 weight)
        {
-               if(!skip(sd, path_flag, LABEL_GLOSSY))
-               {
+               if(!skip(sd, path_flag, LABEL_GLOSSY)) {
                        PrincipledHairBSDF *bsdf = (PrincipledHairBSDF*)alloc(sd, path_flag, weight);
-                       if (!bsdf)
-                       {
+                       if(!bsdf) {
                                return;
                        }
 
index d2d36cefd506c43f88bc3e9915000073ae110b4e..0337c88a5434556b55c85c119fac645e0299c81e 100644 (file)
@@ -98,11 +98,11 @@ ccl_device void svm_node_ao(KernelGlobals *kg,
        float3 normal = stack_valid(normal_offset)? stack_load_float3(stack, normal_offset): sd->N;
        float ao = svm_ao(kg, sd, normal, state, dist, samples, flags);
 
-       if (stack_valid(out_ao_offset)) {
+       if(stack_valid(out_ao_offset)) {
                stack_store_float(stack, out_ao_offset, ao);
        }
 
-       if (stack_valid(out_color_offset)) {
+       if(stack_valid(out_color_offset)) {
                float3 color = stack_load_float3(stack, color_offset);
                stack_store_float3(stack, out_color_offset, ao * color);
        }
index 19cdb71c20f21e184ba82af8a3a7afec0b96326a..79d0fb6ddbecc59b191e1210a2b0d55cd58014af 100644 (file)
@@ -148,11 +148,11 @@ ccl_device_noinline float3 svm_bevel(
                        int prim = kernel_tex_fetch(__prim_index, isect.hits[hit].prim);
                        int shader = kernel_tex_fetch(__tri_shader, prim);
 
-                       if (shader & SHADER_SMOOTH_NORMAL) {
+                       if(shader & SHADER_SMOOTH_NORMAL) {
                                float u = isect.hits[hit].u;
                                float v = isect.hits[hit].v;
 
-                               if (sd->type & PRIMITIVE_TRIANGLE) {
+                               if(sd->type & PRIMITIVE_TRIANGLE) {
                                        N = triangle_smooth_normal(kg, N, prim, u, v);
                                }
 #ifdef __OBJECT_MOTION__
index aa253223c930b7c332bd0b27e1ab11d5b0cb2145..cce0e0eefe0df76adba41cdbbd9dc003512d4bff 100644 (file)
@@ -757,7 +757,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
 
                        const AttributeDescriptor attr_descr_random = find_attribute(kg, sd, data_node4.y);
                        float random = 0.0f;
-                       if (attr_descr_random.offset != ATTR_STD_NOT_FOUND) {
+                       if(attr_descr_random.offset != ATTR_STD_NOT_FOUND) {
                                random = primitive_attribute_float(kg, sd, attr_descr_random, NULL, NULL);
                        }
                        else {
@@ -769,7 +769,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
                        if(bsdf) {
                                PrincipledHairExtra *extra = (PrincipledHairExtra*)closure_alloc_extra(sd, sizeof(PrincipledHairExtra));
 
-                               if (!extra)
+                               if(!extra)
                                        break;
 
                                /* Random factors range: [-randomization/2, +randomization/2]. */
index d3490ab284f01cd928367616218203950674650b..669b174e4a3e36b1d1f3a999216cecb1f9ca8855 100644 (file)
@@ -94,13 +94,13 @@ ccl_device float svm_math(NodeMath type, float Fac1, float Fac2)
                Fac = fabsf(Fac1);
        else if(type == NODE_MATH_ARCTAN2)
                Fac = atan2f(Fac1, Fac2);
-       else if (type == NODE_MATH_FLOOR)
+       else if(type == NODE_MATH_FLOOR)
                Fac = floorf(Fac1);
-       else if (type == NODE_MATH_CEIL)
+       else if(type == NODE_MATH_CEIL)
                Fac = ceilf(Fac1);
-       else if (type == NODE_MATH_FRACT)
+       else if(type == NODE_MATH_FRACT)
                Fac = Fac1 - floorf(Fac1);
-       else if (type == NODE_MATH_SQRT)
+       else if(type == NODE_MATH_SQRT)
                Fac = safe_sqrtf(Fac1);
        else if(type == NODE_MATH_CLAMP)
                Fac = saturate(Fac1);
index 4e66e87611fca6194ecdada17a7b75cbd7350dcc..d661df54ead5cdcae6987ae63dbc3516061b8b2e 100644 (file)
@@ -70,7 +70,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
                                }
 
                                /* To keep the shortest four distances and associated points we have to keep them in sorted order. */
-                               if (d < da[0]) {
+                               if(d < da[0]) {
                                        da[3] = da[2];
                                        da[2] = da[1];
                                        da[1] = da[0];
@@ -81,7 +81,7 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
                                        pa[1] = pa[0];
                                        pa[0] = vp;
                                }
-                               else if (d < da[1]) {
+                               else if(d < da[1]) {
                                        da[3] = da[2];
                                        da[2] = da[1];
                                        da[1] = d;
@@ -90,14 +90,14 @@ ccl_device void voronoi_neighbors(float3 p, NodeVoronoiDistanceMetric distance,
                                        pa[2] = pa[1];
                                        pa[1] = vp;
                                }
-                               else if (d < da[2]) {
+                               else if(d < da[2]) {
                                        da[3] = da[2];
                                        da[2] = d;
 
                                        pa[3] = pa[2];
                                        pa[2] = vp;
                                }
-                               else if (d < da[3]) {
+                               else if(d < da[3]) {
                                        da[3] = d;
                                        pa[3] = vp;
                                }
index 3a9e29814180e3e6a753e3183efce5e8a3f2d419..eea1bed58dcff0dd063e1a4cbcf3dbd66c3e8147 100644 (file)
@@ -245,7 +245,7 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
                ShaderNode *convert;
                ShaderInput *convert_in;
 
-               if (to->type() == SocketType::CLOSURE) {
+               if(to->type() == SocketType::CLOSURE) {
                        EmissionNode *emission = new EmissionNode();
                        emission->color = make_float3(1.0f, 1.0f, 1.0f);
                        emission->strength = 1.0f;
index da29e1a255a80c0a1e681a8cc6ec49d9ffd265a3..3580f4a8eebd9677f9351fd53f35475079fc3f3d 100644 (file)
@@ -548,7 +548,7 @@ void LightManager::device_update_background(Device *device,
        /* get the resolution from the light's size (we stuff it in there) */
        int2 res = make_int2(background_light->map_resolution, background_light->map_resolution/2);
        /* If the resolution isn't set manually, try to find an environment texture. */
-       if (res.x == 0) {
+       if(res.x == 0) {
                Shader *shader = (scene->background->shader) ? scene->background->shader : scene->default_background;
                foreach(ShaderNode *node, shader->graph->nodes) {
                        if(node->type == EnvironmentTextureNode::node_type) {
@@ -560,12 +560,12 @@ void LightManager::device_update_background(Device *device,
                                }
                        }
                }
-               if (res.x > 0 && res.y > 0) {
+               if(res.x > 0 && res.y > 0) {
                        VLOG(2) << "Automatically set World MIS resolution to " << res.x << " by " << res.y << "\n";
                }
        }
        /* If it's still unknown, just use the default. */
-       if (res.x == 0 || res.y == 0) {
+       if(res.x == 0 || res.y == 0) {
                res = make_int2(1024, 512);
                VLOG(2) << "Setting World MIS resolution to default\n";
        }
index 96e7459a48c712a84cdee956709aace8529a051a..1943f8c3e2b2da75d255dc4c7e9f3c2bf00de96d 100644 (file)
@@ -951,9 +951,9 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler)
        ShaderOutput *color_out = output("Color");
        ShaderOutput *fac_out = output("Fac");
 
-       if (vector_in->link) compiler.stack_assign(vector_in);
-       if (scale_in->link) compiler.stack_assign(scale_in);
-       if (exponent_in->link) compiler.stack_assign(exponent_in);
+       if(vector_in->link) compiler.stack_assign(vector_in);
+       if(scale_in->link) compiler.stack_assign(scale_in);
+       if(exponent_in->link) compiler.stack_assign(exponent_in);
 
        int vector_offset = tex_mapping.compile_begin(compiler, vector_in);
 
@@ -2856,7 +2856,7 @@ void AmbientOcclusionNode::compile(SVMCompiler& compiler)
 
        int flags = (inside? NODE_AO_INSIDE : 0) | (only_local? NODE_AO_ONLY_LOCAL : 0);
 
-       if (!distance_in->link && distance == 0.0f) {
+       if(!distance_in->link && distance == 0.0f) {
                flags |= NODE_AO_GLOBAL_RADIUS;
        }
 
index 61ddcc38f506a67dd2f248cc3bae1b20428521b6..b5fbb24091fcacff93d2a66a108c77e191f98b22 100644 (file)
@@ -136,10 +136,10 @@ ccl_device_forceinline bool ray_triangle_intersect(
 
 #if defined(__KERNEL_SSE2__)  && defined (__KERNEL_SSE__)
        int uvw_sign = movemask(UVWW) & 0x7;
-       if (uvw_sign != 0)
-       {
-               if (uvw_sign != 0x7)
+       if(uvw_sign != 0) {
+               if(uvw_sign != 0x7) {
                        return false;
+               }
        }
 #else
        const float minUVW = min(U, min(V, W));
index 8ae5b63b2f96004c547b7384b5968d6bbc0fde16..2428b0b2989caa5a118671ae9da4e8dd74f00f34 100644 (file)
@@ -300,7 +300,7 @@ size_t system_physical_ram()
 #elif defined(__APPLE__)
        uint64_t ram = 0;
        size_t len = sizeof(ram);
-       if (sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
+       if(sysctlbyname("hw.memsize", &ram, &len, NULL, 0) == 0) {
                return ram;
        }
        return 0;