Revision: 8591 http://playerstage.svn.sourceforge.net/playerstage/?rev=8591&view=rev Author: rtv Date: 2010-03-16 05:14:09 +0000 (Tue, 16 Mar 2010)
Log Message: ----------- block refactoring Modified Paths: -------------- code/stage/trunk/libstage/block.cc code/stage/trunk/libstage/blockgroup.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/libstage/block.cc =================================================================== --- code/stage/trunk/libstage/block.cc 2010-03-15 18:01:48 UTC (rev 8590) +++ code/stage/trunk/libstage/block.cc 2010-03-16 05:14:09 UTC (rev 8591) @@ -69,10 +69,10 @@ void Block::Translate( double x, double y ) { - for( unsigned int p=0; p<pt_count; p++) + FOR_EACH( it, pts ) { - pts[p].x += x; - pts[p].y += y; + it->x += x; + it->y += y; } mod->blockgroup.BuildDisplayList( mod ); @@ -83,10 +83,10 @@ double min = billion; double max = -billion; - for( unsigned int p=0; p<pt_count; p++) + FOR_EACH( it, pts ) { - if( pts[p].y > max ) max = pts[p].y; - if( pts[p].y < min ) min = pts[p].y; + if( it->y > max ) max = it->y; + if( it->y < min ) min = it->y; } // return the value half way between max and min @@ -98,10 +98,10 @@ double min = billion; double max = -billion; - for( unsigned int p=0; p<pt_count; p++) + FOR_EACH( it, pts ) { - if( pts[p].x > max ) max = pts[p].x; - if( pts[p].x < min ) min = pts[p].x; + if( it->x > max ) max = it->x; + if( it->x < min ) min = it->x; } // return the value half way between maxx and min @@ -297,8 +297,9 @@ { // no valid cache of model coord points, so generate them mpts.resize( pt_count ); + for( unsigned int i=0; i<pt_count; i++ ) - mpts[i] = BlockPointToModelMeters( pts[i] ); + mpts[i] = BlockPointToModelMeters( pts[i] ); } gpts.clear(); Modified: code/stage/trunk/libstage/blockgroup.cc =================================================================== --- code/stage/trunk/libstage/blockgroup.cc 2010-03-15 18:01:48 UTC (rev 8590) +++ code/stage/trunk/libstage/blockgroup.cc 2010-03-16 05:14:09 UTC (rev 8591) @@ -78,13 +78,12 @@ // examine all the points in the polygon Block* block = *it; - for( unsigned int p=0; p < block->pt_count; p++ ) + FOR_EACH( it, block->pts ) { - stg_point_t* pt = &block->pts[p]; - if( pt->x < minx ) minx = pt->x; - if( pt->y < miny ) miny = pt->y; - if( pt->x > maxx ) maxx = pt->x; - if( pt->y > maxy ) maxy = pt->y; + if( it->x < minx ) minx = it->x; + if( it->y < miny ) miny = it->y; + if( it->x > maxx ) maxx = it->x; + if( it->y > maxy ) maxy = it->y; } size.z = std::max( block->local_z.max, size.z ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2010-03-15 18:01:48 UTC (rev 8590) +++ code/stage/trunk/libstage/model.cc 2010-03-16 05:14:09 UTC (rev 8591) @@ -157,18 +157,15 @@ using namespace Stg; // static members -uint32_t Model::count = 0; -uint32_t Model::trail_length = 50; -uint64_t Model::trail_interval = 5; +uint32_t Model::count(0); +uint32_t Model::trail_length(50); +uint64_t Model::trail_interval(5); std::map<stg_id_t,Model*> Model::modelsbyid; std::map<std::string, creator_t> Model::name_map; -//std::map<void*, std::set<Model::stg_cb_t> > Model::callbacks; void Size::Load( Worldfile* wf, int section, const char* keyword ) { if( CProperty* prop = wf->GetProperty( section, keyword ) ) - - //if( prop ) { if( prop->values.size() != 3 ) { @@ -268,7 +265,7 @@ blockgroup(), blocks_dl(0), boundary(false), - callbacks(__CB_TYPE_COUNT), + callbacks(__CB_TYPE_COUNT), // one slot in the vector for each type color( 1,0,0 ), // red data_fresh(false), disabled(false), @@ -427,10 +424,10 @@ Block* Model::AddBlockRect( stg_meters_t x, - stg_meters_t y, - stg_meters_t dx, - stg_meters_t dy, - stg_meters_t dz ) + stg_meters_t y, + stg_meters_t dx, + stg_meters_t dy, + stg_meters_t dz ) { UnMap(); @@ -445,10 +442,10 @@ pts[3].y = y + dy; Block* newblock = new Block( this, - pts, 4, - 0, dz, - color, - true ); + pts, 4, + 0, dz, + color, + true ); blockgroup.AppendBlock( newblock ); Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2010-03-15 18:01:48 UTC (rev 8590) +++ code/stage/trunk/libstage/stage.hh 2010-03-16 05:14:09 UTC (rev 8591) @@ -1198,17 +1198,11 @@ /** Set the extent in Z of the block */ void SetZ( double min, double max ); - - stg_point_t* Points( unsigned int *count ) - { if( count ) *count = pt_count; return &pts[0]; }; - - std::vector<stg_point_t>& Points() - { return pts; }; - + inline void RemoveFromCellArray( CellPtrVec* blocks ); inline void GenerateCandidateCells(); - - void AppendTouchingModels( ModelPtrSet& touchers ); + + void AppendTouchingModels( ModelPtrSet& touchers ); /** Returns the first model that shares a bitmap cell with this model */ Model* TestCollision(); @@ -1262,32 +1256,32 @@ void InvalidateModelPointCache(); }; - + class BlockGroup { friend class Model; - friend class Block; - + friend class Block; + private: int displaylist; - + void BuildDisplayList( Model* mod ); - - BlockPtrSet blocks; + + BlockPtrSet blocks; Size size; stg_point3_t offset; stg_meters_t minx, maxx, miny, maxy; - + public: BlockGroup(); ~BlockGroup(); - + uint32_t GetCount(){ return blocks.size(); }; const Size& GetSize(){ return size; }; const stg_point3_t& GetOffset(){ return offset; }; - + /** Establish the min and max of all the blocks, so we can scale this - group later. */ + group later. */ void CalcSize(); void AppendBlock( Block* block ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit