From: hgn Date: Wed, 5 Nov 2025 03:53:36 +0000 (+0000) Subject: stuff X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=6a5666e135b2fb03161dc79e27f19024f720283a;p=vg.git stuff --- diff --git a/source/async/sdl_async.c b/source/async/sdl_async.c index c85fcef..3c3a79f 100644 --- a/source/async/sdl_async.c +++ b/source/async/sdl_async.c @@ -3,7 +3,7 @@ #include "generated/threads.c" #include "SDL3/SDL.h" -#define ASYNC_DEBUG_GROUP_COUNTS +//#define ASYNC_DEBUG_GROUP_COUNTS struct thread_context { diff --git a/source/async/vg_async.h b/source/async/vg_async.h index 6b9f006..1d87cd5 100644 --- a/source/async/vg_async.h +++ b/source/async/vg_async.h @@ -20,6 +20,7 @@ struct thread_info *_get_thread_info( enum thread_id thread ); // TODO THIS SHOULD BE PART OF THE METACOMPILER #define ASYNC_GROUP_OPENGL 0x1 #define ASYNC_GROUP_FIRST_LOAD 0x2 +#define ASYNC_GROUP_WORLD_LOAD 0x4 void _set_thread_id( enum thread_id id ); enum thread_id _get_thread_id(void); diff --git a/source/engine/engine.kv b/source/engine/engine.kv index 4a3b361..ca4e2b1 100644 --- a/source/engine/engine.kv +++ b/source/engine/engine.kv @@ -393,6 +393,14 @@ hook event START function _dsp_init } +cvar +{ + name vg_audio + type i32 + default 0 + cheat 1 + description "Show audio info" +} add model.c add metascene.c diff --git a/source/engine/model_entity.h b/source/engine/model_entity.h index 5f7f3b2..a044aa8 100644 --- a/source/engine/model_entity.h +++ b/source/engine/model_entity.h @@ -44,6 +44,8 @@ enum entity_alias k_ent_waterfall = 201, k_ent_rb2 = 202, k_ent_heatpipe = 203, + + k_ent_viewstone = 205, k_ent_max }; @@ -320,7 +322,8 @@ struct volume_particles struct volume_trigger { - i32 blank, blank2; + u32 blank1; + i32 blank; }; struct volume_interact @@ -351,7 +354,7 @@ struct ent_volume }; u32 flags; - u32 deleted0; + u32 filter; union { struct volume_trigger trigger; diff --git a/source/engine/vg_audio.c b/source/engine/vg_audio.c index 9f177d3..0a32788 100644 --- a/source/engine/vg_audio.c +++ b/source/engine/vg_audio.c @@ -6,6 +6,10 @@ #include "vg_audio_vorbis.h" #include "common_maths.h" #include "vg_async.h" +#include "vg_camera.h" +#include "vg_graphics.h" +#include "console_system.h" +#include "vg_engine.h" #include @@ -1028,6 +1032,12 @@ static void audio_channel_mix( audio_channel_id id, v_l *= v_s * (1.0-v_p); v_r *= v_s * (1.0+v_p); } + else + { + f64 v_p = (f64)state->pan / (f64)AUDIO_PAN_RIGHT_100; + v_l *= f32_min( 1.0f, (1.0-v_p) ); + v_r *= f32_min( 1.0f, (1.0+v_p) ); + } f32 s_l, s_r; if( frame_sample_rate != 1.0f ) @@ -1356,3 +1366,186 @@ void vg_audio_preupdate(void) _audio.working = 0; #endif } + +void _audio_gui(void) +{ + if( _cvar_vg_audio == 0 ) + return; + + _audio_lock(); + i16 panel[4] = {0,0,_engine.w,_engine.h}; + + /* Draw audio stack */ + for( i32 id=1; id<=AUDIO_CHANNELS; id ++ ) + { + struct audio_channel *channel = get_audio_channel( id ); + + i16 row[4]; + rect_split( panel, 0, 18, 1, row, panel ); + + if( channel->stage == k_channel_stage_none ) + { + _graphics_fill_rect( row, (union colour){{ 0x33,0x33,0x33,0x50 }} ); + } + else if( channel->stage == k_channel_stage_allocation ) + { + _graphics_fill_rect( row, (union colour){{ 0x33,0x33,0xff,0x50 }} ); + } + else if( channel->stage == k_channel_stage_active ) + { + char buf[256]; + struct stream string; + stream_open_buffer_write( &string, buf, sizeof(buf), k_stream_null_terminate ); + + $v_string( &string, $signed(id) ); + + if( channel->group ) + { + $v_string( &string, {" grp"}, $unsigned( channel->group ) ); + } + else + { + $v_string( &string, {" "} ); + } + + $v_string( &string, {" flags:"} ); + u32 flags = get_audio_channel_controls( id )->flags; + string_append_c8( &string, (flags & AUDIO_FLAG_RELINQUISHED)? 'R': '_' ); + string_append_c8( &string, (flags & AUDIO_FLAG_SPACIAL_3D)? 'S': '_' ); + string_append_c8( &string, (flags & AUDIO_FLAG_WORLD)? 'W': '_' ); + string_append_c8( &string, (flags & AUDIO_FLAG_NO_DOPPLER)? '_':'D' ); + string_append_c8( &string, (flags & AUDIO_FLAG_NO_DSP)? '_':'E' ); + string_append_c8( &string, (flags & AUDIO_FLAG_LOOP)? 'L':'_' ); + + const c8 *formats[] = + { + " mono ", + " stereo ", + " vorbis ", + " none0 ", + " none1 ", + " none2 ", + " none3 ", + " none4 ", + "synth:bird", + " none5 ", + " none6 ", + " none7 ", + " none8 ", + " none9 ", + " none10 ", + " none11 ", + }; + + u32 format_index = (channel->clip->flags & AUDIO_FLAG_FORMAT)>>9; + string_append( &string, " format:", 0 ); + string_append( &string, formats[format_index], 0 ); + + const c8 *activties[] = + { + "wake ", + "play ", + "pause", + "end ", + "error" + }; + $v_string( &string, {" "}, {activties[channel->ui_activity]}, {" "} ); + + f32 volume = (f32)channel->ui_volume / (f32)AUDIO_VOLUME_100; + $v_string( &string, $signed( volume * 100.0f ), {"% "}, {channel->ui_name} ); + + i16 row_l[4], row_r[4]; + rect_split( row, 1, 32, 2, row_l, row_r ); + + i16 indicator_l[4], indicator_r[4]; + rect_split_ratio( row_l, 1, 0.5f, 1, indicator_l, indicator_r ); + + _graphics_fill_rect( indicator_l, (union colour){{0,0,0,255}} ); + if( volume > 0.01f ) + { + f32 h = volume * (f32)indicator_l[3]; + i16 vol_bar[4] = { indicator_l[0], indicator_l[1] + indicator_l[3] - h, indicator_l[2], h }; + _graphics_fill_rect( vol_bar, (union colour){{ 0,255,0, 255 }} ); + if( flags & AUDIO_FLAG_SPACIAL_3D ) + { + f32 h = ((f32)channel->ui_spacial_volume / (f32)AUDIO_VOLUME_100) * (f32)indicator_l[3]; + i16 space_bar[4] = { indicator_l[0], indicator_l[1] + indicator_l[3] - h, indicator_l[2], 1 }; + _graphics_fill_rect( space_bar, (union colour){{ 255,255,255,255 }} ); + } + } + + f32 pan = (f32)channel->ui_pan / (f32)AUDIO_PAN_RIGHT_100; + _graphics_fill_rect( indicator_r, (union colour){{ 0x11,0x11,0x11,255 }} ); + f32 midpoint = (f32)indicator_r[0] + (f32)indicator_r[2] * 0.5f; + + f32 pan_abs = fabsf(pan); + if( pan_abs > 0.01f ) + { + i16 bar[4] = { midpoint,indicator_r[1], pan_abs * (f32)indicator_r[2] * 0.5f, indicator_r[3] }; + if( pan < 0.0f ) + bar[0] -= (f32)bar[2]; + _graphics_fill_rect( bar, (union colour){{ 0xff, 0xaa, 0x00, 0xff }} ); + } + + if( flags & AUDIO_FLAG_SPACIAL_3D ) + { + f32 w = ((f32)channel->ui_spacial_pan / (f32)AUDIO_PAN_RIGHT_100) * (f32)indicator_r[2] * 0.5f; + i16 space_bar[4] = { midpoint+w, indicator_r[1], 1, indicator_r[3] }; + _graphics_fill_rect( space_bar, (union colour){{ 0xff,0xff,0xff,0xff }} ); + } + + _graphics_fill_rect( row_r, (union colour){ .word = 0xa0000000 | channel->ui_colour } ); + _ui_text( row_r, string_get( &string ), k_ui_align_y_center, (union colour){{0xff,0xff,0xff,0xff}} ); + } + } + +#if 0 +#ifdef VG_3D + if( vd->view_3d && (ch->flags & AUDIO_FLAG_SPACIAL_3D) ) + { + v4f wpos; + v3_copy( ch->spacial_falloff, wpos ); + + wpos[3] = 1.0f; + m4x4_mulv( vg.pv, wpos, wpos ); + + if( wpos[3] > 0.0f ) + { + v2_muls( wpos, (1.0f/wpos[3]) * 0.5f, wpos ); + v2_add( wpos, (v2f){ 0.5f, 0.5f }, wpos ); + + ui_rect wr; + wr[0] = vg_clampf(wpos[0] * vg.window_x, -32000.0f,32000.0f); + wr[1] = vg_clampf((1.0f-wpos[1]) * vg.window_y,-32000.0f,32000.0f); + wr[2] = 1000; + wr[3] = 17; + + for( int j=0; j<12; j++ ) + { + int collide = 0; + for( int k=0; k= wk[0])) && + ((wr[1] <= wk[1]+wk[3]) && (wr[1]+wr[3] >= wk[1])) ) + { + collide = 1; + break; + } + } + + if( !collide ) + break; + else + wr[1] += 18; + } + + ui_text( ctx, wr, perf, 1, k_ui_align_middle_left, 0 ); + rect_copy( wr, overlap_buffer[ overlap_length ++ ] ); + } + } +#endif +#endif + + _audio_unlock(); +} diff --git a/source/engine/vg_audio.h b/source/engine/vg_audio.h index 083c9f0..0005b3c 100644 --- a/source/engine/vg_audio.h +++ b/source/engine/vg_audio.h @@ -106,3 +106,5 @@ void _audio_fadeout_flagged_audio( u32 flag, f32 length ); b8 _audio_flagged_stopped( u32 flag ); b8 _audio_is_channel_using_clip( audio_channel_id id, struct audio_clip *clip ); void _audio_set_flagged_pause( u32 flag, b8 pause ); + +void _audio_gui(void); diff --git a/source/engine/vg_engine.c b/source/engine/vg_engine.c index 6f3788a..e9039ee 100644 --- a/source/engine/vg_engine.c +++ b/source/engine/vg_engine.c @@ -7,6 +7,7 @@ #include "vg_opengl.h" #include "vg_engine.h" #include "vg_ui.h" +#include "vg_audio.h" // TODO: temp #include "console_system.h" @@ -270,6 +271,7 @@ L_new_frame:; EVENT_CALL( ENGINE_RENDER ); _engine_ui_pre_render(); EVENT_CALL( ENGINE_UI ); + _audio_gui(); _engine_ui_post_render(); //glfwSwapBuffers(_engine.window_handle);