@@ -194,29 +194,28 @@ void Block::Map()
194194 RemoveFromCellArray ( rendered_cells );
195195
196196 // now calculate the local coords of the block vertices
197- const unsigned int pt_count = pts.size ();
197+ const size_t pt_count ( pts.size () );
198198
199199 if ( mpts.size () == 0 )
200200 {
201201 // no valid cache of model coord points, so generate them
202202 mpts.resize ( pts.size () );
203203
204- for ( unsigned int i=0 ; i<pt_count; ++i )
204+ for ( size_t i=0 ; i<pt_count; ++i )
205205 mpts[i] = BlockPointToModelMeters ( pts[i] );
206206 }
207207
208208 // now calculate the global pixel coords of the block vertices
209209 gpts.clear ();
210210 mod->LocalToPixels ( mpts, gpts );
211-
212- for ( unsigned int i=0 ; i<pt_count; ++i )
213- MapLine ( gpts[i],
214- gpts[(i+1 )%pt_count] );
211+
212+ // and render this block's polygon into the world
213+ mod->GetWorld ()->MapPoly ( gpts, this );
215214
216215 // update the block's absolute z bounds at this rendering
217- Pose gpose = mod->GetGlobalPose ();
216+ Pose gpose ( mod->GetGlobalPose () );
218217 gpose.z += mod->geom .pose .z ;
219- double scalez = mod->geom .size .z / mod->blockgroup .GetSize ().z ;
218+ double scalez ( mod->geom .size .z / mod->blockgroup .GetSize ().z ) ;
220219 meters_t z = gpose.z - mod->blockgroup .GetOffset ().z ;
221220 global_z.min = (scalez * local_z.min ) + z;
222221 global_z.max = (scalez * local_z.max ) + z;
@@ -281,8 +280,8 @@ void Block::Rasterize( uint8_t* data,
281280 // printf( "rasterize block %p : w: %u h: %u scale %.2f %.2f offset %.2f %.2f\n",
282281 // this, width, height, scalex, scaley, offsetx, offsety );
283282
284- const unsigned int pt_count = pts.size ();
285- for ( unsigned int i=0 ; i<pt_count; ++i )
283+ const size_t pt_count = pts.size ();
284+ for ( size_t i=0 ; i<pt_count; ++i )
286285 {
287286 // convert points from local to model coords
288287 point_t mpt1 = BlockPointToModelMeters ( pts[i] );
@@ -406,10 +405,10 @@ void Block::DrawSolid()
406405
407406void Block::Load ( Worldfile* wf, int entity )
408407{
409- const unsigned int pt_count = wf->ReadInt ( entity, " points" , 0 );
408+ const size_t pt_count = wf->ReadInt ( entity, " points" , 0 );
410409
411410 char key[128 ];
412- for ( unsigned int p=0 ; p<pt_count; ++p )
411+ for ( size_t p=0 ; p<pt_count; ++p )
413412 {
414413 snprintf (key, sizeof (key), " point[%d]" , p );
415414
@@ -434,72 +433,72 @@ void Block::Load( Worldfile* wf, int entity )
434433}
435434
436435
437- void Block::MapLine ( const point_int_t & start,
438- const point_int_t & end )
439- {
440- // line rasterization adapted from Cohen's 3D version in
441- // Graphics Gems II. Should be very fast.
442- const int32_t dx ( end.x - start.x );
443- const int32_t dy ( end.y - start.y );
444- const int32_t sx (sgn (dx));
445- const int32_t sy (sgn (dy));
446- const int32_t ax (abs (dx));
447- const int32_t ay (abs (dy));
448- const int32_t bx (2 *ax);
449- const int32_t by (2 *ay);
450- int32_t exy (ay-ax);
451- int32_t n (ax+ay);
452-
453- int32_t globx (start.x );
454- int32_t globy (start.y );
455-
456-
457- World* w = mod-> GetWorld ();
458-
459- while ( n )
460- {
461- Region* reg ( w-> GetSuperRegionCreate ( point_int_t ( GETSREG ( globx), GETSREG (globy)))
462- -> GetRegion ( GETREG (globx), GETREG ( globy) ));
436+ // void Block::MapLine( const point_int_t& start,
437+ // const point_int_t& end )
438+ // {
439+ // // line rasterization adapted from Cohen's 3D version in
440+ // // Graphics Gems II. Should be very fast.
441+ // const int32_t dx( end.x - start.x );
442+ // const int32_t dy( end.y - start.y );
443+ // const int32_t sx(sgn(dx));
444+ // const int32_t sy(sgn(dy));
445+ // const int32_t ax(abs(dx));
446+ // const int32_t ay(abs(dy));
447+ // const int32_t bx(2*ax);
448+ // const int32_t by(2*ay);
449+ // int32_t exy(ay-ax);
450+ // int32_t n(ax+ay);
451+
452+ // int32_t globx(start.x);
453+ // int32_t globy(start.y);
454+
455+ // while( n )
456+ // {
457+ // Region* reg( mod->GetWorld()
458+ // ->GetSuperRegionCreate( point_int_t(GETSREG(globx),
459+ // GETSREG(globy)))
460+ // ->GetRegion( GETREG( globx),
461+ // GETREG(globy)));
463462
464- // printf( "REGION %p\n", reg );
463+ // //printf( "REGION %p\n", reg );
465464
466- // add all the required cells in this region before looking up
467- // another region
468- int32_t cx ( GETCELL (globx) );
469- int32_t cy ( GETCELL (globy) );
465+ // // add all the required cells in this region before looking up
466+ // // another region
467+ // int32_t cx( GETCELL(globx) );
468+ // int32_t cy( GETCELL(globy) );
470469
471- // need to call Region::GetCell() before using a Cell pointer
472- // directly, because the region allocates cells lazily, waiting
473- // for a call of this method
474- Cell* c ( reg->GetCell ( cx, cy ) );
475-
476- // while inside the region, manipulate the Cell pointer directly
477- while ( (cx>=0 ) && (cx<REGIONWIDTH) &&
478- (cy>=0 ) && (cy<REGIONWIDTH) &&
479- n > 0 )
480- {
481- c->AddBlock (this );
470+ // // need to call Region::GetCell() before using a Cell pointer
471+ // // directly, because the region allocates cells lazily, waiting
472+ // // for a call of this method
473+ // Cell* c( reg->GetCell( cx, cy ) );
474+
475+ // // while inside the region, manipulate the Cell pointer directly
476+ // while( (cx>=0) && (cx<REGIONWIDTH) &&
477+ // (cy>=0) && (cy<REGIONWIDTH) &&
478+ // n > 0 )
479+ // {
480+ // c->AddBlock(this);
482481
483- // cleverly skip to the next cell (now it's safe to
484- // manipulate the cell pointer)
485- if ( exy < 0 )
486- {
487- globx += sx;
488- exy += by;
489- c += sx;
490- cx += sx;
491- }
492- else
493- {
494- globy += sy;
495- exy -= bx;
496- c += sy * REGIONWIDTH;
497- cy += sy;
498- }
499- --n;
500- }
501- }
502- }
482+ // // cleverly skip to the next cell (now it's safe to
483+ // // manipulate the cell pointer)
484+ // if( exy < 0 )
485+ // {
486+ // globx += sx;
487+ // exy += by;
488+ // c += sx;
489+ // cx += sx;
490+ // }
491+ // else
492+ // {
493+ // globy += sy;
494+ // exy -= bx;
495+ // c += sy * REGIONWIDTH;
496+ // cy += sy;
497+ // }
498+ // --n;
499+ // }
500+ // }
501+ // }
503502
504503// ///////////////////////////////////////////////////////////////////////////////////////
505504// utility functions to ensure block winding is consistent and matches OpenGL's default
0 commit comments