Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2160 - trunk/Model/Groups


Chronological Thread 
  • From: "Solomon Boulos" <boulos@cs.utah.edu>
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2160 - trunk/Model/Groups
  • Date: Tue, 1 Apr 2008 16:33:12 -0600 (MDT)

Author: boulos
Date: Tue Apr  1 16:33:11 2008
New Revision: 2160

Modified:
   trunk/Model/Groups/DynBVH.cc
   trunk/Model/Groups/DynBVH.h
Log:
Model/Groups/DynBVH.cc
Model/Groups/DynBVH.h

 Still hunting the bizarre differences between full build and
 approximate build. DynBVH::printNode is designed to help with this
 (FileMerge allows me to do diff BVHs easily)

 Adding num_nodes to BVH info output.


Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Tue Apr  1 16:33:11 2008
@@ -60,6 +60,26 @@
   fclose(output);
 }
 
+void
+DynBVH::printNode(int nodeID, int depth) const {
+  BVHNode& node = nodes[nodeID];
+
+  std::string indent;
+  for (int i = 0; i < depth; i++) {
+    indent += "  ";
+  }
+
+  cerr << indent << "NodeID = " << nodeID;
+
+  if (node.isLeaf()) {
+    cerr << " LEAF w/ " << node.children << " children.\n";
+  } else {
+    cerr << " INTR w/ bounds " << node.bounds << endl;
+    printNode(node.child+0, depth+1);
+    printNode(node.child+1, depth+1);
+  }
+}
+
 DynBVH::~DynBVH()
 {
   //  cerr << MANTA_FUNC << " called.\n";
@@ -719,6 +739,7 @@
     // Call rebuild (may call update underneath)
 #if !(USE_LAZY_BUILD)
     rebuild(context.proc, context.numProcs);
+    //printNode(0, 0);
 #endif
 
     // NOTE(boulos): We allow rebuild to set the group_changed flag so
@@ -1304,7 +1325,7 @@
   task->finished();
 }
 
-int DynBVH::partitionObjects(int objBegin, int objEnd, int axis, float 
position, BBox& left_bounds, BBox& right_bounds) const {
+inline int DynBVH::partitionObjects(int objBegin, int objEnd, int axis, 
float position, BBox& left_bounds, BBox& right_bounds) const {
   //cerr << MANTA_FUNC << " begin = " << objBegin << ", end = " << objEnd << 
endl;
   int first = objBegin;
   int last  = objEnd;
@@ -1329,6 +1350,8 @@
       // NOTE(boulos): The bounds can't be computed during the
       // partitioning because the order is changing all over the
       // place.
+      left_bounds.reset();
+      right_bounds.reset();
       for (int i = objBegin; i < first; i++) {
         left_bounds.extendByBox(obj_bounds[object_ids[i]]);
       }
@@ -1601,7 +1624,9 @@
          << "object_ids initialization ("<<build_start-start<<")\n"
          << "build ("<<updateBound_start-build_start<<")\n"
          << "updateBounds ("<<end-updateBound_start<<")\n"
+         << "num_nodes = " << num_nodes << "\n"
          << "BBox = ("<<nodes[0].bounds.getMin()<<", 
"<<nodes[0].bounds.getMax()<<")\n\n";
+
   }
 
   // NOTE(boulos): As of 17-Aug-2007 we don't have a parallel build so
@@ -1809,17 +1834,27 @@
     return -1;
   }
 
+#if 1
+  // NOTE(boulos): Changing this to BBox& results in a completely
+  // different tree... When BVH_num_samples is higher on the bunny
+  // using BBox instead of BBox& produces slowdowns at each step. Using 
BBox& with lots of inlining produces
+  BBox& overall_bounds = nodes[nodeID].bounds;
+#else
+  BBox overall_bounds;
+  for (int i = objBegin; i < objEnd; i++) {
+    overall_bounds.extendByBox(obj_bounds[object_ids[i]]);
+  }
+#endif
+  float inv_overall_area = 1.f/overall_bounds.computeArea();
+
   BVHCostEval best_cost;
   best_cost.cost = BVH_C_isec * num_objects;
   best_cost.axis = -1;
   best_cost.position = FLT_MAX;
   best_cost.event = -1;
 
-  BBox& overall_bounds = nodes[nodeID].bounds;
-  float inv_overall_area = 1.f/overall_bounds.computeArea();
-
   struct SampleBin {
-    SampleBin() { count = 0; }
+    SampleBin() { count = 0;}
     BBox bounds;
     int count;
   };

Modified: trunk/Model/Groups/DynBVH.h
==============================================================================
--- trunk/Model/Groups/DynBVH.h (original)
+++ trunk/Model/Groups/DynBVH.h Tue Apr  1 16:33:11 2008
@@ -122,6 +122,8 @@
 
     void allocate() const;
 
+    void printNode(int nodeID, int depth) const;
+
     void performUpdate(const UpdateContext& context);
     void finishUpdate(TaskList* list, UpdateContext context);
 




  • [Manta] r2160 - trunk/Model/Groups, Solomon Boulos, 04/01/2008

Archive powered by MHonArc 2.6.16.

Top of page