Revision: 7797
http://playerstage.svn.sourceforge.net/playerstage/?rev=7797&view=rev
Author: rtv
Date: 2009-06-06 08:06:43 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
cleaning up
Modified Paths:
--------------
code/stage/trunk/libstage/region.cc
code/stage/trunk/libstage/region.hh
code/stage/trunk/libstage/world.cc
Modified: code/stage/trunk/libstage/region.cc
===================================================================
--- code/stage/trunk/libstage/region.cc 2009-06-06 07:24:49 UTC (rev 7796)
+++ code/stage/trunk/libstage/region.cc 2009-06-06 08:06:43 UTC (rev 7797)
@@ -17,8 +17,6 @@
Region::~Region()
{
- if(cells)
- delete[] cells;
}
void Region::DecrementOccupancy()
Modified: code/stage/trunk/libstage/region.hh
===================================================================
--- code/stage/trunk/libstage/region.hh 2009-06-06 07:24:49 UTC (rev 7796)
+++ code/stage/trunk/libstage/region.hh 2009-06-06 08:06:43 UTC (rev 7797)
@@ -24,11 +24,7 @@
const int32_t SUPERREGIONWIDTH( 1<<SBITS );
const int32_t SUPERREGIONSIZE( SUPERREGIONWIDTH*SUPERREGIONWIDTH );
- /** (x & CELLMASK) converts a global cell index into a local cell
- index in a region */
const int32_t CELLMASK( ~((~0x00)<< RBITS ));
- /** (x & REGIONMASK)converts a global cell index into a local cell
- index in a region */
const int32_t REGIONMASK( ~((~0x00)<< SRBITS ));
inline int32_t GETCELL( const int32_t x ) { return( x & CELLMASK); }
@@ -54,9 +50,9 @@
{
}
- void RemoveBlock( Block* b );
- void AddBlock( Block* b );
- void AddBlockNoRecord( Block* b );
+ inline void RemoveBlock( Block* b );
+ inline void AddBlock( Block* b );
+ inline void AddBlockNoRecord( Block* b );
};
class Region
@@ -72,7 +68,7 @@
Cell* GetCell( int32_t x, int32_t y ) const
{
- return( (Cell*)&cells[ x + (y*REGIONWIDTH) ] );
+ return( (Cell*)&cells[ x + y * REGIONWIDTH ] );
}
void DecrementOccupancy();
@@ -99,7 +95,7 @@
const Region* GetRegion( int32_t x, int32_t y ) const
{
- return( ®ions[ x + (y*SUPERREGIONWIDTH) ] );
+ return( ®ions[ x + y * SUPERREGIONWIDTH ] );
}
void Draw( bool drawall );
@@ -110,15 +106,15 @@
};
-inline void printvec( std::vector<Block*>& vec )
- {
- printf( "Vec: ");
- for( size_t i=0; i<vec.size(); i++ )
- printf( "%p ", vec[i] );
- puts( "" );
- }
+// inline void printvec( std::vector<Block*>& vec )
+// {
+// printf( "Vec: ");
+// for( size_t i=0; i<vec.size(); i++ )
+// printf( "%p ", vec[i] );
+// puts( "" );
+// }
-inline void Cell::RemoveBlock( Block* b )
+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
@@ -139,7 +135,7 @@
region->DecrementOccupancy();
}
-inline void Cell::AddBlock( Block* b )
+void Cell::AddBlock( Block* b )
{
// constant time prepend
blocks.push_back( b );
Modified: code/stage/trunk/libstage/world.cc
===================================================================
--- code/stage/trunk/libstage/world.cc 2009-06-06 07:24:49 UTC (rev 7796)
+++ code/stage/trunk/libstage/world.cc 2009-06-06 08:06:43 UTC (rev 7797)
@@ -651,7 +651,7 @@
const double sina(sin(angle));
const double tana(sina/cosa); // = tan(angle)
- // and the x and y offsets of the ray
+ // the x and y components of the ray
const int32_t dx( ppm * r.range * cosa);
const int32_t dy( ppm * r.range * sina);
@@ -666,8 +666,6 @@
int32_t exy(ay-ax);
int32_t n(ax+ay); // the manhattan distance to the goal cell
- //const int REGIONWIDTH( REGIONWIDTH );
-
// fix a little issue where rays are not drawn long enough when
// drawing to the right or up
if( (dx > 0) || ( dy > 0 ) )
@@ -688,10 +686,8 @@
double distX(0), distY(0);
bool calculatecrossings( true );
- // puts( "=======================" );
-
// Stage spends up to 95% of its time in this loop! It would be
- // neater with more function calls encapsualting things, but even
+ // neater with more function calls encapsulating things, but even
// inline calls have a noticeable (2-3%) effect on performance
while( n > 0 ) // while we are still not at the ray end
{
@@ -701,7 +697,7 @@
// coordinates of the region inside the superregion
int32_t rx( GETREG(glob.x) );
int32_t ry( GETREG(glob.y) );
- Region* reg( &sr->regions[ rx + (ry*SUPERREGIONWIDTH) ]
);
+ Region* reg( &sr->regions[ rx + ry * SUPERREGIONWIDTH ]
);
if( reg->count ) // if the region contains any objects
{
@@ -796,11 +792,6 @@
if( (glob.x < 0) && (ix
% REGIONWIDTH) ) regionx -= REGIONWIDTH;
if( (glob.y < 0) && (iy
% REGIONWIDTH) ) regiony -= REGIONWIDTH;
- //double regionx =
glob.x - fmod(glob.x,REGIONWIDTH);
- //double regiony =
glob.y - fmod(glob.y,REGIONWIDTH);
-
- //printf( "region %.2f
%.2f\n", regionx, regiony );
-
// calculate the
distance to the edge of the current region
double xdx( sx < 0 ?
regionx - glob.x - 1.0 : // going left
@@ -867,13 +858,6 @@
//rt_candidate_cells.push_back( stg_point_int_t( ycrossx, ycrossy ));
}
-
- // if(
(GETCELL(xcrossx) == GETCELL(ycrossx) ) &&
- //
(GETCELL(xcrossy) == GETCELL(ycrossy) ) )
- // printf(
"SAME %d=%d %d=%d\n",
- //
GETCELL(xcrossx), GETCELL(ycrossx),
- //
GETCELL(xcrossy), GETCELL(ycrossy) );
-
//printf( "jumped to glob (%.2f
%.2f)\n", glob.x, glob.y );
}
//rt_cells.push_back( stg_point_int_t( glob.x, glob.y
));
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit