Cycles: Cleanup, style

This commit is contained in:
Sergey Sharybin
2016-10-24 12:26:12 +02:00
parent 3f29259676
commit 48997d2e40
16 changed files with 53 additions and 41 deletions

View 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)) {

View 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 {

View 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 {

View 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;
}

View 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);
}

View 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);

View 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;
}

View 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;

View 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]);
}

View 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;
}

View 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];
}
}

View 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 {

View 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();

View 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;

View 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;
}
}

View 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));
}
}
/*