diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-03 16:08:54 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-01-03 16:08:54 +0400 |
commit | 57cf48e7c6fd04f864072c21433a822907774f78 (patch) | |
tree | 45f3fa51f532a03e25c4d8ffa0c1be58027d01b2 /intern/cycles/render/object.cpp | |
parent | 8ca977b16e745f716d044a5b6ccbb5be4a70ac94 (diff) |
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.
Diffstat (limited to 'intern/cycles/render/object.cpp')
-rw-r--r-- | intern/cycles/render/object.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 588b4d50e1b..4862b47c342 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -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*/ |