X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes.h;h=d866cb7c543d7291f190ab057bd3426f01c4c5fe;hb=e126d5b471eb17ec9e0f0391cc7488b45f213b0d;hp=2454a593c0574aae14c79ffdd68489182a23a5a8;hpb=919d1227839218c57430fe9cab8f74d594c7bd14;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes.h b/world_routes.h index 2454a59..d866cb7 100644 --- a/world_routes.h +++ b/world_routes.h @@ -35,14 +35,18 @@ void world_routes_local_set_record( world_instance *world, ent_route *route, temp.points = 0; temp.time = time_centiseconds; +#if 0 highscores_push_record( &temp ); +#endif struct track_info *ti = &track_infos[ route->official_track_id ]; ti->push = 1; if( ti->achievement_id ){ +#if 0 steam_set_achievement( ti->achievement_id ); steam_store_achievements(); +#endif } } else{ @@ -128,7 +132,8 @@ VG_STATIC void world_routes_activate_entry_gate( world_instance *world, route->checkpoints_start+k ); ent_gate *gk = mdl_arritm( &world->ent_gate, cp->gate_index ); - if( gk == rg ){ + gk = mdl_arritm( &world->ent_gate, gk->target ); + if( gk == dest ){ route->active_checkpoint = k; world_routes_time_lap( world, route ); break; @@ -196,7 +201,7 @@ VG_STATIC void world_routes_debug( world_instance *world ) } VG_STATIC void world_routes_place_curve( world_instance *world, - v4f h[4], v3f n0, v3f n2 ) + v4f h[3], v3f n0, v3f n2 ) { float t; v3f p, pd; @@ -253,35 +258,48 @@ VG_STATIC void world_routes_place_curve( world_instance *world, ray_hit ha, hb; ha.dist = 8.0f; hb.dist = 8.0f; - if( ray_world( world, sa, down, &ha ) && - ray_world( world, sb, down, &hb )) - { - scene_vert va, vb; - - v3_muladds( ha.pos, up, 0.06f, va.co ); - v3_muladds( hb.pos, up, 0.06f, vb.co ); - - scene_vert_pack_norm( &va, up ); - scene_vert_pack_norm( &vb, up ); - - float t1 = (travel_length / total_length) * patch_count; - va.uv[0] = t1; - va.uv[1] = 0.0f; - vb.uv[0] = t1; - vb.uv[1] = 1.0f; - - scene_push_vert( world->scene_lines, &va ); - scene_push_vert( world->scene_lines, &vb ); - - if( last_valid ){ - /* Connect them with triangles */ - scene_push_tri( world->scene_lines, (u32[3]){ - last_valid+0-2, last_valid+1-2, last_valid+2-2} ); - scene_push_tri( world->scene_lines, (u32[3]){ - last_valid+1-2, last_valid+3-2, last_valid+2-2} ); + + int resa = ray_world( world, sa, down, &ha ), + resb = ray_world( world, sb, down, &hb ); + + if( resa && resb ){ + struct world_surface *surfa = ray_hit_surface( world, &ha ), + *surfb = ray_hit_surface( world, &hb ); + + if( (surfa->info.flags & k_material_flag_skate_surface) && + (surfb->info.flags & k_material_flag_skate_surface) ) + { + scene_vert va, vb; + + float gap = vg_fractf(cur_x*0.5f)*0.02f; + + v3_muladds( ha.pos, up, 0.06f+gap, va.co ); + v3_muladds( hb.pos, up, 0.06f+gap, vb.co ); + + scene_vert_pack_norm( &va, up ); + scene_vert_pack_norm( &vb, up ); + + float t1 = (travel_length / total_length) * patch_count; + va.uv[0] = t1; + va.uv[1] = 0.0f; + vb.uv[0] = t1; + vb.uv[1] = 1.0f; + + scene_push_vert( world->scene_lines, &va ); + scene_push_vert( world->scene_lines, &vb ); + + if( last_valid ){ + /* Connect them with triangles */ + scene_push_tri( world->scene_lines, (u32[3]){ + last_valid+0-2, last_valid+1-2, last_valid+2-2} ); + scene_push_tri( world->scene_lines, (u32[3]){ + last_valid+1-2, last_valid+3-2, last_valid+2-2} ); + } + + last_valid = world->scene_lines->vertex_count; } - - last_valid = world->scene_lines->vertex_count; + else + last_valid = 0; } else last_valid = 0; @@ -312,7 +330,8 @@ VG_STATIC void world_routes_create_mesh( world_instance *world, u32 route_id ) 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 ); + ent_gate *end_gate = mdl_arritm( &world->ent_gate, c1->gate_index ), + *collector = mdl_arritm( &world->ent_gate, end_gate->target ); v4f p[3]; @@ -377,9 +396,13 @@ VG_STATIC void world_routes_create_mesh( world_instance *world, u32 route_id ) else{ v3_copy( end_gate->co[0], p[2] ); v3_add( (v3f){0.0f,0.1f,0.0f}, p[2], p[2] ); - p[2][3] = end_gate->ref_count; - p[2][3] -= (float)end_gate->ref_total * 0.5f; - end_gate->ref_count ++; + p[2][3] = collector->ref_count; + + if( i == route->checkpoints_count-1) + p[2][3] -= 1.0f; + + p[2][3] -= (float)collector->ref_total * 0.5f; + //collector->ref_count ++; } /* p0,p1,p2 bezier patch is complete @@ -422,7 +445,7 @@ VG_STATIC void world_routes_generate( world_instance *world ) } for( u32 i=0; ient_route_node); i++ ){ - ent_route_node *rn = mdl_arritm( &world->ent_route, i ); + ent_route_node *rn = mdl_arritm( &world->ent_route_node, i ); rn->ref_count = 0; rn->ref_total = 0; } @@ -439,8 +462,6 @@ VG_STATIC void world_routes_generate( world_instance *world ) 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 ); start_gate->ref_total ++; if( !c0->path_count ) @@ -452,12 +473,6 @@ VG_STATIC void world_routes_generate( world_instance *world ) ent_route_node *rn = mdl_arritm( &world->ent_route_node, index->index ); rn->ref_total ++; - - if( j+1 < c0->path_count ){ - } - else{ - end_gate->ref_total ++; - } } } } @@ -516,6 +531,10 @@ VG_STATIC void world_routes_ent_init( world_instance *world ) gate = mdl_arritm(&world->ent_gate, gate->target ); for( u32 k=0; k<4; k++ ){ + if( gate->routes[k] == i ){ + vg_error( "already assigned route to gate\n" ); + break; + } if( gate->routes[k] == 0xffff ){ gate->routes[k] = i; break; @@ -525,6 +544,15 @@ VG_STATIC void world_routes_ent_init( world_instance *world ) } } + for( u32 i=0; ient_gate); i++ ){ + ent_gate *gate = mdl_arritm( &world->ent_gate, i ); + + vg_info( "ROUTES :: %hu %hu %hu %hu\n", gate->routes[0], + gate->routes[1], + gate->routes[2], + gate->routes[3] ); + } + world_routes_clear( world ); } @@ -564,7 +592,8 @@ VG_STATIC void world_bind_light_index( world_instance *world, GLuint shader, GLuint location, int slot ); -VG_STATIC void render_world_routes( world_instance *world, camera *cam ) +VG_STATIC void render_world_routes( world_instance *world, camera *cam, + int layer_depth ) { m4x3f identity_matrix; m4x3_identity( identity_matrix ); @@ -624,8 +653,9 @@ VG_STATIC void render_world_routes( world_instance *world, camera *cam ) shader_model_gate_uColour( colour ); - u32 next = route->checkpoints_start + - (route->active_checkpoint+1) % route->checkpoints_count; + u32 next = route->active_checkpoint+1+layer_depth; + next = next % route->checkpoints_count; + next += route->checkpoints_start; ent_checkpoint *cp = mdl_arritm( &world->ent_checkpoint, next ); ent_gate *gate = mdl_arritm( &world->ent_gate, cp->gate_index );