routes
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
diff --git a/world.h b/world.h
index 45003cccbe9d87afa6b4fed9c0912bfec860d454..f015a63e0ae43c93a9b4cd15b762bc133d3a7b18 100644 (file)
--- a/world.h
+++ b/world.h
@@ -46,9 +46,6 @@ static struct gworld
    struct subworld_physics system_physics;
    */
 
-   teleport_gate gates[64];
-   u32 gate_count;
-
    /* Paths */
    traffic_node traffic[128];
    u32 traffic_count;
@@ -123,6 +120,8 @@ static void world_register(void)
    shader_gpos_register();
    shader_fscolour_register();
    shader_alphatest_register();
+
+   world_routes_register();
 }
 
 static void world_free(void)
@@ -222,7 +221,6 @@ static void world_load(void)
    mdl_header *mworld = mdl_load( "models/mp_dev.mdl" );
 
    world.spawn_count = 0;
-   world.gate_count = 0;
    world.traffic_count = 0;
    world.instance_cache = NULL;
    
@@ -235,27 +233,6 @@ static void world_load(void)
       
       if( pnode->classtype == k_classtype_none )
       {}
-#if 0
-      else if( pnode->classtype == k_classtype_gate )
-      {
-         struct classtype_gate *entgate = mdl_get_entdata( mworld, pnode );
-
-         if( entgate->target )
-         {
-            mdl_node *pother = mdl_node_from_id( mworld, entgate->target );
-            
-            teleport_gate *gate = &world.gates[ world.gate_count ++ ];
-            
-            v3_copy( pnode->co,  gate->co[0] );
-            v3_copy( pother->co, gate->co[1] );
-            v4_copy( pnode->q,   gate->q[0] );
-            v4_copy( pother->q,  gate->q[1] );
-            v2_copy( pnode->s,   gate->dims );
-
-            gate_transform_update( gate );
-         }
-      }
-#endif
       else if( pnode->classtype == k_classtype_spawn )
       {
          struct respawn_point *rp = &world.spawns[ world.spawn_count ++ ];
@@ -416,7 +393,7 @@ static void world_load(void)
    scene_copy_slice( &world.foliage, &world.sm_foliage_alphatest );
 
    scene_upload( &world.foliage );
-   world_routes_init( mworld );
+   world_routes_loadfrom( mworld );
 
    for( int i=0; i<world.instance_cache_count; i++ )
       free( world.instance_cache[i].mdl );
@@ -688,9 +665,23 @@ static void render_sky(m4x3f camera)
    glDepthMask( GL_TRUE );
 }
 
+static void render_world_gates( m4x4f projection, m4x3f camera )
+{
+   int count = 0;
+   for( int i=0; i<world.routes.gate_count; i++ )
+   {
+      struct route_gate *rg = &world.routes.gates[i];
+      count += render_gate( &rg->gate, camera );
+
+      if( count == 2 )
+         return;
+   }
+}
+
 static void render_world( m4x4f projection, m4x3f camera )
 {
    render_sky( camera );
+   render_world_routes( projection, camera[3] );
    render_world_vb( projection, camera[3] );
    render_world_alphatest( projection, camera[3] );
    render_terrain( projection, camera[3] );