Revision: 6708
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6708&view=rev
Author:   rtv
Date:     2008-06-28 18:05:36 -0700 (Sat, 28 Jun 2008)

Log Message:
-----------
fixed some recursive drawing geometry. still need to fix child model pose 
updates - elimiating the single-displaylist optimization

Modified Paths:
--------------
    code/stage/trunk/libstage/canvas.cc
    code/stage/trunk/libstage/model.cc
    code/stage/trunk/libstage/stage.hh

Modified: code/stage/trunk/libstage/canvas.cc
===================================================================
--- code/stage/trunk/libstage/canvas.cc 2008-06-29 00:35:54 UTC (rev 6707)
+++ code/stage/trunk/libstage/canvas.cc 2008-06-29 01:05:36 UTC (rev 6708)
@@ -482,15 +482,11 @@
                }
                
                // move into this model's local coordinate frame
-               glPushMatrix();
-               gl_pose_shift( &mod->pose );
-               gl_pose_shift( &mod->geom.pose );
-               
+               mod->PushLocalCoords();
                // render the pre-recorded graphics for this model and
                // its children
-               glCallList( mod->displaylist );
-                               
-               glPopMatrix();
+               glCallList( mod->displaylist );                         
+               mod->PopCoords();
        }
 }
 
@@ -575,7 +571,7 @@
        
        if ( StgModel::ShowStatus )
          for( GList* it=world->StgWorld::children; it; it=it->next )
-                ((StgModel*)it->data)->DrawStatus( this );
+                ((StgModel*)it->data)->DrawStatusTree( this );
        
        if( world->GetRayList() )
          {

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2008-06-29 00:35:54 UTC (rev 6707)
+++ code/stage/trunk/libstage/model.cc  2008-06-29 01:05:36 UTC (rev 6708)
@@ -810,11 +810,9 @@
                memcpy( &pose, &checkpoint->pose, sizeof(pose));
                pose.z =  (world->sim_time - checkpoint->time) * timescale;
 
-               glPushMatrix();
-               gl_pose_shift( &pose );
-               gl_pose_shift( &geom.pose );
+               PushLocalCoords();
                glCallList( displaylist);
-               glPopMatrix();
+               PopCoords();
        }
 }
 
@@ -836,12 +834,10 @@
                memcpy( &pose, &checkpoint->pose, sizeof(pose));
                pose.z =  (world->sim_time - checkpoint->time) * timescale;
 
-               glPushMatrix();
+               PushLocalCoords();
 
                // set the height proportional to age
 
-               gl_pose_shift( &pose );
-
                PushColor( checkpoint->color );
 
                glPolygonMode(GL_FRONT_AND_BACK, GL_FILL );
@@ -870,38 +866,52 @@
 
                PopColor();
                PopColor();
-               glPopMatrix();
+               PopCoords();
        }
 }
 
+void StgModel::DrawBlocksTree( )
+{
+  if( parent )
+        PushLocalCoords();
+  
+  DrawBlocks();
+  LISTMETHOD( children, StgModel*, DrawBlocksTree );
+  
+  if( parent )
+        PopCoords();
+}
+  
 
 void StgModel::DrawBlocks( )
 {
   //printf( "model %s drawing blocks\n", token );
-
        LISTMETHOD( this->blocks, StgBlock*, Draw );
+}
 
-       // recursively draw the tree below this model 
-       for( GList* it=children; it; it=it->next )
-       {
-               StgModel* child = ((StgModel*)it->data);
+// move into this model's local coordinate frame
+void StgModel::PushLocalCoords()
+{
+  glPushMatrix();  
+  gl_pose_shift( &pose );
+  gl_pose_shift( &geom.pose );
+}
 
-               glPushMatrix();
-               gl_pose_shift( &child->pose );
-               gl_pose_shift( &child->geom.pose );
-               child->DrawBlocks();
-               glPopMatrix();
-       }
+void StgModel::PopCoords()
+{
+  glPopMatrix();
+}
 
