Update of /cvsroot/playerstage/code/stage/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13640/src

Modified Files:
      Tag: opengl
        gui_gl.c model.c model_load.c p_position.cc stage.h 
        stage_internal.h typetable.c 
Log Message:
tracking down a crash bug

Index: model_load.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/model_load.c,v
retrieving revision 1.8.4.3
retrieving revision 1.8.4.4
diff -C2 -d -r1.8.4.3 -r1.8.4.4
*** model_load.c        5 Jan 2007 04:30:10 -0000       1.8.4.3
--- model_load.c        6 Jan 2007 02:21:28 -0000       1.8.4.4
***************
*** 244,249 ****
  
          // scale all the polys to fit the model's geometry
!         stg_polygons_normalize( (stg_polygon_t*)mod->polys->data,
!                                 mod->polys->len, 
                                  mod->geom.size.x, 
                                  mod->geom.size.y );     
--- 244,249 ----
  
          // scale all the polys to fit the model's geometry
!         stg_polygons_normalize( mod->polygons,
!                                 mod->polygons_count, 
                                  mod->geom.size.x, 
                                  mod->geom.size.y );     
***************
*** 311,316 ****
        
        // scale all the polys to fit the model's geometry
!       stg_polygons_normalize( (stg_polygon_t*)mod->polys->data,
!                             mod->polys->len, 
                              mod->geom.size.x, 
                              mod->geom.size.y );
--- 311,316 ----
        
        // scale all the polys to fit the model's geometry
!       stg_polygons_normalize( mod->polygons,
!                             mod->polygons_count, 
                              mod->geom.size.x, 
                              mod->geom.size.y );

Index: p_position.cc
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/p_position.cc,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -C2 -d -r1.14 -r1.14.4.1
*** p_position.cc       14 Mar 2006 20:03:53 -0000      1.14
--- p_position.cc       6 Jan 2007 02:21:28 -0000       1.14.4.1
***************
*** 271,281 ****
      }
    }
!   else
!   {
!     // Don't know how to handle this message.
!     PRINT_WARN2( "stg_position doesn't support msg with type/subtype %d/%d",
!                hdr->type, hdr->subtype);
!     return(-1);
!   }
  }
  
--- 271,281 ----
      }
    }
!   
!   //else
!   
!   // Don't know how to handle this message.
!   PRINT_WARN2( "stg_position doesn't support msg with type/subtype %d/%d",
!              hdr->type, hdr->subtype);
!   return(-1);
  }
  

Index: stage_internal.h
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/stage_internal.h,v
retrieving revision 1.58.2.5
retrieving revision 1.58.2.6
diff -C2 -d -r1.58.2.5 -r1.58.2.6
*** stage_internal.h    5 Jan 2007 04:30:12 -0000       1.58.2.5
--- stage_internal.h    6 Jan 2007 02:21:28 -0000       1.58.2.6
***************
*** 162,169 ****
      stg_velocity_t velocity;
  
!     //stg_polygon_t* polygons;
!     //size_t polygons_count;
  
!     GArray* polys;
  
      stg_watts_t watts; //< power consumed by this model
--- 162,169 ----
      stg_velocity_t velocity;
  
!     stg_polygon_t* polygons;
!     size_t polygons_count;
  
!     //GArray* polys;
  
      stg_watts_t watts; //< power consumed by this model

Index: stage.h
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/stage.h,v
retrieving revision 1.189.2.6
retrieving revision 1.189.2.7
diff -C2 -d -r1.189.2.6 -r1.189.2.7
*** stage.h     5 Jan 2007 04:30:10 -0000       1.189.2.6
--- stage.h     6 Jan 2007 02:21:28 -0000       1.189.2.7
***************
*** 274,277 ****
--- 274,280 ----
    void stg_points_destroy( stg_point_t* pts );
  
