Update of /cvsroot/playerstage/code/stage/libstage
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26820

Modified Files:
      Tag: opengl
        Makefile.manual ancestor.cc cell.cc model.cc model_laser.cc 
        stage.hh stest.cc world.cc worldgtk.cc 
Log Message:
raytracing reimplmented - a bug remains?

Index: stest.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stest.cc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** stest.cc    13 Oct 2007 07:42:55 -0000      1.1.2.7
--- stest.cc    22 Oct 2007 09:06:28 -0000      1.1.2.8
***************
*** 79,83 ****
  //   // subscribe to the laser - starts it collecting data
  //   position->Subscribe();
!    //laser->Subscribe();
  //   ranger->Subscribe();
  
--- 79,83 ----
  //   // subscribe to the laser - starts it collecting data
  //   position->Subscribe();
!    laser->Subscribe();
  //   ranger->Subscribe();
  

Index: model_laser.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_laser.cc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** model_laser.cc      22 Oct 2007 02:36:33 -0000      1.1.2.5
--- model_laser.cc      22 Oct 2007 09:06:28 -0000      1.1.2.6
***************
*** 104,109 ****
    samples = NULL;
  
-   debug = true;
- 
    dl_debug_laser = glGenLists( 1 );
    glNewList( dl_debug_laser, GL_COMPILE );
--- 104,107 ----
***************
*** 149,156 ****
  }
  
! int laser_raytrace_match( StgModel* mod, StgModel* hitmod )
! {           
!   // Ignore myself and things that are invisible to lasers
!   return( (mod != hitmod) && (hitmod->LaserReturn() > 0) );
  }     
  
--- 147,163 ----
  }
  
! int laser_raytrace_match( StgBlock* testblock, 
!                         StgModel* finder )
! { 
!   // Ignore the model that's looking and things that are invisible to
!   // lasers
! 
!   if( (testblock->mod != finder) &&
!       (testblock->mod->LaserReturn() > 0 ) )
!     return 0; // match!
! 
!   return 1; // no match
! 
!   //return( (mod != hitmod) && (hitmod->LaserReturn() > 0) );
  }     
  
***************
*** 189,197 ****
        
         //printf( "  [%d] %.2f\n", (int)t, samples[t].range );
!        printf( "  [%d] ", (int)t );
  
         samples[t].range = Raytrace( bearing, 
                                    range_max,
!                                   laser_raytrace_match,
                                    &hitmod );
         
--- 196,205 ----
        
         //printf( "  [%d] %.2f\n", (int)t, samples[t].range );
!        //printf( "  [%d] ", (int)t );
  
         samples[t].range = Raytrace( bearing, 
                                    range_max,
!                                   
(stg_block_match_func_t)laser_raytrace_match,
!                                   (const void*)this,
                                    &hitmod );
         
***************
*** 206,210 ****
       }
  
!   puts("");
  
     // we may need to interpolate the samples we skipped 
--- 214,218 ----
       }
  
!   //puts("");
  
     // we may need to interpolate the samples we skipped 

Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model.cc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** model.cc    13 Oct 2007 07:42:55 -0000      1.1.2.6
--- model.cc    22 Oct 2007 09:06:27 -0000      1.1.2.7
***************
*** 299,303 ****
  stg_meters_t StgModel::Raytrace( stg_radians_t angle,
                                 stg_meters_t range, 
!                                stg_itl_test_func_t func,
                                 StgModel** hitmod )
    
--- 299,304 ----
  stg_meters_t StgModel::Raytrace( stg_radians_t angle,
                                 stg_meters_t range, 
!                                stg_block_match_func_t func,
!                                const void* arg,
                                 StgModel** hitmod )
    
***************
*** 311,314 ****
--- 312,316 ----
                          range,
                          func,
+                         arg,
                          hitmod );
  }
***************
*** 316,320 ****
  stg_meters_t StgModel::Raytrace( stg_pose_t* pz,
                                 stg_meters_t range, 
!                                stg_itl_test_func_t func,
                                 StgModel** hitmod )
  
--- 318,323 ----
  stg_meters_t StgModel::Raytrace( stg_pose_t* pz,
                                 stg_meters_t range, 
!                                stg_block_match_func_t func,
!                                const void* arg,
                                 StgModel** hitmod )
  