+void StgModel::DrawStatusTree( StgCanvas* canvas ) 
+{
+  PushLocalCoords();
+  DrawStatus( canvas );
+  LISTMETHODARG( children, StgModel*, DrawStatusTree, canvas );  
+  PopCoords();
 }
 
-void StgModel::DrawStatus( StgCanvas* canvas ) {
-       glPushMatrix();
-       
-       // move into this model's local coordinate frame
-       gl_pose_shift( &this->pose );
-       gl_pose_shift( &this->geom.pose );
-       
+void StgModel::DrawStatus( StgCanvas* canvas ) 
+{
        // draw speech bubble
        if( say_string )
        {
@@ -955,8 +965,6 @@
        {
                DrawImage( TextureManager::getInstance()._stall_texture_id, 
canvas, 0.85 );
        }
-       
-       glPopMatrix();
 }
 
 void StgModel::DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float 
alpha )
@@ -1149,7 +1157,7 @@
 void StgModel::BuildDisplayList()
 {
        glNewList( displaylist, GL_COMPILE );   
-       DrawBlocks();
+       DrawBlocksTree();
        glEndList();
 
        rebuild_displaylist = false; // we just did it
@@ -1162,44 +1170,31 @@
 
 void StgModel::DataVisualizeTree( void )
 {
-  // move into this model's local coordinate frame
-  glPushMatrix();
-  gl_pose_shift( &pose );
-  gl_pose_shift( &geom.pose );
-  
-  DataVisualize(); // virtual function overridden by most model types
-  
-  // recurse on children
-  for( GList* it=children; it; it=it->next )
-        ((StgModel*)it->data)->DataVisualizeTree();
-  
-  // leave the local CF
-  glPopMatrix();
+  PushLocalCoords();
+  DataVisualize(); // virtual function overridden by most model types  
+  LISTMETHOD( children, StgModel*, DataVisualizeTree );
+  PopCoords();
 }
 
 
 void StgModel::DrawGrid( void )
 {
-       if ( gui_grid ) {
-               glPushMatrix();
-               
-               // move into this model's local coordinate frame
-               gl_pose_shift( &this->pose );
-               gl_pose_shift( &this->geom.pose );
-               
-               stg_bounds3d_t vol;
-               vol.x.min = -geom.size.x/2.0;
-               vol.x.max =  geom.size.x/2.0;
-               vol.y.min = -geom.size.y/2.0;
-               vol.y.max =  geom.size.y/2.0;
-               vol.z.min = 0;
-               vol.z.max = geom.size.z;
-
-               PushColor( 0,0,1,0.4 );
-               gl_draw_grid(vol);
-               PopColor();
-               
-               glPopMatrix();
+       if ( gui_grid ) 
+         {
+                PushLocalCoords();
+                
+                stg_bounds3d_t vol;
+                vol.x.min = -geom.size.x/2.0;
+                vol.x.max =  geom.size.x/2.0;
+                vol.y.min = -geom.size.y/2.0;
+                vol.y.max =  geom.size.y/2.0;
+                vol.z.min = 0;
+                vol.z.max = geom.size.z;
+                
+                PushColor( 0,0,1,0.4 );
+                gl_draw_grid(vol);
+                PopColor();             
+                PopCoords();
        }
 }
 

Modified: code/stage/trunk/libstage/stage.hh
===================================================================
--- code/stage/trunk/libstage/stage.hh  2008-06-29 00:35:54 UTC (rev 6707)
+++ code/stage/trunk/libstage/stage.hh  2008-06-29 01:05:36 UTC (rev 6708)
@@ -1333,9 +1333,14 @@
        virtual void UpdatePose();
        virtual void Draw( uint32_t flags, StgCanvas* canvas );
 
+       void DrawBlocksTree();
        virtual void DrawBlocks();
        virtual void DrawStatus( StgCanvas* canvas );
+       void DrawStatusTree( StgCanvas* canvas );
 
+  void PushLocalCoords();
+   void PopCoords();
+
        ///Draw the image stored in texture_id above the model
        void DrawImage( uint32_t texture_id, Stg::StgCanvas* canvas, float 
alpha );
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to