Revision: 7322 http://playerstage.svn.sourceforge.net/playerstage/?rev=7322&view=rev Author: rtv Date: 2009-02-09 18:53:51 +0000 (Mon, 09 Feb 2009)
Log Message: ----------- increased effciency of charging model Modified Paths: -------------- code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/powerpack.cc code/stage/trunk/libstage/stage.hh code/stage/trunk/libstage/world.cc Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/CMakeLists.txt 2009-02-09 18:53:51 UTC (rev 7322) @@ -29,7 +29,6 @@ options_dlg.cc options_dlg.hh powerpack.cc - puck.cc region.cc resource.cc stage.cc @@ -42,6 +41,10 @@ worldgui.cc ) +# TODO +# puck.cc + + add_library(stage SHARED ${stageSrcs}) set_source_files_properties( ${stageSrcs} PROPERTIES COMPILE_FLAGS "${FLTK_CFLAGS}" ) Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/canvas.cc 2009-02-09 18:53:51 UTC (rev 7322) @@ -829,7 +829,7 @@ DrawBoundingBoxes(); - LISTMETHOD( world->puck_list, Puck*, Draw ); + //LISTMETHOD( world->puck_list, Puck*, Draw ); // TODO - finish this properly //LISTMETHOD( models_sorted, Model*, DrawWaypoints ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/model.cc 2009-02-09 18:53:51 UTC (rev 7322) @@ -216,6 +216,7 @@ parent(parent), pose(), power_pack( NULL ), + pps_charging(NULL), props(NULL), rebuild_displaylist(true), say_string(NULL), @@ -782,8 +783,11 @@ PowerPack* mypp = FindPowerPack(); assert( mypp ); - // make sure we only charge a powerpack once - GList* ppacks_serviced = NULL; + // detach charger from all the packs charged last time + for( GList* it = pps_charging; it; it = it->next ) + ((PowerPack*)it->data)->charging = false; + g_list_free( pps_charging ); + pps_charging = NULL; // run through and update all appropriate touchers for( GList* touchers = AppendTouchingModels( NULL ); @@ -807,6 +811,9 @@ // move some joules from me to him mypp->TransferTo( hispp, amount ); hispp->charging = true; + + // remember who we are charging so we can detatch next time + pps_charging = g_list_prepend( pps_charging, hispp ); } } } Modified: code/stage/trunk/libstage/powerpack.cc =================================================================== --- code/stage/trunk/libstage/powerpack.cc 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/powerpack.cc 2009-02-09 18:53:51 UTC (rev 7322) @@ -28,13 +28,6 @@ printf( "%s stored %.2f/%.2f joules\n", prefix, stored, capacity ); } -// this is called every world update cycle - can we get away without doing this? -void PowerPack::Update() -{ - charging = false; -} - - /** OpenGL visualization of the powerpack state */ void PowerPack::Visualize( Camera* cam ) { Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/stage.hh 2009-02-09 18:53:51 UTC (rev 7322) @@ -732,25 +732,66 @@ 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(); + // class Puck +// { +// private: +// void BuildDisplayList(); - public: - stg_color_t color; - int displaylist; - stg_meters_t height; - Pose pose; - stg_meters_t radius; +// 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 ); +// Puck(); +// void Load( Worldfile* wf, int section ); +// void Save( Worldfile* wf, int section ); - void Draw(); - }; +// 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 @@ -825,6 +866,7 @@ GList* charge_list; ///< Models which receive charge are listed here bool destroy; bool dirty; ///< iff true, a gui redraw would be required + GList* event_list; //< GHashTable* models_by_name; ///< the models that make up the world, indexed by name double ppm; ///< the resolution of the world model in pixels per meter bool quit; ///< quit this world ASAP @@ -1418,10 +1460,6 @@ void Print( const char* prefix ) { printf( "%s PowerPack %.2f/%.2f J\n", prefix, stored, capacity ); } - - /** Called exactly once for each pack on every world update - cycle */ - void Update(); }; class Visibility @@ -1593,6 +1631,10 @@ /** Optional attached PowerPack, defaults to NULL */ PowerPack* power_pack; + /** list of powerpacks that this model is currently charging, + initially NULL. */ + GList* pps_charging; + /** GData datalist can contain arbitrary named data items. Can be used by derived model types to store properties, and for user code to associate arbitrary items with a model. */ Modified: code/stage/trunk/libstage/world.cc =================================================================== --- code/stage/trunk/libstage/world.cc 2009-02-09 03:58:32 UTC (rev 7321) +++ code/stage/trunk/libstage/world.cc 2009-02-09 18:53:51 UTC (rev 7322) @@ -191,12 +191,12 @@ mod->LoadBlock( wf, entity ); } -void World::LoadPuck( Worldfile* wf, int entity, GHashTable* entitytable ) -{ - Puck* puck = new Puck(); - puck->Load( wf, entity ); - puck_list = g_list_prepend( puck_list, puck ); -} +// void World::LoadPuck( Worldfile* wf, int entity, GHashTable* entitytable ) +// { +// Puck* puck = new Puck(); +// puck->Load( wf, entity ); +// puck_list = g_list_prepend( puck_list, puck ); +// } @@ -334,8 +334,8 @@ } else if( strcmp( typestr, "block" ) == 0 ) LoadBlock( wf, entity, entitytable ); - else if( strcmp( typestr, "puck" ) == 0 ) - LoadPuck( wf, entity, entitytable ); +// else if( strcmp( typestr, "puck" ) == 0 ) +// LoadPuck( wf, entity, entitytable ); else LoadModel( wf, entity, entitytable ); } @@ -426,9 +426,6 @@ // upate all positions first LISTMETHOD( velocity_list, Model*, UpdatePose ); - // upate all powerpacks - LISTMETHOD( powerpack_list, PowerPack*, Update ); - // test all models that supply charge to see if they are touching // something that takes charge LISTMETHOD( charge_list, Model*, UpdateCharge ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM) software. With Adobe AIR, Ajax developers can use existing skills and code to build responsive, highly engaging applications that combine the power of local resources and data with the reach of the web. Download the Adobe AIR SDK and Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit