diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-10 12:10:06 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-02-10 15:34:09 +0300 |
commit | d395d81bfc9e1c312159ff7b9ca9ba514a46af95 (patch) | |
tree | c1e09ed2b120ee3d682e92dd276e6b1eeba01a12 /intern/cycles | |
parent | 0b65b889efb83a11aece9776d36e9e8b72eb6f71 (diff) |
Cycles: Cleanup: Use less indentation by inverting condition
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 7b46f6ce398..04da8e2915f 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -530,58 +530,57 @@ static void attr_create_pointiness(Scene *scene, BL::Mesh& b_mesh, bool subdivision) { - if(mesh->need_attribute(scene, ATTR_STD_POINTINESS)) { - const int numverts = b_mesh.vertices.length(); - AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes; - Attribute *attr = attributes.add(ATTR_STD_POINTINESS); - float *data = attr->data_float(); - vector<int> counter(numverts, 0); - vector<float> raw_data(numverts, 0.0f); - vector<float3> edge_accum(numverts, make_float3(0.0f, 0.0f, 0.0f)); - - /* Calculate pointiness using single ring neighborhood. */ - BL::Mesh::edges_iterator e; - int i = 0; - for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) { - int v0 = b_mesh.edges[i].vertices()[0], - v1 = b_mesh.edges[i].vertices()[1]; - float3 co0 = get_float3(b_mesh.vertices[v0].co()), - co1 = get_float3(b_mesh.vertices[v1].co()); - float3 edge = normalize(co1 - co0); - edge_accum[v0] += edge; - edge_accum[v1] += -edge; - ++counter[v0]; - ++counter[v1]; - } - i = 0; - BL::Mesh::vertices_iterator v; - for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i) { - if(counter[i] > 0) { - float3 normal = get_float3(b_mesh.vertices[i].normal()); - float angle = safe_acosf(dot(normal, edge_accum[i] / counter[i])); - raw_data[i] = angle * M_1_PI_F; - } - else { - raw_data[i] = 0.0f; - } - } - - /* Blur vertices to approximate 2 ring neighborhood. */ - memset(&counter[0], 0, sizeof(int) * counter.size()); - memcpy(data, &raw_data[0], sizeof(float) * raw_data.size()); - i = 0; - for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) { - int v0 = b_mesh.edges[i].vertices()[0], - v1 = b_mesh.edges[i].vertices()[1]; - data[v0] += raw_data[v1]; - data[v1] += raw_data[v0]; - ++counter[v0]; - ++counter[v1]; + if(!mesh->need_attribute(scene, ATTR_STD_POINTINESS)) { + return; + } + const int numverts = b_mesh.vertices.length(); + AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes; + Attribute *attr = attributes.add(ATTR_STD_POINTINESS); + float *data = attr->data_float(); + vector<int> counter(numverts, 0); + vector<float> raw_data(numverts, 0.0f); + vector<float3> edge_accum(numverts, make_float3(0.0f, 0.0f, 0.0f)); + /* Calculate pointiness using single ring neighborhood. */ + BL::Mesh::edges_iterator e; + int i = 0; + for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) { + int v0 = b_mesh.edges[i].vertices()[0], + v1 = b_mesh.edges[i].vertices()[1]; + float3 co0 = get_float3(b_mesh.vertices[v0].co()), + co1 = get_float3(b_mesh.vertices[v1].co()); + float3 edge = normalize(co1 - co0); + edge_accum[v0] += edge; + edge_accum[v1] += -edge; + ++counter[v0]; + ++counter[v1]; + } + i = 0; + BL::Mesh::vertices_iterator v; + for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++i) { + if(counter[i] > 0) { + float3 normal = get_float3(b_mesh.vertices[i].normal()); + float angle = safe_acosf(dot(normal, edge_accum[i] / counter[i])); + raw_data[i] = angle * M_1_PI_F; } - for(i = 0; i < numverts; ++i) { - data[i] /= counter[i] + 1; + else { + raw_data[i] = 0.0f; } } + /* Blur vertices to approximate 2 ring neighborhood. */ + memset(&counter[0], 0, sizeof(int) * counter.size()); + memcpy(data, &raw_data[0], sizeof(float) * raw_data.size()); + i = 0; + for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) { + int v0 = b_mesh.edges[i].vertices()[0], + v1 = b_mesh.edges[i].vertices()[1]; + data[v0] += raw_data[v1]; + data[v1] += raw_data[v0]; + ++counter[v0]; + ++counter[v1]; + } + for(i = 0; i < numverts; ++i) { + data[i] /= counter[i] + 1; + } } /* Create Mesh */ |