Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r958 - trunk/Model/Groups


Chronological Thread 
  • From: boulos@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r958 - trunk/Model/Groups
  • Date: Fri, 24 Feb 2006 00:43:52 -0700 (MST)

Author: boulos
Date: Fri Feb 24 00:43:51 2006
New Revision: 958

Modified:
   trunk/Model/Groups/DynBVH.cc
Log:
Slight bugfixes.  For a simple 3200 polygon
dent model, the code is 3x faster than the 
previous BVHs for a zoomed in view.



Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Fri Feb 24 00:43:51 2006
@@ -4,6 +4,7 @@
 #include <float.h>
 using namespace Manta;
 
+// these constants control the SAH cost model
 const float BVH_C_isec = 10.f;
 const float BVH_C_trav = 10.f;
 
@@ -29,15 +30,16 @@
             // we need not create a subpacket to help it stop early
 
             // actually if we're just one ray it'll look more than it
-            // needs to... damn
+            // needs to since it will reintersect the firstActive ray... damn
             int lastActive = lastIntersects(node.bounds, rays);
 
-            // build a subpacket from firstActive to lastActive
-            RayPacket subpacket(rays, firstActive, lastActive);
+            // build a subpacket from firstActive to lastActive (inclusive, 
hence +1)
+            RayPacket subpacket(rays, firstActive, lastActive+1);
 
             for (int i = 0; i < node.children; i++ )
             {
                 const int object_id = object_ids[node.child+i];
+
                 this->get(object_id)->intersect(context,subpacket);
             }
         }
@@ -53,12 +55,15 @@
     }
 }
 
+// TODO: add interval arithmetic tests so that we can skip big portions? 
maybe collapse the
+// forward and backward search?
+
 // return the first index (between [rays.begin(),rays.end()]) which hits the 
box
 int DynBVH::firstIntersects(const BBox& box, const RayPacket& rays) const
 {
     for (int ray = rays.begin(); ray < rays.end(); ray++ )
     {
-        float maximum_minimum = 1e-4;
+        float maximum_minimum = 1e-5;
         float minimum_maximum = rays.getMinT(ray);
 
         float x_minimum = (box[rays.getSign(ray,0)][0]   - 
rays.getOrigin(ray,0)) * rays.getInverseDirection(ray,0);
@@ -97,7 +102,7 @@
 {
     for (int ray = rays.end() - 1; ray >= rays.begin(); ray-- )
     {
-        float maximum_minimum = 1e-4;
+        float maximum_minimum = 1e-5;
         float minimum_maximum = rays.getMinT(ray);
 
         float x_minimum = (box[rays.getSign(ray,0)][0]   - 
rays.getOrigin(ray,0)) * rays.getInverseDirection(ray,0);
@@ -141,7 +146,8 @@
         object_ids[i] = i;
 
     num_nodes = 1; // root node
-    build(context, 0, 0, this->getSize(), num_nodes);
+    int nextFree = 1;
+    build(context, 0, 0, this->getSize(), nextFree);
     updateBounds(context, 0);
 }
 
@@ -150,7 +156,7 @@
                    int& nextFree, int depth)
 {
 
-    if (objectBegin <= objectEnd)
+    if (objectEnd <= objectBegin)
     {
         printf("ERROR! Tried building BVH over 
%d,%d\n",objectBegin,objectEnd);
         exit(-1);




  • [MANTA] r958 - trunk/Model/Groups, boulos, 02/24/2006

Archive powered by MHonArc 2.6.16.

Top of page