Revision: 6783
http://playerstage.svn.sourceforge.net/playerstage/?rev=6783&view=rev
Author: alexcb
Date: 2008-07-07 11:12:19 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
fixed draging models bug created by camera model dirtying the offscreen buffer
Modified Paths:
--------------
code/stage/trunk/libstage/canvas.cc
code/stage/trunk/libstage/model_camera.cc
code/stage/trunk/libstage/stage.hh
Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-07-07 16:30:32 UTC (rev 6782)
+++ code/stage/trunk/libstage/canvas.cc 2008-07-07 18:12:19 UTC (rev 6783)
@@ -68,6 +68,7 @@
perspective_camera.setPose( -3.0, 0.0, 1.0 );
perspective_camera.setPitch( 70.0 ); //look down
current_camera = &camera;
+ setDirtyBuffer();
startx = starty = 0;
//panx = pany = stheta = sphi = 0.0;
@@ -213,6 +214,17 @@
else if( py >= h() )
py = h() - 1;
+ //redraw the screen only if the camera model isn't active.
+ //TODO new selection technique will simply use drawfloor to result in z
= 0 always and prevent strange behaviours near walls
+ //TODO refactor, so glReadPixels reads (then caches) the whole screen
only when the camera changes.
+ if( true || dirtyBuffer() ) {
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ current_camera->SetProjection();
+ current_camera->Draw();
+ DrawFloor(); //call this rather than renderFrame for speed -
this won't give correct z values
+ dirty_buffer = false;
+ }
+
int viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
@@ -220,11 +232,12 @@
glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
GLdouble projection[16];
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
+ glGetDoublev(GL_PROJECTION_MATRIX, projection);
GLfloat pz;
glReadPixels( px, h()-py, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &pz );
gluUnProject( px, w()-py, pz, modelview, projection, viewport, wx,wy,wz );
+
}
int StgCanvas::handle(int event)
Modified: code/stage/trunk/libstage/model_camera.cc
===================================================================
--- code/stage/trunk/libstage/model_camera.cc 2008-07-07 16:30:32 UTC (rev
6782)
+++ code/stage/trunk/libstage/model_camera.cc 2008-07-07 18:12:19 UTC (rev
6783)
@@ -232,6 +232,7 @@
glViewport( viewport[0], viewport[1], viewport[2], viewport[3] );
_canvas->invalidate();
+ _canvas->setDirtyBuffer();
return true;
}
Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh 2008-07-07 16:30:32 UTC (rev 6782)
+++ code/stage/trunk/libstage/stage.hh 2008-07-07 18:12:19 UTC (rev 6783)
@@ -1931,7 +1931,8 @@
StgCamera* current_camera;
StgOrthoCamera camera;
StgPerspectiveCamera perspective_camera;
-
+ bool dirty_buffer;
+
int startx, starty;
bool selectedModel;
bool clicked_empty_space;
@@ -1998,6 +1999,9 @@
void unSelect( StgModel* mod );
void unSelectAll();
+ inline void setDirtyBuffer( void ) { dirty_buffer = true; }
+ inline bool dirtyBuffer( void ) const { return dirty_buffer; }
+
inline void PushColor( stg_color_t col )
{ colorstack.Push( col ); }
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit