Revision: 7361
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7361&view=rev
Author:   rtv
Date:     2009-03-03 20:45:37 +0000 (Tue, 03 Mar 2009)

Log Message:
-----------
attempt to fix GL bug in laser code (bug 2642532)

Modified Paths:
--------------
    code/stage/trunk/examples/ctrl/fasr.cc
    code/stage/trunk/libstage/model_getset.cc
    code/stage/trunk/libstage/model_laser.cc
    code/stage/trunk/libstage/stage.cc
    code/stage/trunk/libstage/stage.hh

Modified: code/stage/trunk/examples/ctrl/fasr.cc
===================================================================
--- code/stage/trunk/examples/ctrl/fasr.cc      2009-03-03 18:40:23 UTC (rev 
7360)
+++ code/stage/trunk/examples/ctrl/fasr.cc      2009-03-03 20:45:37 UTC (rev 
7361)
@@ -368,9 +368,6 @@
                  printf( "unrecognized mode %u\n", robot->mode );              
                }
   
-        //if( robot->charger_ahoy )
-        //return 1;
-        //else
         return 0;
   }
 

Modified: code/stage/trunk/libstage/model_getset.cc
===================================================================
--- code/stage/trunk/libstage/model_getset.cc   2009-03-03 18:40:23 UTC (rev 
7360)
+++ code/stage/trunk/libstage/model_getset.cc   2009-03-03 20:45:37 UTC (rev 
7361)
@@ -180,19 +180,12 @@
   if( parent == NULL )
     return pose;
   
-  // otherwise  
-  
+  // otherwise    
   Pose global_pose = pose_sum( parent->GetGlobalPose(), pose );                
   
   // we are on top of our parent
   global_pose.z += parent->geom.size.z;
   
-  //   PRINT_DEBUG4( "GET GLOBAL POSE [x:%.2f y:%.2f z:%.2f a:%.2f]",
-  //           global_pose.x,
-  //           global_pose.y,
-  //           global_pose.z,
-  //           global_pose.a );
-
   return global_pose;
 }
 

Modified: code/stage/trunk/libstage/model_laser.cc
===================================================================
--- code/stage/trunk/libstage/model_laser.cc    2009-03-03 18:40:23 UTC (rev 
7360)
+++ code/stage/trunk/libstage/model_laser.cc    2009-03-03 20:45:37 UTC (rev 
7361)
@@ -105,9 +105,6 @@
   // set default color
   SetColor( stg_lookup_color(DEFAULT_COLOR));
   
-  if( world->IsGUI() )
-    data_dl = glGenLists(1);
-       
   RegisterOption( &showLaserData );
   RegisterOption( &showLaserStrikes );
   RegisterOption( &showLaserFov );
@@ -320,6 +317,9 @@
     {      
       data_dirty = false;
 
+               if( data_dl < 1 )
+                 data_dl = glGenLists(1);
+       
       glNewList( data_dl, GL_COMPILE );
 
       glTranslatef( 0,0, geom.size.z/2.0 ); // shoot the laser beam out at the 
right height

Modified: code/stage/trunk/libstage/stage.cc
===================================================================
--- code/stage/trunk/libstage/stage.cc  2009-03-03 18:40:23 UTC (rev 7360)
+++ code/stage/trunk/libstage/stage.cc  2009-03-03 20:45:37 UTC (rev 7361)
@@ -53,18 +53,7 @@
        return init_called;
 }
 
-double Stg::normalize( double a )
-{
-  assert( ! isnan(a) );
-  
-  //return( atan2(sin(a), cos(a)));
-  // faster than return( atan2(sin(a), cos(a)));
-  while( a < -M_PI ) a += (2.0 * M_PI);
-  while( a > M_PI ) a -= (2.0 * M_PI);
-  return a;
-};
 
-
 void Stg::RegisterModel( stg_model_type_t type, 
                                                                 const char* 
name, 
                                                                 stg_creator_t 
creator )
@@ -210,21 +199,6 @@
 }      
 
 
