+/*
+ * -----------------------------------------------------------------------------
+ * Events
+ * -----------------------------------------------------------------------------
+ */
+
+static void world_routes_register(void)
+{
+ struct subworld_routes *r = &world.routes;
+ r->current_run_version = 2;
+
+ shader_route_register();
+ shader_routeui_register();
+}
+
+static void world_routes_free(void)
+{
+ struct subworld_routes *r = &world.routes;
+
+ free( r->nodes );
+ free( r->routes );
+ free( r->gates );
+}
+
+static void world_routes_update(void)
+{
+ struct subworld_routes *r = &world.routes;
+
+ for( int i=0; i<r->route_count; i++ )
+ {
+ struct route *route = &r->routes[i];
+ route->factive = vg_lerpf( route->factive, route->active, 0.01f );
+
+ if( route->active )
+ {
+ world_routes_ui_updatetime( i, vg_time - route->latest_pass );
+ }
+ }
+}
+
+static void bind_terrain_textures(void);
+static void render_world_routes( m4x4f projection, v3f camera )
+{
+ struct subworld_routes *r = &world.routes;
+
+ m4x3f identity_matrix;
+ m4x3_identity( identity_matrix );
+
+ shader_route_use();
+ shader_route_uTexGarbage(0);
+ shader_link_standard_ub( _shader_route.id, 2 );
+ bind_terrain_textures();
+
+ shader_route_uPv( projection );
+ shader_route_uMdl( identity_matrix );
+ shader_route_uCamera( camera );
+
+ scene_bind( &r->scene_lines );
+
+ for( int i=0; i<r->route_count; i++ )
+ {
+ struct route *route = &r->routes[i];
+
+ v4f colour;
+ v3_lerp( (v3f){0.7f,0.7f,0.7f}, route->colour, route->factive, colour );
+ colour[3] = 1.0f;
+
+ shader_route_uColour( colour );
+ mdl_draw_submesh( &route->sm );
+ }
+}
+
+static void render_world_routes_ui(void)
+{
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
+ struct subworld_routes *r = &world.routes;
+
+ float active_offset = 0.0f;
+ for( int i=0; i<r->route_count; i++ )
+ {
+ struct route *route = &r->routes[i];
+ world_routes_ui_draw( i, route->colour, active_offset );
+ active_offset += route->factive;
+ }
+
+ glDisable(GL_BLEND);
+}
+