Cycles: Cleanup, style
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 24 Oct 2016 10:26:12 +0000 (12:26 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 24 Oct 2016 10:26:12 +0000 (12:26 +0200)
16 files changed:
intern/cycles/blender/blender_mesh.cpp
intern/cycles/bvh/bvh.cpp
intern/cycles/bvh/bvh_node.h
intern/cycles/device/opencl/opencl_base.cpp
intern/cycles/kernel/kernel_camera.h
intern/cycles/kernel/kernel_image_opencl.h
intern/cycles/kernel/svm/svm_ramp_util.h
intern/cycles/render/camera.cpp
intern/cycles/render/graph.cpp
intern/cycles/render/image.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/nodes.cpp
intern/cycles/render/object.cpp
intern/cycles/render/osl.cpp
intern/cycles/subd/subd_patch_table.cpp
intern/cycles/test/render_graph_finalize_test.cpp

index ff1d49ffd12cd0fd9a44e21a1d91d67e918e5193..fab03c7659bdb8c75adca94d81857753e389cad1 100644 (file)
@@ -847,7 +847,7 @@ static void sync_mesh_fluid_motion(BL::Object& b_ob, Scene *scene, Mesh *mesh)
 
        /* Only export previous and next frame, we don't have any in between data. */
        float motion_times[2] = {-1.0f, 1.0f};
-       for (int step = 0; step < 2; step++) {
+       for(int step = 0; step < 2; step++) {
                float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f;
                float3 *mP = attr_mP->data_float3() + step*mesh->verts.size();
 
@@ -1081,7 +1081,7 @@ void BlenderSync::sync_mesh_motion(BL::Object& b_ob,
 
        /* fluid motion is exported immediate with mesh, skip here */
        BL::DomainFluidSettings b_fluid_domain = object_fluid_domain_find(b_ob);
-       if (b_fluid_domain)
+       if(b_fluid_domain)
                return;
 
        if(ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) {
index 9f2468e4d95127811cc2f4735990d6b4cab9359b..4851de5b4816db57fe984543d3c264d0d1e396b6 100644 (file)
@@ -147,7 +147,7 @@ void BVH::pack_primitives()
        /* Count number of triangles primitives in BVH. */
        for(unsigned int i = 0; i < tidx_size; i++) {
                if((pack.prim_index[i] != -1)) {
-                       if ((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) {
+                       if((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) {
                                ++num_prim_triangles;
                        }
                }
@@ -450,7 +450,7 @@ void RegularBVH::pack_inner(const BVHStackEntry& e,
                             const BVHStackEntry& e0,
                             const BVHStackEntry& e1)
 {
-       if (e0.node->is_unaligned() || e1.node->is_unaligned()) {
+       if(e0.node->is_unaligned() || e1.node->is_unaligned()) {
                pack_unaligned_inner(e, e0, e1);
        } else {
                pack_aligned_inner(e, e0, e1);
@@ -597,8 +597,8 @@ void RegularBVH::pack_nodes(const BVHNode *root)
                else {
                        /* innner node */
                        int idx[2];
-                       for (int i = 0; i < 2; ++i) {
-                               if (e.node->get_child(i)->is_leaf()) {
+                       for(int i = 0; i < 2; ++i) {
+                               if(e.node->get_child(i)->is_leaf()) {
                                        idx[i] = nextLeafNodeIdx++;
                                }
                                else {
index f2965a785e64a9e8ed3442afabe0abaac4c76e97..2faa40ab657b112f649f3204ac4d712a2645dd37 100644 (file)
@@ -66,7 +66,7 @@ public:
        inline void set_aligned_space(const Transform& aligned_space)
        {
                m_is_unaligned = true;
-               if (m_aligned_space == NULL) {
+               if(m_aligned_space == NULL) {
                        m_aligned_space = new Transform(aligned_space);
                }
                else {
index e67ffb1a836ee805c21a86278578aeb27fa91913..a2b900312e7a3b1f7adacf5142dcc862ba77a2a6 100644 (file)
@@ -409,7 +409,7 @@ void OpenCLDeviceBase::enqueue_kernel(cl_kernel kernel, size_t w, size_t h)
         * much work per pixel (if we don't check global ID on Y axis) or will
         * be checking for global ID to always have Y of 0.
         */
-       if (h == 1) {
+       if(h == 1) {
                global_size[h] = 1;
        }
 
index 0888466f5ffcfd84ff638caf3da60bcfb931ae34..b99a82b0203e437b821752f6476dbc08c8697e9d 100644 (file)
@@ -109,7 +109,7 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo
        D = normalize(transform_direction(&cameratoworld, D));
 
        bool use_stereo = kernel_data.cam.interocular_offset != 0.0f;
-       if (!use_stereo) {
+       if(!use_stereo) {
                /* No stereo */
                ray->P = P;
                ray->D = D;
@@ -300,7 +300,7 @@ ccl_device_inline void camera_sample_panorama(KernelGlobals *kg,
 
        /* Stereo transform */
        bool use_stereo = kernel_data.cam.interocular_offset != 0.0f;
-       if (use_stereo) {
+       if(use_stereo) {
                spherical_stereo_transform(kg, &P, &D);
        }
 
@@ -316,7 +316,7 @@ ccl_device_inline void camera_sample_panorama(KernelGlobals *kg,
        float3 Dcenter = panorama_to_direction(kg, Pcenter.x, Pcenter.y);
        Pcenter = transform_point(&cameratoworld, Pcenter);
        Dcenter = normalize(transform_direction(&cameratoworld, Dcenter));
-       if (use_stereo) {
+       if(use_stereo) {
                spherical_stereo_transform(kg, &Pcenter, &Dcenter);
        }
 
@@ -324,7 +324,7 @@ ccl_device_inline void camera_sample_panorama(KernelGlobals *kg,
        float3 Dx = panorama_to_direction(kg, Px.x, Px.y);
        Px = transform_point(&cameratoworld, Px);
        Dx = normalize(transform_direction(&cameratoworld, Dx));
-       if (use_stereo) {
+       if(use_stereo) {
                spherical_stereo_transform(kg, &Px, &Dx);
        }
 
@@ -335,7 +335,7 @@ ccl_device_inline void camera_sample_panorama(KernelGlobals *kg,
        float3 Dy = panorama_to_direction(kg, Py.x, Py.y);
        Py = transform_point(&cameratoworld, Py);
        Dy = normalize(transform_direction(&cameratoworld, Dy));
-       if (use_stereo) {
+       if(use_stereo) {
                spherical_stereo_transform(kg, &Py, &Dy);
        }
 
index f6c31b28f2cc3e49c2a8da6c232bbb57e58667a0..0352c58037d8f181b567e058001afd68cec8ac26 100644 (file)
@@ -162,16 +162,18 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
                svm_image_texture_frac(y*height, &iy);
                svm_image_texture_frac(z*depth, &iz);
 
-               if (extension == EXTENSION_REPEAT) {
+               if(extension == EXTENSION_REPEAT) {
                        ix = svm_image_texture_wrap_periodic(ix, width);
                        iy = svm_image_texture_wrap_periodic(iy, height);
                        iz = svm_image_texture_wrap_periodic(iz, depth);
                }
                else {
-                       if (extension == EXTENSION_CLIP) {
+                       if(extension == EXTENSION_CLIP) {
                                if(x < 0.0f || y < 0.0f || z < 0.0f ||
                                   x > 1.0f || y > 1.0f || z > 1.0f)
+                                {
                                        return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+                               }
                        }
                        /* Fall through. */
                        /* EXTENSION_EXTEND */
@@ -196,10 +198,12 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
                        niz = svm_image_texture_wrap_periodic(iz+1, depth);
                }
                else {
-                       if (extension == EXTENSION_CLIP)
+                       if(extension == EXTENSION_CLIP)
                                if(x < 0.0f || y < 0.0f || z < 0.0f ||
                                   x > 1.0f || y > 1.0f || z > 1.0f)
+                               {
                                        return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+                               }
                        /* Fall through. */
                        /*  EXTENSION_EXTEND */
                        nix = svm_image_texture_wrap_clamp(ix+1, width);
index 9f2ce1276f9f83a5aaddb99b3d3a8cf0d8e757d5..b0adadae9b73fa367b221ef93625ac599076025d 100644 (file)
@@ -27,9 +27,9 @@ ccl_device_inline float3 rgb_ramp_lookup(const float3 *ramp,
                                          bool extrapolate,
                                          int table_size)
 {
-       if ((f < 0.0f || f > 1.0f) && extrapolate) {
+       if((f < 0.0f || f > 1.0f) && extrapolate) {
                float3 t0, dy;
-               if (f < 0.0f) {
+               if(f < 0.0f) {
                        t0 = ramp[0];
                        dy = t0 - ramp[1],
                        f = -f;
@@ -50,8 +50,9 @@ ccl_device_inline float3 rgb_ramp_lookup(const float3 *ramp,
 
        float3 result = ramp[i];
 
-       if (interpolate && t > 0.0f)
+       if(interpolate && t > 0.0f) {
                result = (1.0f - t) * result + t * ramp[i + 1];
+       }
 
        return result;
 }
@@ -62,9 +63,9 @@ ccl_device float float_ramp_lookup(const float *ramp,
                                    bool extrapolate,
                                    int table_size)
 {
-       if ((f < 0.0f || f > 1.0f) && extrapolate) {
+       if((f < 0.0f || f > 1.0f) && extrapolate) {
                float t0, dy;
-               if (f < 0.0f) {
+               if(f < 0.0f) {
                        t0 = ramp[0];
                        dy = t0 - ramp[1],
                        f = -f;
@@ -85,8 +86,9 @@ ccl_device float float_ramp_lookup(const float *ramp,
 
        float result = ramp[i];
 
-       if (interpolate && t > 0.0f)
+       if(interpolate && t > 0.0f) {
                result = (1.0f - t) * result + t * ramp[i + 1];
+       }
 
        return result;
 }
index a6df656d22012c435286173e93b4d9c5bebb3195..c8c51ec96d2f43976a1cb9f1ca9598033a61c839 100644 (file)
@@ -32,8 +32,9 @@ CCL_NAMESPACE_BEGIN
 static float shutter_curve_eval(float x,
                                 array<float>& shutter_curve)
 {
-       if (shutter_curve.size() == 0)
+       if(shutter_curve.size() == 0) {
                return 1.0f;
+       }
 
        x *= shutter_curve.size();
        int index = (int)x;
index 131ec824be3d8d6582d40e6022a0b0bd3be1508f..f6c83fb5c7e355418052ec8d6695e4f43699b877 100644 (file)
@@ -148,8 +148,9 @@ void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 
 bool ShaderNode::equals(const ShaderNode& other)
 {
-       if (type != other.type || bump != other.bump)
+       if(type != other.type || bump != other.bump) {
                return false;
+       }
 
        assert(inputs.size() == other.inputs.size());
 
@@ -597,13 +598,13 @@ void ShaderGraph::deduplicate_nodes()
                /* Try to merge this node with another one. */
                ShaderNode *merge_with = NULL;
                foreach(ShaderNode *other_node, candidates[node->type->name]) {
-                       if (node != other_node && node->equals(*other_node)) {
+                       if(node != other_node && node->equals(*other_node)) {
                                merge_with = other_node;
                                break;
                        }
                }
                /* If found an equivalent, merge; otherwise keep node for later merges */
-               if (merge_with != NULL) {
+               if(merge_with != NULL) {
                        for(int i = 0; i < node->outputs.size(); ++i) {
                                relink(node, node->outputs[i], merge_with->outputs[i]);
                        }
index 3cb0aa961ec5fff6177576758f2a0d6f3c0d932b..073a0aa2ac905898d11f82392d8363d3bea5e216 100644 (file)
@@ -43,7 +43,7 @@ ImageManager::ImageManager(const DeviceInfo& info)
         * be screwed on so many levels..
         */
        DeviceType device_type = info.type;
-       if (device_type == DEVICE_MULTI) {
+       if(device_type == DEVICE_MULTI) {
                device_type = info.multi_devices[0].type;
        }
 
index 039bb49d82f17bedc57cc1c6077f08d919a28a9e..ac369a0d5f8f0af4912260bf0ed75161457f47f0 100644 (file)
@@ -1462,7 +1462,7 @@ void MeshManager::device_update_mesh(Device *device,
        else {
                PackedBVH& pack = bvh->pack;
                for(size_t i = 0; i < pack.prim_index.size(); ++i) {
-                       if ((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) {
+                       if((pack.prim_type[i] & PRIMITIVE_ALL_TRIANGLE) != 0) {
                                tri_prim_index[pack.prim_index[i]] = pack.prim_tri_index[i];
                        }
                }
index 7ea52b28b9cf6035ff9eeb71438222fc5b5c3d4b..3b4aa389c132ad573b1be35be44214efa258aa31 100644 (file)
@@ -2378,8 +2378,9 @@ void EmissionNode::constant_fold(const ConstantFolder& folder)
        ShaderInput *color_in = input("Color");
        ShaderInput *strength_in = input("Strength");
 
-       if ((!color_in->link && color == make_float3(0.0f, 0.0f, 0.0f)) ||
-           (!strength_in->link && strength == 0.0f)) {
+       if((!color_in->link && color == make_float3(0.0f, 0.0f, 0.0f)) ||
+          (!strength_in->link && strength == 0.0f))
+       {
                folder.discard();
        }
 }
@@ -2430,8 +2431,9 @@ void BackgroundNode::constant_fold(const ConstantFolder& folder)
        ShaderInput *color_in = input("Color");
        ShaderInput *strength_in = input("Strength");
 
-       if ((!color_in->link && color == make_float3(0.0f, 0.0f, 0.0f)) ||
-           (!strength_in->link && strength == 0.0f)) {
+       if((!color_in->link && color == make_float3(0.0f, 0.0f, 0.0f)) ||
+          (!strength_in->link && strength == 0.0f))
+       {
                folder.discard();
        }
 }
@@ -4864,8 +4866,9 @@ void CurvesNode::constant_fold(const ConstantFolder& folder, ShaderInput *value_
 
        /* evaluate fully constant node */
        if(folder.all_inputs_constant()) {
-               if (curves.size() == 0)
+               if(curves.size() == 0) {
                        return;
+               }
 
                float3 pos = (value - make_float3(min_x, min_x, min_x)) / (max_x - min_x);
                float3 result;
@@ -5140,7 +5143,7 @@ OSLNode* OSLNode::create(size_t num_inputs, const OSLNode *from)
        char *node_memory = (char*) operator new(node_size + inputs_size);
        memset(node_memory, 0, node_size + inputs_size);
 
-       if (!from) {
+       if(!from) {
                return new(node_memory) OSLNode();
        }
        else {
index d8f3ce58505cc992194ac15fde0e9f0fab544d62..8b8b988b969d365c0bb9ddf67424c601de8eef0c 100644 (file)
@@ -253,7 +253,7 @@ vector<float> Object::motion_times()
 bool Object::is_traceable()
 {
        /* Mesh itself can be empty,can skip all such objects. */
-       if (!bounds.valid() || bounds.size() == make_float3(0.0f, 0.0f, 0.0f)) {
+       if(!bounds.valid() || bounds.size() == make_float3(0.0f, 0.0f, 0.0f)) {
                return false;
        }
        /* TODO(sergey): Check for mesh vertices/curves. visibility flags. */
@@ -624,8 +624,9 @@ void ObjectManager::device_update_flags(Device *device,
 
 void ObjectManager::device_update_patch_map_offsets(Device *device, DeviceScene *dscene, Scene *scene)
 {
-       if (scene->objects.size() == 0)
+       if(scene->objects.size() == 0) {
                return;
+       }
 
        uint4* objects = (uint4*)dscene->objects.get_data();
 
index 18a32f7f328dd9106b21397ad0354ee0bb78944c..67b68e63cb2211b8af59419a866ecf3d2e8ed541 100644 (file)
@@ -825,7 +825,7 @@ void OSLCompiler::parameter(ShaderNode* node, const char *name)
                        // OSL does not support booleans, so convert to int
                        const array<bool>& value = node->get_bool_array(socket);
                        array<int> intvalue(value.size());
-                       for (size_t i = 0; i < value.size(); i++)
+                       for(size_t i = 0; i < value.size(); i++)
                                intvalue[i] = value[i];
                        ss->Parameter(uname, array_typedesc(TypeDesc::TypeInt, value.size()), intvalue.data());
                        break;
@@ -861,8 +861,7 @@ void OSLCompiler::parameter(ShaderNode* node, const char *name)
                        // convert to tightly packed array since float3 has padding
                        const array<float3>& value = node->get_float3_array(socket);
                        array<float> fvalue(value.size() * 3);
-                       for (size_t i = 0, j = 0; i < value.size(); i++)
-                       {
+                       for(size_t i = 0, j = 0; i < value.size(); i++) {
                                fvalue[j++] = value[i].x;
                                fvalue[j++] = value[i].y;
                                fvalue[j++] = value[i].z;
index 62572efa88ade12f06dcb02d9da7c1608dfdf4b0..d437b045c07781514034fb43987916671197bd05 100644 (file)
@@ -46,7 +46,7 @@ struct PatchMapQuadNode {
        /* sets all the children to point to the patch of index */
        void set_child(int index)
        {
-               for (int i = 0; i < 4; i++) {
+               for(int i = 0; i < 4; i++) {
                        children[i] = index | PATCH_MAP_NODE_IS_SET | PATCH_MAP_NODE_IS_LEAF;
                }
        }
index 6f1c0b88b51c67e5527a42e577d9377f679da39b..32b4c7265ee1453d3912771a2d040f6670158a55 100644 (file)
@@ -1407,8 +1407,9 @@ void init_test_curve(array<T> &buffer, T start, T end, int steps)
 {
        buffer.resize(steps);
 
-       for (int i = 0; i < steps; i++)
+       for(int i = 0; i < steps; i++) {
                buffer[i] = lerp(start, end, float(i)/(steps-1));
+       }
 }
 
 /*