Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r570 - in trunk: Core/Geometry Model/Primitives scenes


Chronological Thread 
  • From: aek@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r570 - in trunk: Core/Geometry Model/Primitives scenes
  • Date: Mon, 26 Sep 2005 17:22:17 -0600 (MDT)

Author: aek
Date: Mon Sep 26 17:22:17 2005
New Revision: 570

Modified:
   trunk/Core/Geometry/BBox.h
   trunk/Model/Primitives/ParticleBVH.cc
   trunk/Model/Primitives/ParticleBVH.h
   trunk/scenes/ParticleBVHTest.cc
Log:
* Added an option to ParticleBVHTest for a default radius to use if none is
  provided in the file.
* Fixed error in longestAxis() method in BBox.
* Fixed float/double confusion in ParticleBVH



Modified: trunk/Core/Geometry/BBox.h
==============================================================================
--- trunk/Core/Geometry/BBox.h  (original)
+++ trunk/Core/Geometry/BBox.h  Mon Sep 26 17:22:17 2005
@@ -96,7 +96,7 @@
       if ( lenx > leny )
           return lenx > lenz ? 0 : 2;
       else
-          return lenx > lenz ? 1 : 2;
+          return leny > lenz ? 1 : 2;
     }
 
   private:

Modified: trunk/Model/Primitives/ParticleBVH.cc
==============================================================================
--- trunk/Model/Primitives/ParticleBVH.cc       (original)
+++ trunk/Model/Primitives/ParticleBVH.cc       Mon Sep 26 17:22:17 2005
@@ -36,7 +36,7 @@
   int first,
   int last,
   int const axis,
