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

Modified Files:
      Tag: opengl
        canvas.cc model.cc model_laser.cc model_load.cc 
        model_ranger.cc stage.hh stest.cc world.cc worldfile.cc 
        worldfile.hh worldgui.cc 
Log Message:
vastly improved worldfile loading time. can run 10000 robots no problem.

Index: worldgui.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldgui.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** worldgui.cc 22 Nov 2007 01:36:47 -0000      1.1.2.3
--- worldgui.cc 26 Nov 2007 06:28:16 -0000      1.1.2.4
***************
*** 54,58 ****
    menubar->item_pathname(picked, sizeof(picked)-1);
  
!   printf("CALLBACK: You picked '%s'\n", picked);
    
    // this is slow and a little ugly, but it's the least hacky approach I think
--- 54,58 ----
    menubar->item_pathname(picked, sizeof(picked)-1);
  
!   //printf("CALLBACK: You picked '%s'\n", picked);
    
    // this is slow and a little ugly, but it's the least hacky approach I think
***************
*** 107,117 ****
    mbar->add( "Help/About Stage...", FL_CTRL + 'f', (Fl_Callback *)dummy_cb );
    mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback 
*)dummy_cb );
- 
- 
-   // set the checked state appropriately
-   
- 
    show();
!  }
  
  StgWorldGui::~StgWorldGui()
--- 107,112 ----
    mbar->add( "Help/About Stage...", FL_CTRL + 'f', (Fl_Callback *)dummy_cb );
    mbar->add( "Help/HTML Documentation", FL_CTRL + 'g', (Fl_Callback 
*)dummy_cb );
    show();
! }
  
  StgWorldGui::~StgWorldGui()
***************
*** 138,151 ****
    canvas->sphi = wf->ReadTupleFloat( wf_section, "rotate", 1, canvas->sphi );
    canvas->scale = wf->ReadFloat(wf_section, "scale", canvas->scale );
!   canvas->interval = wf->ReadInt(wf_section, "redraw_interval", 
canvas->interval );
  
!   // set the canvas visibilty flags 
! //   canvas->SetShowFlag( STG_SHOW_GRID,   wf->ReadInt(wf_section, 
"show_grid"  , flags & STG_SHOW_GRID )); 
! //   canvas->SetShowFlag( STG_SHOW_BLOCKS, wf->ReadInt(wf_section, 
"show_blocks", flags & STG_SHOW_BLOCKS )); 
! //   canvas->SetShowFlag( STG_SHOW_DATA,   wf->ReadInt(wf_section, 
"show_data",   flags & STG_SHOW_DATA ));
! //   canvas->SetShowFlag( STG_SHOW_FOLLOW, wf->ReadInt(wf_section, 
"show_follow", flags & STG_SHOW_FOLLOW )); 
! //   canvas->SetShowFlag( STG_SHOW_QUADTREE,   wf->ReadInt(wf_section, 
"show_tree",   flags & STG_SHOW_QUADTREE ));
! //   canvas->SetShowFlag( STG_SHOW_OCCUPANCY,   wf->ReadInt(wf_section, 
"show_occupancy",   flags & STG_SHOW_OCCUPANCY ));
!   
    uint32_t flags = canvas->GetShowFlags();
    uint32_t grid = wf->ReadInt(wf_section, "show_grid", flags & STG_SHOW_GRID 
) ? STG_SHOW_GRID : 0;
--- 133,139 ----
    canvas->sphi = wf->ReadTupleFloat( wf_section, "rotate", 1, canvas->sphi );
    canvas->scale = wf->ReadFloat(wf_section, "scale", canvas->scale );
!   canvas->interval = wf->ReadInt(wf_section, "interval", canvas->interval );
  
!   // set the canvas visibilty flags   
    uint32_t flags = canvas->GetShowFlags();
    uint32_t grid = wf->ReadInt(wf_section, "show_grid", flags & STG_SHOW_GRID 
) ? STG_SHOW_GRID : 0;
***************
*** 156,168 ****
    uint32_t clock = wf->ReadInt(wf_section, "show_clock", flags & 
STG_SHOW_CLOCK ) ? STG_SHOW_CLOCK : 0;
    
!  
! //canvas->SetShowFlag( STG_SHOW_BLOCKS, wf->ReadInt(wf_section, 
"show_blocks", flags & STG_SHOW_BLOCKS )); 
! //  canvas->SetShowFlag( STG_SHOW_DATA,   wf->ReadInt(wf_section, 
"show_data",   flags & STG_SHOW_DATA ));
! //canvas->SetShowFlag( STG_SHOW_FOLLOW, wf->ReadInt(wf_section, 
"show_follow", flags & STG_SHOW_FOLLOW )); 
! //canvas->SetShowFlag( STG_SHOW_QUADTREE,   wf->ReadInt(wf_section, 
"show_tree",   flags & STG_SHOW_QUADTREE ));
! //canvas->SetShowFlag( STG_SHOW_OCCUPANCY,   wf->ReadInt(wf_section, 
"show_occupancy",   flags & STG_SHOW_OCCUPANCY ));
! 
!   flags = grid | data | follow | blocks | quadtree | clock;  
!   canvas->SetShowFlags( flags );  
    canvas->invalidate(); // we probably changed something
  
--- 144,148 ----
    uint32_t clock = wf->ReadInt(wf_section, "show_clock", flags & 
STG_SHOW_CLOCK ) ? STG_SHOW_CLOCK : 0;
    
!   canvas->SetShowFlags( grid | data | follow | blocks | quadtree | clock );  
    canvas->invalidate(); // we probably changed something
  

Index: worldfile.hh
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldfile.hh,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** worldfile.hh        4 Oct 2007 01:17:03 -0000       1.1.2.1
--- worldfile.hh        26 Nov 2007 06:28:16 -0000      1.1.2.2
***************
*** 31,34 ****
--- 31,58 ----
  #include <stdint.h> // for portable int types eg. uint32_t
  #include <stdio.h> // for FILE ops
+ #include <glib.h>
+ 
+   // Private property class
+ struct CProperty
+   {
+     // Index of entity this property belongs to
+     int entity;
+ 
+     // Name of property
+     const char *name;
+ 
+     char* key; // this property's hash table key
+     
+     // A list of token indexes
+     int value_count;
+     int *values;
+ 
+     // Line this property came from
+     int line;
+ 
+     // Flag set if property has been used
+     bool used;
+   };
+ 
  
  // Class for loading/saving world file.  This class hides the syntax
***************
*** 189,193 ****
  
    // Parse a tuple.
!   private: bool ParseTokenTuple(int entity, int property, int *index, int 
*line);
  
    // Clear the macro list
--- 213,217 ----
  
    // Parse a tuple.
!   private: bool ParseTokenTuple( CProperty*  property, int *index, int *line);
  
    // Clear the macro list
***************
*** 232,242 ****
  
    // Add an property
!   private: int AddProperty(int entity, const char *name, int line);
! 
    // Add an property value.
!   private: void AddPropertyValue(int property, int index, int value_token);
    
    // Get an property
!   public: int GetProperty(int entity, const char *name);
  
    // returns true iff the property exists in the file, so that you can
--- 256,265 ----
  
    // Add an property
!   private: CProperty* AddProperty(int entity, const char *name, int line);
    // Add an property value.
!   private: void AddPropertyValue( CProperty* property, int index, int 
value_token);
    
    // Get an property
!   public: CProperty* GetProperty(int entity, const char *name);
  
    // returns true iff the property exists in the file, so that you can
