Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1264 - in trunk: Interface scenes


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1264 - in trunk: Interface scenes
  • Date: Thu, 21 Dec 2006 09:31:23 -0700 (MST)

Author: bigler
Date: Thu Dec 21 09:31:22 2006
New Revision: 1264

Modified:
   trunk/Interface/RayPacket.cc
   trunk/Interface/RayPacket.h
   trunk/scenes/primtest.cc
Log:

Interface/RayPacket.cc

  In actualNormalizeDirections don't requery if the normals have
  already been computed.  This is done by the calling functions and
  breaks the convention of other actualXYZ functions.

  Always renormalize Hit positions for now.  HaveHitRecords is not
  currently being maintained.

  Recompute HaveInverseDirections if you normalize ray directions and
  the inverse directions were already computed.

  Add actualComputeInverseDirections function.

Interface/RayPacket.h

  Add actualComputeInverseDirections function.

scenes/primtest.cc

  Added ability to turn off background plane and optionally put it
  before all the geometry.  This fixes a bug with some of the
  primitives that call normalizeDirections.  There is still a bug
  which I'm tracking down.


Modified: trunk/Interface/RayPacket.cc
==============================================================================
--- trunk/Interface/RayPacket.cc        (original)
+++ trunk/Interface/RayPacket.cc        Thu Dec 21 09:31:22 2006
@@ -6,10 +6,7 @@
 
 void RayPacket::actualNormalizeDirections()
 {
-  if(flags & NormalizedDirections)
-    return;
-
-  if(flags & HaveHitRecords){
+  if(flags & HaveHitRecords || 1){
 #ifdef MANTA_SSE
     int b = (rayBegin + 3) & (~3);
     int e = rayEnd & (~3);
@@ -133,9 +130,44 @@
 #endif
   }
   flags |= NormalizedDirections;
-  flags &= ~HaveInverseDirections;
+
+  if (flags & HaveInverseDirections)
+    actualComputeInverseDirections();
 }
 
+void RayPacket::actualComputeInverseDirections()
+{
+#if MANTA_SSE
+  int b = (rayBegin + 3) & (~3);
+  int e = rayEnd & (~3);
+  if (b == e) {
+    for(int i=rayBegin;i<rayEnd;i++)
+      for(int j=0;j<3;j++)
+        data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
+  } else {
+    int i = rayBegin;
+    // Do the non aligned in front
+    for(;i<b;++i)
+      for(int j=0;j<3;j++)
+        data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
+    // Do the aligned in the middle
+    for(;i<e;i+=4)
+      for(int j=0;j<3;j++) {
+        _mm_store_ps(&data->inverseDirection[j][i],
+                     oneOver(_mm_load_ps(&data->direction[j][i])));
+      }
+    // Do the non aligned in end
+    for(;i<rayEnd;++i)
+      for(int j=0;j<3;j++)
+        data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
+  }
+#else
+  for(int i=rayBegin;i<rayEnd;i++)
+    for(int j=0;j<3;j++)
+      data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
+#endif
+  flags |= HaveInverseDirections;
+}
 
 void RayPacket::actualComputeHitPositions()
 {

Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Thu Dec 21 09:31:22 2006
@@ -334,36 +334,8 @@
     {
       if(flags & HaveInverseDirections)
         return;
-#if MANTA_SSE
-      int b = (rayBegin + 3) & (~3);
-      int e = rayEnd & (~3);
-      if (b == e) {
-        for(int i=rayBegin;i<rayEnd;i++)
-          for(int j=0;j<3;j++)
-            data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
-      } else {
-        int i = rayBegin;
-        // Do the non aligned in front
-        for(;i<b;++i)
-          for(int j=0;j<3;j++)
-            data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
-        // Do the aligned in the middle
-        for(;i<e;i+=4)
-          for(int j=0;j<3;j++) {
-            _mm_store_ps(&data->inverseDirection[j][i],
-                         oneOver(_mm_load_ps(&data->direction[j][i])));
-          }
-        // Do the non aligned in end
-        for(;i<rayEnd;++i)
-          for(int j=0;j<3;j++)
-            data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
-      }
-#else
-      for(int i=rayBegin;i<rayEnd;i++)
-        for(int j=0;j<3;j++)
-          data->inverseDirection[j][i] = (Real)1/data->direction[j][i];
-#endif
-      flags |= HaveInverseDirections;
+
+      actualComputeInverseDirections();
     }
     void computeSigns()
     {
@@ -816,6 +788,7 @@
 
   private:
     void actualNormalizeDirections();
+    void actualComputeInverseDirections();
     void actualComputeHitPositions();
     void actualComputeNormals(const RenderContext& context);
     void actualComputeFFNormals(const RenderContext& context);

Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc    (original)
+++ trunk/scenes/primtest.cc    Thu Dec 21 09:31:22 2006
@@ -73,6 +73,7 @@
   string imageName = "texture.tga";
   bool set_primtype = false;
   bool bgpoly = true;
+  bool bgpoly_first = false;
   int argc = static_cast<int>(args.size());
   for(int i=0;i<argc;i++){
     string arg = args[i];
@@ -97,6 +98,10 @@
     } else if(arg == "-image"){
       if(!getStringArg(i, args, imageName))
         throw IllegalArgument("scene primtest -image", i, args);
+    } else if(arg == "-nobgpoly"){
+      bgpoly = false;
+    } else if(arg == "-bgpolyfirst"){
+      bgpoly_first = true;
     } else {
       if(arg[0] == '-' || set_primtype) {
         cerr << "Valid options for scene primtest:\n";
@@ -111,9 +116,34 @@
   }
 
   Group* group = new Group();
+  int max = SCIRun::Max(numx, numy);
+
+
+  if(bgpoly && bgpoly_first){
+    Texture<Color>* tex = new CheckerTexture<Color>(Color(RGB(0.4, 0.4, 
0.4)),
+                                                    Color(RGB(0.2, 0.2, 
0.2)),
+                                                    Vector(1,0,0)*numx*2,
+                                                    Vector(0,1,0)*numy*2);
+    //    Material* bgmatl = new Lambertian(tex);
+    Material* bgmatl = new Phong(tex,
+                                 new Constant<Color>(Color(RGB(0.9, 0.9, 
0.9))),
+                                 32, NULL);
+
+    Vector anchor(-scale-1./max, -scale-1./max, -1.5/max);
+    Vector v1(scale*2+2./max, 0, 0);
+    Vector v2(0, scale*2+2./max, 0);
+#if 1
+    group->add(new Triangle(bgmatl, anchor, anchor+v1, anchor+v2));
+    group->add(new Triangle(bgmatl, anchor+v1+v2, anchor+v2, anchor+v1));
+#else
+    group->add(new Parallelogram(bgmatl, anchor, v1, v2));
+#endif
+  }
+  
+
+
   Material* matl;
   TexCoordMapper* mapr = 0;
-  int max = SCIRun::Max(numx, numy);
 
   if(material == "redphong")
     matl=new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
@@ -400,7 +430,7 @@
       throw IllegalArgument("Unknown array type for primtest: "+primtype, 0, 
args);
     }
   }
-  if(bgpoly){
+  if(bgpoly && !bgpoly_first){
     Texture<Color>* tex = new CheckerTexture<Color>(Color(RGB(0.4, 0.4, 
0.4)),
                                                     Color(RGB(0.2, 0.2, 
0.2)),
                                                     Vector(1,0,0)*numx*2,
@@ -413,7 +443,7 @@
     Vector anchor(-scale-1./max, -scale-1./max, -1.5/max);
     Vector v1(scale*2+2./max, 0, 0);
     Vector v2(0, scale*2+2./max, 0);
-#if 0
+#if 1
     group->add(new Triangle(bgmatl, anchor, anchor+v1, anchor+v2));
     group->add(new Triangle(bgmatl, anchor+v1+v2, anchor+v2, anchor+v1));
 #else




  • [MANTA] r1264 - in trunk: Interface scenes, bigler, 12/21/2006

Archive powered by MHonArc 2.6.16.

Top of page