merge with trunk at r31523
[blender.git] / source / blender / render / intern / raytrace / reorganize.h
index 7ef7296945c24315d305d36581ce2bb67340459a..f4cd3a4330d4b1ac23c8434ba068ccc87476ee42 100644 (file)
@@ -27,8 +27,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 #include <stdio.h>
  * ***** END GPL LICENSE BLOCK *****
  */
 #include <stdio.h>
-#include <algorithm>
 #include <math.h>
 #include <math.h>
+#include <algorithm>
 #include <vector>
 #include <queue>
 
 #include <vector>
 #include <queue>
 
@@ -168,7 +168,7 @@ void pushup(Node *parent)
        {
                float c_area = bb_area(child->bb, child->bb+3) ;
                int nchilds = count_childs(child);
        {
                float c_area = bb_area(child->bb, child->bb+3) ;
                int nchilds = count_childs(child);
-               float original_cost = ((p_area != 0.0f)? (c_area / p_area)*nchilds: 1.0f) + 1;
+               float original_cost = (c_area / p_area)*nchilds + 1;
                float flatten_cost = nchilds;
                if(flatten_cost < original_cost && nchilds >= 2)
                {
                float flatten_cost = nchilds;
                if(flatten_cost < original_cost && nchilds >= 2)
                {
@@ -299,6 +299,7 @@ float bvh_refit(Node *node)
  * with the purpose to reduce the expected cost (eg.: number of BB tests).
  */
 #include <vector>
  * with the purpose to reduce the expected cost (eg.: number of BB tests).
  */
 #include <vector>
+#include <cmath>
 #define MAX_CUT_SIZE   16
 #define MAX_OPTIMIZE_CHILDS    MAX_CUT_SIZE
 
 #define MAX_CUT_SIZE   16
 #define MAX_OPTIMIZE_CHILDS    MAX_CUT_SIZE
 
@@ -406,7 +407,7 @@ struct VBVH_optimalPackSIMD
                                for(Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling)
                                {
                                        this->child[nchilds] = child;
                                for(Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling)
                                {
                                        this->child[nchilds] = child;
-                                       this->child_hit_prob[nchilds] = (parent_area != 0.0f)? bb_area(child->bb, child->bb+3) / parent_area: 1.0f;
+                                       this->child_hit_prob[nchilds] = bb_area(child->bb, child->bb+3) / parent_area;
                                        nchilds++;
                                }
 
                                        nchilds++;
                                }
 
@@ -476,7 +477,7 @@ struct VBVH_optimalPackSIMD
                                float parent_area = bb_area(node->bb, node->bb+3);
                                for(Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling)
                                {
                                float parent_area = bb_area(node->bb, node->bb+3);
                                for(Node *child = node->child; child && RE_rayobject_isAligned(child); child = child->sibling)
                                {
-                                       cost += ((parent_area != 0.0f)? ( bb_area(child->bb, child->bb+3) / parent_area ): 1.0f) * child->get_cost(1);
+                                       cost += ( bb_area(child->bb, child->bb+3) / parent_area ) * child->get_cost(1);
                                }
                                
                                cost += testcost(nchilds);
                                }
                                
                                cost += testcost(nchilds);