-// returns the pose of p2 in p1's coordinate system
-Pose Stg::pose_sum( const Pose& p1, const Pose& p2 )
-{
-       double cosa = cos(p1.a);
-       double sina = sin(p1.a);
-
-       Pose result;
-       result.x = p1.x + p2.x * cosa - p2.y * sina;
-       result.y = p1.y + p2.x * sina + p2.y * cosa;
-       result.z = p1.z + p2.z;
-       result.a = normalize(p1.a + p2.a);
-
-       return result;
-}
-
 // returns the resultant of vector [p1] and [p2] 
 Pose Stg::pose_scale( const Pose& p1, const double sx, const double sy, const 
double sz )
 {

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-03-03 18:40:23 UTC (rev 7360)
+++ code/stage/trunk/libstage/stage.hh  2009-03-03 20:45:37 UTC (rev 7361)
@@ -158,7 +158,12 @@
   inline double dtor( double d ){ return( d*M_PI/180.0 ); }
 
   /** Normalize an angle to within +/_ M_PI. */
-  double normalize( double a );
+  inline double normalize( const double a )
+  {
+        static const double TWO_PI = 2.0 * M_PI;
+        assert( ! isnan(a) );  
+        return( fmod(a + M_PI, TWO_PI ) - M_PI);
+  };
 
   /** take binary sign of a, either -1, or 1 if >= 0 */
   inline int sgn( int a){ return( a<0 ? -1 : 1); }
@@ -562,8 +567,20 @@
   stg_color_t stg_lookup_color(const char *name);
 
   /** returns the sum of [p1] + [p2], in [p1]'s coordinate system */
-  Pose pose_sum( const Pose& p1, const Pose& p2 );
-  
+  inline Pose pose_sum( const Pose& p1, const Pose& p2 )
+  {
+        double cosa = cos(p1.a);
+        double sina = sin(p1.a);
+        
+        Pose result;
+        result.x = p1.x + p2.x * cosa - p2.y * sina;
+        result.y = p1.y + p2.x * sina + p2.y * cosa;
+        result.z = p1.z + p2.z;
+        result.a = normalize(p1.a + p2.a);
+        
+        return result;
+  }
+
   /** returns a new pose, with each axis scaled */
   Pose pose_scale( const Pose& p1, const double x, const double y, const 
double z );
 
@@ -735,66 +752,6 @@
       record within a model and called whenever the record is set.*/
   typedef int (*stg_model_callback_t)( Model* mod, void* user );
   
- //  class Puck
-//   {
-//   private:
-//      void BuildDisplayList();
-
-//   public:
-//      stg_color_t color;
-//      int displaylist;
-//      stg_meters_t height;
-//      Pose pose;
-//      stg_meters_t radius;
-        
-//      Puck();
-//      void Load( Worldfile* wf, int section );
-//      void Save( Worldfile* wf, int section );
-        
-//      void Draw();  
-//   };
-  
-  
- //  class EventQueue
-//   {
-//   private:
-//      GTree* future;
-
-//      static gint InstantCompare( stg_usec_t a, stg_usec_t b )
-//      {
-//             if( a < b )
-//               return -1;
-               
-//             if( a > b )
-//               return 1;
-
-//             return 0; // they are equal
-//      }
-
-//   public:
-//      EventQueue()
-//      {
-//             future = g_tree_new( InstantCompare );
-//      }
-
-//      RunInstant() ///< Updates all events due at the next instant
-//      {
-//             GList* instant_list = 
-//      }
-        
-//      QueueModel( Model* mod ) ///< Adds the model to the event queue
-//      {
-//             g_tree_insert( mod->updatedue, g_list_prepend( g_tree_lookup( 
mod->updatedue ), mod ); );
-//      }
-
-//      DeQueueModel( Model* mod ) ///< removes the model from the event queue
-//      {
-//             g_tree_insert( mod->updatedue, g_list_remove( g_tree_lookup( 
mod->updatedue ), mod ));          
-//      }
-        
-//   };
-
-
   // ANCESTOR CLASS
   /** Base class for Model and World */
   class Ancestor


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to