Revision: 16309
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16309
Author:   unclezeiv
Date:     2008-08-30 17:12:10 +0200 (Sat, 30 Aug 2008)

Log Message:
-----------
Minor code refactoring.

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c

Modified: 
branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 
2008-08-30 14:32:16 UTC (rev 16308)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 
2008-08-30 15:12:10 UTC (rev 16309)
@@ -396,23 +396,26 @@
 }
 
 /* this one uses kd tree */
-static void find_and_insert_new_min2(Heap * heap, KDTree * tree, KDTreeNearest 
*nearest, LightcutsCluster * array, LightcutsClusterPair * pair, int id, float 
c)
+static void find_and_insert_new_min2(Heap * heap, KDTree * tree, KDTreeNearest 
*nearest, KDSearchCallbackData *data, LightcutsClusterPair * pair, int id)
 {
-       LightcutsCluster *one= &array[id];
-       KDSearchCallbackData data= {c, 0.0f, one, array};
+       LightcutsCluster *one= &data->array[id];
        int other;
        
+       data->one= one;
+       
        if (one->type == CLUSTER_SPOT) {
                float cos_a= cosf(one->cone_angle);
                cos_a= MAX2(0.0f, cos_a);
-               data.mindir= (1 - cos_a) * (1 - cos_a) * c;
+               data->mindir= (1 - cos_a) * (1 - cos_a) * data->c;
        }
+       else
+               data->mindir= 0.0f;
        
-       other= BLI_kdtree_find_callback(tree, one->lar->co, NULL, one->id, 
cb_update_metric_max_dist, &data, nearest);
+       other= BLI_kdtree_find_callback(tree, one->lar->co, NULL, one->id, 
cb_update_metric_max_dist, data, nearest);
        
        if (other != -1)
        {
-               float metric= lightcuts_compute_metric(c, one, &array[other]);
+               float metric= lightcuts_compute_metric(data->c, one, 
&data->array[other]);
                pair->first = id;
                pair->second = other;
 
@@ -643,6 +646,8 @@
        
        KDTree* kdtree = BLI_kdtree_new(tree->counter);
        KDTreeNearest *nearest= MEM_callocN(sizeof(KDTreeNearest) * 
tree->counter, "kdtreenearest");
+       
+       KDSearchCallbackData data= {c, 0.0f, NULL, array};
 
 #ifdef LIGHTCUTS_DEBUG
        if (print_times)
@@ -686,7 +691,7 @@
                
        for (i = 0; i < tree->counter; i++)
                if (array[i].type != CLUSTER_EMPTY)
-                       find_and_insert_new_min2(heap, kdtree, nearest, array, 
&pair_array[i], i, c);
+                       find_and_insert_new_min2(heap, kdtree, nearest, &data, 
&pair_array[i], i);
 
        /* now we have a nice heap with shortest metric for each element */
        /* heap size = N (number of lights) - 1, and it doesn't grow */
@@ -702,7 +707,7 @@
 
                /* we look for another minimum */
                if (in_tree2) {
-                       find_and_insert_new_min2(heap, kdtree, nearest, array, 
minpair, minpair->first, c);
+                       find_and_insert_new_min2(heap, kdtree, nearest, &data, 
minpair, minpair->first);
                        continue;
                }
 
@@ -720,7 +725,7 @@
                }
 
                /* new search, avoid considering in_tree children */
-               find_and_insert_new_min2(heap, kdtree, nearest, array, minpair, 
cluster_id, c);
+               find_and_insert_new_min2(heap, kdtree, nearest, &data, minpair, 
cluster_id);
        }
 
        BLI_heap_free(heap, 0);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to