Cycles: Cleanup: Use less indentation by inverting condition
This commit is contained in:
parent
0b65b889ef
commit
d395d81bfc
@ -530,58 +530,57 @@ static void attr_create_pointiness(Scene *scene,
|
|||||||
BL::Mesh& b_mesh,
|
BL::Mesh& b_mesh,
|
||||||
bool subdivision)
|
bool subdivision)
|
||||||
{
|
{
|
||||||
if(mesh->need_attribute(scene, ATTR_STD_POINTINESS)) {
|
if(!mesh->need_attribute(scene, ATTR_STD_POINTINESS)) {
|
||||||
const int numverts = b_mesh.vertices.length();
|
return;
|
||||||
AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes;
|
}
|
||||||
Attribute *attr = attributes.add(ATTR_STD_POINTINESS);
|
const int numverts = b_mesh.vertices.length();
|
||||||
float *data = attr->data_float();
|
AttributeSet& attributes = (subdivision)? mesh->subd_attributes: mesh->attributes;
|
||||||
vector<int> counter(numverts, 0);
|
Attribute *attr = attributes.add(ATTR_STD_POINTINESS);
|
||||||
vector<float> raw_data(numverts, 0.0f);
|
float *data = attr->data_float();
|
||||||
vector<float3> edge_accum(numverts, make_float3(0.0f, 0.0f, 0.0f));
|
vector<int> counter(numverts, 0);
|
||||||
|
vector<float> raw_data(numverts, 0.0f);
|
||||||
/* Calculate pointiness using single ring neighborhood. */
|
vector<float3> edge_accum(numverts, make_float3(0.0f, 0.0f, 0.0f));
|
||||||
BL::Mesh::edges_iterator e;
|
/* Calculate pointiness using single ring neighborhood. */
|
||||||
int i = 0;
|
BL::Mesh::edges_iterator e;
|
||||||
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) {
|
int i = 0;
|
||||||
int v0 = b_mesh.edges[i].vertices()[0],
|
for(b_mesh.edges.begin(e); e != b_mesh.edges.end(); ++e, ++i) {
|
||||||
v1 = b_mesh.edges[i].vertices()[1];
|
int v0 = b_mesh.edges[i].vertices()[0],
|
||||||
float3 co0 = get_float3(b_mesh.vertices[v0].co()),
|
v1 = b_mesh.edges[i].vertices()[1];
|
||||||
co1 = get_float3(b_mesh.vertices[v1].co());
|
float3 co0 = get_float3(b_mesh.vertices[v0].co()),
|
||||||
float3 edge = normalize(co1 - co0);
|
co1 = get_float3(b_mesh.vertices[v1].co());
|
||||||
edge_accum[v0] += edge;
|
float3 edge = normalize(co1 - co0);
|
||||||
edge_accum[v1] += -edge;
|
edge_accum[v0] += edge;
|
||||||
++counter[v0];
|
edge_accum[v1] += -edge;
|
||||||
++counter[v1];
|
++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;
|
||||||
}
|
}
|
||||||
i = 0;
|
else {
|
||||||
BL::Mesh::vertices_iterator v;
|
raw_data[i] = 0.0f;
|
||||||
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];
|
|
||||||
}
|
|
||||||
for(i = 0; i < numverts; ++i) {
|
|
||||||
data[i] /= counter[i] + 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* 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 */
|
/* Create Mesh */
|
||||||
|
Loading…
Reference in New Issue
Block a user