***************
*** 245,252 ****
  
    // Set the value of an property.
!   private: void SetPropertyValue(int property, int index, const char *value);
  
    // Get the value of an property.
!   private: const char *GetPropertyValue(int property, int index);
  
    // Dump the property list for debugging
--- 268,275 ----
  
    // Set the value of an property.
!   private: void SetPropertyValue( CProperty* property, int index, const char 
*value);
  
    // Get the value of an property.
!   private: const char *GetPropertyValue( CProperty* property, int index);
  
    // Dump the property list for debugging
***************
*** 317,345 ****
    private: CEntity *entities;
  
-   // Private property class
-   private: struct CProperty
-   {
-     // Index of entity this property belongs to
-     int entity;
- 
-     // Name of property
-     const char *name;
-     
-     // A list of token indexes
-     int value_count;
-     int *values;
- 
-     // Line this property came from
-     int line;
- 
-     // Flag set if property has been used
-     bool used;
-   };
    
    // Property list
!   private: int property_size;
    private: int property_count;
!   private: CProperty *properties;
! 
    // Name of the file we loaded
    public: char *filename;
--- 340,351 ----
    private: CEntity *entities;
  
    
    // Property list
!   //private: int property_size;
    private: int property_count;
!   //private: CProperty *properties;
!   
!   private: GHashTable* nametable;
!   
    // Name of the file we loaded
    public: char *filename;

Index: model_laser.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_laser.cc,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** model_laser.cc      19 Nov 2007 07:40:41 -0000      1.1.2.11
--- model_laser.cc      26 Nov 2007 06:28:16 -0000      1.1.2.12
***************
*** 152,156 ****
  }
  
! int laser_raytrace_match( StgBlock* testblock, 
                          StgModel* finder )
  { 
--- 152,156 ----
  }
  
! bool laser_raytrace_match( StgBlock* testblock, 
                          StgModel* finder )
  { 
***************
*** 160,166 ****
    if( (testblock->mod != finder) &&
        (testblock->mod->LaserReturn() > 0 ) )
!     return TRUE; // match!
  
!   return FALSE; // no match
  
    //return( (mod != hitmod) && (hitmod->LaserReturn() > 0) );
--- 160,166 ----
    if( (testblock->mod != finder) &&
        (testblock->mod->LaserReturn() > 0 ) )
!     return true; // match!
  
!   return false; // no match
  
    //return( (mod != hitmod) && (hitmod->LaserReturn() > 0) );
***************
*** 321,330 ****
  void StgModelLaser::DataVisualize( void )
  {
-   // rebuild the graphics for this data
-   //glNewList( dl_data, GL_COMPILE );
-   
    if( samples && sample_count )
!     {
!       
        glPushMatrix();
        glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at 
the right height
--- 321,326 ----
  void StgModelLaser::DataVisualize( void )
  {
    if( samples && sample_count )
!     {      
        glPushMatrix();
        glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at 
the right height
***************
*** 353,396 ****
              glEnd();
            }
!           
        }
        PopColor();
! 
!       glPointSize( 1.0 );
! 
        glEnableClientState( GL_VERTEX_ARRAY );
        glVertexPointer( 2, GL_FLOAT, 0, pts );   
  
!       // todo
!       //if( world->win->show_alpha )
!       {   
!         glDepthMask( GL_FALSE );
! 
!         glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
!         PushColor( 0, 0, 1, 0.1 );
!         glDrawArrays( GL_POLYGON, 0, sample_count+1 );
!         PopColor();
  
!         PushColor( 0, 0, 0, 1.0 );
!         glDrawArrays( GL_POINTS, 0, sample_count+1 );
!         PopColor();
  
!         glDepthMask( GL_TRUE );
!       }
! //       else
! //    {
! //      glPolygonMode( GL_FRONT_AND_BACK, GL_LINES );
! //      PushColor( 0, 0, 1, 1 );
! //      glDrawArrays( GL_POLYGON, 0, sample_count+1 );
! //      PopColor();
! //    }
!         
        glPopMatrix();      
      }
-   
-   //if( this->debug )
-   //glCallList( this->dl_debug_laser );
- 
-   //glEndList();
  }
  
--- 349,378 ----
              glEnd();
            }
!         
        }
        PopColor();
!       
!       
        glEnableClientState( GL_VERTEX_ARRAY );
        glVertexPointer( 2, GL_FLOAT, 0, pts );   
  
!       glDepthMask( GL_FALSE );
!       glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
  
!       // draw the filled polygon in transparent blue
!       PushColor( 0, 0, 1, 0.1 );
!       glDrawArrays( GL_POLYGON, 0, sample_count+1 );
!       
!       // draw the beam strike points in black
!       PushColor( 0, 0, 0, 1.0 );
!       glPointSize( 1.0 );
!       glDrawArrays( GL_POINTS, 0, sample_count+1 );
  
!       // reset
!       PopColor();
!       PopColor();      
!       glDepthMask( GL_TRUE );
        glPopMatrix();      
      }
  }
  

Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model.cc,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -C2 -d -r1.1.2.14 -r1.1.2.15
*** model.cc    22 Nov 2007 01:36:47 -0000      1.1.2.14
--- model.cc    26 Nov 2007 06:28:16 -0000      1.1.2.15
***************
*** 160,163 ****
--- 160,165 ----
    this->world = world;
  
+   this->debug = false;
+ 
    // generate a name. This might be overwritten if the "name" property
    // is set in the worldfile when StgModel::Load() is called
***************
*** 712,715 ****
--- 714,718 ----
    snprintf( buf, 63, "%s [%.2f,%.2f,%.2f]", token, gpose.x, gpose.y, 
RTOD(gpose.a) );
    
+   PushColor( 0,0,0,1 ); // text color black
    gl_draw_string( 0.5,0.5,0.5, buf );
  
***************
*** 718,728 ****
    gl_pose_shift( &geom.pose );
    
!   double dx = geom.size.x / 2.0 * 1.3;
!   double dy = geom.size.y / 2.0 * 1.3;
!   
!   //glTranslatef( 0,0,0.1 );
    
    glRectf( -dx, -dy, dx, dy );
  
    glPopMatrix();
  }
--- 721,732 ----
    gl_pose_shift( &geom.pose );
    
!   double dx = geom.size.x / 2.0 * 1.6;
!   double dy = geom.size.y / 2.0 * 1.6;
    
+   PopColor();
+   PushColor( 1,0,0,0.8 ); // highlight color red
    glRectf( -dx, -dy, dx, dy );
  
+   PopColor();
    glPopMatrix();
  }
***************
*** 1167,1171 ****
    // will just be a few blocks, grippers 3 blocks, etc. not too bad. 
  
!   // no blocks? no hit!
    if( this->blocks == NULL )
      return NULL;
--- 1171,1175 ----
    // will just be a few blocks, grippers 3 blocks, etc. not too bad. 
  
!   // no blocks, no hit!
    if( this->blocks == NULL )
      return NULL;
***************
*** 1305,1310 ****
     if( hitthing )
       {
!        // printf( "hit %s at %.2f %.2f\n",
!        //    hitthing->Token(), hitx, hity );
       }
     else
--- 1309,1314 ----
     if( hitthing )
       {
!        printf( "hit %s at %.2f %.2f\n",
!              hitthing->Token(), hitx, hity );
       }
     else

Index: stest.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stest.cc,v
retrieving revision 1.1.2.17
retrieving revision 1.1.2.18
diff -C2 -d -r1.1.2.17 -r1.1.2.18
*** stest.cc    22 Nov 2007 01:36:47 -0000      1.1.2.17
--- stest.cc    26 Nov 2007 06:28:16 -0000      1.1.2.18
***************
*** 71,76 ****
     
    char namebuf[256];  
!   robot_t robots[POPSIZE];
    
    for( int i=0; i<POPSIZE; i++ )
      {
--- 71,79 ----
     
    char namebuf[256];  
!   //robot_t robots[POPSIZE];
    
+   robot_t* robots = new robot_t[POPSIZE];
+ 
+ 
    for( int i=0; i<POPSIZE; i++ )
      {
***************
*** 80,94 ****
         
         char* base = "r";
!        sprintf( namebuf, "%s%02d", base, i );
         robots[i].position = (StgModelPosition*)world.GetModel( namebuf );
         assert(robots[i].position);
         robots[i].position->Subscribe();
         
!        sprintf( namebuf, "%s%02d.laser:0", base, i );
         //robots[i].laser = (StgModelLaser*)world.GetModel( namebuf );
         //assert(robots[i].laser);
         //robots[i].laser->Subscribe();
  
!        sprintf( namebuf, "%s%02d.ranger:0", base, i );
         robots[i].ranger = (StgModelRanger*)world.GetModel( namebuf );
         assert(robots[i].ranger);
--- 83,97 ----
         
         char* base = "r";
!        sprintf( namebuf, "%s%d", base, i );
         robots[i].position = (StgModelPosition*)world.GetModel( namebuf );
         assert(robots[i].position);
         robots[i].position->Subscribe();
         
!        sprintf( namebuf, "%s%d.laser:0", base, i );
         //robots[i].laser = (StgModelLaser*)world.GetModel( namebuf );
         //assert(robots[i].laser);
         //robots[i].laser->Subscribe();
  
!        sprintf( namebuf, "%s%d.ranger:0", base, i );
         robots[i].ranger = (StgModelRanger*)world.GetModel( namebuf );
         assert(robots[i].ranger);
***************
*** 241,244 ****
--- 244,249 ----
    //#endif  
  
+ 
+     delete[] robots;  
    exit( 0 );
  }

Index: world.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/world.cc,v
retrieving revision 1.1.2.15
retrieving revision 1.1.2.16
diff -C2 -d -r1.1.2.15 -r1.1.2.16
*** world.cc    19 Nov 2007 07:40:41 -0000      1.1.2.15
--- world.cc    26 Nov 2007 06:28:16 -0000      1.1.2.16
***************
*** 209,213 ****
  #ifdef DEBUG
    if( hours > 0 )
!     snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.1f]\tsubs: %d  %s",
              hours, minutes, seconds, msec,
              localratio,
--- 209,213 ----
  #ifdef DEBUG
    if( hours > 0 )
!     snprintf( str, maxlen, "Time: %uh%02um%02u.%03us\t[%.6f]\tsubs: %d  %s",
              hours, minutes, seconds, msec,
              localratio,
***************
*** 215,219 ****
              paused ? "--PAUSED--" : "" );
    else
!     snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.1f]\tsubs: %d  %s",
              minutes, seconds, msec,
              localratio,
--- 215,219 ----
              paused ? "--PAUSED--" : "" );
    else
!     snprintf( str, maxlen, "Time: %02um%02u.%03us\t[%.6f]\tsubs: %d  %s",
              minutes, seconds, msec,
              localratio,
***************
*** 222,231 ****
  #else
    if( hours > 0 )
!     snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.1f] %s",
              hours, minutes, seconds, msec,
              localratio,
              paused ? "--PAUSED--" : "" );
    else
!     snprintf( str, maxlen, "%02um%02u.%03us\t[%.1f] %s",
              minutes, seconds, msec,
              localratio,
--- 222,231 ----
  #else
    if( hours > 0 )
!     snprintf( str, maxlen, "%uh%02um%02u.%03us\t[%.6f] %s",
              hours, minutes, seconds, msec,
              localratio,
              paused ? "--PAUSED--" : "" );
    else
!     snprintf( str, maxlen, "%02um%02u.%03us\t[%.6f] %s",
              minutes, seconds, msec,
              localratio,
***************
*** 239,242 ****
--- 239,244 ----
    fflush(stdout);
  
+   stg_usec_t load_start_time = RealTimeNow();
+ 
    this->wf = new CWorldFile();
    wf->Load( worldfile_path );
***************
*** 244,248 ****
  
    // end the output line of worldfile components
!   puts("");
  
    int entity = 0;
--- 246,250 ----
  
    // end the output line of worldfile components
!   //puts("");
  
    int entity = 0;
***************
*** 275,279 ****
  
    //_stg_disable_gui = wf->ReadInt( entity, "gui_disable", _stg_disable_gui );
- 
       
    // Iterate through entitys and create client-side models
--- 277,280 ----
***************
*** 318,322 ****
    
    // warn about unused WF linesa
!   //wf->WarnUnused();
  }
  
--- 319,328 ----
    
    // warn about unused WF linesa
!   wf->WarnUnused();
! 
!   stg_usec_t load_end_time = RealTimeNow();
! 
!   printf( "[Load time %.3fsec]\n", (load_end_time - load_start_time) / 
1000000.0 );
!   
  }
  
***************
*** 380,392 ****
        //PRINT_DEBUG( "StgWorld::Update()" );
  
! //       if( interval_real > 0 || updates % 100 == 0 )
! //    {
! //      char str[64];
! //      ClockString( str, 64 );
! //      //printf( "Stage timestep: %lu simtime: %lu\n",
! //      //      updates, sim_time );
! //      printf( "\r%s", str );
! //      fflush(stdout);
! //    }
  
        // update any models that are due to be updated
--- 386,396 ----
        //PRINT_DEBUG( "StgWorld::Update()" );
  
!        if( interval_real > 0 || updates % 100 == 0 )
!       {
!         char str[64];
!         ClockString( str, 64 );
!         printf( "\r%s", str );
!         fflush(stdout);
!       }
  
        // update any models that are due to be updated

Index: model_load.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_load.cc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** model_load.cc       31 Oct 2007 03:55:11 -0000      1.1.2.3
--- model_load.cc       26 Nov 2007 06:28:16 -0000      1.1.2.4
***************
*** 3,6 ****
--- 3,7 ----
  #include <libgen.h> // for dirname()
  #include <string.h>
+ #include "stage.hh"
  
  //#define DEBUG 1
***************
*** 15,20 ****
    
    if( wf->PropertyExists( this->id, "debug" ) )
!     this->debug = wf->ReadInt( this->id, "debug", this->debug );
!   
    if( wf->PropertyExists( this->id, "name" ) )
      {
--- 16,25 ----
    
    if( wf->PropertyExists( this->id, "debug" ) )
!     {
!       PRINT_WARN2( "debug property specified for model %d  %s\n",
!                  this->id, this->token );
!       this->debug = wf->ReadInt( this->id, "debug", this->debug );
!     }
! 
    if( wf->PropertyExists( this->id, "name" ) )
      {
***************
*** 38,60 ****
      {
        stg_geom_t geom;
!       this->GetGeom( &geom );
! 
        geom.pose.x = wf->ReadTupleLength(this->id, "origin", 0, geom.pose.x );
        geom.pose.y = wf->ReadTupleLength(this->id, "origin", 1, geom.pose.y );
!       geom.pose.z = wf->ReadTupleLength(this->id, "origin", 2, geom.pose.z );
!       geom.pose.a = wf->ReadTupleAngle(this->id, "origin", 3, geom.pose.a );
! 
        this->SetGeom( &geom );
      }
  
    if( wf->PropertyExists( this->id, "size" ) )
      {
        stg_geom_t geom;
!       this->GetGeom( &geom );
!       
        geom.size.x = wf->ReadTupleLength(this->id, "size", 0, geom.size.x );
        geom.size.y = wf->ReadTupleLength(this->id, "size", 1, geom.size.y );
!       geom.size.z = wf->ReadTupleLength(this->id, "size", 2, geom.size.z );
!       
        this->SetGeom( &geom );
      }
--- 43,80 ----
      {
        stg_geom_t geom;
!       GetGeom( &geom );
        geom.pose.x = wf->ReadTupleLength(this->id, "origin", 0, geom.pose.x );
        geom.pose.y = wf->ReadTupleLength(this->id, "origin", 1, geom.pose.y );
!       geom.pose.a =  wf->ReadTupleAngle(this->id, "origin", 2, geom.pose.a );
        this->SetGeom( &geom );
      }
  
+   if( wf->PropertyExists( this->id, "origin4" ) )
+     {
+       stg_geom_t geom;
+       GetGeom( &geom );
+       geom.pose.x = wf->ReadTupleLength(this->id, "origin4", 0, geom.pose.x );
+       geom.pose.y = wf->ReadTupleLength(this->id, "origin4", 1, geom.pose.y );
+       geom.pose.z = wf->ReadTupleLength(this->id, "origin4", 2, geom.pose.z );
+       geom.pose.a =  wf->ReadTupleAngle(this->id, "origin4", 3, geom.pose.a );
+       this->SetGeom( &geom );
+     }
+   
    if( wf->PropertyExists( this->id, "size" ) )
      {
        stg_geom_t geom;
!       GetGeom( &geom );
        geom.size.x = wf->ReadTupleLength(this->id, "size", 0, geom.size.x );
        geom.size.y = wf->ReadTupleLength(this->id, "size", 1, geom.size.y );
!       this->SetGeom( &geom );
!     }
! 
!   if( wf->PropertyExists( this->id, "size3" ) )
!     {
!       stg_geom_t geom;
!       GetGeom( &geom );
!       geom.size.x = wf->ReadTupleLength(this->id, "size3", 0, geom.size.x );
!       geom.size.y = wf->ReadTupleLength(this->id, "size3", 1, geom.size.y );
!       geom.size.z = wf->ReadTupleLength(this->id, "size3", 2, geom.size.z );  
    
        this->SetGeom( &geom );
      }
***************
*** 63,73 ****
      {
        stg_pose_t pose;
!       this->GetPose( &pose );
! 
        pose.x = wf->ReadTupleLength(this->id, "pose", 0, pose.x );
        pose.y = wf->ReadTupleLength(this->id, "pose", 1, pose.y ); 
!       pose.z = wf->ReadTupleLength(this->id, "pose", 2, pose.z ); 
!       pose.a = wf->ReadTupleAngle(this->id, "pose", 3,  pose.a );
! 
        this->SetPose( &pose );
      }
--- 83,102 ----
      {
        stg_pose_t pose;
!       GetPose( &pose );
        pose.x = wf->ReadTupleLength(this->id, "pose", 0, pose.x );
        pose.y = wf->ReadTupleLength(this->id, "pose", 1, pose.y ); 
!       pose.a =  wf->ReadTupleAngle(this->id, "pose", 2, pose.a );
!       this->SetPose( &pose );
!     }
!   
!   if( wf->PropertyExists( this->id, "pose4" ))
!     {
!       stg_pose_t pose;
!       GetPose( &pose );
!       pose.x = wf->ReadTupleLength(this->id, "pose4", 0, pose.x );
!       pose.y = wf->ReadTupleLength(this->id, "pose4", 1, pose.y ); 
!       pose.z = wf->ReadTupleLength(this->id, "pose4", 2, pose.z ); 
!       pose.a = wf->ReadTupleAngle( this->id, "pose4", 3,  pose.a );
!       
        this->SetPose( &pose );
      }
***************
*** 76,86 ****
      {
        stg_velocity_t vel;
!       this->GetVelocity( &vel );
!       
        vel.x = wf->ReadTupleLength(this->id, "velocity", 0, vel.x );
        vel.y = wf->ReadTupleLength(this->id, "velocity", 1, vel.y );
-       vel.z = wf->ReadTupleLength(this->id, "velocity", 2, vel.z );
        vel.a = wf->ReadTupleAngle(this->id, "velocity", 3,  vel.a );      
  
        this->SetVelocity( &vel );
      }
--- 105,123 ----
      {
        stg_velocity_t vel;
!       GetVelocity( &vel );
        vel.x = wf->ReadTupleLength(this->id, "velocity", 0, vel.x );
        vel.y = wf->ReadTupleLength(this->id, "velocity", 1, vel.y );
        vel.a = wf->ReadTupleAngle(this->id, "velocity", 3,  vel.a );      
+       this->SetVelocity( &vel );
+     }
  
+   if( wf->PropertyExists( this->id, "velocity4" ))
+     {
+       stg_velocity_t vel;
+       GetVelocity( &vel );
+       vel.x = wf->ReadTupleLength(this->id, "velocity4", 0, vel.x );
+       vel.y = wf->ReadTupleLength(this->id, "velocity4", 1, vel.y );
+       vel.z = wf->ReadTupleLength(this->id, "velocity4", 2, vel.z );
+       vel.a =  wf->ReadTupleAngle(this->id, "velocity4", 3,  vel.a );      
        this->SetVelocity( &vel );
      }

Index: model_ranger.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model_ranger.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_ranger.cc     22 Nov 2007 01:36:47 -0000      1.1.2.5
--- model_ranger.cc     26 Nov 2007 06:28:16 -0000      1.1.2.6
***************
*** 217,225 ****
  }
  
! int ranger_raytrace_match( StgBlock* block, StgModel* finder )
  {
    // Ignore myself, my children, and my ancestors.
    return( block->mod->RangerReturn() && !block->mod->IsRelated( finder ) );
-   //return true;
  }     
  
--- 217,224 ----
  }
  
! bool ranger_raytrace_match( StgBlock* block, StgModel* finder )
  {
    // Ignore myself, my children, and my ancestors.
    return( block->mod->RangerReturn() && !block->mod->IsRelated( finder ) );
  }     
  
***************
*** 239,286 ****
    for( unsigned int t=0; t<sensor_count; t++ )
      {
!       // get the sensor's pose in global coords
!       //stg_pose_t pz;
!       //memcpy( &pz, &sensors[t].pose, sizeof(pz) ); 
!       //this->LocalToGlobal( &pz );
!       
!       double range;
!       
!       int r;
!       for( r=0; r<sensors[t].ray_count; r++ )
!       {         
!         //double angle_per_ray = sensors[t].fov / sensors[t].ray_count;
!         //double ray_angle = -sensors[t].fov/2.0 + angle_per_ray * r + 
angle_per_ray/2.0;
!         
!         range = Raytrace( &sensors[t].pose,
!                           sensors[t].bounds_range.max,
!                           (stg_block_match_func_t)ranger_raytrace_match,
!                           this,
!                           NULL );                            
! 
! //      // if the ray hits anything, 'range' will be changed
! //      if( stg_first_model_on_ray( pz.x, pz.y, pz.z + 0.01, // TODO: UNHACK 
! //                                  pz.a + ray_angle, 
! //                                  sensors[t].bounds_range.max, 
! //                                  world->matrix, 
! //                                  PointToBearingRange, 
! //                                  ranger_raytrace_match,
! //                                  this,
! //                                  &hitrange, &hitx, &hity ) )
! //        {
! //          if( hitrange < range )
! //            range = hitrange;
! //        } 
! 
!         
!         //double a = sensors[t].pose.a + ray_angle;
!         //double dx = range * cos(a);//' + range * sin(a);
!         //double dy = range * sin(a);// - range * cos(a);
  
!         //glBegin( GL_LINES );
!         //glVertex3f( sensors[t].pose.x, sensors[t].pose.y, 0 );
!         //glVertex3f( sensors[t].pose.x+dx, sensors[t].pose.y+dy, 0 );
!         //glEnd();
!         //pop_color();
!       }
        // low-threshold the range
        if( range < sensors[t].bounds_range.min )
--- 238,253 ----
    for( unsigned int t=0; t<sensor_count; t++ )
      {
!       double range = 0;
  
!       // TODO - reinstate multi-ray rangers
!       //for( int r=0; r<sensors[t].ray_count; r++ )
!       //{       
!       range = Raytrace( &sensors[t].pose,
!                           sensors[t].bounds_range.max,
!                       (stg_block_match_func_t)ranger_raytrace_match,
!                       this,
!                       NULL );                        
!       //}
!       
        // low-threshold the range
        if( range < sensors[t].bounds_range.min )
***************
*** 288,303 ****
        
        sensors[t].range = range;
!       //sensors[t].error = TODO;
!       
!       
      }   
-   
-   //pop_color();
-   //glEndList();
- 
-   // data graphics will be updated before being drawn onscreen again
-   data_dirty = true;
  }
  
  /*
  int ranger_noise_test( stg_ranger_sample_t* data, size_t count,  )
--- 255,263 ----
        
        sensors[t].range = range;
!       //sensors[t].error = TODO;            
      }   
  }
  
+ // TODO: configurable ranger noise model
  /*
  int ranger_noise_test( stg_ranger_sample_t* data, size_t count,  )
***************
*** 323,379 ****
  }
  
- 
- void render_rangers( stg_ranger_sensor_t* sensors, size_t sensor_count )
- {
-   for( unsigned int s=0; s<sensor_count; s++ ) 
-     { 
-       if( sensors[s].range > 0.0 ) 
-       { 
-         stg_ranger_sensor_t* rngr = &sensors[s]; 
-         
-         // sensor FOV 
-         double sidelen = sensors[s].range; 
-         double da = rngr->fov/2.0; 
-             
-         double x1= rngr->pose.x + sidelen*cos(rngr->pose.a - da ); 
-         double y1= rngr->pose.y + sidelen*sin(rngr->pose.a - da ); 
-         double x2= rngr->pose.x + sidelen*cos(rngr->pose.a + da ); 
-         double y2= rngr->pose.y + sidelen*sin(rngr->pose.a + da ); 
-         
-         //printf( "%.2f %.2f  to %.2f %.2f\n",
-         //  rngr->pose.x, rngr->pose.y, x1, y1 );
-         
-         glBegin( GL_POLYGON);                 
-         glVertex3f( rngr->pose.x, rngr->pose.y, 0 ); 
-         glVertex3f( x1, y1, 0 ); 
-         glVertex3f( x2, y2, 0 ); 
-         glEnd();                    
-       } 
-     } 
- }
- 
  void StgModelRanger::DataVisualize( void )
  {
-   // recreate the display list for this data
-   //glNewList( this->dl_data, GL_COMPILE );
-   
    if( sensors && sensor_count ) 
      {
!       //puts( "ranger graphics" );
  
        glDepthMask( GL_FALSE ); 
- 
-       // now get on with rendering the ranger data 
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
!                    //              world->win->show_alpha ? GL_FILL : 
GL_LINES );
!       PushColor( 0, 1, 0, 0.2 ); // transparent pale green 
!       render_rangers( sensors, sensor_count );
!       PopColor(); 
! 
        // restore state 
        glDepthMask( GL_TRUE ); 
      }
- 
-   //glEndList();
  }
     
--- 283,331 ----
  }
  
  void StgModelRanger::DataVisualize( void )
  {
    if( sensors && sensor_count ) 
      {
!       // if all models have the same number of sensors, this is fast
!       // as it will probably not use a system call or cause a cache
!       // miss
!       static float* pts = NULL;
!       size_t memsize =  6 * sensor_count * sizeof(float);
!       pts = (float*)g_realloc( pts, memsize );
!       bzero( pts, memsize );
!       
!       // calculate a triangle for each non-zero sensor range
!       for( unsigned int s=0; s<sensor_count; s++ ) 
!       { 
!         if( sensors[s].range > 0.0 ) 
!           { 
!             stg_ranger_sensor_t* rngr = &sensors[s]; 
!             
!             // sensor FOV 
!             double sidelen = sensors[s].range; 
!             double da = rngr->fov/2.0; 
!             
!             unsigned int index = s*6;
!             pts[index+0] = rngr->pose.x;
!             pts[index+1] = rngr->pose.y;
!             pts[index+2] = rngr->pose.x + sidelen*cos(rngr->pose.a - da ); 
!             pts[index+3] = rngr->pose.y + sidelen*sin(rngr->pose.a - da ); 
!             pts[index+4] = rngr->pose.x + sidelen*cos(rngr->pose.a + da ); 
!             pts[index+5] = rngr->pose.y + sidelen*sin(rngr->pose.a + da ); 
!           }
!       }
  
+       // draw the filled triangles in transparent blue
        glDepthMask( GL_FALSE ); 
        glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
!       PushColor( 0, 1, 0, 0.1 ); // transparent pale green       
!       glEnableClientState( GL_VERTEX_ARRAY );
!       glVertexPointer( 2, GL_FLOAT, 0, pts );         
!       glDrawArrays( GL_TRIANGLES, 0, 3 * sensor_count );
!       
        // restore state 
        glDepthMask( GL_TRUE ); 
+       PopColor();
      }
  }
     

Index: stage.hh
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stage.hh,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -C2 -d -r1.1.2.16 -r1.1.2.17
*** stage.hh    22 Nov 2007 01:36:47 -0000      1.1.2.16
--- stage.hh    26 Nov 2007 06:28:16 -0000      1.1.2.17
***************
*** 695,703 ****
  class StgBlock;
  
! typedef int (*stg_block_match_func_t)(StgBlock* candidate, const void* arg );
! 
!   
! 
! 
  
  
--- 695,699 ----
  class StgBlock;
  
! typedef bool (*stg_block_match_func_t)(StgBlock* candidate, const void* arg );
  
  
***************
*** 1012,1015 ****
--- 1008,1015 ----
    bool graphics;
  
+   virtual void PushColor( stg_color_t col ) { /* do nothing */  };
+   virtual void PushColor( double r, double g, double b, double a ) { /* do 
nothing */  };
+   virtual void PopColor(){ /* do nothing */  };
+ 
    stg_usec_t real_time_now;
    stg_usec_t RealTimeNow(void);
***************
*** 1186,1193 ****
  
    void Say( char* str );
!   
!   void UpdateIfDue( void );
!   //void UpdateTree( void );
!   //void UpdateTreeIfDue( void );
  
    /** configure a model by reading from the current world file */
--- 1186,1190 ----
  
    void Say( char* str );
!     void UpdateIfDue( void );
  
    /** configure a model by reading from the current world file */
***************
*** 1197,1207 ****
    virtual void Draw( uint32_t flags );
    virtual void DrawPicker( void );
-   //virtual void DrawBody( void );
-   //virtual void DrawData( void );
    virtual void DataVisualize( void );
    void DrawGrid();
    virtual void DrawSelected(void);
-   //virtual void InitGraphics(void); // called by a world that supports
-                                  // graphics
  
    virtual void PushColor( stg_color_t col )
--- 1194,1200 ----
***************
*** 1497,1503 ****
  
    StgModel* mod; //< model to which this block belongs
-   
-   //void AddCell( StgCell* cell );
-   
    stg_point_int_t* pts_global; //< points defining a polygon in global coords
  
--- 1490,1493 ----

Index: worldfile.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldfile.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** worldfile.cc        4 Oct 2007 01:17:03 -0000       1.1.2.1
--- worldfile.cc        26 Nov 2007 06:28:16 -0000      1.1.2.2
***************
*** 59,62 ****
--- 59,74 ----
  
  
+ 
+ // guint PropertyHash( const CProperty* prop )
+ // {
+ //   char key[128];
+ //   snprintf( key, 127, "%d%s", prop->entity, prop->name );
+ //   prop->key = strdup( key );
+   
+ //   return g_str_hash( prop->key );
+ // }
+ 
+ 
+ 
  ///////////////////////////////////////////////////////////////////////////
  // Default constructor
***************
*** 78,87 ****
  
    this->property_count = 0;
!   this->property_size = 0;
!   this->properties = NULL;
  
    // Set defaults units
    this->unit_length = 1.0;
    this->unit_angle = M_PI / 180;
  }
  
--- 90,101 ----
  
    this->property_count = 0;
!   //this->property_size = 0;
!   //this->properties = NULL;
  
    // Set defaults units
    this->unit_length = 1.0;
    this->unit_angle = M_PI / 180;
+ 
+   this->nametable = g_hash_table_new( g_str_hash, g_str_equal );
  }
  
***************
*** 96,99 ****
--- 110,115 ----
    ClearTokens();
  
+   g_hash_table_destroy( this->nametable );
+   
    if (this->filename)
      free(this->filename);
***************
*** 245,260 ****
  bool CWorldFile::WarnUnused()
  {
!   bool unused = false;
!   for (int i = 0; i < this->property_count; i++)
!   {
!     CProperty *property = this->properties + i;
!     if (!property->used)
!     {
!       unused = true;
!       PRINT_WARN3("worldfile %s:%d : property [%s] is defined but not used",
!                   this->filename, property->line, property->name);
!     }
!   }
!   return unused;
  }
  
--- 261,277 ----
  bool CWorldFile::WarnUnused()
  {
! //   bool unused = false;
! //   for (int i = 0; i < this->property_count; i++)
! //   {
! //     CProperty *property = this->properties + i;
! //     if (!property->used)
! //     {
! //       unused = true;
! //       PRINT_WARN3("worldfile %s:%d : property [%s] is defined but not 
used",
! //                   this->filename, property->line, property->name);
! //     }
! //   }
! //   return unused;
!   return false;
  }
  
