Cycles Hair: refactoring to support generic attributes for hair curves. There
should be no functional changes yet. UV, tangent and intercept are now stored as attributes, with the intention to add more like multiple uv's, vertex colors, generated coordinates and motion vectors later. Things got a bit messy due to having both triangle and curve data in the same mesh data structure, which also gives us two sets of attributes. This will get cleaned up when we split the mesh class.
This commit is contained in:
@@ -89,12 +89,9 @@ void Object::apply_transform()
|
||||
mesh->verts[i] = transform_point(&tfm, mesh->verts[i]);
|
||||
|
||||
for(size_t i = 0; i < mesh->curve_keys.size(); i++)
|
||||
mesh->curve_keys[i].loc = transform_point(&tfm, mesh->curve_keys[i].loc);
|
||||
|
||||
for(size_t i = 0; i < mesh->curve_keysCD.size(); i++)
|
||||
mesh->curve_keysCD[i].tg = transform_direction(&tfm, mesh->curve_keysCD[i].tg);
|
||||
|
||||
mesh->curve_keys[i].co = transform_point(&tfm, mesh->curve_keys[i].co);
|
||||
|
||||
Attribute *attr_tangent = mesh->curve_attributes.find(ATTR_STD_CURVE_TANGENT);
|
||||
Attribute *attr_fN = mesh->attributes.find(ATTR_STD_FACE_NORMAL);
|
||||
Attribute *attr_vN = mesh->attributes.find(ATTR_STD_VERTEX_NORMAL);
|
||||
|
||||
@@ -119,6 +116,13 @@ void Object::apply_transform()
|
||||
vN[i] = transform_direction(&ntfm, vN[i]);
|
||||
}
|
||||
|
||||
if(attr_tangent) {
|
||||
float3 *tangent = attr_tangent->data_float3();
|
||||
|
||||
for(size_t i = 0; i < mesh->curve_keys.size(); i++)
|
||||
tangent[i] = transform_direction(&tfm, tangent[i]);
|
||||
}
|
||||
|
||||
if(bounds.valid()) {
|
||||
mesh->compute_bounds();
|
||||
compute_bounds(false, 0.0f);
|
||||
@@ -199,10 +203,10 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
|
||||
surface_area += triangle_area(p1, p2, p3);
|
||||
}
|
||||
|
||||
foreach(Mesh::CurveSeg& t, mesh->curve_segs) {
|
||||
float3 p1 = mesh->curve_keys[t.v[0]].loc;
|
||||
foreach(Mesh::CurveSegment& t, mesh->curve_segments) {
|
||||
float3 p1 = mesh->curve_keys[t.v[0]].co;
|
||||
float r1 = mesh->curve_keys[t.v[0]].radius;
|
||||
float3 p2 = mesh->curve_keys[t.v[1]].loc;
|
||||
float3 p2 = mesh->curve_keys[t.v[1]].co;
|
||||
float r2 = mesh->curve_keys[t.v[1]].radius;
|
||||
|
||||
/* currently ignores segment overlaps*/
|
||||
@@ -225,10 +229,10 @@ void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene
|
||||
surface_area += triangle_area(p1, p2, p3);
|
||||
}
|
||||
|
||||
foreach(Mesh::CurveSeg& t, mesh->curve_segs) {
|
||||
float3 p1 = mesh->curve_keys[t.v[0]].loc;
|
||||
foreach(Mesh::CurveSegment& t, mesh->curve_segments) {
|
||||
float3 p1 = mesh->curve_keys[t.v[0]].co;
|
||||
float r1 = mesh->curve_keys[t.v[0]].radius;
|
||||
float3 p2 = mesh->curve_keys[t.v[1]].loc;
|
||||
float3 p2 = mesh->curve_keys[t.v[1]].co;
|
||||
float r2 = mesh->curve_keys[t.v[1]].radius;
|
||||
|
||||
/* currently ignores segment overlaps*/
|
||||
|
Reference in New Issue
Block a user