-  float const position )
+  double const position )
 {
   --first;
   for ( ; ; ) {
@@ -71,7 +71,7 @@
     return size;
   }
   int axis = node.bound.longestAxis();
-  float position = ( node.bound.getMin()[ axis ] + node.bound.getMax()[ axis 
] ) * 0.5f;
+  double position = ( node.bound.getMin()[ axis ] + node.bound.getMax()[ 
axis ] ) * 0.5;
   int split = partition( first, last, axis, position );
   if ( split == first || split == last ) {
     node.index = first;
@@ -108,20 +108,20 @@
   RayPacket &rays,
   BBox const &box ) const
 {
-  float bound[ 6 ];
+  double bound[ 6 ];
   bound[ 0 ] = box.getMin().x(); bound[ 1 ] = box.getMax().x();
   bound[ 2 ] = box.getMin().y(); bound[ 3 ] = box.getMax().y();
   bound[ 4 ] = box.getMin().z(); bound[ 5 ] = box.getMax().z();
   for ( int ray = 0; ray < rays.getSize(); ++ray ) {
     RayPacket::Element &element( rays.get( ray ) );
-    float maximum_minimum = T_EPSILON;
-    float minimum_maximum = element.hitInfo.minT();
-    float x_minimum = ( bound[     element.sign[ 0 ] ] - 
element.ray.origin().x() ) * element.inverseDirection.x();
-    float x_maximum = ( bound[ 1 - element.sign[ 0 ] ] - 
element.ray.origin().x() ) * element.inverseDirection.x();
-    float y_minimum = ( bound[ 2 + element.sign[ 1 ] ] - 
element.ray.origin().y() ) * element.inverseDirection.y();
-    float y_maximum = ( bound[ 3 - element.sign[ 1 ] ] - 
element.ray.origin().y() ) * element.inverseDirection.y();
-    float z_minimum = ( bound[ 4 + element.sign[ 2 ] ] - 
element.ray.origin().z() ) * element.inverseDirection.z();
-    float z_maximum = ( bound[ 5 - element.sign[ 2 ] ] - 
element.ray.origin().z() ) * element.inverseDirection.z();
+    double maximum_minimum = T_EPSILON;
+    double minimum_maximum = element.hitInfo.minT();
+    double x_minimum = ( bound[     element.sign[ 0 ] ] - 
element.ray.origin().x() ) * element.inverseDirection.x();
+    double x_maximum = ( bound[ 1 - element.sign[ 0 ] ] - 
element.ray.origin().x() ) * element.inverseDirection.x();
+    double y_minimum = ( bound[ 2 + element.sign[ 1 ] ] - 
element.ray.origin().y() ) * element.inverseDirection.y();
+    double y_maximum = ( bound[ 3 - element.sign[ 1 ] ] - 
element.ray.origin().y() ) * element.inverseDirection.y();
+    double z_minimum = ( bound[ 4 + element.sign[ 2 ] ] - 
element.ray.origin().z() ) * element.inverseDirection.z();
+    double z_maximum = ( bound[ 5 - element.sign[ 2 ] ] - 
element.ray.origin().z() ) * element.inverseDirection.z();
     if ( minimum_maximum < x_minimum ||
          maximum_minimum > x_maximum )
       continue;
@@ -160,10 +160,10 @@
       if ( discriminant >= 0.0 ) {
         double r = sqrt( discriminant );
         double t0 = -r - B;
-        if( t0 > 0.0 ) {
+        if( t0 > 0.0 )
           if ( element.hitInfo.hit( t0, material, this, tex ) )
             element.hitInfo.scratchpad< ParticleHit >().particle = current;
-        } else {
+        else {
           double t1 = r - B;
           if ( element.hitInfo.hit( t1, material, this, tex ) )
             element.hitInfo.scratchpad< ParticleHit >().particle = current;

Modified: trunk/Model/Primitives/ParticleBVH.h
==============================================================================
--- trunk/Model/Primitives/ParticleBVH.h        (original)
+++ trunk/Model/Primitives/ParticleBVH.h        Mon Sep 26 17:22:17 2005
@@ -39,7 +39,7 @@
       int particle;
     };
 
-    int partition( int first, int last, int const axis, float const position 
);
+    int partition( int first, int last, int const axis, double const 
position );
     int build( int const index, int const first, int const last, int const 
size );
     bool testBox( RayPacket &rays, BBox const &box ) const;
     bool intersectParticles( RayPacket &rays, int const first, int const 
last ) const;

Modified: trunk/scenes/ParticleBVHTest.cc
==============================================================================
--- trunk/scenes/ParticleBVHTest.cc     (original)
+++ trunk/scenes/ParticleBVHTest.cc     Mon Sep 26 17:22:17 2005
@@ -8,7 +8,7 @@
 #include <Model/AmbientLights/ArcAmbient.h>
 #include <Model/Backgrounds/LinearBackground.h>
 #include <Model/Lights/PointLight.h>
-#include <Model/Materials/Phong.h>
+#include <Model/Materials/Lambertian.h>
 #include <Model/Primitives/ParticleBVH.h>
 
 #include <Core/Math/MinMax.h>
@@ -29,6 +29,7 @@
 {
   string model_name = "/usr/sci/data/Geometry/particle/sd173-crop.mpm";
   int maximum_particles = 0;
+  double default_radius = 0.0005;
   int argc = static_cast< int >( args.size() );
   for ( int i = 0; i < argc; i++ ) {
     string arg = args[ i ];
@@ -38,15 +39,17 @@
     } else if ( arg == "-max" ) {
       if ( !getIntArg( i, args, maximum_particles ) )
         throw IllegalArgument( "scene particlebvhtest -max", i, args );
+    } else if ( arg == "-radius" ) {
+      if ( !getDoubleArg( i, args, default_radius ) )
+        throw IllegalArgument( "scene particlebvhtest -radius", i, args );
     } else {
       cerr << "Valid options for scene particlebvhtest:" << endl
            << " -model file - MPM particle set model to show" << endl
-           << " -max number - Maximum number of particles to show" << endl;
+           << " -max number - Maximum number of particles to show" << endl
+           << " -radius number - Default radius if none given in file" << 
endl;
       throw IllegalArgument( "scene particlebvhtest", i, args );
     }
   }
-  Material *material = new Phong( Color( RGB( 0.6, 0.0, 0.0 ) ),
-                                  Color( RGB( 0.6, 0.6, 0.6 ) ), 32, 0.4 );
   ifstream in( model_name.c_str() );
   if ( !in.is_open() )
     throw IllegalArgument( "Couldn't load model: " + model_name, 0, args );
@@ -54,6 +57,7 @@
   in >> number_of_particles >> number_of_variables >> radius_index;
   if ( maximum_particles > 0 )
     number_of_particles = min( number_of_particles, maximum_particles );
+  Material *material = new Lambertian( Color( RGB( 0.2, 0.5, 0.7 ) ) );
   ParticleBVH *bvh = new ParticleBVH( material, number_of_particles );
   float data[ number_of_variables ];
   for ( int particle = 0; particle < number_of_particles; ++particle ) {
@@ -61,7 +65,7 @@
       in >> data[ variable ];
     bvh->setParticle( particle,
                       Point( data[ 0 ], data[ 1 ], data[ 2 ] ),
-                      radius_index > 0 ? data[ radius_index ] : 0.0005 );
+                      radius_index > 0 ? data[ radius_index ] : 
default_radius );
   }
   Scene *scene = new Scene();
   scene->setBackground( new LinearBackground( Color( RGB( 0.2, 0.4, 0.9 ) ),




  • [MANTA] r570 - in trunk: Core/Geometry Model/Primitives scenes, aek, 09/26/2005

Archive powered by MHonArc 2.6.16.

Top of page