Revision: 8234
http://playerstage.svn.sourceforge.net/playerstage/?rev=8234&view=rev
Author: rtv
Date: 2009-08-26 23:41:05 +0000 (Wed, 26 Aug 2009)
Log Message:
-----------
revised FLTK timer and idle callbacks to better suit Linux
Modified Paths:
--------------
code/stage/trunk/libstage/canvas.cc
code/stage/trunk/libstage/model.cc
code/stage/trunk/libstage/region.cc
code/stage/trunk/libstage/region.hh
code/stage/trunk/libstage/stage.hh
code/stage/trunk/libstage/worldgui.cc
code/stage/trunk/worlds/fasr.world
Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/libstage/canvas.cc 2009-08-26 23:41:05 UTC (rev 8234)
@@ -46,9 +46,9 @@
c->world->dirty = false;
}
- Fl::repeat_timeout(((double)c->interval/1000),
- (Fl_Timeout_Handler)Canvas::TimerCallback,
- c);
+ Fl::repeat_timeout( c->interval/1000.0,
+
(Fl_Timeout_Handler)Canvas::TimerCallback,
+ c);
}
Canvas::Canvas( WorldGui* world,
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/libstage/model.cc 2009-08-26 23:41:05 UTC (rev 8234)
@@ -296,9 +296,6 @@
UnMap(); // remove any old cruft rendered during startup
Map();
- if( FindPowerPack() )
- world->Enqueue( 0, World::Event::ENERGY, interval_energy, this );
-
// find the queue for update events: zero if thread safe, else we
// ask the world to assign us to a queue
if( event_queue_num < 1 )
@@ -649,7 +646,10 @@
// put my first events in the world's queue
world->Enqueue( event_queue_num, World::Event::UPDATE, interval, this );
world->Enqueue( 0, World::Event::POSE, interval_pose, this );
+ if( FindPowerPack() )
+ world->Enqueue( 0, World::Event::ENERGY, interval_energy, this );
+
CallCallbacks( &hooks.startup );
}
Modified: code/stage/trunk/libstage/region.cc
===================================================================
--- code/stage/trunk/libstage/region.cc 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/libstage/region.cc 2009-08-26 23:41:05 UTC (rev 8234)
@@ -52,19 +52,36 @@
// outline superregion
glColor3f( 0,0,1 );
- glRecti( 0,0, 1<<SRBITS, 1<<SRBITS );
+ glRecti( 0,0, 1<<SRBITS, 1<<SRBITS );
+
+ // outline regions
+ const Region* r = GetRegion(0,0);
+ char buf[32];
- // outline regions
glColor3f( 0,1,0 );
- for( int x=0; x<SUPERREGIONWIDTH; x++ )
- for( int y=0; y<SUPERREGIONWIDTH; y++ )
+ for( int y=0; y<SUPERREGIONWIDTH; y++ )
+ for( int x=0; x<SUPERREGIONWIDTH; x++ )
{
- const Region* r = GetRegion(x,y);
-
if( r->count )
- // outline regions with contents
- glRecti( x<<RBITS, y<<RBITS,
- (x+1)<<RBITS, (y+1)<<RBITS );
+ {
+ // outline regions with contents
+ glRecti( x<<RBITS, y<<RBITS,
+ (x+1)<<RBITS,
(y+1)<<RBITS );
+
+ snprintf( buf, 15, "%lu", r->count );
+ Gl::draw_string( x<<RBITS, y<<RBITS, 0, buf );
+
+ for( int p=0; p<REGIONWIDTH; p++ )
+ for( int q=0; q<REGIONWIDTH; q++ )
+ if(
r->cells[p+(q*REGIONWIDTH)].blocks.size() )
+ {
+ GLfloat xx = p+(x<<RBITS);
+ GLfloat yy = q+(y<<RBITS);
+
+ glRecti( xx, yy,
+ xx+1,
yy+1);
+ }
+ }
else if( ! r->cells.empty() )
{
double left = x << RBITS;
@@ -94,22 +111,38 @@
glVertex2f( right, bottom );
glVertex2f( right, bottom+d );
glEnd();
- }
+ }
+
+ r++; // next region quickly
}
-
- char buf[32];
+
snprintf( buf, 15, "%lu", count );
Gl::draw_string( 1<<SBITS, 1<<SBITS, 0, buf );
- glColor3f( 1.0,0,0 );
+ glPopMatrix();
+}
- for( int x=0; x<SUPERREGIONWIDTH; x++ )
- for( int y=0; y<SUPERREGIONWIDTH; y++ )
- {
- const Region* r = GetRegion( x, y);
-
+// TODO
+#if 0
+void SuperRegion::Draw( bool drawall )
+{
+ glEnable( GL_DEPTH_TEST );
+
+ glPushMatrix();
+ glTranslatef( origin.x<<SRBITS, origin.y<<SRBITS,0);
+
+ glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
+
+ r = GetRegion( 0, 0);
+
+ for( int y=0; y<SUPERREGIONWIDTH; y++ )
+ for( int x=0; x<SUPERREGIONWIDTH; x++ )
+ {
if( r->count < 1 )
- continue;
+ {
+ r++;
+ continue;
+ }
snprintf( buf, 15, "%lu", r->count );
Gl::draw_string( x<<RBITS, y<<RBITS, 0, buf );
@@ -131,14 +164,11 @@
Cell* c =
(Cell*)&r->cells[p+(q*REGIONWIDTH)];
FOR_EACH( it, c->blocks )
- // for(
std::vector<Block*>::iterator it = c->blocks.begin();
-// it !=
c->blocks.end();
-// ++it )
{
Block* block =
*it;
-
+
//printf( "zb
%.2f %.2f\n", ent->zbounds.min, ent->zbounds.max );
-
+
Color c =
block->GetColor();
glColor4f( c.r,
c.g, c.b, 1.0 );
@@ -217,11 +247,13 @@
}
}
}
+
+ ++r;
}
glPopMatrix();
}
+#endif
-
//inline
void SuperRegion::Floor()
{
Modified: code/stage/trunk/libstage/region.hh
===================================================================
--- code/stage/trunk/libstage/region.hh 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/libstage/region.hh 2009-08-26 23:41:05 UTC (rev 8234)
@@ -7,9 +7,6 @@
#include "stage.hh"
-#include <algorithm>
-#include <vector>
-
namespace Stg
{
@@ -34,7 +31,6 @@
// this is slightly faster than the inline method above, but not as safe
//#define GETREG(X) (( (static_cast<int32_t>(X)) & REGIONMASK ) >> RBITS)
-
class Cell
{
friend class Region;
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/libstage/stage.hh 2009-08-26 23:41:05 UTC (rev 8234)
@@ -1454,6 +1454,8 @@
virtual void AddModel( Model* mod );
+ void SetTimeouts();
+
protected:
virtual void PushColor( Color col );
Modified: code/stage/trunk/libstage/worldgui.cc
===================================================================
--- code/stage/trunk/libstage/worldgui.cc 2009-08-26 19:30:17 UTC (rev
8233)
+++ code/stage/trunk/libstage/worldgui.cc 2009-08-26 23:41:05 UTC (rev
8234)
@@ -342,9 +342,10 @@
}
bool WorldGui::Update()
-{
- double timeout = speedup > 0 ? (sim_interval/1e6) / speedup : 0;
- Fl::repeat_timeout( timeout, (Fl_Timeout_Handler)UpdateCallback, this );
+{
+ if( speedup > 0 )
+ Fl::repeat_timeout( (sim_interval/1e6) / speedup,
(Fl_Timeout_Handler)UpdateCallback, this );
+ // else we're called by an idle callback
//printf( "speedup %.2f timeout %.6f\n", speedup, timeout );
@@ -535,12 +536,16 @@
void WorldGui::realtimeCb( Fl_Widget* w, WorldGui* wg )
{
+ //puts( "real time" );
wg->speedup = 1.0;
+ wg->SetTimeouts();
}
void WorldGui::fasttimeCb( Fl_Widget* w, WorldGui* wg )
{
+ //puts( "fast time" );
wg->speedup = -1;
+ wg->SetTimeouts();
}
void WorldGui::Start()
@@ -551,8 +556,27 @@
Fl::add_timeout( ((double)canvas->interval/1000),
(Fl_Timeout_Handler)Canvas::TimerCallback,
canvas );
+
+ SetTimeouts();
+}
- Fl::add_timeout( 0.01, (Fl_Timeout_Handler)UpdateCallback, this );
+
+void WorldGui::SetTimeouts()
+{
+ if( speedup > 0.0 )
+ {
+ //puts( "removing idle" );
+ Fl::remove_idle( (Fl_Timeout_Handler)WorldGui::UpdateCallback,
this );
+ Fl::remove_timeout(
(Fl_Timeout_Handler)WorldGui::UpdateCallback, this );
+ Fl::add_timeout( (sim_interval/1e6) / speedup,
(Fl_Timeout_Handler)UpdateCallback, this );
+ }
+ else
+ {
+ //puts( "removing timeout" );
+ Fl::remove_timeout(
(Fl_Timeout_Handler)WorldGui::UpdateCallback, this );
+ Fl::remove_idle( (Fl_Timeout_Handler)WorldGui::UpdateCallback,
this );
+ Fl::add_idle( (Fl_Timeout_Handler)UpdateCallback, this );
+ }
}
void WorldGui::Stop()
Modified: code/stage/trunk/worlds/fasr.world
===================================================================
--- code/stage/trunk/worlds/fasr.world 2009-08-26 19:30:17 UTC (rev 8233)
+++ code/stage/trunk/worlds/fasr.world 2009-08-26 23:41:05 UTC (rev 8234)
@@ -83,6 +83,8 @@
joules -1 # provides infinite energy
give_watts 1000
fiducial_return 2 # look for this in the fiducial sensor
+
+ alwayson 1 # so we give charge without any explicit subscriber
)
)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit