Revision: 8231
http://playerstage.svn.sourceforge.net/playerstage/?rev=8231&view=rev
Author: rtv
Date: 2009-08-26 17:27:57 +0000 (Wed, 26 Aug 2009)
Log Message:
-----------
fixed occupancy grid bug - but a problem with powerpacks remains
Modified Paths:
--------------
code/stage/trunk/libstage/ancestor.cc
code/stage/trunk/libstage/block.cc
code/stage/trunk/libstage/blockgroup.cc
code/stage/trunk/libstage/model.cc
code/stage/trunk/libstage/model_getset.cc
code/stage/trunk/libstage/region.cc
code/stage/trunk/libstage/region.hh
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/world.cc
code/stage/trunk/webstage/webstage.cc
Modified: code/stage/trunk/libstage/ancestor.cc
===================================================================
--- code/stage/trunk/libstage/ancestor.cc 2009-08-26 08:36:23 UTC (rev
8230)
+++ code/stage/trunk/libstage/ancestor.cc 2009-08-26 17:27:57 UTC (rev
8231)
@@ -41,7 +41,7 @@
mod->SetToken( buf );
- children.push_back( mod );
+ children.insert( mod );
child_type_counts[mod->type]++;
@@ -52,7 +52,7 @@
{
child_type_counts[mod->type]--;
- children.erase( std::remove( children.begin(), children.end(), mod ) );
+ children.erase( mod );//std::remove( children.begin(), children.end(), mod )
);
}
Pose Ancestor::GetGlobalPose()
Modified: code/stage/trunk/libstage/block.cc
===================================================================
--- code/stage/trunk/libstage/block.cc 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/block.cc 2009-08-26 17:27:57 UTC (rev 8231)
@@ -193,8 +193,6 @@
// TODO - if called often, we may not need to generate each time
GenerateCandidateCells();
SwitchToTestedCells();
- return;
-
mapped = true;
}
@@ -227,6 +225,8 @@
rendered_cells = candidate_cells;
candidate_cells = tmp;
+ // XXXX todo
+
mapped = true;
}
Modified: code/stage/trunk/libstage/blockgroup.cc
===================================================================
--- code/stage/trunk/libstage/blockgroup.cc 2009-08-26 08:36:23 UTC (rev
8230)
+++ code/stage/trunk/libstage/blockgroup.cc 2009-08-26 17:27:57 UTC (rev
8231)
@@ -26,7 +26,7 @@
void BlockGroup::AppendBlock( Block* block )
{
- blocks.push_back( block );
+ blocks.insert( block );
}
void BlockGroup::Clear()
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/model.cc 2009-08-26 17:27:57 UTC (rev 8231)
@@ -277,8 +277,8 @@
// remove myself from my parent's child list, or the world's child
// list if I have no parent
- ModelPtrVec& vec = parent ? parent->children : world->children;
- vec.erase( std::remove( vec.begin(), vec.end(), this ));
+ ModelPtrSet& vec = parent ? parent->children : world->children;
+ vec.erase( this );//std::remove( vec.begin(), vec.end(), this ));
modelsbyid.erase(id);
@@ -809,7 +809,9 @@
Model* hitmod( TestCollisionTree() );
if( hitmod )
- pose = startpose; // move failed - put me back where I started
+ {
+ pose = startpose; // move failed - put me back where I started
+ }
else
{
CommitTestedPose(); // shift anyrecursively commit to blocks to the new
pose
Modified: code/stage/trunk/libstage/model_getset.cc
===================================================================
--- code/stage/trunk/libstage/model_getset.cc 2009-08-26 08:36:23 UTC (rev
8230)
+++ code/stage/trunk/libstage/model_getset.cc 2009-08-26 17:27:57 UTC (rev
8231)
@@ -136,14 +136,16 @@
int Model::SetParent( Model* newparent)
{
+
// remove the model from its old parent (if it has one)
if( parent )
//this->parent->children = g_list_remove( this->parent->children, this );
- parent->children.erase( remove( parent->children.begin(),
parent->children.end(), this ) );
+ //parent->children.erase( remove( parent->children.begin(),
parent->children.end(), this ) );
+ parent->children.erase( this );
if( newparent )
//newparent->children = g_list_append( newparent->children, this );
- newparent->children.push_back( this );
+ newparent->children.insert( this );
// link from the model to its new parent
this->parent = newparent;
Modified: code/stage/trunk/libstage/region.cc
===================================================================
--- code/stage/trunk/libstage/region.cc 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/region.cc 2009-08-26 17:27:57 UTC (rev 8231)
@@ -146,9 +146,11 @@
else // draw a rectangular solid
{
Cell* c =
(Cell*)&r->cells[p+(q*REGIONWIDTH)];
- for(
std::vector<Block*>::iterator it = c->blocks.begin();
- it !=
c->blocks.end();
- ++it )
+
+ FOR_EACH( it, c->blocks )
+ // for(
std::vector<Block*>::iterator it = c->blocks.begin();
+// it !=
c->blocks.end();
+// ++it )
{
Block* block =
*it;
Modified: code/stage/trunk/libstage/region.hh
===================================================================
--- code/stage/trunk/libstage/region.hh 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/region.hh 2009-08-26 17:27:57 UTC (rev 8231)
@@ -45,6 +45,7 @@
private:
Region* region;
std::vector<Block*> blocks;
+ //std::set<Block*> blocks;
bool boundary;
public:
@@ -82,30 +83,8 @@
return( (Cell*)&cells[ x + y * REGIONWIDTH ] );
}
+ }; // end class Region
-
- /** Returns an initialized region, either from the top of the
- stack, or if the stack is empty, a newly constructed Region */
- //static Region* GetRegion( SuperRegion* superregion );
- // static std::stack<Region*> recycled_regions;
-
-// static std::set<Region*> empty_regions;
-
-// static void GarbageCollect()
-// {
-// FOR_EACH( it, empty_regions )
-// {
-// Region* reg = *it;
-// //delete reg;
-
-// printf( "Garbage collecting region %p\n", reg );
-// }
-
-// empty_regions.clear();
-// }
-
- };
-
class SuperRegion
{
friend class World;
@@ -129,50 +108,26 @@
void Floor();
unsigned long count; // number of blocks rendered into this superregion
- };
-
-
- // inline void printvec( std::vector<Block*>& vec )
- // {
- // printf( "Vec: ");
- // for( size_t i=0; i<vec.size(); i++ )
- // printf( "%p ", vec[i] );
- // puts( "" );
- // }
-
+ }; // class SuperRegion;
+
void Cell::RemoveBlock( Block* b )
{
// linear time removal, but these vectors are very short, usually 1
- // or 2 elements. Fast removal - our strategy is to copy the last
- // item in the vector over the item we want to remove, then pop off
- // the tail. This avoids moving the other items in the vector. Saves
- // maybe 1 or 2% run time in my tests.
-
- // find the value in the vector
- // printf( "\nremoving %p\n", b );
- // puts( "before" );
- // printvec( blocks );
-
- // copy the last item in the vector to overwrite this one
- copy_backward( blocks.end(), blocks.end(), std::find( blocks.begin(),
blocks.end(), b ));
- blocks.pop_back(); // and remove the redundant copy at the end of
- // the vector
-
- --region->count;
- --region->superregion->count;
+ // or 2 elements.
+ blocks.erase( std::remove( blocks.begin(), blocks.end(), b ),
blocks.end() );
-// if( region->count == 0 && region->candidate_count == 0 )
-// Region::empty_regions.insert( region );
+ --region->count;
+ --region->superregion->count;
}
-
+
void Cell::AddBlock( Block* b )
{
blocks.push_back( b );
b->RecordRendering( this );
-
+
++region->count;
++region->superregion->count;
- }
+ }
}; // namespace Stg
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/stage.hh 2009-08-26 17:27:57 UTC (rev 8231)
@@ -88,10 +88,10 @@
/** Set of pointers to Models. */
typedef std::set<Model*> ModelPtrSet;
- /** Vector of pointers to Models. */
- typedef std::vector<Model*> ModelPtrVec;
- /** Vector of pointers to Blocks. */
- typedef std::vector<Block*> BlockPtrVec;
+
+ /** Set of pointers to Blocks. */
+ typedef std::set<Block*> BlockPtrSet;
+
/** Vector of pointers to Cells.*/
typedef std::vector<Cell*> CellPtrVec;
@@ -679,7 +679,7 @@
friend class Canvas; // allow Canvas access to our private members
protected:
- ModelPtrVec children;
+ ModelPtrSet children;
bool debug;
char* token;
pthread_mutex_t access_mutex; ///< Used by Lock() and Unlock() to
prevent parallel access to this model
@@ -690,7 +690,7 @@
public:
/** get the children of the this element */
- ModelPtrVec& GetChildren(){ return children;}
+ ModelPtrSet& GetChildren(){ return children;}
/** recursively call func( model, arg ) for each descendant */
void ForEachDescendant( stg_model_callback_t func, void* arg );
@@ -842,8 +842,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<ModelPtrVec > update_lists;
+ std::vector<ModelPtrSet> update_lists;
uint64_t updates; ///< the number of simulated time steps executed so far
Worldfile* wf; ///< If set, points to the worldfile used to create this
world
@@ -1193,7 +1192,7 @@
void BuildDisplayList( Model* mod );
- BlockPtrVec blocks;
+ BlockPtrSet blocks;
Size size;
stg_point3_t offset;
stg_meters_t minx, maxx, miny, maxy;
@@ -1239,9 +1238,7 @@
void InvalidateModelPointCache()
{
- for( BlockPtrVec::iterator it( blocks.begin() );
- it != blocks.end();
- ++it )
+ FOR_EACH( it, blocks )
(*it)->InvalidateModelPointCache();
}
Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc 2009-08-26 08:36:23 UTC (rev 8230)
+++ code/stage/trunk/libstage/world.cc 2009-08-26 17:27:57 UTC (rev 8231)
@@ -716,9 +716,7 @@
(cy>=0) && (cy<REGIONWIDTH) &&
n > 0 )
{
- for( BlockPtrVec::iterator it(
c->blocks.begin() );
- it != c->blocks.end();
- ++it )
+ FOR_EACH( it, c->blocks )
{
Block* block( *it );
assert( block );
@@ -946,7 +944,7 @@
void World::ForEachCellInLine( const stg_point_int_t& start,
const stg_point_int_t& end,
-
std::vector<Cell*>& cells )
+
CellPtrVec& cells )
{
// line rasterization adapted from Cohen's 3D version in
// Graphics Gems II. Should be very fast.
Modified: code/stage/trunk/webstage/webstage.cc
===================================================================
--- code/stage/trunk/webstage/webstage.cc 2009-08-26 08:36:23 UTC (rev
8230)
+++ code/stage/trunk/webstage/webstage.cc 2009-08-26 17:27:57 UTC (rev
8231)
@@ -54,7 +54,7 @@
puts( "[WebStage] Clock tick" );
world->paused = true;
- world->sim_interval = msec * 1e3; // usec
+ world->sim_interval = msec * 1e-3; // usec
world->Update();
return true;
@@ -137,7 +137,7 @@
virtual bool GetModelChildren(const std::string& model,
std::vector<std::string>& children)
{
- std::vector<Model*> c;
+ std::set<Model*> c;
if(model == "")
{
@@ -157,7 +157,7 @@
}
- for( std::vector<Model*>::iterator it = c.begin();
+ for( std::set<Model*>::iterator it = c.begin();
it != c.end();
it++ )
{
@@ -572,21 +572,18 @@
// add an FLTK event loop update to WebSim's implementation
virtual void Wait()
{
- Fl::check();
-
- while( unacknowledged_ticks || unacknowledged_pushes ||
ticks_remaining )
- {
- printf( "event loop in wait (%d %d %d)\n",
+ do
+ {
+ printf( " event loop in wait (%d %d %d)\r",
unacknowledged_ticks,
unacknowledged_pushes, ticks_remaining );
-
- event_loop( EVLOOP_NONBLOCK );
- puts( "fl::check\n" );
- Fl::check();
- }
+ event_loop( EVLOOP_NONBLOCK );
+ Fl::check();
+ }
+ while( unacknowledged_ticks || unacknowledged_pushes ||
ticks_remaining );
}
-};
+}; // close WebStage class
int main( int argc, char** argv )
@@ -652,7 +649,10 @@
if( usefedfile )
ws.LoadFederationFile( fedfilename );
- ws.Startup( true );
+ ws.Startup( true ); // start http server
+
+ if( ! world->paused )
+ world->Start(); // start sumulation running
puts( "entering main loop" );
@@ -671,14 +671,12 @@
//puts( "tick done" );
// update Stage
- world->Update();
+ //world->Update();
//puts( "update done" );
- Fl::check();
-
// wait until everyone report simulation step done
ws.Wait();
- puts( "wait done" );
+ //puts( "wait done" );
}
printf( "Webstage done.\n" );
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit