Update of /cvsroot/playerstage/code/stage/libstage
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20596
Modified Files:
Tag: opengl
blockgrid.cc model.cc stage.hh world.cc worldgtk.cc
Log Message:
added nested grid to elimate large memory requirements. raytracing still uses
fine grid, so that remains to fix
Index: stage.hh
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/stage.hh,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -C2 -d -r1.1.2.9 -r1.1.2.10
*** stage.hh 30 Oct 2007 01:01:48 -0000 1.1.2.9
--- stage.hh 30 Oct 2007 04:20:45 -0000 1.1.2.10
***************
*** 1166,1176 ****
! class StgBlockGrid
{
! private:
GSList** lists;
public:
! uint32_t width, height;
StgBlockGrid( uint32_t width, uint32_t height );
~StgBlockGrid();
--- 1166,1183 ----
! typedef struct
{
! uint16_t counter;
GSList** lists;
+ } stg_bigblock_t;
+ class StgBlockGrid
+ {
+ private:
+ //GSList** lists;
+ stg_bigblock_t* map;
+
public:
! uint32_t width, height, bwidth, bheight;
StgBlockGrid( uint32_t width, uint32_t height );
~StgBlockGrid();
***************
*** 1179,1183 ****
GSList* GetList( uint32_t x, uint32_t y );
void RemoveBlock( StgBlock* block );
! void Draw();
};
--- 1186,1190 ----
GSList* GetList( uint32_t x, uint32_t y );
void RemoveBlock( StgBlock* block );
! void Draw( bool drawall );
};
***************
*** 1290,1296 ****
void MapBlock( StgBlock* block );
- // void MapBlockLine( StgBlock* block,
- // double x1, double y1, double z1,
- // double x2, double y2, double z2 );
stg_meters_t Raytrace( StgModel* finder,
--- 1297,1300 ----
***************
*** 1301,1311 ****
StgModel** hit_model );
- stg_meters_t Raytrace2( StgModel* finder,
- stg_pose_t* pose,
- stg_meters_t max_range,
- stg_block_match_func_t func,
- const void* arg,
- StgModel** hit_model );
-
void ClockString( char* str, size_t maxlen );
--- 1305,1308 ----
Index: blockgrid.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/blockgrid.cc,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** blockgrid.cc 30 Oct 2007 01:01:48 -0000 1.1.2.1
--- blockgrid.cc 30 Oct 2007 04:20:45 -0000 1.1.2.2
***************
*** 1,19 ****
#include "stage.hh"
StgBlockGrid::StgBlockGrid( uint32_t width, uint32_t height )
{
- printf( "Creating StgBlockGrid of [%d,%d] elements\n",
- width, height );
-
this->width = width;
this->height = height;
! this->lists = new GSList*[width * height];
! bzero( lists, width*height * sizeof(GSList*));
}
StgBlockGrid::~StgBlockGrid()
{
! delete[] lists;
}
--- 1,30 ----
#include "stage.hh"
+ #define NBITS 4
+ #define NSIZE (1<<NBITS)
+ #define MASK (NSIZE-1)
+
+
StgBlockGrid::StgBlockGrid( uint32_t width, uint32_t height )
{
this->width = width;
this->height = height;
! this->bwidth = width >> NBITS;
! this->bheight = height >> NBITS;
!
! printf( "Creating StgBlockGrid of [%u,%u](%u,%u) elements\n",
! width, height, bwidth, bheight );
!
!
! size_t bits = bwidth * bheight;
! this->map = new stg_bigblock_t[ bits ];
! bzero( map, sizeof(stg_bigblock_t)*bits );
}
StgBlockGrid::~StgBlockGrid()
{
! //delete[] lists;
! delete[] map;
}
***************
*** 22,27 ****
if( x < width && y < height )
{
! unsigned int index = x + width*y;
! lists[index] = g_slist_prepend( lists[index], block );
block->RecordRenderPoint( x, y );
}
--- 33,58 ----
if( x < width && y < height )
{
! uint32_t a = x>>NBITS;
! uint32_t b = y>>NBITS;
!
! stg_bigblock_t* bb = &map[ a + b*bwidth ];
! assert(bb); // it really should be there
!
! //printf( "incrementing block at %u %u (width %u height %u\n",
! // a,b, bwidth, bheight );
!
! if( bb->lists == NULL )
! {
! assert( bb->lists == NULL );
! bb->lists = new GSList*[ NSIZE*NSIZE ];
! bzero( bb->lists, NSIZE*NSIZE * sizeof(GSList*));
! }
!
! bb->counter++;
!
! // use only the NBITS least significant bits of the address
! uint32_t index = (x&MASK) + (y&MASK)*NSIZE;
! bb->lists[index] = g_slist_prepend( bb->lists[index], block );
!
block->RecordRenderPoint( x, y );
}
***************
*** 33,38 ****
if( x < width && y < height )
{
! unsigned int index = x + width*y;
! return lists[index];
}
return NULL;
--- 64,77 ----
if( x < width && y < height )
{
! uint32_t a = x>>NBITS;
! uint32_t b = y>>NBITS;
!
! stg_bigblock_t* bb = &map[ a + b*bwidth ];
!
! if( bb->lists )
! {
! uint32_t index = (x&MASK) + (y&MASK)*NSIZE;
! return bb->lists[index];
! }
}
return NULL;
***************
*** 42,50 ****
{
//printf( "remove block %u %u\n", x, y );
!
if( x < width && y < height )
{
! unsigned int index = x + width*y;
! lists[index] = g_slist_remove( lists[index], block );
}
}
--- 81,105 ----
{
//printf( "remove block %u %u\n", x, y );
!
if( x < width && y < height )
{
! uint32_t a = x>>NBITS;
! uint32_t b = y>>NBITS;
!
! stg_bigblock_t* bb = &map[ a + b*bwidth ];
! assert( bb ); // it really should be there
!
! // remove list entry
! uint32_t index = (x&MASK) + (y&MASK)*NSIZE;
! assert( bb->lists[index] );
! bb->lists[index] = g_slist_remove( bb->lists[index], block );
!
! bb->counter--;
!
! if( bb->counter == 0 ) // this was the last entry in this block;
! {
! delete[] bb->lists;
! bb->lists = NULL;
! }
}
}
***************
*** 58,105 ****
}
! void StgBlockGrid::Draw()
{
! for( uint32_t x=0; x<width; x++ )
! for( uint32_t y=0; y<height; y++ )
! if( lists[ x + width*y] )
! glRecti( x,y,x+1,y+1 );
!
! //printf( "printing %d %d %d \n", x, y, index );
!
! //glTranslatef( x,y,0 );
!
! // glBegin(GL_QUADS); // Draw The Cube Using quads
! // glColor3f(0.0f,1.0f,0.0f); // Color Blue
! // glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Top)
! // glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Top)
! // glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
! // glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad
(Top)
! // glColor3f(1.0f,0.5f,0.0f); // Color Orange
! // glVertex3f( 1.0f,-1.0f, 1.0f); // Top Right Of The Quad
(Bottom)
! // glVertex3f(-1.0f,-1.0f, 1.0f); // Top Left Of The Quad (Bottom)
! // glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad
(Bottom)
! // glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad
(Bottom)
! // glColor3f(1.0f,0.0f,0.0f); // Color Red
! // glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
! // glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
! // glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad
(Front)
! // glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad
(Front)
! // glColor3f(1.0f,1.0f,0.0f); // Color Yellow
! // glVertex3f( 1.0f,-1.0f,-1.0f); // Top Right Of The Quad (Back)
! // glVertex3f(-1.0f,-1.0f,-1.0f); // Top Left Of The Quad (Back)
! // glVertex3f(-1.0f, 1.0f,-1.0f); // Bottom Left Of The Quad
(Back)
! // glVertex3f( 1.0f, 1.0f,-1.0f); // Bottom Right Of The Quad
(Back)
! // glColor3f(0.0f,0.0f,1.0f); // Color Blue
! // glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
! // glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Left)
! // glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad
(Left)
! // glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad
(Left)
! // glColor3f(1.0f,0.0f,1.0f); // Color Violet
! // glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Right)
! // glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
! // glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad
(Right)
! // glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad
(Right)
! // glEnd(); // End Drawing The Cube
!
! //glTranslatef( -x, -y, 0 );
}
--- 113,138 ----
}
! void StgBlockGrid::Draw( bool drawall )
{
! for( uint32_t x=0; x<bwidth; x++ )
! for( uint32_t y=0; y<bheight; y++ )
! {
! stg_bigblock_t* bb = &map[ x + y*bwidth ];
!
! if( drawall || bb->lists )
! {
! glRecti( x<<NBITS,y<<NBITS,(x+1)<<NBITS,(y+1)<<NBITS );
!
! for( uint32_t a=0; a<NSIZE*NSIZE; a++ )
! {
! if( drawall || bb->lists[ a ] )
! glRecti( (x<<NBITS)+a%NSIZE,
! (y<<NBITS)+a/NSIZE,
! (x<<NBITS)+a%NSIZE+1,
! (y<<NBITS)+a/NSIZE+1 );
!
! }
! }
! }
}
+
Index: world.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/world.cc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** world.cc 30 Oct 2007 01:22:44 -0000 1.1.2.10
--- world.cc 30 Oct 2007 04:20:45 -0000 1.1.2.11
***************
*** 487,496 ****
! stg_meters_t StgWorld::Raytrace2( StgModel* finder,
! stg_pose_t* pose,
! stg_meters_t max_range,
! stg_block_match_func_t func,
! const void* arg,
! StgModel** hit_model )
{
// find the global integer bitmap address of the ray
--- 487,496 ----
! stg_meters_t StgWorld::Raytrace( StgModel* finder,
! stg_pose_t* pose,
! stg_meters_t max_range,
! stg_block_match_func_t func,
! const void* arg,
! StgModel** hit_model )
{
// find the global integer bitmap address of the ray
Index: model.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/model.cc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** model.cc 30 Oct 2007 01:01:48 -0000 1.1.2.8
--- model.cc 30 Oct 2007 04:20:45 -0000 1.1.2.9
***************
*** 308,312 ****
gpose.a += angle;
! return world->Raytrace2( this,
&gpose,
range,
--- 308,312 ----
gpose.a += angle;
! return world->Raytrace( this,
&gpose,
range,
***************
*** 327,331 ****
LocalToGlobal( &gpose );
! return world->Raytrace2( this,
&gpose,
range,
--- 327,331 ----
LocalToGlobal( &gpose );
! return world->Raytrace( this,
&gpose,
range,
Index: worldgtk.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/libstage/Attic/worldgtk.cc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** worldgtk.cc 30 Oct 2007 01:01:48 -0000 1.1.2.7
--- worldgtk.cc 30 Oct 2007 04:20:45 -0000 1.1.2.8
***************
*** 1851,1855 ****
glPolygonMode( GL_FRONT, GL_LINE );
colorstack.Push(1,0,0);
! this->bgrid->Draw();
colorstack.Pop();
glPopMatrix();
--- 1851,1861 ----
glPolygonMode( GL_FRONT, GL_LINE );
colorstack.Push(1,0,0);
!
! if( show_occupancy )
! this->bgrid->Draw( false );
!
! if( show_quadtree )
! this->bgrid->Draw( true );
!
colorstack.Pop();
glPopMatrix();
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit