Revision: 7932
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7932&view=rev
Author:   rtv
Date:     2009-06-30 22:26:15 +0000 (Tue, 30 Jun 2009)

Log Message:
-----------
tweaking velocity & charge lists

Modified Paths:
--------------
    code/stage/trunk/libstage/model_load.cc
    code/stage/trunk/libstage/stage.hh
    code/stage/trunk/libstage/world.cc

Modified: code/stage/trunk/libstage/model_load.cc
===================================================================
--- code/stage/trunk/libstage/model_load.cc     2009-06-30 22:03:37 UTC (rev 
7931)
+++ code/stage/trunk/libstage/model_load.cc     2009-06-30 22:26:15 UTC (rev 
7932)
@@ -56,8 +56,9 @@
         PRINT_WARN1( "Model %s: Setting \"watts_give\" has no effect unless 
\"joules\" is specified for this model or a parent", token );
   
   if( watts_give ) // need to get the world to test this model for charging
-        if( ! g_list_find( world->charge_list, this ) )
-               world->charge_list = g_list_append( world->charge_list, this );
+       //if( ! g_list_find( world->charge_list, this ) )
+       //world->charge_list = g_list_append( world->charge_list, this );
+       world->ChargeListAdd( this );
   
   watts_take = wf->ReadFloat( wf_entity, "take_watts", watts_take );
   if( (watts_take > 0.0) & !pp )

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2009-06-30 22:03:37 UTC (rev 7931)
+++ code/stage/trunk/libstage/stage.hh  2009-06-30 22:26:15 UTC (rev 7932)
@@ -940,7 +940,7 @@
     static void UpdateCb( World* world);
     static unsigned int next_id; ///<initially zero, used to allocate unique 
sequential world ids
         
-    GList* charge_list; ///< Models which receive charge are listed here
+       std::set<Model*> charge_list; ///< Models which receive charge are 
listed here
     bool destroy;
     bool dirty; ///< iff true, a gui redraw would be required
         GList* event_list; //< 
@@ -956,7 +956,7 @@
         unsigned int show_clock_interval; ///< updates between clock xoutputs
     GMutex* thread_mutex; ///< protect the worker thread management stuff
     int total_subs; ///< the total number of subscriptions to all models
-       std::vector<Model*> velocity_list; ///< Models with non-zero velocity 
and should have their poses updated
+       std::set<Model*> velocity_list; ///< Models with non-zero velocity and 
should have their poses updated
        
        unsigned int worker_threads; ///< the number of worker threads to use
        unsigned int threads_working; ///< the number of worker threads not yet 
finished
@@ -980,6 +980,7 @@
         std::map<stg_point_int_t,SuperRegion*> superregions;
     SuperRegion* sr_cached; ///< The last superregion looked up by this world
        
+       // todo - test performance of std::set
        std::vector<std::vector<Model*> > update_lists;  
         
     long unsigned int updates; ///< the number of simulated time steps 
executed so far
@@ -1105,6 +1106,9 @@
     
        void VelocityListAdd( Model* mod );
        void VelocityListRemove( Model* mod );
+       
+       void ChargeListAdd( Model* mod );
+       void ChargeListRemove( Model* mod );
 
     static gpointer update_thread_entry( std::pair<World*,int>* info );
         

Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc  2009-06-30 22:03:37 UTC (rev 7931)
+++ code/stage/trunk/libstage/world.cc  2009-06-30 22:26:15 UTC (rev 7932)
@@ -78,7 +78,7 @@
                          double ppm )
   : 
   // private
-  charge_list( NULL ),
+  charge_list(),
   destroy( false ),
   dirty( true ),
   models_by_name( g_hash_table_new( g_str_hash, g_str_equal ) ),
@@ -538,7 +538,8 @@
 
   // test all models that supply charge to see if they are touching
   // something that takes charge
-  LISTMETHOD( charge_list, Model*, UpdateCharge );
+  FOR_EACH( it, charge_list )
+       (*it)->UpdateCharge();
   
   // then update all models on the update lists
   FOR_EACH( it, update_lists[0] )
@@ -1091,14 +1092,24 @@
 
 void World::VelocityListAdd( Model* mod )
 { 
-  velocity_list.push_back( mod );
+  velocity_list.insert( mod );
 }
 
 void World::VelocityListRemove( Model* mod )
 { 
-  velocity_list.erase( remove( velocity_list.begin(), velocity_list.end(), mod 
));
+  velocity_list.erase( mod );
 }
 
+void World::ChargeListAdd( Model* mod )
+{ 
+  charge_list.insert( mod );
+}
+
+void World::ChargeListRemove( Model* mod )
+{ 
+  charge_list.erase( mod );
+}
+
 stg_usec_t World::SimTimeNow(void)
 { return sim_time; }
 


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

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to