Permalink
Browse files

blocks are now contours of complex polygons, and are no longer limite…

…d to being convex simple polygons. This allows us to parse bitmaps into a few complex polygons instead of a lot of small rectangles. It looks a lot better in the GUI, though there are some glitches to figure out with internal-vs-external contours indicated by winding direction. This is just cosmetic though, so it can go in master
  • Loading branch information...
1 parent 59be1dd commit f0e1c49bb63c088f141e44b26f338c65ff013d9d @rtv rtv committed Jan 17, 2012
Showing with 325 additions and 199 deletions.
  1. +14 −45 libstage/block.cc
  2. +124 −80 libstage/blockgroup.cc
  3. +4 −3 libstage/model.cc
  4. +1 −1 libstage/region.cc
  5. +142 −25 libstage/stage.cc
  6. +31 −33 libstage/stage.hh
  7. +4 −4 libstage/world.cc
  8. +1 −1 worlds/benchmark/cave.world
  9. +3 −3 worlds/fasr.world
  10. +1 −1 worlds/map.inc
  11. +0 −3 worlds/walle.inc
View
59 libstage/block.cc
@@ -12,14 +12,11 @@ static void canonicalize_winding(vector<point_t>& pts);
after calling this.*/
Block::Block( BlockGroup* group,
const std::vector<point_t>& pts,
- const Bounds& zrange,
- const Color& color,
- bool inherit_color ) :
+ const Bounds& zrange ) :
group(group),
pts(pts),
local_z( zrange ),
- color( color ),
- inherit_color( inherit_color ),
+ global_z(),
rendered_cells()
{
assert( group );
@@ -33,29 +30,23 @@ Block::Block( BlockGroup* group,
: group(group),
pts(),
local_z(),
- color(),
- inherit_color(true),
+ global_z(),
rendered_cells()
{
+ assert(group);
assert(wf);
assert(entity);
Load( wf, entity );
+ canonicalize_winding(this->pts);
}
Block::~Block()
{
- if( mapped )
- {
- UnMap(0);
- UnMap(1);
- }
+ UnMap(0);
+ UnMap(1);
}
-Model* Block::GetModel()
-{
- return &group->mod;
-};
void Block::Translate( double x, double y )
@@ -137,11 +128,6 @@ void Block::SetZ( double min, double max )
group->BuildDisplayList();
}
-const Color& Block::GetColor()
-{
- return( inherit_color ? group->mod.color : color );
-}
-
void Block::AppendTouchingModels( std::set<Model*>& touchers )
{
unsigned int layer = group->mod.world->updates % 2;
@@ -211,8 +197,6 @@ void Block::Map( unsigned int layer )
gpose.z += group->mod.geom.pose.z;
global_z.min = local_z.min + gpose.z;
global_z.max = local_z.max + gpose.z;
-
- mapped = true;
}
@@ -222,7 +206,6 @@ void Block::UnMap( unsigned int layer )
(*it)->RemoveBlock(this, layer );
rendered_cells[layer].clear();
- mapped = false;
}
void swap( int& a, int& b )
@@ -306,10 +289,13 @@ void Block::Rasterize( uint8_t* data,
}
}
+
+
void Block::DrawTop()
{
// draw the top of the block - a polygon at the highest vertical
// extent
+
glBegin( GL_POLYGON);
FOR_EACH( it, pts )
glVertex3f( it->x, it->y, local_z.max );
@@ -342,17 +328,15 @@ void Block::DrawFootPrint()
void Block::DrawSolid( bool topview )
{
- if( ! topview )
- DrawSides();
-
+ DrawSides();
DrawTop();
}
void Block::Load( Worldfile* wf, int entity )
{
const size_t pt_count = wf->ReadInt( entity, "points", 0);
- char key[128];
+ char key[256];
for( size_t p=0; p<pt_count; ++p )
{
snprintf(key, sizeof(key), "point[%d]", (int)p );
@@ -364,17 +348,7 @@ void Block::Load( Worldfile* wf, int entity )
canonicalize_winding(pts);
- wf->ReadTuple( entity, "z", 0, 2, "ll", &local_z.min, &local_z.max );
-
- const std::string& colorstr = wf->ReadString( entity, "color", "" );
-
- if( colorstr != "" )
- {
- color = Color( colorstr );
- inherit_color = false;
- }
- else
- inherit_color = true;
+ wf->ReadTuple( entity, "z", 0, 2, "ll", &local_z.min, &local_z.max );
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -444,12 +418,7 @@ static
/// Util
bool is_canonical_winding(vector<point_t> const& ps)
{
- // reuse point_t as vector
- vector<point_t> vs = find_vectors(ps);
- radians_t sum = angles_sum(vs);
- bool bCanon = 0 < sum;
-
- return bCanon;
+ return( 0 < angles_sum( find_vectors(ps) ) );
}
static
View
204 libstage/blockgroup.cc
@@ -138,86 +138,146 @@ void BlockGroup::DrawFootPrint( const Geom & geom )
it->DrawFootPrint();
}
+// tesselation callbacks used in BlockGroup::BuildDisplayListTess()------------
+
+static void errorCallback(GLenum errorCode)
+{
+ const GLubyte *estring;
+
+ estring = gluErrorString(errorCode);
+ fprintf (stderr, "Tessellation Error: %s\n", estring);
+ exit (0);
+}
+
+static void combineCallback(GLdouble coords[3],
+ GLdouble *vertex_data[4],
+ GLfloat weight[4], GLdouble **dataOut )
+{
+ GLdouble *vertex;
+
+ vertex = (GLdouble *) malloc(3 * sizeof(GLdouble));
+ vertex[0] = coords[0];
+ vertex[1] = coords[1];
+ vertex[2] = coords[2];
+
+ // @todo: fix the leak of this vertex buffer. it's not a lot of
+ // data, and doesn't happen much, but it would be tidy.
+
+ *dataOut = vertex;
+}
+
+// render each block as a polygon extruded into Z
void BlockGroup::BuildDisplayList()
{
- //puts( "build" );
+ static bool init = false;
+ static GLUtesselator *tobj = NULL;
if( ! mod.world->IsGUI() )
return;
//printf( "display list for model %s\n", mod->token );
if( displaylist == 0 )
{
+ CalcSize(); // todo: is this redundant? count calls per model to figure this out.
+
displaylist = glGenLists(1);
- CalcSize();
+ assert(displaylist !=0 );
+
+ // Stage polygons need not be convex, so we have to tesselate them for rendering in OpenGL.
+ tobj = gluNewTess();
+ assert(tobj != NULL);
+
+ // these use the standard GL calls
+ gluTessCallback(tobj, GLU_TESS_VERTEX,
+ (GLvoid (*) ()) &glVertex3dv);
+ gluTessCallback(tobj, GLU_TESS_EDGE_FLAG,
+ (GLvoid (*) ()) &glEdgeFlag);
+ gluTessCallback(tobj, GLU_TESS_BEGIN,
+ (GLvoid (*) ()) &glBegin);
+ gluTessCallback(tobj, GLU_TESS_END,
+ (GLvoid (*) ()) &glEnd);
+
+ // these are custom, defined above.
+ gluTessCallback(tobj, GLU_TESS_ERROR,
+ (GLvoid (*) ()) &errorCallback);
+ gluTessCallback(tobj, GLU_TESS_COMBINE,
+ (GLvoid (*) ()) &combineCallback);
}
-
- glNewList( displaylist, GL_COMPILE );
-
-
- // render each block as a polygon extruded into Z
-
Geom geom = mod.GetGeom();
+ std::vector<std::vector<GLdouble> > contours;
+
+ FOR_EACH( blk, blocks )
+ {
+ std::vector<GLdouble> verts;
+ FOR_EACH( it, blk->pts )
+ {
+ verts.push_back( it->x );
+ verts.push_back( it->y );
+ verts.push_back( blk->local_z.max );
+ }
+ contours.push_back( verts );
+ }
+
+ glNewList( displaylist, GL_COMPILE );
Gl::pose_shift( geom.pose );
-
+
+ // draw filled polys
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
glEnable(GL_POLYGON_OFFSET_FILL);
- glPolygonOffset(1.0, 1.0);
+ glPolygonOffset(0.5, 0.5);
mod.PushColor( mod.color );
-
- //const bool topview = dynamic_cast<WorldGui*>(mod->world)->IsTopView();
-
- FOR_EACH( blk, blocks )
- {
- if( (!blk->inherit_color) && (blk->color != mod.color) )
- {
- mod.PushColor( blk->color );
- blk->DrawSolid(false);
- mod.PopColor();
- }
- else
- blk->DrawSolid(false);
+
+ gluTessBeginPolygon(tobj, NULL);
+
+ FOR_EACH( contour, contours )
+ {
+ gluTessBeginContour(tobj);
+ for( size_t v=0; v<contour->size(); v+=3 )
+ gluTessVertex(tobj, &(*contour)[v], &(*contour)[v]);
+ gluTessEndContour(tobj);
}
-
- mod.PopColor();
-
- // outline each poly in a darker version of the same color
+
+ gluTessEndPolygon(tobj);
- glDisable(GL_POLYGON_OFFSET_FILL);
+ FOR_EACH( blk, blocks )
+ blk->DrawSides();
+
+ mod.PopColor();
+ // now outline the polys
+ glDisable(GL_POLYGON_OFFSET_FILL);
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
glDepthMask(GL_FALSE);
-
+
Color c = mod.color;
c.r /= 2.0;
c.g /= 2.0;
c.b /= 2.0;
mod.PushColor( c );
- FOR_EACH( blk, blocks )
- {
- if( (!blk->inherit_color) && (blk->color != mod.color) )
- {
- Color c = blk->color;
- c.r /= 2.0;
- c.g /= 2.0;
- c.b /= 2.0;
- mod.PushColor( c );
- blk->DrawSolid(false);
- mod.PopColor();
- }
- else
- blk->DrawSolid(false);
- }
+ gluTessBeginPolygon(tobj, NULL);
+ FOR_EACH( contour, contours )
+ {
+ gluTessBeginContour(tobj);
+ for( size_t v=0; v<contour->size(); v+=3 )
+ gluTessVertex(tobj, &(*contour)[v], &(*contour)[v]);
+ gluTessEndContour(tobj);
+ }
+
+ gluTessEndPolygon(tobj);
+
+ FOR_EACH( blk, blocks )
+ blk->DrawSides();
+
glDepthMask(GL_TRUE);
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
-
- mod.PopColor();
+ mod.PopColor();
+
glEndList();
}
@@ -252,50 +312,34 @@ void BlockGroup::LoadBitmap( const std::string& bitmapfile, Worldfile* wf )
full = std::string(dirname(workaround_const)) + "/" + bitmapfile;
free( workaround_const );
}
+
+ char buf[512];
+ snprintf( buf, 512, "[Image \"%s\"", bitmapfile.c_str() );
+ fputs( buf, stdout );
+ fflush( stdout );
PRINT_DEBUG1( "attempting to load image %s", full );
- std::vector<rotrect_t> rects;
- if( rotrects_from_image_file( full,
- rects ) )
+ Color col( 1.0, 0.0, 1.0, 1.0 );
+
+ std::vector<std::vector<point_t> > polys;
+
+ if( polys_from_image_file( full,
+ polys ) )
{
- PRINT_ERR1( "failed to load rects from image file \"%s\"",
+ PRINT_ERR1( "failed to load polys from image file \"%s\"",
full.c_str() );
return;
}
- //printf( "found %d rects in \"%s\" at %p\n",
- // rect_count, full, rects );
-
- // TODO fix this
- Color col( 1.0, 0.0, 1.0, 1.0 );
-
- FOR_EACH( rect, rects )
- {
- std::vector<point_t> pts(4);
-
- const double x = rect->pose.x;
- const double y = rect->pose.y;
- const double w = rect->size.x;
- const double h = rect->size.y;
-
- pts[0].x = x;
- pts[0].y = y;
- pts[1].x = x + w;
- pts[1].y = y;
- pts[2].x = x + w;
- pts[2].y = y + h;
- pts[3].x = x;
- pts[3].y = y + h;
-
- AppendBlock( Block( this,
- pts,
- Bounds(0,1) ,
- col,
- true ) );
- }
+ FOR_EACH( it, polys )
+ AppendBlock( Block( this,
+ *it,
+ Bounds(0,1) ));
CalcSize();
+
+ fputs( "]", stdout );
}
View
7 libstage/model.cc
@@ -458,9 +458,8 @@ void Model::AddBlockRect( meters_t x,
blockgroup.AppendBlock( Block( &blockgroup,
pts,
- Bounds(0,dz),
- color,
- true ));
+ Bounds(0,dz) ));
+
Map();
}
@@ -1235,6 +1234,8 @@ void Model::SetGeom( const Geom& val )
blockgroup.CalcSize();
+ //printf( "model %s SetGeom size [%.3f %.3f %.3f]\n", Token(), geom.size.x, geom.size.y, geom.size.z );
+
NeedRedraw();
MapWithChildren(0);
View
2 libstage/region.cc
@@ -230,7 +230,7 @@ void SuperRegion::DrawVoxels(unsigned int layer) const
FOR_EACH( it, blocks )
{
Block* block = *it;
- Color c = block->GetColor();
+ Color c = block->group->mod.GetColor();
const std::vector<GLfloat> v = DrawBlock( xx, yy, block->global_z.min, block->global_z.max );
verts.insert( verts.end(), v.begin(), v.end() );
View
167 libstage/stage.cc
@@ -157,7 +157,7 @@ int Stg::rotrects_from_image_file( const std::string& filename,
// rather than graphics coordinates. this is much faster than
// inverting the original image.
- rotrect_t latest;// = &(*rects)[(*rect_count)-1];
+ rotrect_t latest;
latest.pose.x = startx;
latest.pose.y = height-1 - (starty + rheight);
latest.pose.a = 0.0;
@@ -182,36 +182,153 @@ int Stg::rotrects_from_image_file( const std::string& filename,
return 0; // ok
}
-/*
-private static void Floodfill(byte[,] vals, point_int_t q, byte SEED_COLOR, byte COLOR)
+double direction( double a )
{
- int h = vals.GetLength(0);
- int w = vals.GetLength(1);
+ if( a == 0.0 )
+ return 0;
+ else
+ return sgn(a);
+}
- if (q.Y < 0 || q.Y > h - 1 || q.X < 0 || q.X > w - 1)
- return;
+int Stg::polys_from_image_file( const std::string& filename,
+ std::vector<std::vector<point_t> >& polys )
+{
+ // TODO: make this a parameter
+ const int threshold = 127;
+
+ Fl_Shared_Image *img = Fl_Shared_Image::get(filename.c_str());
+ if( img == NULL )
+ {
+ std::cerr << "failed to open file: " << filename << std::endl;
- std::stack<Point> stack = new Stack<Point>();
- stack.Push(q);
- while (stack.Count > 0)
+ assert( img ); // easy access to this point in debugger
+ exit(-1);
+ }
+
+ //printf( "loaded image %s w %d h %d d %d count %d ld %d\n",
+ // filename, img->w(), img->h(), img->d(), img->count(), img->ld() );
+
+ const unsigned int width = img->w();
+ const unsigned height = img->h();
+ const unsigned int depth = img->d();
+ uint8_t* pixels = (uint8_t*)img->data()[0];
+
+ // a set of previously seen directed edges, The key is a 4-element vector
+ // [x1,y1,x2,y2].
+ std::set<std::vector<uint32_t> > edges;
+
+ for(unsigned int y = 0; y < height; y++)
+ {
+ for(unsigned int x = 0; x < width; x++)
+ {
+ // skip blank (white) pixels
+ if( pixel_is_set( pixels, width, depth, x, y, threshold) )
+ continue;
+
+ // generate the four directed edges for this pixel
+ std::vector<uint32_t> edge[4];
+
+ for( int i=0; i<4; i++ )
+ edge[i].resize(4);
+
+ edge[0][0] = x+0;
+ edge[0][1] = y+0;
+ edge[0][2] = x+1;
+ edge[0][3] = y+0;
+
+ edge[1][0] = x+1;
+ edge[1][1] = y+0;
+ edge[1][2] = x+1;
+ edge[1][3] = y+1;
+
+ edge[2][0] = x+1;
+ edge[2][1] = y+1;
+ edge[2][2] = x+0;
+ edge[2][3] = y+1;
+
+ edge[3][0] = x+0;
+ edge[3][1] = y+1;
+ edge[3][2] = x+0;
+ edge[3][3] = y+0;
+
+ // put them in the set of the inverse edge does not exist
+ for( int i=0; i<4; i++ )
+ {
+ // the same edge with the opposite direction
+ std::vector<uint32_t> inv(4);
+ inv[0] = edge[i][2];
+ inv[1] = edge[i][3];
+ inv[2] = edge[i][0];
+ inv[3] = edge[i][1];
+
+ std::set<std::vector<uint32_t> >::iterator it =
+ edges.find( inv );
+
+ if( it == edges.end() ) // inverse not found
+ edges.insert( edge[i] ); // add the new edge
+ else // inverse found! delete it
+ edges.erase( it );
+ }
+ }
+ }
+
+ std::multimap<point_t,point_t> mmap;
+
+ FOR_EACH( it, edges )
+ {
+ // fill a multimap with start-point / end-point pairs.
+ std::pair<point_t,point_t> p( point_t( (*it)[0], (*it)[1] ),
+ point_t( (*it)[2], (*it)[3] ));
+ mmap.insert( p );
+ }
+
+ for( std::multimap<point_t,point_t>::iterator seedit = mmap.begin();
+ seedit != mmap.end();
+ seedit = mmap.begin() )
{
- Point p = stack.Pop();
- int x = p.X;
- int y = p.Y;
- if (y < 0 || y > h - 1 || x < 0 || x > w - 1)
- continue;
- byte val = vals[y, x];
- if (val == SEED_COLOR)
- {
- vals[y, x] = COLOR;
- stack.Push(new Point(x + 1, y));
- stack.Push(new Point(x - 1, y));
- stack.Push(new Point(x, y + 1));
- stack.Push(new Point(x, y - 1));
- }
+ std::vector<point_t> poly;
+
+ while( seedit != mmap.end() )
+ {
+ // invert y axis and add the new point to the poly
+ point_t pt = seedit->first;
+ pt.y = -pt.y;
+
+ // can this vector simply extend the previous one?
+ size_t psize = poly.size();
+ if( psize > 2 ) // need at least two points already
+ {
+ // find the direction of the vector descrived by the two previous points
+ double ldx = direction( poly[psize-1].x - poly[psize-2].x );
+ double ldy = direction( poly[psize-1].y - poly[psize-2].y );
+
+ // find the direction of the vector described by the new point and the previous point
+ double ndx = direction( pt.x - poly[psize-1].x );
+ double ndy = direction( pt.y - poly[psize-1].y );
+
+ // if the direction is the same, we can replace the
+ // previous point with this one, rather than adding a
+ // new point
+ if( ldx == ndx && ldy == ndy )
+ poly[psize-1] = pt;
+ else
+ poly.push_back( pt );
+ }
+ else
+ poly.push_back( pt );
+
+ point_t next = seedit->second;
+ mmap.erase( seedit );
+
+ seedit = mmap.find( next );
+ }
+
+ polys.push_back( poly );
}
+
+ if( img ) img->release(); // frees all resources for this image
+ return 0; // ok
}
-*/
// POINTS -----------------------------------------------------------
View
64 libstage/stage.hh
@@ -476,6 +476,17 @@ namespace Stg
bool operator+=( const point_t& other )
{ return ((x += other.x) && (y += other.y) ); }
+
+ /** required to put these in sorted containers like std::map */
+ bool operator<( const point_t& other ) const
+ {
+ if( x < other.x ) return true;
+ if( other.x < x ) return false;
+ return y < other.y;
+ }
+
+ bool operator==( const point_t& other ) const
+ { return ((x == other.x) && (y == other.y) ); }
};
/** Define a point in 3d space */
@@ -597,6 +608,10 @@ namespace Stg
int rotrects_from_image_file( const std::string& filename,
std::vector<rotrect_t>& rects );
+ int polys_from_image_file( const std::string& filename,
+ std::vector<std::vector<point_t> >& polys );
+
+
/** matching function should return true iff the candidate block is
stops the ray, false if the block transmits the ray
*/
@@ -882,10 +897,10 @@ namespace Stg
double ppm; ///< the resolution of the world model in pixels per meter
bool quit; ///< quit this world ASAP
-
bool show_clock; ///< iff true, print the sim time on stdout
unsigned int show_clock_interval; ///< updates between clock outputs
+ //--- thread sync ----
pthread_mutex_t sync_mutex; ///< protect the worker thread management stuff
unsigned int threads_working; ///< the number of worker threads not yet finished
pthread_cond_t threads_start_cond; ///< signalled to unblock worker threads
@@ -956,29 +971,30 @@ namespace Stg
virtual std::string ClockString( void ) const;
Model* CreateModel( Model* parent, const std::string& typestr );
- void LoadModel( Worldfile* wf, int entity );
- void LoadBlock( Worldfile* wf, int entity );
+
+ void LoadModel( Worldfile* wf, int entity );
+ void LoadBlock( Worldfile* wf, int entity );
void LoadBlockGroup( Worldfile* wf, int entity );
-
- void LoadSensor( Worldfile* wf, int entity );
+ void LoadSensor( Worldfile* wf, int entity );
virtual Model* RecentlySelectedModel() const { return NULL; }
-
- /** call Cell::AddBlock(block) for each cell on the polygon */
+
+ /** Add the block to every raytrace bitmap cell that intersects
+ the edges of the polygon.*/
void MapPoly( const std::vector<point_int_t>& poly,
Block* block,
unsigned int layer );
SuperRegion* AddSuperRegion( const point_int_t& coord );
SuperRegion* GetSuperRegion( const point_int_t& org );
SuperRegion* GetSuperRegionCreate( const point_int_t& org );
- //void ExpireSuperRegion( SuperRegion* sr );
/** convert a distance in meters to a distance in world occupancy
grid pixels */
int32_t MetersToPixels( meters_t x ) const
{ return (int32_t)floor(x * ppm); };
-
+
+ /** Return the bitmap coordinates corresponding to the location in meters. */
point_int_t MetersToPixels( const point_t& pt ) const
{ return point_int_t( MetersToPixels(pt.x), MetersToPixels(pt.y)); };
@@ -1208,9 +1224,7 @@ namespace Stg
after constructing the block.*/
Block( BlockGroup* group,
const std::vector<point_t>& pts,
- const Bounds& zrange,
- const Color& color,
- bool inherit_color );
+ const Bounds& zrange );
/** A from-file constructor */
Block( BlockGroup* group, Worldfile* wf, int entity);
@@ -1257,29 +1271,15 @@ namespace Stg
void Load( Worldfile* wf, int entity );
- /** return a pointer to the Model that owns the BlockGroup that owns this Block.*/
- Model* GetModel();
-
- const Color& GetColor();
-
void Rasterize( uint8_t* data,
unsigned int width, unsigned int height,
meters_t cellwidth, meters_t cellheight );
-
+
private:
- //Model* mod; ///< model to which this block belongs.
-
- BlockGroup* group;
-
+ BlockGroup* group; ///< The BlockGroup to which this Block belongs.
std::vector<point_t> pts; ///< points defining a polygon.
- Size size; ///< Size of the polygon in meters.
Bounds local_z; ///< z extent in local coords.
- Color color; ///< Color of the polygon as seen in sensors and the GUI.
- bool inherit_color; ///< Use parent's color instead of this->color.
-
Bounds global_z; ///< z extent in global coordinates.
-
- bool mapped; ///< iff true, the block has been mapped in the bitmap (TODO: which layer?)
/** record the cells into which this block has been rendered so we
can remove them very quickly. One vector for each of the two
@@ -1296,6 +1296,7 @@ namespace Stg
friend class Model;
friend class Block;
friend class World;
+ friend class SuperRegion;
private:
std::vector<Block> blocks; ///< Contains the blocks in this group.
@@ -1749,7 +1750,7 @@ namespace Stg
friend class ModelFiducial;
private:
- /** the number of models instatiated - used to assign unique IDs */
+ /** the number of models instatiated - used to assign unique sequential IDs */
static uint32_t count;
static std::map<id_t,Model*> modelsbyid;
@@ -1894,8 +1895,6 @@ namespace Stg
uint32_t id;
usec_t interval; ///< time between updates in usec
usec_t interval_energy; ///< time between updates of powerpack in usec
- // usec_t interval_pose; ///< time between updates of pose due to velocity in usec
-
usec_t last_update; ///< time of last update in us
bool log_state; ///< iff true, model state is logged
meters_t map_resolution;
@@ -2748,8 +2747,7 @@ namespace Stg
{
public:
public:
- ModelRanger( World* world, Model* parent,
- const std::string& type );
+ ModelRanger( World* world, Model* parent, const std::string& type );
virtual ~ModelRanger();
virtual void Load();
View
8 libstage/world.cc
@@ -878,9 +878,9 @@ RaytraceResult World::Raytrace( const Ray& r )
if( (*r.func)( &block->group->mod, (Model*)r.mod, r.arg ))
{
// a hit!
- sample.color = block->GetColor();
- sample.mod = &block->group->mod;
-
+ sample.mod = &block->group->mod;
+ sample.color = sample.mod->GetColor();
+
if( ax > ay ) // faster than the equivalent hypot() call
sample.range = fabs((globx-startx) / cosa) / ppm;
else
@@ -1051,7 +1051,7 @@ void World::MapPoly( const std::vector<point_int_t>& pts, Block* block, unsigned
GETSREG(globy)))
->GetRegion( GETREG(globx),
GETREG(globy)));
- // assert(reg);
+ assert(reg);
// add all the required cells in this region before looking up
// another region
View
2 worlds/benchmark/cave.world
@@ -29,7 +29,7 @@ floorplan
name "cave"
size [16.000 16.000 0.600]
pose [0 0 0 0]
- bitmap "../bitmaps/cave.png"
+ bitmap "../bitmaps/cave_filled.png"
)
#define rob pioneer2dx
View
6 worlds/fasr.world
@@ -39,12 +39,12 @@ floorplan
name "cave"
pose [0 0 0 0]
size [16.000 16.000 0.600]
- bitmap "bitmaps/cave.png"
+ bitmap "bitmaps/cave_filled.png"
)
zone
(
- size [ 2.000 2.000 0 ]
+ size [ 2.000 2.000 0.01 ]
color "green"
pose [ -7.000 -7.000 0 0 ]
name "source"
@@ -53,7 +53,7 @@ zone
zone
(
- size [ 2.000 2.000 0 ]
+ size [ 2.000 2.000 0.01 ]
color "red"
pose [ 7.000 7.000 0 0 ]
name "sink"
View
2 worlds/map.inc
@@ -24,7 +24,7 @@ define floorplan model
define zone model
(
color "orange"
- size [ 4 4 0.02 ]
+ size [ 4 4 0.01 ]
gui_nose 0
gui_grid 0
View
3 worlds/walle.inc
@@ -30,7 +30,6 @@ define walle position
point[2] [ 0.9 0.75 ]
point[3] [ 0.1 0.75 ]
z [ 0.2 0.6 ]
- color "yellow"
)
# body top
@@ -53,7 +52,6 @@ define walle position
point[2] [ 0.0 0.25 ]
point[3] [ 0 0.0 ]
z [ 0.0 0.4 ]
- color "gray40"
)
# right wheel
@@ -76,7 +74,6 @@ define walle position
point[2] [0.6 0.49]
point[3] [0.6 0.30]
z [0.8 0.95]
- color "gray40"
)
# left eye front

0 comments on commit f0e1c49

Please sign in to comment.