***************
*** 328,331 ****
--- 331,335 ----
                          range,
                          func,
+                         arg,
                          hitmod );
  }

Index: world.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/world.cc,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** world.cc    22 Oct 2007 02:36:33 -0000      1.1.2.6
--- world.cc    22 Oct 2007 09:06:28 -0000      1.1.2.7
***************
*** 158,163 ****
    this->ppm = ppm; // this is the finest resolution of the matrix
  
!   int32_t dx = width/2.0 * ppm;
!   int32_t dy = height/2.0 * ppm;
    this->root = new StgCell( NULL, -dx, +dx, -dy, +dy );
  
--- 158,163 ----
    this->ppm = ppm; // this is the finest resolution of the matrix
  
!   int32_t dx = (int32_t)(width/2.0 * ppm);
!   int32_t dy = (int32_t)(height/2.0 * ppm);
    this->root = new StgCell( NULL, -dx, +dx, -dy, +dy );
  
***************
*** 251,256 ****
      delete root;
    
!   int32_t dx = width/2.0 * ppm;
!   int32_t dy = height/2.0 * ppm;
    this->root = new StgCell( NULL, -dx, +dx, -dy, +dy );
  
--- 251,256 ----
      delete root;
    
!   int32_t dx = (int32_t)(width/2.0 * ppm);
!   int32_t dy = (int32_t)(height/2.0 * ppm);
    this->root = new StgCell( NULL, -dx, +dx, -dy, +dy );
  
***************
*** 441,484 ****
  
  
! StgModel* StgWorld::TestCandidateList( StgModel* finder, 
!                                      stg_itl_test_func_t func,
!                                      stg_meters_t z,
!                                      GSList* list )
! {
!   assert(list);
    
!   for( GSList* it = list; it; it=it->next )
!     {
!       StgBlock* block = (StgBlock*)it->data;          
!       StgModel* candidate = block->mod;               
!       assert( candidate );
        
!       //printf( "block of %s\n", candidate->Token() );
        
!       stg_pose_t gpose;
!       candidate->GetGlobalPose( &gpose );
        
!       // test to see if the block exists at height z
!       double block_min = gpose.z + block->zmin;
!       double block_max = gpose.z + block->zmax;
        
!       //printf( "[%.2f %.2f %.2f] %s testing %s (laser return %d)\n",
!       //      x,y,z,
!       //      finder->Token(), candidate->Token(), candidate->LaserReturn() );
        
        
!       if( LT(block_min,z) && 
!         GT(block_max,z) && 
!         (*func)( finder, candidate ) )
!       return candidate;
!     }
  
!   return NULL;
! }
  
  stg_meters_t StgWorld::Raytrace( StgModel* finder,
                                 stg_pose_t* pose,
                                 stg_meters_t max_range,
!                                stg_itl_test_func_t func,
                                 StgModel** hit_model )
  {
--- 441,485 ----
  
  
! // StgModel* StgWorld::TestCandidateList( StgModel* finder, 
! //                                   stg_itl_test_func_t func,
! //                                   stg_meters_t z,
! //                                   GSList* list )
! // {
! //   assert(list);
    
! //   for( GSList* it = list; it; it=it->next )
! //     {
! //       StgBlock* block = (StgBlock*)it->data;               
! //       StgModel* candidate = block->mod;            
! //       assert( candidate );
        
! //       //printf( "block of %s\n", candidate->Token() );
        
! //       stg_pose_t gpose;
! //       candidate->GetGlobalPose( &gpose );
        
! //       // test to see if the block exists at height z
! //       double block_min = gpose.z + block->zmin;
! //       double block_max = gpose.z + block->zmax;
        
! //       //printf( "[%.2f %.2f %.2f] %s testing %s (laser return %d)\n",
! //       //      x,y,z,
! //       //      finder->Token(), candidate->Token(), 
candidate->LaserReturn() );
        
        
! //       if( LT(block_min,z) && 
! //      GT(block_max,z) && 
! //      (*func)( finder, candidate ) )
! //    return candidate;
! //     }
  
! //   return NULL;
! // }
  
  stg_meters_t StgWorld::Raytrace( StgModel* finder,
                                 stg_pose_t* pose,
                                 stg_meters_t max_range,
!                                stg_block_match_func_t func,
!                                const void* arg,
                                 StgModel** hit_model )
  {
***************
*** 488,492 ****
    double y = pose->y;
    double z = pose->z;
!   double a = pose->a;
  
    double tana = tan( a );
--- 489,493 ----
    double y = pose->y;
    double z = pose->z;
!   double a = NORMALIZE(pose->a);
  
    double tana = tan( a );
***************
*** 497,532 ****
    StgModel* hit = NULL;
  
    while( LT(range,max_range) )
      {
-       printf( "locating cell at (%.2f %.2f)\n", x, y );
        
        // locate the leaf cell at X,Y
!       //cell = StgCell::Locate( cell, x, y );      
!       cell = cell->Locate( x*ppm, y*ppm );
  
        // the cell is null iff the point was outside the root
        if( cell == NULL )
        {
!         printf( "ray at angle %.2f out of bounds at [%d, %d]",
!                 a, x, y );
  
          break;
        }
!       
        if( finder->debug )
        {
!         PushColor( 1,0,0, 0.3 );
          glPolygonMode( GL_FRONT, GL_LINE );
          cell->Draw();
          PopColor();
        }
        
!       if( cell->list ) 
!       { 
!         hit = TestCandidateList( finder, func, z, cell->list );
!         if( hit )
!           break; // we're done looking          
!       }           
        
        double c = y - tana * x; // line offset
        
--- 498,550 ----
    StgModel* hit = NULL;
  
+   double p2m = 1.0/ppm;
+ 
    while( LT(range,max_range) )
      {
        
+       int xpix = floor(x*ppm);
+       int ypix = floor(y*ppm);
+       
+       //printf( "locating cell at (%.2f %.2f) [%d,%d]\n", x, y, xpix, ypix );
+ 
        // locate the leaf cell at X,Y
!       cell = cell->Locate( xpix, ypix );
  
        // the cell is null iff the point was outside the root
        if( cell == NULL )
        {
!         //printf( "ray at angle %.2f out of bounds at [%.2f, %.2f]",
!         //  a, x, y );
  
          break;
        }
! 
!      //  printf( "found cell (%.2f,%.2f) (%.2f,%.2f)\n",
! //          cell->xmin * p2m, 
! //          cell->xmax * p2m, 
! //          cell->ymin * p2m,
! //          cell->ymax * p2m );
!     
! 
        if( finder->debug )
        {
!         glPushMatrix();      
!         glTranslatef( 0,0,1.2 );
!         glScalef( 1.0/ppm, 1.0/ppm, 0 );        
!         PushColor( 1,0,1, 1 );
          glPolygonMode( GL_FRONT, GL_LINE );
          cell->Draw();
          PopColor();
+         glPopMatrix();
        }
        
!       StgBlock* hitblock = cell->FindBlock( func, arg );
        
+       if( hitblock )
+       {
+         hit = hitblock->mod;
+         break;
+       }
+ 
        double c = y - tana * x; // line offset
        
***************
*** 536,546 ****
        if( GT(a,0) ) // up
        {
          // ray could leave through the top edge
          // solve x for known y      
!         yleave = cell->ymax; // top edge
          xleave = (yleave - c) / tana;
!         
          // if the edge crossing was not in cell bounds     
!         if( !((xleave >= cell->xmin) && (xleave < cell->xmax)) )
            {
              // it must have left the cell on the left or right instead 
--- 554,572 ----
        if( GT(a,0) ) // up
        {
+         //puts( "up" );
+ 
          // ray could leave through the top edge
          // solve x for known y      
!         yleave = cell->ymax * p2m; // top edge
          xleave = (yleave - c) / tana;
! 
!         int32_t xleave_pixel = floor(xleave*ppm);
! 
          // if the edge crossing was not in cell bounds     
!         //if( !(  GTE(xleave,cell->xmin*p2m) && LT(xleave,cell->xmax*p2m)) )
!         //if( ! cell->Contains( xleave*ppm, yleave*ppm )
!         
!         if( xleave_pixel < cell->xmin || 
!             xleave_pixel >= cell->xmax )
            {
              // it must have left the cell on the left or right instead 
***************
*** 549,557 ****
              if( GT(a,M_PI/2.0) ) // left side
                {
!                 xleave = cell->xmin-epsilon;
                }
              else // right side
                {
!                 xleave = cell->xmax;
                }
              
--- 575,583 ----
              if( GT(a,M_PI/2.0) ) // left side
                {
!                 xleave = (cell->xmin*p2m)-epsilon;
                }
              else // right side
                {
!                 xleave = cell->xmax*p2m +epsilon;
                }
              
***************
*** 561,581 ****
        else 
        {
          // ray could leave through the bottom edge
          // solve x for known y      
!         yleave = cell->ymin; // bottom edge
          xleave = (yleave - c) / tana;
          
          // if the edge crossing was not in cell bounds     
!         if( !((xleave >= cell->xmin) && (xleave < cell->xmax)) )
            {
              // it must have left the cell on the left or right instead 
              // solve y for known x      
              if( LT(a,-M_PI/2.0) ) // left side
                {
!                 xleave = cell->xmin-epsilon;
                }
              else
                {
!                 xleave = cell->xmax;
                }
              
--- 587,629 ----
        else 
        {
+         //puts( "down" );
+         
          // ray could leave through the bottom edge
          // solve x for known y      
!         yleave = cell->ymin*p2m; // bottom edge
          xleave = (yleave - c) / tana;
          
+         int32_t xleave_pixel = floor(xleave*ppm);
+ 
+ //      printf( "test leave (%.2f %.2f) %d [%d %d] %d %d %d\n", 
+ //              xleave, 
+ //              yleave,
+ //              xleave_pixel,
+ //              cell->xmin,
+ //              cell->xmax,
+ //              xleave_pixel < cell->xmin,
+ //              xleave_pixel >= cell->xmax,
+ //              xleave_pixel < cell->xmin ||
+ //              xleave_pixel >= cell->xmax              
+ //      );
+         
          // if the edge crossing was not in cell bounds     
!         //if( !( GTE(xleave,cell->xmin*p2m) && LT(xleave,cell->xmax*p2m)))
!         if( xleave_pixel < cell->xmin || 
!             xleave_pixel >= cell->xmax )
            {
+             //              puts( "L or R" );
+ 
              // it must have left the cell on the left or right instead 
              // solve y for known x      
              if( LT(a,-M_PI/2.0) ) // left side
                {
!                 //puts( "L" );
!                 xleave = (cell->xmin*p2m)-epsilon;
                }
              else
                {
!                 //puts(  "R" );
!                 xleave = cell->xmax*p2m+epsilon;
                }
              
***************
*** 583,591 ****
            }
          else
!           yleave-=epsilon;
        }
  
!       cell->Print( NULL );
!       printf( "(%.2f %.2f)\n", hypot( yleave - y, xleave - x ), range );
        
        // jump to the leave point
--- 631,643 ----
            }
          else
!           {
!             yleave-=epsilon;
!             //printf( "left through bottom edge\n" );
!           }
        }
  
!       //cell->Print( NULL );
!       //printf( "leave at (%.2f %.2f)\n", hypot( yleave - y, xleave - x ), 
range );
!       //printf( "leave at (%.2f %.2f)\n", xleave, yleave );
        
        // jump to the leave point
***************
*** 608,614 ****
          glEnd();
  
!         PushColor( 0,0,1, 1 );
          glBegin( GL_POINTS );
!         glVertex3f( xleave+0.01, yleave+0.01, z );
          glEnd();
          PopColor();
--- 660,666 ----
          glEnd();
  
!         PushColor( 0,1,0, 1 );
          glBegin( GL_POINTS );
!         glVertex3f( xleave, yleave, z );
          glEnd();
          PopColor();
***************
*** 621,630 ****
      }
    
!   if( hit )
!     printf( "HIT %s at [%d %d %.2f] range %.2f\n",
!           hit->Token(),
!           x,y,z, range );
!   else
!     printf( "no hit at range %.2f\n", range );
    
    // if the caller supplied a place to store the hit model pointer,
--- 673,682 ----
      }
    
! //   if( hit )
! //     printf( "HIT %s at [%.2f %.2f %.2f] range %.2f\n",
! //        hit->Token(),
! //        x,y,z, range );
! //   else
! //     printf( "no hit at range %.2f\n", range );
    
    // if the caller supplied a place to store the hit model pointer,
***************
*** 633,636 ****
--- 685,689 ----
      *hit_model = hit;
    
+ 
    // return the range
    return MIN( range, max_range );
***************
*** 716,726 ****
                             double mx2, double my2 )
  {
!   int32_t x1 = mx1 * ppm - 0.5;
!   int32_t x2 = mx2 * ppm - 0.5;
!   int32_t y1 = my1 * ppm - 0.5;
!   int32_t y2 = my2 * ppm - 0.5;
    
    StgCell* cell = root;
!   
    // Extremely Fast Line Algorithm Var A (Division)
    // Copyright 2001-2, By Po-Han Lin
--- 769,786 ----
                             double mx2, double my2 )
  {
!   //int32_t x1 = (int32_t)(mx1 * ppm - 0.5);
!   //int32_t x2 = (int32_t)(mx2 * ppm - 0.5);
!   //int32_t y1 = (int32_t)(my1 * ppm - 0.5);
!   //int32_t y2 = (int32_t)(my2 * ppm - 0.5);
! 
!   int32_t x1 = floor(mx1 * ppm);
!   int32_t x2 = floor(mx2 * ppm);
!   int32_t y1 = floor(my1 * ppm);
!   int32_t y2 = floor(my2 * ppm);
    
    StgCell* cell = root;
! 
!   //cell = myPixel( cell, block, x1, y1 );
! 
    // Extremely Fast Line Algorithm Var A (Division)
    // Copyright 2001-2, By Po-Han Lin
***************
*** 737,741 ****
      "Contains an implementation of the Extremely Fast Line Algorithm (EFLA)"
      "by Po-Han Lin (http://www.edepot.com/phl.html)";
!   
    bool yLonger=false;
    int incrementVal;
--- 797,803 ----
      "Contains an implementation of the Extremely Fast Line Algorithm (EFLA)"
      "by Po-Han Lin (http://www.edepot.com/phl.html)";
!   char* dummy = (char*)EFLA_CREDIT; // prevents compiler warning about unused 
var
!   dummy++; // ditto
! 
    bool yLonger=false;
    int incrementVal;

Index: Makefile.manual
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/Makefile.manual,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** Makefile.manual     4 Oct 2007 07:43:21 -0000       1.1.2.2
--- Makefile.manual     22 Oct 2007 09:06:27 -0000      1.1.2.3
***************
*** 32,39 ****
  LIBS= `pkg-config --libs gtkglext-1.0`
  
  foo : $(OBS) $(HEADERS)
        g++ -o foo $(CPPFLAGS) $(OBS) $(LIBS)  
  
  clean : 
!       rm *.o *.lo
  
--- 32,42 ----
  LIBS= `pkg-config --libs gtkglext-1.0`
  
+ 
+ all: foo
+ 
  foo : $(OBS) $(HEADERS)
        g++ -o foo $(CPPFLAGS) $(OBS) $(LIBS)  
  
  clean : 
!       rm -f *.o *.lo
  

Index: stage.hh
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stage.hh,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** stage.hh    13 Oct 2007 07:42:55 -0000      1.1.2.7
--- stage.hh    22 Oct 2007 09:06:28 -0000      1.1.2.8
***************
*** 769,799 ****
  } stg_split_t;
  
- typedef enum {
-   STG_EXPAND_LEFT=0, 
-   STG_EXPAND_RIGHT,
-   STG_EXPAND_UP,
-   STG_EXPAND_DOWN
- } stg_expand_t;
- 
- 
  class StgBlock;
  
  /** A node in the occupancy quadtree */
  class StgCell
  {
  private:
! public:
    GSList* list;
    int32_t width, height;
    
!   // bounding box
    int32_t xmin,ymin,xmax,ymax;
    
    stg_split_t split;
-   //stg_expand_t expand;
  
    StgCell *left, *right;
!   StgCell* parent;
!   
    StgCell( StgCell* parent, 
           int32_t xmin, int32_t xmax, 
--- 769,806 ----
  } stg_split_t;
  
  class StgBlock;
  
+ /** matching function should return 0 iff the candidate block is
+     acceptable */
+ typedef int(*stg_block_match_func_t)(StgBlock* candidate, const void* arg );
+ 
  /** A node in the occupancy quadtree */
  class StgCell
  {
+   friend class StgWorld;
+ 
  private:
!   void Split(); ///< split the cell into children
! 
!   /** list of models that have been AddBlock()ed into this
!       cell */
    GSList* list;
+ 
+   /** extent of the cell */
    int32_t width, height;
    
!   /** bounding box */
    int32_t xmin,ymin,xmax,ymax;
    
+   /** direction of split for this cell */
    stg_split_t split;
  
+   /** links for BSP tree */
    StgCell *left, *right;
! 
!   /** links for BSP tree */
!   StgCell* parent;  
! 
! public:
    StgCell( StgCell* parent, 
           int32_t xmin, int32_t xmax, 
***************
*** 802,827 ****
    ~StgCell();
    
    static void RemoveBlock( StgCell* cell, StgBlock* block );
    void AddBlock( StgBlock* block );  
    
    void Draw();
    void DrawTree( bool leaf_only );
-   void Print( char* prefix );
  
!   void Split(); ///< split the cell into children
!   StgCell* ExpandLeft(); ///< add a new parent to this cell, twice the size
!   StgCell* ExpandRight(); ///< add a new parent to this cell, twice the size
!   StgCell* ExpandUp(); ///< add a new parent to this cell, twice the size
!   StgCell* ExpandDown(); ///< add a new parent to this cell, twice the size
  
!   bool Atomic();  
!   bool Contains( int32_t x, int32_t y );
    
!   StgCell* Locate( int32_t x, int32_t y );
!   StgCell* LocateAtom( int32_t x, int32_t y );
! };
    
  
! typedef int(*stg_itl_test_func_t)(StgModel* finder, StgModel* found );
  
  
--- 809,854 ----
    ~StgCell();
    
+   /** Return the root of the tree that contains this cell */
+   StgCell* Root();
+ 
+   /** Remove block from the cell. This method is static as it may
+       destroy the cell. */
    static void RemoveBlock( StgCell* cell, StgBlock* block );
+ 
+   /** Add a pointer to block to the list of this cells contents */
    void AddBlock( StgBlock* block );  
    
+   /** Return the first block in the cell that matches the comparison
+       function */
+   StgBlock* FindBlock( stg_block_match_func_t, const void* arg );
+ 
+   /** Draw the cell into the current OpenGL context */
    void Draw();
+ 
+   /** Draw the cell and all its descendents in the current OpenGL
+       context. If leaf_only is true, only occupied leaf nodes are
+       drawn */
    void DrawTree( bool leaf_only );
  
!   /** Print a human-readable description of the cell on stdout,
!       prefixed by the string prefix. */
!   void Print( char* prefix );
  
!   /** returns true iff the cell is a unit square (ie. as small as it
!       can be */
!   bool Atomic(); 
    
!   /** Returns true iff the cell contains the  point <x,y> */
!   bool Contains( int32_t x, int32_t y ); 
    
+   /** returns the smallest currently existing cell that contains point
+       <x,y>. Does not create new cells. */
+   StgCell* Locate( int32_t x,  int32_t y );
  
!   /** returns a unit cell that contains <x,y>, creating cells if
!       necessary */
!   StgCell* LocateAtom( int32_t x, int32_t y ); 
! };
!   
  
  
***************
*** 1082,1085 ****
--- 1109,1114 ----
    char* token;
    
+   bool debug;
+ 
  public:
    StgAncestor();
***************
*** 1120,1128 ****
    static GHashTable* typetable;  
    
-   StgModel* TestCandidateList( StgModel* finder, 
-                              stg_itl_test_func_t func,
-                              stg_meters_t z,
-                              GSList* list );
- 
  public:
  
--- 1149,1152 ----
***************
*** 1211,1219 ****
                     double x1, double y1, 
                     double x2, double y2 );
! 
    stg_meters_t Raytrace( StgModel* finder,
                         stg_pose_t* pose,                       
                         stg_meters_t max_range,
!                        stg_itl_test_func_t func,
                         StgModel** hit_model );
                         
--- 1235,1244 ----
                     double x1, double y1, 
                     double x2, double y2 );
!   
    stg_meters_t Raytrace( StgModel* finder,
                         stg_pose_t* pose,                       
                         stg_meters_t max_range,
!                        stg_block_match_func_t func,
!                        const void* arg,
                         StgModel** hit_model );
                         
***************
*** 1567,1571 ****
    stg_meters_t Raytrace( stg_radians_t angle, 
                         stg_meters_t range, 
!                        stg_itl_test_func_t func,
                         StgModel** hitmod );
    
--- 1592,1597 ----
    stg_meters_t Raytrace( stg_radians_t angle, 
                         stg_meters_t range, 
!                        stg_block_match_func_t func,
!                        const void* arg,
                         StgModel** hitmod );
    
***************
*** 1573,1577 ****
    stg_meters_t Raytrace( stg_pose_t* pose,
                         stg_meters_t range, 
!                        stg_itl_test_func_t func,
                         StgModel** hitmod );
    
--- 1599,1604 ----
    stg_meters_t Raytrace( stg_pose_t* pose,
                         stg_meters_t range, 
!                        stg_block_match_func_t func,
!                        const void* arg,
                         StgModel** hitmod );
    

Index: ancestor.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/ancestor.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** ancestor.cc 4 Oct 2007 07:43:21 -0000       1.1.2.2
--- ancestor.cc 22 Oct 2007 09:06:27 -0000      1.1.2.3
***************
*** 6,9 ****
--- 6,10 ----
    children = NULL;
    child_types = g_hash_table_new( g_str_hash, g_str_equal );
+   debug = false;
  }
  

Index: cell.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/cell.cc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** cell.cc     13 Oct 2007 07:42:55 -0000      1.1.2.2
--- cell.cc     22 Oct 2007 09:06:27 -0000      1.1.2.3
***************
*** 46,49 ****
--- 46,59 ----
  }
  
+ StgCell* StgCell::Root()
+ {
+   StgCell* cell = this;
+ 
+   while( parent )
+     cell = parent;
+ 
+   return cell;
+ }
+     
  bool StgCell::Atomic()
  {
***************
*** 51,55 ****
    //  width, height, sz );
  
!   return( (width < 2) && (height < 2)); 
  }
  
--- 61,65 ----
    //  width, height, sz );
  
!   return( (width == 1) && (height == 1)); 
  }
  
***************
*** 59,64 ****
  {
    //this->Print( "Draw" );
!   //printf( "left %.2f right %.2f bottom %.2f top %.2f\n",
!   //  left, right, bottom, top );
  
    glRecti( xmin, ymin, xmax, ymax );
--- 69,74 ----
  {
    //this->Print( "Draw" );
!   //printf( "left %d right %d bottom %d top %d\n",
!   //  xmin, xmax, ymin, ymax );
  
    glRecti( xmin, ymin, xmax, ymax );
***************
*** 161,164 ****
--- 171,212 ----
  }
  
+ StgBlock* StgCell::FindBlock( stg_block_match_func_t func, 
+                             const void* arg )
+ {  
+   GSList* match = 
+     g_slist_find_custom( this->list, arg, (GCompareFunc)func );
+   
+   return match ? (StgBlock*)match->data : (StgBlock*)NULL;
+ 
+   //for( GSList* it = list; it; it=it->next )
+   //{
+   //  StgBlock* block = (StgBlock*)it->data;          
+   //  StgModel* candidate = block->mod;               
+   //  assert( candidate );
+       
+       //printf( "block of %s\n", candidate->Token() );
+       
+       //stg_pose_t gpose;
+       //candidate->GetGlobalPose( &gpose );
+       
+       // test to see if the block exists at height z
+       //double block_min = gpose.z + block->zmin;
+       //double block_max = gpose.z + block->zmax;
+       
+       //printf( "[%.2f %.2f %.2f] %s testing %s (laser return %d)\n",
+       //      x,y,z,
+       //      finder->Token(), candidate->Token(), candidate->LaserReturn() );
+       
+       
+       //if( LT(block_min,z) && 
+       //  GT(block_max,z) && 
+       
+   // if( (*func)( arg, candidate ) )
+   //return block;
+   // }
+   
+   //return NULL;
+ }                          
+ 
  void StgCell::RemoveBlock( StgCell* cell, StgBlock* block )
  {

Index: worldgtk.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldgtk.cc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** worldgtk.cc 13 Oct 2007 07:42:55 -0000      1.1.2.5
--- worldgtk.cc 22 Oct 2007 09:06:28 -0000      1.1.2.6
***************
*** 1853,1859 ****
        
        StgCell* cell = root;
!       while( cell->parent )
!       cell = cell->parent;
! 
        if( show_quadtree )
        {
--- 1853,1857 ----
        
        StgCell* cell = root;
!  
        if( show_quadtree )
        {


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to