From 0c3ef87e654d436e0cad5f5b40f3631ae26ab649 Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 4 Oct 2022 17:26:49 +0100 Subject: [PATCH] routes - auto disappear --- world.h | 16 ++++++++++++---- world_routes.h | 23 ++++++++++++++++++++--- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/world.h b/world.h index 007d672..8779df9 100644 --- a/world.h +++ b/world.h @@ -27,9 +27,15 @@ static int ray_world( v3f pos, v3f dir, ray_hit *hit ); #include "shaders/fscolour.h" #include "shaders/alphatest.h" -enum { k_max_ui_segments = 32 }; -enum { k_route_ui_max_verts = 2000 }; -enum { k_route_ui_max_indices = 3000 }; +enum { k_max_ui_segments = 8 }; +enum { k_max_ui_splits_per_segment = 16 }; + +enum { k_max_ui_elements = k_max_ui_segments*k_max_ui_splits_per_segment }; +enum { k_max_element_verts = 10 }; +enum { k_max_element_indices = 20 }; + +enum { k_route_ui_max_verts = k_max_ui_elements*k_max_element_verts }; +enum { k_route_ui_max_indices = k_max_ui_elements*k_max_element_indices }; static struct gworld { @@ -84,7 +90,7 @@ static struct gworld { float length; u32 vertex_start, vertex_count, - index_start, index_count; + index_start, index_count, notches; } segments[k_max_ui_segments]; @@ -98,6 +104,8 @@ static struct gworld } *routes; + double last_interaction; + u32 route_count, route_cap; diff --git a/world_routes.h b/world_routes.h index 7f108aa..2b85f87 100644 --- a/world_routes.h +++ b/world_routes.h @@ -14,6 +14,11 @@ enum route_special_type k_route_special_type_collector = 2 }; +static void world_routes_interact(void) +{ + world.routes.last_interaction = vg_time; +} + static void debug_sbpath( struct route_node *rna, struct route_node *rnb, u32 colour, float xoffset ) { @@ -265,6 +270,7 @@ static void world_routes_ui_newseg( u32 route ) segment->vertex_count = 4; segment->index_start = pr->ui.indices_head; segment->index_count = 6; + segment->notches = 0; world_routes_ui_set_indices( pr, indices, 6 ); } @@ -302,6 +308,12 @@ static void world_routes_ui_notch( u32 route, float time ) if( (time - pr->ui.last_notch) > 1.0 ) { + struct route_ui_segment *segment = world_routes_ui_curseg(pr); + if( segment->notches == k_max_ui_splits_per_segment ) + return; + + segment->notches ++; + v2f verts[8]; float const k_notch_width = 1.0f; @@ -360,7 +372,6 @@ static void world_routes_ui_notch( u32 route, float time ) pr->ui.last_notch = time; - struct route_ui_segment *segment = world_routes_ui_curseg(pr); segment->vertex_count += 6; segment->index_count += 18; } @@ -414,12 +425,15 @@ static void world_routes_ui_draw( u32 route, v4f colour, float offset ) v4_copy( colour, fade_colour ); fade_colour[3] *= 1.0f-fade_amt; + float timer_delta = (vg_time - world.routes.last_interaction) * (1.0/60.0), + timer_scale = 1.0f - vg_minf( timer_delta, 1.0f ); + /* * Draw fadeout bar */ - float height = pr->factive*k_bar_height, - base = -1.0f + (offset+0.5f)*k_bar_height; + float height = pr->factive*k_bar_height * timer_scale, + base = -1.0f + (offset+0.5f)*k_bar_height * timer_scale; shader_routeui_uColour( fade_colour ); for( u32 i=0; iui.fade_count; i++ ) @@ -592,6 +606,8 @@ static void world_routes_verify_run( u32 route ) */ static void world_routes_activate_gate( u32 id ) { + world_routes_interact(); + struct subworld_routes *r = &world.routes; struct route_gate *rg = &r->gates[id]; struct route_node *pnode = &r->nodes[rg->node_id], @@ -644,6 +660,7 @@ static void world_routes_activate_gate( u32 id ) static void world_routes_notify_reset(void) { struct subworld_routes *r = &world.routes; + world_routes_interact(); for( int i=0; iroute_count; i++ ) { -- 2.25.1