Revision: 7868
http://playerstage.svn.sourceforge.net/playerstage/?rev=7868&view=rev
Author: rtv
Date: 2009-06-21 23:15:55 +0000 (Sun, 21 Jun 2009)
Log Message:
-----------
more STLization. Simple.world benchmark now below below 4 seconds on my Mac.
Modified Paths:
--------------
code/stage/trunk/libstage/blockgroup.cc
code/stage/trunk/libstage/model_position.cc
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/waypoint.cc
code/stage/trunk/libstage/world.cc
Modified: code/stage/trunk/libstage/blockgroup.cc
===================================================================
--- code/stage/trunk/libstage/blockgroup.cc 2009-06-21 13:59:20 UTC (rev
7867)
+++ code/stage/trunk/libstage/blockgroup.cc 2009-06-21 23:15:55 UTC (rev
7868)
@@ -7,11 +7,11 @@
#undef DEBUG
using namespace Stg;
+using namespace std;
BlockGroup::BlockGroup()
: displaylist(0),
- blocks(NULL),
- count(0),
+ blocks(),
minx(0),
maxx(0),
miny(0),
@@ -25,33 +25,46 @@
void BlockGroup::AppendBlock( Block* block )
{
- blocks = g_list_append( blocks, block );
- ++count;
+ blocks.push_back( block );
}
void BlockGroup::Clear()
{
- while( blocks )
- {
- delete (Block*)blocks->data;
- blocks = blocks->next;
- }
+// while( blocks )
+// {
+// delete (Block*)blocks->data;
+// blocks = blocks->next;
+// }
- g_list_free( blocks );
- blocks = NULL;
+ //g_list_free( blocks );
+ //blocks = NULL;
+
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ delete *it;
+
+ blocks.clear();
}
void BlockGroup::SwitchToTestedCells()
{
// confirm the tentative pose for all blocks
- LISTMETHOD( blocks, Block*, SwitchToTestedCells );
+ //LISTMETHOD( blocks, Block*, SwitchToTestedCells );
+
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->SwitchToTestedCells();
}
GList* BlockGroup::AppendTouchingModels( GList* list )
{
- for( GList* it=blocks; it; it = it->next )
- list = ((Block*)it->data)->AppendTouchingModels( list );
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ list = (*it)->AppendTouchingModels( list );
return list;
}
@@ -60,9 +73,16 @@
{
Model* hitmod = NULL;
- for( GList* it=blocks; it; it = it->next )
- if( (hitmod = ((Block*)it->data)->TestCollision()))
- break; // bail on the earliest collision
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ if( (hitmod = (*it)->TestCollision()))
+ break; // bail on the earliest collision
+
+// for( GList* it=blocks; it; it = it->next )
+// if( (hitmod = ((Block*)it->data)->TestCollision()))
+// break; // bail on the earliest collision
+
return hitmod; // NULL if no collision
}
@@ -78,10 +98,13 @@
size.z = 0.0; // grow to largest z we see
- for( GList* it=blocks; it; it=it->next ) // examine all the blocks
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ // for( GList* it=blocks; it; it=it->next ) // examine all the blocks
{
// examine all the points in the polygon
- Block* block = (Block*)it->data;
+ Block* block = *it;
for( unsigned int p=0; p < block->pt_count; p++ )
{
@@ -109,12 +132,22 @@
void BlockGroup::Map()
{
- LISTMETHOD( blocks, Block*, Map );
+ for( std::vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->Map();
+
+ //LISTMETHOD( blocks, Block*, Map );
}
void BlockGroup::UnMap()
{
- LISTMETHOD( blocks, Block*, UnMap );
+ for( std::vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->UnMap();
+
+ //LISTMETHOD( blocks, Block*, UnMap );
}
void BlockGroup::DrawSolid( const Geom & geom )
@@ -128,9 +161,13 @@
geom.size.z / size.z );
glTranslatef( -offset.x, -offset.y, -offset.z );
+
+ for( std::vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->DrawSolid();
+ // LISTMETHOD( blocks, Block*, DrawSolid );
- LISTMETHOD( blocks, Block*, DrawSolid );
-
glPopMatrix();
}
@@ -144,7 +181,11 @@
glTranslatef( -offset.x, -offset.y, -offset.z );
- LISTMETHOD( blocks, Block*, DrawFootPrint);
+ for( std::vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->DrawFootPrint();
+// LISTMETHOD( blocks, Block*, DrawFootPrint);
glPopMatrix();
}
@@ -181,9 +222,12 @@
mod->PushColor( mod->color );
- for( GList* it=blocks; it; it=it->next )
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ //for( GList* it=blocks; it; it=it->next )
{
- Block* blk = (Block*)it->data;
+ Block* blk = (*it);
if( (!blk->inherit_color) && (blk->color != mod->color) )
{
@@ -206,9 +250,12 @@
stg_color_unpack( mod->color, &r, &g, &b, &a );
mod->PushColor( stg_color_pack( r/2.0, g/2.0, b/2.0, a ));
- for( GList* it=blocks; it; it=it->next )
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ //for( GList* it=blocks; it; it=it->next )
{
- Block* blk = (Block*)it->data;
+ Block* blk = *it;
if( (!blk->inherit_color) && (blk->color != mod->color) )
{
@@ -318,6 +365,9 @@
stg_meters_t cellwidth,
stg_meters_t cellheight )
{
- for( GList* it = blocks; it; it=it->next )
- ((Block*)it->data)->Rasterize( data, width, height, cellwidth,
cellheight );
+ for( vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ //for( GList* it = blocks; it; it=it->next )
+ (*it)->Rasterize( data, width, height, cellwidth, cellheight );
}
Modified: code/stage/trunk/libstage/model_position.cc
===================================================================
--- code/stage/trunk/libstage/model_position.cc 2009-06-21 13:59:20 UTC (rev
7867)
+++ code/stage/trunk/libstage/model_position.cc 2009-06-21 23:15:55 UTC (rev
7868)
@@ -654,13 +654,16 @@
glTranslatef( 0,0,0.02 );
// draw waypoints
+ glLineWidth( 3 );
for( unsigned int i=0; i < waypoint_count; i++ )
- waypoints[i].Draw();
-
+ waypoints[i].Draw();
+ glLineWidth( 1 );
+
// draw lines connecting the waypoints
if( waypoint_count > 1 )
{
- glBegin( GL_LINES );
+ pos->PushColor( 1,0,0,0.3 );
+ glBegin( GL_LINES );
for( unsigned int i=1; i < waypoint_count; i++ )
{
@@ -669,6 +672,8 @@
}
glEnd();
+
+ pos->PopColor();
}
pos->PopColor();
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-06-21 13:59:20 UTC (rev 7867)
+++ code/stage/trunk/libstage/stage.hh 2009-06-21 23:15:55 UTC (rev 7868)
@@ -1265,8 +1265,8 @@
int displaylist;
void BuildDisplayList( Model* mod );
- GList* blocks;
- uint32_t count;
+
+ std::vector<Block*> blocks;
Size size;
stg_point3_t offset;
stg_meters_t minx, maxx, miny, maxy;
@@ -1275,8 +1275,8 @@
BlockGroup();
~BlockGroup();
- GList* GetBlocks(){ return blocks; };
- uint32_t GetCount(){ return count; };
+ //std::vector<Block*>&GList* GetBlocks(){ return blocks; };
+ uint32_t GetCount(){ return blocks.size(); };
Size GetSize(){ return size; };
stg_point3_t GetOffset(){ return offset; };
@@ -1312,7 +1312,13 @@
stg_meters_t cellwidth,
stg_meters_t cellheight );
void InvalidateModelPointCache()
- { LISTMETHOD( blocks, Block*, InvalidateModelPointCache ); }
+ {
+ for( std::vector<Block*>::iterator it( blocks.begin() );
+ it != blocks.end();
+ ++it )
+ (*it)->InvalidateModelPointCache();
+ }
+
};
Modified: code/stage/trunk/libstage/waypoint.cc
===================================================================
--- code/stage/trunk/libstage/waypoint.cc 2009-06-21 13:59:20 UTC (rev
7867)
+++ code/stage/trunk/libstage/waypoint.cc 2009-06-21 23:15:55 UTC (rev
7868)
@@ -33,7 +33,7 @@
glVertex3f( pose.x, pose.y, pose.z );
glEnd();
- stg_meters_t quiver_length = 0.1;
+ stg_meters_t quiver_length = 0.15;
double dx = cos(pose.a) * quiver_length;
double dy = sin(pose.a) * quiver_length;
Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc 2009-06-21 13:59:20 UTC (rev 7867)
+++ code/stage/trunk/libstage/world.cc 2009-06-21 23:15:55 UTC (rev 7868)
@@ -940,10 +940,10 @@
->GetCell( GETCELL(glob.x),
GETCELL(glob.y) )) ;
}
-
+
void World::ForEachCellInLine( const stg_point_int_t& start,
-
const stg_point_int_t& end,
-
std::vector<Cell*>& cells )
+
const stg_point_int_t& end,
+
std::vector<Cell*>& cells )
{
// line rasterization adapted from Cohen's 3D version in
// Graphics Gems II. Should be very fast.
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit