Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r281 - in branches/newPointVector: Core/Geometry Model/Groups Model/Instances Model/MiscObjects Model/Primitives


Chronological Thread 
  • From: sparker@sci.utah.edu
  • To: rtrt@sci.utah.edu
  • Subject: [MANTA] r281 - in branches/newPointVector: Core/Geometry Model/Groups Model/Instances Model/MiscObjects Model/Primitives
  • Date: Tue, 10 May 2005 21:49:23 -0600 (MDT)

Author: sparker
Date: Tue May 10 21:49:12 2005
New Revision: 281

Modified:
   branches/newPointVector/Core/Geometry/BBox.h
   branches/newPointVector/Model/Groups/BVH.cc
   branches/newPointVector/Model/Instances/Instance.cc
   branches/newPointVector/Model/Instances/InstanceRST.cc
   branches/newPointVector/Model/Instances/InstanceRT.cc
   branches/newPointVector/Model/Instances/InstanceST.cc
   branches/newPointVector/Model/Instances/InstanceT.cc
   branches/newPointVector/Model/MiscObjects/Intersection.cc
   branches/newPointVector/Model/Primitives/Cone.cc
   branches/newPointVector/Model/Primitives/Cube.cc
   branches/newPointVector/Model/Primitives/Parallelogram.cc
   branches/newPointVector/Model/Primitives/Sphere.cc
   branches/newPointVector/Model/Primitives/SuperEllipsoid.cc
   branches/newPointVector/Model/Primitives/Triangle.cc
Log:
Added extend method to bbox.  Clarified methods - they are now:
 - extendByPoint
 - extendBySphere
 - extendByDisc
Added getCorner to box to simplify instance box projections


Modified: branches/newPointVector/Core/Geometry/BBox.h
==============================================================================
--- branches/newPointVector/Core/Geometry/BBox.h        (original)
+++ branches/newPointVector/Core/Geometry/BBox.h        Tue May 10 21:49:12 
2005
@@ -20,14 +20,19 @@
       return Interpolate(min, max, 0.5);
     }
 
-    void extend(const Point& p) {
+    void extendByPoint(const Point& p) {
       min = Min(min, p);
       max = Max(max, p);
     }
-    void extend(const Point& p, Real radius) {
+    void extendBySphere(const Point& p, Real radius) {
       min = Min(min, p-Vector(radius, radius, radius));
       max = Max(max, p+Vector(radius, radius, radius));
     }
+    void extendByDisc(const Point& p, const Vector& n, Real radius) {
+      Vector v(sqrt(1-p.x()*p.x()), sqrt(1-p.y()*p.y()), 
sqrt(1-p.z()*p.z()));
+      min = Min(min, p-v*radius);
+      max = Max(max, p+v*radius);
+    }
 
     const Point& getMin() const {
       return min;
@@ -36,12 +41,11 @@
       return max;
     }
 
-        // Bracket operator to min and max.
-        const Point& operator[] (unsigned int i) {
-               if (i==0) return min;
-               else      return max;
-        }
-        
+    Point getCorner(int i) const {
+      return Point(i&4?min.x():max.x(),
+                   i&2?min.y():max.y(),
+                   i&1?min.z():max.z());
+    }
   private:
     BBox(const BBox&);
     BBox& operator=(const BBox&);

Modified: branches/newPointVector/Model/Groups/BVH.cc
==============================================================================
--- branches/newPointVector/Model/Groups/BVH.cc (original)
+++ branches/newPointVector/Model/Groups/BVH.cc Tue May 10 21:49:12 2005
@@ -85,14 +85,14 @@
     for(int i=nprims-1;i>=1;i--){
       BBox box;
       if(nodes[i].left > 0){
-        box.extend(nodes[nodes[i].left].min);
-        box.extend(nodes[nodes[i].left].max);
+        box.extendByPoint(nodes[nodes[i].left].min);
+        box.extendByPoint(nodes[nodes[i].left].max);
       } else {
         objs[-nodes[i].left]->computeBounds(context, box);
       }
       if(nodes[i].right > 0){
-        box.extend(nodes[nodes[i].right].min);
-        box.extend(nodes[nodes[i].right].max);
+        box.extendByPoint(nodes[nodes[i].right].min);
+        box.extendByPoint(nodes[nodes[i].right].max);
       } else {
         objs[-nodes[i].right]->computeBounds(context, box);
       }

Modified: branches/newPointVector/Model/Instances/Instance.cc
==============================================================================
--- branches/newPointVector/Model/Instances/Instance.cc (original)
+++ branches/newPointVector/Model/Instances/Instance.cc Tue May 10 21:49:12 
2005
@@ -35,14 +35,8 @@
   instance->computeBounds(context, ibox);
 
   // Transform the eight corners of the child bounding box
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
+  for(int i=0;i<8;i++)
+    bbox.extendByPoint(transform * ibox.getCorner(i));
 }
 
 void Instance::intersect(const RenderContext& context, RayPacket& rays) const

Modified: branches/newPointVector/Model/Instances/InstanceRST.cc
==============================================================================
--- branches/newPointVector/Model/Instances/InstanceRST.cc      (original)
+++ branches/newPointVector/Model/Instances/InstanceRST.cc      Tue May 10 
21:49:12 2005
@@ -51,14 +51,8 @@
   instance->computeBounds(context, ibox);
 
   // Transform the eight corners of the child bounding box
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
+  for(int i=0;i<8;i++)
+    bbox.extendByPoint(transform * ibox.getCorner(i));
 }
 
 void InstanceRST::intersect(const RenderContext& context, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/Instances/InstanceRT.cc
==============================================================================
--- branches/newPointVector/Model/Instances/InstanceRT.cc       (original)
+++ branches/newPointVector/Model/Instances/InstanceRT.cc       Tue May 10 
21:49:12 2005
@@ -50,15 +50,8 @@
   instance->computeBounds(context, ibox);
 
   // Transform the eight corners of the child bounding box
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMin()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMin()[1], 
ibox.getMax()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMin()[2]));
-  bbox.extend(transform * Point(ibox.getMax()[0], ibox.getMax()[1], 
ibox.getMax()[2]));
-  
+  for(int i=0;i<8;i++)
+    bbox.extendByPoint(transform * ibox.getCorner(i));
 }
 
 void InstanceRT::intersect(const RenderContext& context, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/Instances/InstanceST.cc
==============================================================================
--- branches/newPointVector/Model/Instances/InstanceST.cc       (original)
+++ branches/newPointVector/Model/Instances/InstanceST.cc       Tue May 10 
21:49:12 2005
@@ -32,8 +32,8 @@
 {
   BBox ibox;
   instance->computeBounds(context, ibox);
-  bbox.extend(Point(Vector(ibox.getMin())*scale)+translation);
-  bbox.extend(Point(Vector(ibox.getMax())*scale)+translation);
+  bbox.extendByPoint(Point(Vector(ibox.getMin())*scale)+translation);
+  bbox.extendByPoint(Point(Vector(ibox.getMax())*scale)+translation);
 }
 
 void InstanceST::intersect(const RenderContext& context, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/Instances/InstanceT.cc
==============================================================================
--- branches/newPointVector/Model/Instances/InstanceT.cc        (original)
+++ branches/newPointVector/Model/Instances/InstanceT.cc        Tue May 10 
21:49:12 2005
@@ -26,8 +26,8 @@
 {
   BBox ibox;
   instance->computeBounds(context, ibox);
-  bbox.extend(ibox.getMin()+translation);
-  bbox.extend(ibox.getMax()+translation);
+  bbox.extendByPoint(ibox.getMin()+translation);
+  bbox.extendByPoint(ibox.getMax()+translation);
 }
 
 void InstanceT::intersect(const RenderContext& context, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/MiscObjects/Intersection.cc
==============================================================================
--- branches/newPointVector/Model/MiscObjects/Intersection.cc   (original)
+++ branches/newPointVector/Model/MiscObjects/Intersection.cc   Tue May 10 
21:49:12 2005
@@ -26,8 +26,8 @@
   object1->computeBounds(context, ibox1);
   BBox ibox2;
   object2->computeBounds(context, ibox2);
-  bbox.extend(Max(ibox1.getMin(), ibox2.getMin()));
-  bbox.extend(Min(ibox1.getMax(), ibox2.getMax()));
+  bbox.extendByPoint(Max(ibox1.getMin(), ibox2.getMin()));
+  bbox.extendByPoint(Min(ibox1.getMax(), ibox2.getMax()));
 }
 
 void Intersection::intersect(const RenderContext& context, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/Primitives/Cone.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/Cone.cc    (original)
+++ branches/newPointVector/Model/Primitives/Cone.cc    Tue May 10 21:49:12 
2005
@@ -20,8 +20,8 @@
 {
   Vector axis(top-bottom);
   axis.normalize();
-  bbox.extend_disc(bottom, axis, Rb);
-  bbox.extend_disc(top, axis, Rt);
+  bbox.extendByDisc(bottom, axis, Rb);
+  bbox.extendByDisc(top, axis, Rt);
 }
 
 void Cone::intersect(const RenderContext&, RayPacket& rays) const

Modified: branches/newPointVector/Model/Primitives/Cube.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/Cube.cc    (original)
+++ branches/newPointVector/Model/Primitives/Cube.cc    Tue May 10 21:49:12 
2005
@@ -7,8 +7,6 @@
 using namespace Manta;
 using namespace std;
 using SCIRun::Abs;
-using SCIRun::Max;
-using SCIRun::Min;
 
 Cube::Cube(Material* mat, const Point& anch, double w, double h, double d)
   : PrimitiveCommon(mat), anchor(anch), w(w), h(h), d(d)
@@ -24,12 +22,14 @@
 
 void Cube::computeBounds(const PreprocessContext&, BBox& bbox) const
 {
-  bbox.extend(Point(xmin, ymin, zmin));
-  bbox.extend(Point(xmax, ymax, zmax));
+  bbox.extendByPoint(Point(xmin, ymin, zmin));
+  bbox.extendByPoint(Point(xmax, ymax, zmax));
 }
 
 void Cube::intersect(const RenderContext&, RayPacket& rays) const
 {  
+  using SCIRun::Max;
+  using SCIRun::Min;
   rays.computeInverseDirections();
   if(rays.getFlags() & RayPacket::ConstantOrigin && rays.getSize()>1) {
     RayPacket::Element& e0 = rays.get(0);
@@ -66,8 +66,8 @@
        t1 = t2;
        t2 = temp;
       }
-      tnear = max(t1, tnear);
-      tfar = min(t2, tfar);
+      tnear = Max(t1, tnear);
+      tfar = Min(t2, tfar);
 
       if(tnear <= tfar)
        e.hitInfo.hit(tnear, material, this, tex);
@@ -107,8 +107,8 @@
        t1 = t2;
        t2 = temp;
       }
-      tnear = max(t1, tnear);
-      tfar = min(t2, tfar);
+      tnear = Max(t1, tnear);
+      tfar = Min(t2, tfar);
 
       if(tnear <= tfar)
        e.hitInfo.hit(tnear, material, this, tex);

Modified: branches/newPointVector/Model/Primitives/Parallelogram.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/Parallelogram.cc   (original)
+++ branches/newPointVector/Model/Primitives/Parallelogram.cc   Tue May 10 
21:49:12 2005
@@ -28,10 +28,10 @@
   // v1 and v2 are stored with an inverse length to avoid extra
   // computation in the intersect routine, but we must divide that
   // out here.
-  bbox.extend(anchor);
-  bbox.extend(anchor+v1/v1.length2());
-  bbox.extend(anchor+v2/v2.length2());
-  bbox.extend(anchor+v1/v1.length2()+v2/v2.length2());
+  bbox.extendByPoint(anchor);
+  bbox.extendByPoint(anchor+v1/v1.length2());
+  bbox.extendByPoint(anchor+v2/v2.length2());
+  bbox.extendByPoint(anchor+v1/v1.length2()+v2/v2.length2());
 }
 
 void Parallelogram::computeNormal(const RenderContext&, RayPacket& rays) 
const

Modified: branches/newPointVector/Model/Primitives/Sphere.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/Sphere.cc  (original)
+++ branches/newPointVector/Model/Primitives/Sphere.cc  Tue May 10 21:49:12 
2005
@@ -20,7 +20,7 @@
 
 void Sphere::computeBounds(const PreprocessContext&, BBox& bbox) const
 {
-  bbox.extend(center, radius);
+  bbox.extendBySphere(center, radius);
 }
 
 void Sphere::intersect(const RenderContext&, RayPacket& rays) const

Modified: branches/newPointVector/Model/Primitives/SuperEllipsoid.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/SuperEllipsoid.cc  (original)
+++ branches/newPointVector/Model/Primitives/SuperEllipsoid.cc  Tue May 10 
21:49:12 2005
@@ -73,7 +73,7 @@
     PreprocessContext const &,
     BBox &bbox ) const
 {
-  bbox.extend( center, radius );
+  bbox.extendBySphere( center, radius );
 }
 
 void SuperEllipsoid::intersect(const RenderContext&, RayPacket& rays) const

Modified: branches/newPointVector/Model/Primitives/Triangle.cc
==============================================================================
--- branches/newPointVector/Model/Primitives/Triangle.cc        (original)
+++ branches/newPointVector/Model/Primitives/Triangle.cc        Tue May 10 
21:49:12 2005
@@ -29,9 +29,9 @@
 
 void Triangle::computeBounds(const PreprocessContext&, BBox& bbox) const
 {
-  bbox.extend(a);
-  bbox.extend(b);
-  bbox.extend(c);
+  bbox.extendByPoint(a);
+  bbox.extendByPoint(b);
+  bbox.extendByPoint(c);
 }
 
 void Triangle::intersect(const RenderContext&, RayPacket& rays) const




  • [MANTA] r281 - in branches/newPointVector: Core/Geometry Model/Groups Model/Instances Model/MiscObjects Model/Primitives, sparker, 05/10/2005

Archive powered by MHonArc 2.6.16.

Top of page