[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21490] branches/soc-2009-jaguarandi/ source/blender/render/intern/source/rayobject_bvh.c: Cost of a BVH is calculated using SA(child)/SA(parent)

André Pinto andresusanopinto at gmail.com
Fri Jul 10 17:33:35 CEST 2009


Revision: 21490
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21490
Author:   jaguarandi
Date:     2009-07-10 17:33:35 +0200 (Fri, 10 Jul 2009)

Log Message:
-----------
Cost of a BVH is calculated using SA(child)/SA(parent)
Although tests didnt showed this to be clearly superior to: cost(bvh) = log(size)

Modified Paths:
--------------
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c	2009-07-10 14:46:52 UTC (rev 21489)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_bvh.c	2009-07-10 15:33:35 UTC (rev 21490)
@@ -407,17 +407,22 @@
 		parent->split_axis = builder->split_axis;
 		for(i=0; i<nc; i++)
 		{
+			float cbb[6];
 			float tcost;
 			parent->child[i] = bvh_rearrange( tree, rtbuild_get_child(builder, i, &tmp), child_id(nid,i), &tcost );
-			bvh_merge_bb(parent->child[i], parent->bb, parent->bb+3);
 			
-			*cost += tcost;
+			INIT_MINMAX(cbb, cbb+3);
+			bvh_merge_bb(parent->child[i], cbb, cbb+3);
+			DO_MIN(cbb,   parent->bb);
+			DO_MAX(cbb+3, parent->bb+3);
+			
+			*cost += tcost*bb_area(cbb, cbb+3);
 		}
 		for(; i<BVH_NCHILDS; i++)
 			parent->child[i] = 0;
 
-		*cost /= nc*bb_area(parent->bb, parent->bb+3);
-		*cost += RAY_BB_TEST_COST;
+		*cost /= bb_area(parent->bb, parent->bb+3);
+		*cost += nc*RAY_BB_TEST_COST;
 		return parent;
 	}
 }
@@ -458,7 +463,7 @@
 	
 	obj->root = bvh_rearrange( obj, obj->builder, 1, &obj->cost );
 //	obj->cost = 1.0;
-	obj->cost = logf( rtbuild_size( obj->builder ) );
+//	obj->cost = logf( rtbuild_size( obj->builder ) );
 	
 #ifndef DYNAMIC_ALLOC
 	assert(obj->node_alloc+needed_nodes >= obj->node_next);





More information about the Bf-blender-cvs mailing list