- struct subworld_routes *r = subworld_routes();
- struct route_gate *rg = &r->gates[id];
- struct route_node *pnode = &r->nodes[rg->node_id],
- *pdest = &r->nodes[pnode->next[0]];
-
- struct route_collector *rc = &r->collectors[ pdest->special_id ];
-
- r->active_gate = id;
- rg->timing.version = r->current_run_version;
- rg->timing.time = vg_time;
- for( u32 i=0; i<r->route_count; i++ )
- {
- struct route *route = &r->routes[i];
-
- route->active = 0;
- for( u32 j=0; j<pdest->ref_count; j++ )
- {
- if( pdest->route_ids[j] == i )
- {
- world_routes_verify_run( i );
- route->active = 1;
- break;
+ ent_route *route = mdl_arritm( &world->ent_route, route_id );
+ u8 colour[4];
+ colour[0] = route->colour[0] * 255.0f;
+ colour[1] = route->colour[1] * 255.0f;
+ colour[2] = route->colour[2] * 255.0f;
+ colour[3] = route->colour[3] * 255.0f;
+
+ u32 last_valid = 0;
+
+ for( int i=0; i<route->checkpoints_count; i++ ){
+ int i0 = route->checkpoints_start+i,
+ i1 = route->checkpoints_start+((i+1)%route->checkpoints_count);
+
+ ent_checkpoint *c0 = mdl_arritm(&world->ent_checkpoint, i0),
+ *c1 = mdl_arritm(&world->ent_checkpoint, i1);
+
+ ent_gate *start_gate = mdl_arritm( &world->ent_gate, c0->gate_index );
+ start_gate = mdl_arritm( &world->ent_gate, start_gate->target );
+
+ ent_gate *end_gate = mdl_arritm( &world->ent_gate, c1->gate_index ),
+ *collector = mdl_arritm( &world->ent_gate, end_gate->target );
+
+ v4f p[3];
+
+ v3_add( (v3f){0.0f,0.1f,0.0f}, start_gate->co[0], p[0] );
+ p[0][3] = start_gate->ref_count;
+ p[0][3] -= (float)start_gate->route_count * 0.5f;
+ start_gate->ref_count ++;
+
+ if( !c0->path_count )
+ continue;
+
+ /* this is so that we get nice flow through the gates */
+ v3f temp_alignments[2];
+ ent_gate *both[] = { start_gate, end_gate };
+
+ for( int j=0; j<2; j++ ){
+ int pi = c0->path_start + ((j==1)? c0->path_count-1: 0);
+
+ ent_path_index *index = mdl_arritm( &world->ent_path_index, pi );
+ ent_route_node *rn = mdl_arritm( &world->ent_route_node,
+ index->index );
+ v3f v0;
+ v3_sub( rn->co, both[j]->co[0], v0 );
+ float d = v3_dot( v0, both[j]->to_world[2] );
+
+ v3_muladds( both[j]->co[0], both[j]->to_world[2], d,
+ temp_alignments[j] );
+ v3_add( (v3f){0.0f,0.1f,0.0f}, temp_alignments[j], temp_alignments[j]);
+ }
+
+
+ for( int j=0; j<c0->path_count; j ++ ){
+ ent_path_index *index = mdl_arritm( &world->ent_path_index,
+ c0->path_start+j );
+ ent_route_node *rn = mdl_arritm( &world->ent_route_node,
+ index->index );
+ if( j==0 || j==c0->path_count-1 )
+ if( j == 0 )
+ v3_copy( temp_alignments[0], p[1] );
+ else
+ v3_copy( temp_alignments[1], p[1] );
+ else
+ v3_copy( rn->co, p[1] );
+
+ p[1][3] = rn->ref_count;
+ p[1][3] -= (float)rn->ref_total * 0.5f;
+ rn->ref_count ++;
+
+ if( j+1 < c0->path_count ){
+ index = mdl_arritm( &world->ent_path_index,
+ c0->path_start+j+1 );
+ rn = mdl_arritm( &world->ent_route_node, index->index );
+
+ if( j+1 == c0->path_count-1 )
+ v3_lerp( p[1], temp_alignments[1], 0.5f, p[2] );
+ else
+ v3_lerp( p[1], rn->co, 0.5f, p[2] );
+
+ p[2][3] = rn->ref_count;
+ p[2][3] -= (float)rn->ref_total * 0.5f;