Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-01-03 16:08:54 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-01-03 16:08:54 +0400
commit57cf48e7c6fd04f864072c21433a822907774f78 (patch)
tree45f3fa51f532a03e25c4d8ffa0c1be58027d01b2 /intern/cycles/bvh
parent8ca977b16e745f716d044a5b6ccbb5be4a70ac94 (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/bvh')
-rw-r--r--intern/cycles/bvh/bvh.cpp37
-rw-r--r--intern/cycles/bvh/bvh_build.cpp10
-rw-r--r--intern/cycles/bvh/bvh_split.cpp6
3 files changed, 25 insertions, 28 deletions
diff --git a/intern/cycles/bvh/bvh.cpp b/intern/cycles/bvh/bvh.cpp
index 102414e4a3d..0b43704b7b8 100644
--- a/intern/cycles/bvh/bvh.cpp
+++ b/intern/cycles/bvh/bvh.cpp
@@ -76,9 +76,7 @@ bool BVH::cache_read(CacheData& key)
key.add(ob->mesh->verts);
key.add(ob->mesh->triangles);
key.add(ob->mesh->curve_keys);
- key.add(ob->mesh->curve_keysCD);
- key.add(ob->mesh->curve_segs);
- key.add(ob->mesh->curve_attrib);
+ key.add(ob->mesh->curve_segments);
key.add(&ob->bounds, sizeof(ob->bounds));
key.add(&ob->visibility, sizeof(ob->visibility));
key.add(&ob->mesh->transform_applied, sizeof(bool));
@@ -278,34 +276,33 @@ void BVH::pack_curve_seg(int idx, float4 woop[3])
int tob = pack.prim_object[idx];
const Mesh *mesh = objects[tob]->mesh;
int tidx = pack.prim_index[idx];
- float3 v0 = mesh->curve_keys[mesh->curve_segs[tidx].v[0]].loc;
- float3 v1 = mesh->curve_keys[mesh->curve_segs[tidx].v[1]].loc;
- float t0 = mesh->curve_keys[mesh->curve_segs[tidx].v[0]].time;
- float t1 = mesh->curve_keys[mesh->curve_segs[tidx].v[1]].time;
+ float3 v0 = mesh->curve_keys[mesh->curve_segments[tidx].v[0]].co;
+ float3 v1 = mesh->curve_keys[mesh->curve_segments[tidx].v[1]].co;
float3 d0 = v1 - v0;
float l = len(d0);
- float u = mesh->curve_attrib[mesh->curve_segs[tidx].curve].uv[0];
- float v = mesh->curve_attrib[mesh->curve_segs[tidx].curve].uv[1];
-
/*Plan
*Transform tfm = make_transform(
* location <3> , l,
* extra curve data <3> , StrID,
- * nextkey, flags/tip?, r, t);
+ * nextkey, flags/tip?, 0, 0);
*/
- float3 tg1 = make_float3(1.0f,0.0f,0.0f);
- float3 tg2 = make_float3(1.0f,0.0f,0.0f);
- if(mesh->curve_keysCD.size()) {
- tg1 = mesh->curve_keysCD[mesh->curve_segs[tidx].v[0]].tg;
- tg2 = mesh->curve_keysCD[mesh->curve_segs[tidx].v[1]].tg;
+ Attribute *attr_tangent = mesh->curve_attributes.find(ATTR_STD_CURVE_TANGENT);
+ float3 tg1 = make_float3(1.0f, 0.0f, 0.0f);
+ float3 tg2 = make_float3(1.0f, 0.0f, 0.0f);
+
+ if(attr_tangent) {
+ const float3 *data_tangent = attr_tangent->data_float3();
+
+ tg1 = data_tangent[mesh->curve_segments[tidx].v[0]];
+ tg2 = data_tangent[mesh->curve_segments[tidx].v[1]];
}
Transform tfm = make_transform(
tg1.x, tg1.y, tg1.z, l,
tg2.x, tg2.y, tg2.z, 0,
- t0, t1, u, v,
+ 0, 0, 0, 0,
0, 0, 0, 1);
woop[0] = tfm.x;
@@ -628,10 +625,10 @@ void RegularBVH::refit_node(int idx, bool leaf, BoundBox& bbox, uint& visibility
if(pack.prim_type[prim]) {
/* strands */
int str_offset = (params.top_level)? mesh->curveseg_offset: 0;
- const int *hidx = mesh->curve_segs[pidx - str_offset].v;
+ const int *hidx = mesh->curve_segments[pidx - str_offset].v;
- bbox.grow(mesh->curve_keys[hidx[0]].loc, mesh->curve_keys[hidx[0]].radius);
- bbox.grow(mesh->curve_keys[hidx[1]].loc, mesh->curve_keys[hidx[1]].radius);
+ bbox.grow(mesh->curve_keys[hidx[0]].co, mesh->curve_keys[hidx[0]].radius);
+ bbox.grow(mesh->curve_keys[hidx[1]].co, mesh->curve_keys[hidx[1]].radius);
}
else {
/* triangles */
diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp
index cdd94324f53..665c783b2d8 100644
--- a/intern/cycles/bvh/bvh_build.cpp
+++ b/intern/cycles/bvh/bvh_build.cpp
@@ -85,12 +85,12 @@ void BVHBuild::add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh,
}
}
- for(uint j = 0; j < mesh->curve_segs.size(); j++) {
- Mesh::CurveSeg s = mesh->curve_segs[j];
+ for(uint j = 0; j < mesh->curve_segments.size(); j++) {
+ Mesh::CurveSegment s = mesh->curve_segments[j];
BoundBox bounds = BoundBox::empty;
for(int k = 0; k < 2; k++) {
- float3 pt = mesh->curve_keys[s.v[k]].loc;
+ float3 pt = mesh->curve_keys[s.v[k]].co;
bounds.grow(pt, mesh->curve_keys[s.v[k]].radius);
}
@@ -118,14 +118,14 @@ void BVHBuild::add_references(BVHRange& root)
if(params.top_level) {
if(ob->mesh->transform_applied) {
num_alloc_references += ob->mesh->triangles.size();
- num_alloc_references += ob->mesh->curve_segs.size();
+ num_alloc_references += ob->mesh->curve_segments.size();
}
else
num_alloc_references++;
}
else {
num_alloc_references += ob->mesh->triangles.size();
- num_alloc_references += ob->mesh->curve_segs.size();
+ num_alloc_references += ob->mesh->curve_segments.size();
}
}
diff --git a/intern/cycles/bvh/bvh_split.cpp b/intern/cycles/bvh/bvh_split.cpp
index 860e2c8d7df..67fdfd77657 100644
--- a/intern/cycles/bvh/bvh_split.cpp
+++ b/intern/cycles/bvh/bvh_split.cpp
@@ -283,9 +283,9 @@ void BVHSpatialSplit::split_reference(BVHBuild *builder, BVHReference& left, BVH
else {
/* Strand split: NOTE - Currently ignores strand width and needs to be fixed.*/
- const int *inds = mesh->curve_segs[ref.prim_index()].v;
- const float3* v0 = &mesh->curve_keys[inds[0]].loc;
- const float3* v1 = &mesh->curve_keys[inds[1]].loc;
+ const int *inds = mesh->curve_segments[ref.prim_index()].v;
+ const float3* v0 = &mesh->curve_keys[inds[0]].co;
+ const float3* v1 = &mesh->curve_keys[inds[1]].co;
float v0p = (*v0)[dim];
float v1p = (*v1)[dim];