Raytrace: only print debug info when running with -d option.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 12 Jan 2010 19:45:01 +0000 (19:45 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 12 Jan 2010 19:45:01 +0000 (19:45 +0000)
source/blender/render/intern/include/rayobject.h
source/blender/render/intern/raytrace/rayobject_vbvh.cpp
source/blender/render/intern/raytrace/reorganize.h
source/blender/render/intern/raytrace/svbvh.h
source/blender/render/intern/source/rayshade.c

index 5579f3896c115752f84ffe78a2a150c8376b8cf6..309048d8efbb928e396743d826c1131d0bb91174 100644 (file)
@@ -181,7 +181,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c);
 #include <time.h>
 
 #define BENCH(a,name)  \
-       do {                    \
+       {                       \
                double _t1, _t2;                                \
                struct timeval _tstart, _tend;  \
                clock_t _clock_init = clock();  \
@@ -191,7 +191,7 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *c);
                _t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 );    \
                _t2 = ( double )   _tend.tv_sec + ( double )   _tend.tv_usec/ ( 1000*1000 );    \
                printf("BENCH:%s: %fs (real) %fs (cpu)\n", #name, _t2-_t1, (float)(clock()-_clock_init)/CLOCKS_PER_SEC);\
-       } while(0)
+       }
 #else
 
 #define BENCH(a,name)  (a)
index 4a2a56fa8ef122a38afe995e0258590ae97ace91..6185be324d6090d8b5350c4bc74c9883c71abace 100644 (file)
@@ -37,6 +37,7 @@ int tot_hints    = 0;
 #include "RE_raytrace.h"
 #include "BLI_memarena.h"
 #include "MEM_guardedalloc.h"
+#include "BKE_global.h"
 #include "BKE_utildefines.h"
 #include "BLI_math.h"
 
@@ -145,10 +146,13 @@ void bfree(VBVHTree *tree)
 {
        if(tot_pushup + tot_pushdown + tot_hints + tot_moves)
        {
-               printf("tot pushups: %d\n", tot_pushup);
-               printf("tot pushdowns: %d\n", tot_pushdown);
-               printf("tot moves: %d\n", tot_moves);
-               printf("tot hints created: %d\n", tot_hints);
+               if(G.f & G_DEBUG) {
+                       printf("tot pushups: %d\n", tot_pushup);
+                       printf("tot pushdowns: %d\n", tot_pushdown);
+                       printf("tot moves: %d\n", tot_moves);
+                       printf("tot hints created: %d\n", tot_hints);
+               }
+
                tot_pushup = 0;
                tot_pushdown = 0;
                tot_hints = 0;
index 7b14108760a2bb3954fe02c5eca20d4cbeaf7297..845f53605a855403a2a3e9a3db1871cbc9215b82 100644 (file)
@@ -32,6 +32,8 @@
 #include <vector>
 #include <queue>
 
+#include "BKE_global.h"
+
 #ifdef _WIN32
 #define INFINITY FLT_MAX // in mingw math.h: (1.0F/0.0F). This generates compile error, though.
 #endif
@@ -515,7 +517,7 @@ struct VBVH_optimalPackSIMD
                        if(num == 0) { num++; first = true; }
                        
                        calc_costs(node);
-                       if(first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize );
+                       if((G.f & G_DEBUG) && first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize );
                        node->optimize();
                }
                return node;            
index 80e6e2ea190f4b4bf1a3b10715e17981d0ce3097..873f44d6d66488855d11ffc88d0b4bde138dde53 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "bvh.h"
 #include "BLI_memarena.h"
+#include "BKE_global.h"
 #include <stdio.h>
 #include <algorithm>
 
@@ -142,10 +143,12 @@ struct Reorganize_SVBVH
        
        ~Reorganize_SVBVH()
        {
-               printf("%f childs per node\n", childs_per_node / nodes);
-               printf("%d childs BB are useless\n", useless_bb);
-               for(int i=0; i<16; i++)
-                       printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes,  nodes_with_childs[i]/float(nodes));
+               if(G.f & G_DEBUG) {
+                       printf("%f childs per node\n", childs_per_node / nodes);
+                       printf("%d childs BB are useless\n", useless_bb);
+                       for(int i=0; i<16; i++)
+                               printf("%i childs per node: %d/%d = %f\n", i, nodes_with_childs[i], nodes,  nodes_with_childs[i]/float(nodes));
+               }
        }
        
        SVBVHNode *create_node(int nchilds)
index 9fa23c73ec60a74903edad892b849c07bc30b8c8..36284e7919db0087373eda132fa7c5ed266f6a2b 100644 (file)
@@ -435,7 +435,12 @@ void makeraytree(Render *re)
        if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE)
                re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS);
 
-       BENCH(makeraytree_single(re), tree_build);
+       if(G.f & G_DEBUG) {
+               BENCH(makeraytree_single(re), tree_build);
+       }
+       else
+               makeraytree_single(re);
+
        if(test_break(re))
        {
                freeraytree(re);