[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44660] trunk/blender/source/blender/ blenlib/intern/pbvh.c: Code cleanup: add comments for build_sub() and remove debug function.
Nicholas Bishop
nicholasbishop at gmail.com
Mon Mar 5 23:12:54 CET 2012
Revision: 44660
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44660
Author: nicholasbishop
Date: 2012-03-05 22:12:50 +0000 (Mon, 05 Mar 2012)
Log Message:
-----------
Code cleanup: add comments for build_sub() and remove debug function.
Remove the function (and call to) check_partitioning(), this was just
a debug function.
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/pbvh.c
Modified: trunk/blender/source/blender/blenlib/intern/pbvh.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/pbvh.c 2012-03-05 21:55:53 UTC (rev 44659)
+++ trunk/blender/source/blender/blenlib/intern/pbvh.c 2012-03-05 22:12:50 UTC (rev 44660)
@@ -280,20 +280,6 @@
}
}
-static void check_partitioning(int *prim_indices, int lo, int hi, int axis,
- float mid, BBC *prim_bbc, int index_of_2nd_partition)
-{
- int i;
- for(i = lo; i <= hi; ++i) {
- const float c = prim_bbc[prim_indices[i]].bcentroid[axis];
-
- if((i < index_of_2nd_partition && c > mid) ||
- (i > index_of_2nd_partition && c < mid)) {
- printf("fail\n");
- }
- }
-}
-
static void grow_nodes(PBVH *bvh, int totnode)
{
if(totnode > bvh->node_mem_count) {
@@ -464,35 +450,34 @@
return;
}
+ /* Add two child nodes */
BB_reset(&bvh->nodes[node_index].vb);
bvh->nodes[node_index].children_offset = bvh->totnode;
grow_nodes(bvh, bvh->totnode + 2);
+ /* Update parent node bounding box */
+ for(i = offset + count - 1; i >= offset; --i) {
+ BB_expand_with_bb(&bvh->nodes[node_index].vb,
+ (BB*)(prim_bbc + bvh->prim_indices[i]));
+ }
+ bvh->nodes[node_index].orig_vb= bvh->nodes[node_index].vb;
+
+ /* Find axis with widest range of primitive centroids */
if(!cb) {
cb = &cb_backing;
BB_reset(cb);
for(i = offset + count - 1; i >= offset; --i)
BB_expand(cb, prim_bbc[bvh->prim_indices[i]].bcentroid);
}
-
axis = BB_widest_axis(cb);
- for(i = offset + count - 1; i >= offset; --i) {
- BB_expand_with_bb(&bvh->nodes[node_index].vb,
- (BB*)(prim_bbc + bvh->prim_indices[i]));
- }
-
- bvh->nodes[node_index].orig_vb= bvh->nodes[node_index].vb;
-
+ /* Partition primitives along that axis */
end = partition_indices(bvh->prim_indices, offset, offset + count - 1,
axis,
(cb->bmax[axis] + cb->bmin[axis]) * 0.5f,
prim_bbc);
- check_partitioning(bvh->prim_indices, offset, offset + count - 1,
- axis,
- (cb->bmax[axis] + cb->bmin[axis]) * 0.5f,
- prim_bbc, end);
+ /* Build children */
build_sub(bvh, bvh->nodes[node_index].children_offset, NULL,
prim_bbc, offset, end - offset);
build_sub(bvh, bvh->nodes[node_index].children_offset + 1, NULL,
More information about the Bf-blender-cvs
mailing list