***************
*** 1052,1056 ****
  bool CWorldFile::ParseTokenProperty(int entity, int *index, int *line)
  {
!   int i, property;
    int name, value, count;
    CToken *token;
--- 1069,1074 ----
  bool CWorldFile::ParseTokenProperty(int entity, int *index, int *line)
  {
!   int i;
!   CProperty* property;
    int name, value, count;
    CToken *token;
***************
*** 1078,1082 ****
        case TokenOpenTuple:
          property = AddProperty(entity, GetTokenValue(name), *line);
!         if (!ParseTokenTuple(entity, property, &i, line))
            return false;
          *index = i;
--- 1096,1100 ----
        case TokenOpenTuple:
          property = AddProperty(entity, GetTokenValue(name), *line);
!         if (!ParseTokenTuple( property, &i, line))
            return false;
          *index = i;
***************
*** 1095,1099 ****
  ///////////////////////////////////////////////////////////////////////////
  // Parse a tuple.
! bool CWorldFile::ParseTokenTuple(int entity, int property, int *index, int 
*line)
  {
    int i, count;
--- 1113,1117 ----
  ///////////////////////////////////////////////////////////////////////////
  // Parse a tuple.
! bool CWorldFile::ParseTokenTuple( CProperty* property, int *index, int *line)
  {
    int i, count;
***************
*** 1279,1282 ****
--- 1297,1306 ----
  
  
+ void PrintProp( char* key, CProperty* prop, void* user )
+ {
+   if( prop )
+     printf( "Print key %s prop ent %d name %s\n", key, prop->entity, 
prop->name );
+ }
+ 
  ///////////////////////////////////////////////////////////////////////////
  // Dump the entity list for debugging
***************
*** 1284,1294 ****
  {
    printf("\n## begin entities\n");
!   for (int i = 0; i < this->entity_count; i++)
!   {
!     CEntity *entity = this->entities + i;
  
-     printf("## [%d][%d]", i, entity->parent);
-     printf("[%s]\n", entity->type);
-   }
    printf("## end entities\n");
  }
--- 1308,1314 ----
  {
    printf("\n## begin entities\n");
!   
!   g_hash_table_foreach( this->nametable, (GHFunc)PrintProp, NULL );
  
    printf("## end entities\n");
  }
***************
*** 1299,1314 ****
  void CWorldFile::ClearProperties()
  {
-   int i;
-   CProperty *property;
- 
-   for (i = 0; i < this->property_count; i++)
-   {
-     property = this->properties + i;
-     free(property->values);
-   }
-   free(this->properties);
-   this->properties = NULL;
-   this->property_size = 0;
    this->property_count = 0;
  }
  
--- 1319,1327 ----
  void CWorldFile::ClearProperties()
  {
    this->property_count = 0;
+   
+   if( this->nametable )
+     g_hash_table_destroy( this->nametable );
+   this->nametable = g_hash_table_new( g_str_hash, g_str_equal );
  }
  
***************
*** 1316,1345 ****
  ///////////////////////////////////////////////////////////////////////////
  // Add an property
! int CWorldFile::AddProperty(int entity, const char *name, int line)
  {
!   int i;
!   CProperty *property;
    
-   // See if this property already exists; if it does, we dont need to
-   // add it again.
-   for (i = 0; i < this->property_count; i++)
-   {
-     property = this->properties + i;
-     if (property->entity != entity)
-       continue;
-     if (strcmp(property->name, name) == 0)
-       return i;
-   }
- 
-   // Expand property array if necessary.
-   if (i >= this->property_size)
-   {
-     this->property_size += 100;
-     this->properties = (CProperty*)
-       realloc(this->properties, this->property_size * 
sizeof(this->properties[0]));
-   }
- 
-   property = this->properties + i;
-   memset(property, 0, sizeof(CProperty));
    property->entity = entity;
    property->name = name;
--- 1329,1337 ----
  ///////////////////////////////////////////////////////////////////////////
  // Add an property
! CProperty* CWorldFile::AddProperty(int entity, const char *name, int line)
  {
!   //int i;
!   CProperty *property = g_new0( CProperty, 1 );
    
    property->entity = entity;
    property->name = name;
***************
*** 1349,1355 ****
    property->used = false;
  
    this->property_count++;
  
!   return i;
  }
  
--- 1341,1356 ----
    property->used = false;
  
+   char key[128];
+   snprintf( key, 127, "%d%s", entity, name );
+   property->key = strdup( key );
+   
+   // add this property to a hash table keyed by name for fast lookup
+   g_hash_table_insert( nametable, property->key, property );
+   
+   //printf( "added key %s for prop %p entity %d name %s\n", key, property, 
property->entity, property->name );
+   
    this->property_count++;
  
!   return property;
  }
  
***************
*** 1357,1391 ****
  ///////////////////////////////////////////////////////////////////////////
  // Add an property value
! void CWorldFile::AddPropertyValue(int property, int index, int value_token)
  {
!   assert(property >= 0);
!   CProperty *pproperty = this->properties + property;
  
    // Expand the array if it's too small
!   if (index >= pproperty->value_count)
    {
!     pproperty->value_count = index + 1;
!     pproperty->values = (int*) realloc(pproperty->values, 
pproperty->value_count * sizeof(int));
    }
  
    // Set the relevant value
!   pproperty->values[index] = value_token;
  }
  
  
  ///////////////////////////////////////////////////////////////////////////
  // Get an property 
! int CWorldFile::GetProperty(int entity, const char *name)
  {
!   // Find first instance of property
!   for (int i = 0; i < this->property_count; i++)
!   {
!     CProperty *property = this->properties + i;
!     if (property->entity != entity)
!       continue;
!     if (strcmp(property->name, name) == 0)
!       return i;
!   }
!   return -1;
  }
  
--- 1358,1397 ----
  ///////////////////////////////////////////////////////////////////////////
  // Add an property value
! void CWorldFile::AddPropertyValue( CProperty* property, int index, int 
value_token)
  {
!   assert(property);
  
    // Expand the array if it's too small
!   if (index >= property->value_count)
    {
!     property->value_count = index + 1;
!     property->values = (int*) realloc(property->values, property->value_count 
* sizeof(int));
    }
  
    // Set the relevant value
!   property->values[index] = value_token;
  }
  
  
+ 
  ///////////////////////////////////////////////////////////////////////////
  // Get an property 
! CProperty* CWorldFile::GetProperty(int entity, const char *name)
  {
!   char key[128];
!   snprintf( key, 127, "%d%s", entity, name );
!   
!   //  printf( "looking up key %s for entity %d name %s\n", key, entity, name 
);
! 
!   // g_hash_table_foreach( this->nametable, (GHFunc)PrintProp, NULL );
! 
!   CProperty* prop = (CProperty*)g_hash_table_lookup( this->nametable, key );
! 
!  //  if( prop )
! //     printf( "found entity %d name %s\n", prop->entity, prop->name );
! //   else
! //     printf( "key %s not found\n", key );
! 
!   return prop;  
  }
  
***************
*** 1393,1397 ****
  bool CWorldFile::PropertyExists( int section, char* token )
  {
!   return( this->GetProperty( section, token ) > -1 );
  }
  
--- 1399,1403 ----
  bool CWorldFile::PropertyExists( int section, char* token )
  {
!   return( this->GetProperty( section, token ) ? true : false );
  }
  
***************
*** 1399,1412 ****
  ///////////////////////////////////////////////////////////////////////////
  // Set the value of an property
! void CWorldFile::SetPropertyValue(int property, int index, const char *value)
  {
!   //assert(property >= 0 && property < this->property_count);
!   if(property < 0 || property >= this->property_count)
!     return;
!   CProperty *pproperty = this->properties + property;
!   assert(index >= 0 && index < pproperty->value_count);
  
    // Set the relevant value
!   SetTokenValue(pproperty->values[index], value);
  }
  
--- 1405,1415 ----
  ///////////////////////////////////////////////////////////////////////////
  // Set the value of an property
! void CWorldFile::SetPropertyValue( CProperty* property, int index, const char 
*value)
  {
!   assert( property );
!   assert(index >= 0 && index < property->value_count);
  
    // Set the relevant value
!   SetTokenValue( property->values[index], value);
  }
  
***************
*** 1414,1432 ****
  ///////////////////////////////////////////////////////////////////////////
  // Get the value of an property 
! const char *CWorldFile::GetPropertyValue(int property, int index)
  {
!   assert(property >= 0);
!   CProperty *pproperty = this->properties + property;
! 
!   // changed this as the assert prevents us for asking for a value
!   // that does not exist in the array - it should fail nicely rather
!   // than crashing out -rtv
!   //assert(index < pproperty->value_count);
!   
!   if( !(index < pproperty->value_count) )
!     return NULL;
! 
!   pproperty->used = true;
!   return GetTokenValue(pproperty->values[index]);
  }
  
--- 1417,1425 ----
  ///////////////////////////////////////////////////////////////////////////
  // Get the value of an property 
! const char *CWorldFile::GetPropertyValue(CProperty* property, int index)
  {
!   assert(property);
!   property->used = true;
!   return GetTokenValue(property->values[index]);
  }
  
***************
*** 1437,1452 ****
  {
    printf("\n## begin properties\n");
!   for (int i = 0; i < this->property_count; i++)
!   {
!     CProperty *property = this->properties + i;
!     CEntity *entity = this->entities + property->entity;
      
!     printf("## [%d]", property->entity);
!     printf("[%s]", entity->type);
!     printf("[%s]", property->name);
!     for (int j = 0; j < property->value_count; j++)
!       printf("[%s]", GetTokenValue(property->values[j]));
!     printf("\n");
!   }
    printf("## end properties\n");
  }
--- 1430,1445 ----
  {
    printf("\n## begin properties\n");
! //   for (int i = 0; i < this->property_count; i++)
! //   {
! //     CProperty *property = this->properties + i;
! //     CEntity *entity = this->entities + property->entity;
      
! //     printf("## [%d]", property->entity);
! //     printf("[%s]", entity->type);
! //     printf("[%s]", property->name);
! //     for (int j = 0; j < property->value_count; j++)
! //       printf("[%s]", GetTokenValue(property->values[j]));
! //     printf("\n");
! //   }
    printf("## end properties\n");
  }
***************
*** 1457,1462 ****
  const char *CWorldFile::ReadString(int entity, const char *name, const char 
*value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return GetPropertyValue(property, 0);
--- 1450,1455 ----
  const char *CWorldFile::ReadString(int entity, const char *name, const char 
*value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return GetPropertyValue(property, 0);
***************
*** 1468,1473 ****
  void CWorldFile::WriteString(int entity, const char *name, const char *value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return;
    SetPropertyValue(property, 0, value);  
--- 1461,1466 ----
  void CWorldFile::WriteString(int entity, const char *name, const char *value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if( property == NULL )
      return;
    SetPropertyValue(property, 0, value);  
***************
*** 1479,1484 ****
  int CWorldFile::ReadInt(int entity, const char *name, int value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atoi(GetPropertyValue(property, 0));
--- 1472,1477 ----
  int CWorldFile::ReadInt(int entity, const char *name, int value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atoi(GetPropertyValue(property, 0));
***************
*** 1509,1514 ****
  double CWorldFile::ReadFloat(int entity, const char *name, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, 0));
--- 1502,1507 ----
  double CWorldFile::ReadFloat(int entity, const char *name, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atof(GetPropertyValue(property, 0));
***************
*** 1520,1525 ****
  double CWorldFile::ReadLength(int entity, const char *name, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, 0)) * this->unit_length;
--- 1513,1518 ----
  double CWorldFile::ReadLength(int entity, const char *name, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atof(GetPropertyValue(property, 0)) * this->unit_length;
***************
*** 1540,1545 ****
  double CWorldFile::ReadAngle(int entity, const char *name, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, 0)) * this->unit_angle;
--- 1533,1538 ----
  double CWorldFile::ReadAngle(int entity, const char *name, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atof(GetPropertyValue(property, 0)) * this->unit_angle;
***************
*** 1552,1556 ****
  {
  //return (bool) ReadInt(entity, name, value);
!   int property = GetProperty(entity, name);
    if (property < 0)
      return value;
--- 1545,1549 ----
  {
  //return (bool) ReadInt(entity, name, value);
!   CProperty* property = GetProperty(entity, name);
    if (property < 0)
      return value;
***************
*** 1572,1580 ****
  uint32_t CWorldFile::ReadColor(int entity, const char *name, uint32_t value)
  {
!   int property;
    const char *color;
    
    property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    color = GetPropertyValue(property, 0);
--- 1565,1573 ----
  uint32_t CWorldFile::ReadColor(int entity, const char *name, uint32_t value)
  {
!   CProperty* property;
    const char *color;
    
    property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    color = GetPropertyValue(property, 0);
***************
*** 1594,1599 ****
  const char *CWorldFile::ReadFilename(int entity, const char *name, const char 
*value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    const char *filename = GetPropertyValue(property, 0);
--- 1587,1592 ----
  const char *CWorldFile::ReadFilename(int entity, const char *name, const char 
*value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    const char *filename = GetPropertyValue(property, 0);
***************
*** 1643,1648 ****
                                          int index, const char *value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return GetPropertyValue(property, index);
--- 1636,1641 ----
                                          int index, const char *value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL)
      return value;
    return GetPropertyValue(property, index);
***************
*** 1655,1659 ****
                                    int index, const char *value)
  {
!   int property = GetProperty(entity, name);
    /* TODO
    if (property < 0)
--- 1648,1652 ----
                                    int index, const char *value)
  {
!   CProperty* property = GetProperty(entity, name);
    /* TODO
    if (property < 0)
***************
*** 1669,1674 ****
                                    int index, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, index));
--- 1662,1667 ----
                                    int index, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atof(GetPropertyValue(property, index));
***************
*** 1692,1697 ****
                                     int index, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, index)) * this->unit_length;
--- 1685,1690 ----
                                     int index, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL )
      return value;
    return atof(GetPropertyValue(property, index)) * this->unit_length;
***************
*** 1715,1720 ****
                                    int index, double value)
  {
!   int property = GetProperty(entity, name);
!   if (property < 0)
      return value;
    return atof(GetPropertyValue(property, index)) * this->unit_angle;
--- 1708,1713 ----
                                    int index, double value)
  {
!   CProperty* property = GetProperty(entity, name);
!   if (property == NULL)
      return value;
    return atof(GetPropertyValue(property, index)) * this->unit_angle;

Index: canvas.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/canvas.cc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** canvas.cc   22 Nov 2007 01:36:47 -0000      1.1.2.4
--- canvas.cc   26 Nov 2007 06:28:16 -0000      1.1.2.5
***************
*** 52,65 ****
    showflags = (showflags ^ invertflags);
  
!   printf( "flags %u data %d grid %d blocks %d follow %d clock %d tree %d occ 
%d\n",
!         showflags, 
!         showflags & STG_SHOW_DATA,
!         showflags & STG_SHOW_GRID,
!         showflags & STG_SHOW_BLOCKS,
!         showflags & STG_SHOW_FOLLOW,
!         showflags & STG_SHOW_CLOCK,
!         showflags & STG_SHOW_QUADTREE,
!         showflags & STG_SHOW_OCCUPANCY );
!         
  }
  
--- 52,64 ----
    showflags = (showflags ^ invertflags);
  
! //   printf( "flags %u data %d grid %d blocks %d follow %d clock %d tree %d 
occ %d\n",
! //      showflags, 
! //      showflags & STG_SHOW_DATA,
! //      showflags & STG_SHOW_GRID,
! //      showflags & STG_SHOW_BLOCKS,
! //      showflags & STG_SHOW_FOLLOW,
! //      showflags & STG_SHOW_CLOCK,
! //      showflags & STG_SHOW_QUADTREE,
! //      showflags & STG_SHOW_OCCUPANCY );
  }
  
***************
*** 166,175 ****
        else
        {
          scale -= 0.5 * (double)Fl::event_dy();
          if( scale < 1 )
            scale = 1;    
  
-         //if( width
- 
          invalidate();
        }
--- 165,173 ----
        else
        {
+         //scale -= 0.5 * (double)Fl::event_dy();
          scale -= 0.5 * (double)Fl::event_dy();
          if( scale < 1 )
            scale = 1;    
  
          invalidate();
        }
***************
*** 332,335 ****
--- 330,335 ----
  void StgCanvas::draw() 
  {
+   //  static int centerx = 0, centery = 0;
+ 
    if (!valid()) 
      { 
***************
*** 357,386 ****
        double pixels_height = h();
        
        glMatrixMode (GL_PROJECTION);
!       glLoadIdentity ();
        
!       // map the viewport to pixel units by scaling it the same as the window
        glOrtho( -pixels_width/2.0, pixels_width/2.0,
!              -pixels_height/2.0, pixels_height/2.0,
!              0, zclip );
!       
!       glMatrixMode (GL_MODELVIEW);
!       
        glLoadIdentity ();
- 
- 
-       glTranslatef(  -panx, 
-                    -pany, 
-                    -zclip / 2.0 );
-       
-       glRotatef( RTOD(-stheta), 1,0,0);  
-       
-       //glTranslatef(  -panx * cos(sphi) - pany*sin(sphi), 
-       //       panx*sin(sphi) - pany*cos(sphi), 0 );
        
!       glRotatef( RTOD(sphi), 0.0, 0.0, 1.0);   // rotate about z - pitch
        
!       // meter scale
!       glScalef ( scale, scale, scale ); // zoom
      }      
  
--- 357,381 ----
        double pixels_height = h();
        
+       // map the viewport to pixel units by scaling it the same as the window
        glMatrixMode (GL_PROJECTION);
!       glLoadIdentity ();      
        
! 
        glOrtho( -pixels_width/2.0, pixels_width/2.0,
!              -pixels_height/2.0, pixels_height/2.0,
!              -zclip, zclip );
!             
!       // set the modelview matrix
!       glMatrixMode (GL_MODELVIEW);      
        glLoadIdentity ();
        
!       // move the next two lines...
!       glScalef( scale, scale, scale ); 
!       glTranslatef(  -panx/scale, -pany/scale, 0 );
! 
!       glRotatef( RTOD(-stheta), fabs(cos(sphi)), 0, 0 );
!       glRotatef( RTOD(sphi), 0,0,1 );   // rotate about z - yaw
        
!       // ... to here to get rotation about the center of the window (but 
broken panning)
      }      
  
***************
*** 404,407 ****
--- 399,403 ----
    
  
+   // if following selected, shift the view to above the selected robot
    if( (showflags & STG_SHOW_FOLLOW)  && last_selection )
      {      
***************
*** 455,471 ****
        glEnable( GL_LINE_SMOOTH );
       }
! 
!   colorstack.Push( 1, 0, 0 );
!   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
!   glLineWidth( 4 );
!   
!   for( GList* it=selected_models; it; it=it->next )
!       ((StgModel*)it->data)->DrawSelected();
! 
!   colorstack.Pop();
!   
!   glLineWidth( 1 );
!   
!   
    // draw the models
    GList* it;
--- 451,458 ----
        glEnable( GL_LINE_SMOOTH );
       }
!    
!    for( GList* it=selected_models; it; it=it->next )
!      ((StgModel*)it->data)->DrawSelected();
!    
    // draw the models
    GList* it;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to