+   /** create an array of 4 points containing the corners of a unit
+       square.*/
+   stg_point_t* stg_unit_square_points_create( void );
    /[EMAIL PROTECTED]/
  

Index: gui_gl.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/Attic/gui_gl.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -C2 -d -r1.1.2.6 -r1.1.2.7
*** gui_gl.c    5 Jan 2007 04:30:10 -0000       1.1.2.6
--- gui_gl.c    6 Jan 2007 02:21:28 -0000       1.1.2.7
***************
*** 1240,1247 ****
    int i=0;
    stg_endpoint_t* ep;
!   //puts( "X List:" ); 
    for( ep = world->endpts.x; ep; ep=ep->next )
      {
!       //printf( "\t%.2f %d %s\n",  ep->value, ep->type, ep->mod->token );
        
        push_color_stgcolor( ep->polygon->color );
--- 1240,1254 ----
    int i=0;
    stg_endpoint_t* ep;
! 
!   print_endpoint_list( world->endpts.x, "DRAW ENDPOINTS: X LIST" );
! 
!   puts( "X List:" ); 
    for( ep = world->endpts.x; ep; ep=ep->next )
      {
!       assert( ep );
!       assert( ep->polygon);
!       assert( ep->polygon->mod );
! 
!       printf( "\t%.2f %d %s\n",  ep->value, ep->type, ep->polygon->mod->token 
);
        
        push_color_stgcolor( ep->polygon->color );
***************
*** 1269,1275 ****
  
    i=0;
!   //puts( "Y List:" ); 
    for( ep = world->endpts.y; ep; ep=ep->next )
      {
        push_color_stgcolor( ep->polygon->color );
  
--- 1276,1284 ----
  
    i=0;
!   puts( "Y List:" ); 
    for( ep = world->endpts.y; ep; ep=ep->next )
      {
+       printf( "\t%s at %.2f\n", ep->polygon->mod->token, ep->value );
+ 
        push_color_stgcolor( ep->polygon->color );
  
***************
*** 1296,1303 ****
  
    i=0;
!   //puts( "Z List:" ); 
    for( ep = world->endpts.z; ep; ep=ep->next )
      {
!       //printf( "\t%s at %.2f\n", ep->mod->token, ep->value );
  
        push_color_stgcolor( ep->polygon->color );
--- 1305,1312 ----
  
    i=0;
!   puts( "Z List:" ); 
    for( ep = world->endpts.z; ep; ep=ep->next )
      {
!       printf( "\t%s at %.2f\n", ep->polygon->mod->token, ep->value );
  
        push_color_stgcolor( ep->polygon->color );
***************
*** 2047,2051 ****
  
    // recompile display lists
!   stg_model_add_callback( mod, &mod->polys, gl_model_polygons, NULL );
    stg_model_add_callback( mod, &mod->gui_outline, gl_model_polygons, NULL );
    stg_model_add_callback( mod, &mod->boundary, gl_model_polygons, NULL );
--- 2056,2060 ----
  
    // recompile display lists
!   stg_model_add_callback( mod, &mod->polygons, gl_model_polygons, NULL );
    stg_model_add_callback( mod, &mod->gui_outline, gl_model_polygons, NULL );
    stg_model_add_callback( mod, &mod->boundary, gl_model_polygons, NULL );

Index: model.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/model.c,v
retrieving revision 1.153.2.7
retrieving revision 1.153.2.8
diff -C2 -d -r1.153.2.7 -r1.153.2.8
*** model.c     5 Jan 2007 05:53:54 -0000       1.153.2.7
--- model.c     6 Jan 2007 02:21:28 -0000       1.153.2.8
***************
*** 260,270 ****
--- 260,284 ----
  
  
+ /* void print_endpoint_list( stg_endpoint_t* head, char* prefix ) */
+ /* { */
+ /*   puts( prefix ); */
+ /*   for( ; head; head=head->next ) */
+ /*     printf( "\ttype:%d poly:%p value:%.2f\n",  */
+ /*        head->type, */
+ /*        head->polygon, */
+ /*        head->value ); */
+ /* } */
  
  stg_endpoint_t* prepend_endpoint( stg_endpoint_t* head, stg_endpoint_t* ep )
  {
+   //print_endpoint_list( head, "before prepend" );
+ 
    if( head )
      head->prev = ep;
  
    ep->next = head;
+ 
+   //print_endpoint_list( ep, "after prepend" );
+ 
    return ep;
  }
***************
*** 276,285 ****
    
    // now shift the endpoint right until it's in correct sorted position
!   //while( ep->next && (ep->value < ep->next->value) )
!   //head = endpoint_right( head, ep ); 
    
    return head;
  }
  
  
  stg_model_t* stg_model_create( stg_world_t* world, 
--- 290,315 ----
    
    // now shift the endpoint right until it's in correct sorted position
!   while( ep->next && (ep->value < ep->next->value) )
!     head = endpoint_right( head, ep ); 
!   
!   //print_endpoint_list( ep, "inserted new endpoint. List now:" );
    
    return head;
  }
  
+ stg_endpoint_t* remove_endpoint( stg_endpoint_t* head, stg_endpoint_t* ep )
+ {
+   if( ep->next )
+     ep->next->prev = ep->prev;
+ 
+   if( ep->prev )
+     ep->prev->next = ep->next;
+   
+   if( head == ep ) // if we were at the head, there's a new head;
+     return ep->next;
+   else
+     return head;
+ } 
+ 
  
  stg_model_t* stg_model_create( stg_world_t* world, 
***************
*** 369,373 ****
  
    // most models are a single polygon
!   mod->polys = g_array_sized_new( FALSE, TRUE, sizeof(stg_polygon_t), 0 );
  
    // now it's safe to create the GUI components
--- 399,404 ----
  
    // most models are a single polygon
!   mod->polygons = NULL;
!   mod->polygons_count = 0;
  
    // now it's safe to create the GUI components
***************
*** 419,430 ****
  // DO NOT USE THIS FUNCTION!
  // copy a model and all it's properties safely
! stg_model_t* stg_model_duplicate( stg_model_t* mod )
! {
!   // TODO - this is NOT safe! do it properly
!   stg_model_t* dupe = NULL;
!   assert( malloc( sizeof(stg_model_t) ));
!   memcpy( dupe, mod, sizeof(stg_model_t));
!   return dupe;
! }
  
  int stg_model_is_antecedent( stg_model_t* mod, stg_model_t* testmod )
--- 450,461 ----
  // DO NOT USE THIS FUNCTION!
  // copy a model and all it's properties safely
! /* stg_model_t* stg_model_duplicate( stg_model_t* mod ) */
! /* { */
! /*   // TODO - this is NOT safe! do it properly */
! /*   stg_model_t* dupe = NULL; */
! /*   assert( malloc( sizeof(stg_model_t) )); */
! /*   memcpy( dupe, mod, sizeof(stg_model_t)); */
! /*   return dupe; */
! /* } */
  
  int stg_model_is_antecedent( stg_model_t* mod, stg_model_t* testmod )
***************
*** 778,782 ****
  
  
! void print_endpoint_list( char* prefix, stg_endpoint_t* ep )
  {
    printf( "%s (list at %p)\n", prefix, ep );
--- 809,813 ----
  
  
! void print_endpoint_list( stg_endpoint_t* ep, char* prefix )
  {
    printf( "%s (list at %p)\n", prefix, ep );
***************
*** 788,795 ****
        assert( i < 30 );
  
!       printf( "\t%d %.4f %s %s\n", 
              i++, 
              ep->value,
!             ep->type == STG_BEGIN ? "BEGIN" : "END",
              ep->polygon->mod->token );
        
--- 819,829 ----
        assert( i < 30 );
  
!       printf( "\t%d %p %.4f %s %p %d %s\n", 
              i++, 
+             ep,
              ep->value,
!             ep->type == STG_BEGIN ? "BGN" : "END",
!             ep->polygon,
!             ep->polygon->points->len,
              ep->polygon->mod->token );
        
***************
*** 881,892 ****
  {
    //printf( "adding polygon of %d points to %s\n", pt_count, mod->token );
! 
! 
    // make the array one slot larger
!   g_array_set_size( mod->polys, mod->polys->len+1 );
    
    // get a pointer to the last (i.e. new) item in the array
!   stg_polygon_t* poly = & g_array_index( mod->polys, stg_polygon_t, 
mod->polys->len-1 );
    
    poly->mod = mod;
    poly->color = color;
--- 915,933 ----
  {
    //printf( "adding polygon of %d points to %s\n", pt_count, mod->token );
!   
!   printf( "adding a polygon to the %d polygons of model %s\n",  
!         (int)mod->polygons_count, mod->token );
!   
    // make the array one slot larger
!   //g_array_set_size( mod->polys, mod->polys->len+1 );
    
    // get a pointer to the last (i.e. new) item in the array
!   //stg_polygon_t* poly = & g_array_index( mod->polys, stg_polygon_t, 
mod->polys->len-1 );
    
+   mod->polygons_count++;
+   mod->polygons = realloc( mod->polygons, sizeof(stg_polygon_t) * 
mod->polygons_count );
+ 
+   stg_polygon_t* poly = & mod->polygons[ mod->polygons_count-1];
+ 
    poly->mod = mod;
    poly->color = color;
***************
*** 918,928 ****
        
    // add this model's endpoints to the world's lists
!   stg_world_t* w = mod->world;
!    w->endpts.x = insert_endpoint( w->endpts.x, &poly->epts[0] ); 
! /*   w->endpts.x = insert_endpoint( w->endpts.x, &poly->epts[1] );  */
! /*   w->endpts.y = insert_endpoint( w->endpts.y, &poly->epts[2] ); */
! /*   w->endpts.y = insert_endpoint( w->endpts.y, &poly->epts[3] ); */
! /*   w->endpts.z = insert_endpoint( w->endpts.z, &poly->epts[4] ); */
! /*   w->endpts.z = insert_endpoint( w->endpts.z, &poly->epts[5] ); */
  
    // TODO - update intersections?
--- 959,972 ----
        
    // add this model's endpoints to the world's lists
!   stg_endpoint3_t* ep3 = &mod->world->endpts;
!   ep3->x = insert_endpoint( ep3->x, &poly->epts[0] ); 
!   ep3->x = insert_endpoint( ep3->x, &poly->epts[1] );  
! /*   ep3->y = insert_endpoint( ep3->y, &poly->epts[2] ); */
! /*   ep3->y = insert_endpoint( ep3->y, &poly->epts[3] ); */
! /*   ep3->z = insert_endpoint( ep3->z, &poly->epts[4] ); */
! /*   ep3->z = insert_endpoint( ep3->z, &poly->epts[5] ); */
! 
!   print_endpoint_list( ep3->x, "inserted new endpoint pair. List now:" );
! 
  
    // TODO - update intersections?
***************
*** 931,940 ****
  }
  
  void stg_model_clear_polygons( stg_model_t* mod )
  {
!   while( mod->polys->len > 0 )
      {
!       stg_polygon_t* p = & g_array_index( mod->polys, stg_polygon_t, 0 );
! 
        if( p->points )
        g_array_free( p->points, TRUE );
--- 975,989 ----
  }
  
+ 
  void stg_model_clear_polygons( stg_model_t* mod )
  {
!   int i;
!   for( i=0; i<mod->polygons_count; i++ )
      {
!       printf( "removing %d/%d polygons from model %s\n",  
!             i, (int)mod->polygons_count, mod->token );
!       
!       stg_polygon_t* p = & mod->polygons[i];
!       
        if( p->points )
        g_array_free( p->points, TRUE );
***************
*** 943,956 ****
        g_list_free( p->intersectors );
        
-       g_array_remove_index_fast( mod->polys, 0 );
- 
        // remove the endpoints
!       //mod->world->endpts.x = g_list_remove( mod->world->endpts.x, 
&p->epts[0] );
! /*       mod->world->endpts.x = g_list_remove( mod->world->endpts.x, 
&p->epts[1] ); */
! /*       mod->world->endpts.y = g_list_remove( mod->world->endpts.y, 
&p->epts[2] ); */
! /*       mod->world->endpts.y = g_list_remove( mod->world->endpts.y, 
&p->epts[3] ); */
! /*       mod->world->endpts.z = g_list_remove( mod->world->endpts.z, 
&p->epts[4] ); */
! /*       mod->world->endpts.z = g_list_remove( mod->world->endpts.z, 
&p->epts[5] ); */
      }
  }
  
--- 992,1010 ----
        g_list_free( p->intersectors );
        
        // remove the endpoints
!       stg_endpoint3_t* ep3 = &mod->world->endpts;
!       ep3->x = remove_endpoint( ep3->x, &p->epts[0] );
!       ep3->x = remove_endpoint( ep3->x, &p->epts[1] ); 
!       /*       ep3->y = remove_endpoint( ep3->y, &p->epts[2] ); */
!       /*       ep3->y = remove_endpoint( ep3->y, &p->epts[3] ); */
!       /*       ep3->z = remove_endpoint( ep3->z, &p->epts[4] ); */
!       /*       ep3->z = remove_endpoint( ep3->z, &p->epts[5] ); */
!       
!       print_endpoint_list( ep3->x, "removed endpoint pair. List now:" );
!       
      }
+   free(mod->polygons);
+   mod->polygons = NULL;
+   mod->polygons_count = 0;
  }
  
***************
*** 1123,1133 ****
  
    // we can do it in-place
!   if( mod->polys && mod->polys->len > 0 )
!     stg_polygons_normalize( (stg_polygon_t*)mod->polys->data, 
!                           mod->polys->len, 
                            geom->size.x, geom->size.y );
    //model_update_bbox( mod );
    
!   model_change( mod, &mod->polys );
    
    // re-render int the matrix
--- 1177,1187 ----
  
    // we can do it in-place
!   if( mod->polygons && mod->polygons_count > 0 )
!     stg_polygons_normalize( mod->polygons, 
!                           mod->polygons_count, 
                            geom->size.x, geom->size.y );
    //model_update_bbox( mod );
    
!   model_change( mod, &mod->polygons );
    
    // re-render int the matrix
***************
*** 1269,1274 ****
    assert(mod);
    assert(poly_count);
!   *poly_count = mod->polys->len;
!   return (stg_polygon_t*)mod->polys->data;
  }
  
--- 1323,1328 ----
    assert(mod);
    assert(poly_count);
!   *poly_count = mod->polygons_count;
!   return mod->polygons;
  }
  

Index: typetable.c
===================================================================
RCS file: /cvsroot/playerstage/code/stage/src/typetable.c,v
retrieving revision 1.8.4.2
retrieving revision 1.8.4.3
diff -C2 -d -r1.8.4.2 -r1.8.4.3
*** typetable.c 5 Jan 2007 04:30:12 -0000       1.8.4.2
--- typetable.c 6 Jan 2007 02:21:28 -0000       1.8.4.3
***************
*** 31,35 ****
      { "speech", speech_init },       
      { "bumper", bumper_init },       
!     { NULL, 0, NULL } // this must be the last entry
    };
  
--- 31,35 ----
      { "speech", speech_init },       
      { "bumper", bumper_init },       
!     { NULL, NULL } // this must be the last entry
    };
  


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to