Blender 2.78: Port style cleanup from Cycles

Kinda nice to have official release code to be really clean.
This commit is contained in:
Sergey Sharybin 2016-10-24 12:38:33 +02:00
parent 66ed7d7566
commit faaf033d36
12 changed files with 40 additions and 32 deletions

View File

@ -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);
@ -598,7 +598,7 @@ void RegularBVH::pack_nodes(const BVHNode *root)
/* innner node */
int idx[2];
for (int i = 0; i < 2; ++i) {
if (e.node->get_child(i)->is_leaf()) {
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

@ -1254,7 +1254,7 @@ public:
* 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;
}
@ -2810,7 +2810,7 @@ public:
/* Execute SumALLRadiance kernel to accumulate radiance calculated in
* per_sample_output_buffers into RenderTile's output buffer.
*/
if (!canceled) {
if(!canceled) {
size_t sum_all_radiance_local_size[2] = {16, 16};
size_t sum_all_radiance_global_size[2];
sum_all_radiance_global_size[0] =

View File

@ -109,7 +109,7 @@ ccl_device void camera_sample_perspective(KernelGlobals *kg, float raster_x, flo
ray->D = normalize(transform_direction(&cameratoworld, ray->D));
bool use_stereo = kernel_data.cam.interocular_offset != 0.0f;
if (!use_stereo) {
if(!use_stereo) {
/* No stereo */
#ifdef __RAY_DIFFERENTIALS__
float3 Dcenter = transform_direction(&cameratoworld, Pcamera);
@ -295,7 +295,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, &ray->P, &ray->D);
}
@ -308,7 +308,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);
}
@ -316,7 +316,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);
}
@ -327,7 +327,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

@ -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();
}
}
@ -4851,8 +4853,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;
@ -5127,7 +5130,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();